question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@nrwl/tao fails to validate schema in case of multiple types

See original GitHub issue

I’m using “@nrwl/angular”: “^12.9.0” and “@angular/fire”: “~7.2.0”.

@angular/fire:deploy accepts the following parameter in its schema:

{
  "$schema": "http://json-schema.org/draft-07/schema",
  "$id": "FirebaseDeploySchema",
  "title": "Firebase Deploy",
  "description": "Ng Deploy target options for Firebase.",
  "properties": {
    // ...
    "ssr": {
      "type": ["boolean", "string"],
      "description": "Should we attempt to deploy the function to Cloud Functions (true or 'cloud-functions') / Cloud Run ('cloud-run') or just Hosting (false)"
    }
  }
}

In my angular.json I have:

"deploy": {
	"builder": "@angular/fire:deploy",
	"options": {
		"prerender": false,
		"ssr": false,
		"browserTarget": "my-app:build:production",
		"firebaseProject": "my-project-id",
	}
}

Current Behavior

If I run: nx run my-app:deploy, it fails:

Property 'ssr' does not match the schema. 'false' should be a 'boolean,string'.

Expected Behavior

It runs successfully. I don’t know if it’s ever worked.

Considerations

I’m pretty sure it depends on validation logic, that does not take into account the possibility of (valid) mutliple types in the schema.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

3reactions
fr-escocommented, Jan 11, 2022

Is there anything I could add?

3reactions
fr-escocommented, Dec 11, 2021

Actually, I’m referring to multiple types, as per the last example of this page: https://json-schema.org/understanding-json-schema/reference/type.html

{ "type": ["number", "string"] }

The definition of type is:

The type keyword may either be a string or an array:

  • If it’s a string, it is the name of one of the basic types above.
  • If it is an array, it must be an array of strings, where each string is the name of one of the basic types, and each element is unique. In this case, the JSON snippet is valid if it matches any of the given types.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Correct JSON Schema for an array of items of different type
I don't want to specify an order, just validate the objects within the array, regardless of order or number of objects. From the...
Read more >
A Vocabulary for Structural Validation of JSON - JSON Schema
JSON Schema (application/schema+json) has several purposes, one of which is JSON ... possible instance values of the correct type that will fail validation....
Read more >
Understanding schema errors | HESA
Schema errors prevent the validation being run in full because the file cannot be ... This type of error is similar to the...
Read more >
Schema validation - Postman Quick Reference Guide
Schema validation ¶. This section contains different examples of validating JSON responses using the Ajv schema validator. I do not recommend using the...
Read more >
Schema Validation
An XML Schema precisely defines the elements and attributes that constitute an instance XML document. It also specifies the data types of these...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found