-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@ngtools/json-schema): serialize object properties better. (#4103)
The problem was that in an object that allowed additional properties, we were not serializing the object new values properly. Fixes #4044.
- Loading branch information
Showing
8 changed files
with
431 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
packages/@ngtools/json-schema/tests/serializer/schema1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"id": "JsonSchema", | ||
"type": "object", | ||
"properties": { | ||
"requiredKey": { | ||
"type": "number" | ||
}, | ||
"stringKeyDefault": { | ||
"type": "string", | ||
"default": "defaultValue" | ||
}, | ||
"stringKey": { | ||
"type": "string" | ||
}, | ||
"booleanKey": { | ||
"type": "boolean" | ||
}, | ||
"numberKey": { | ||
"type": "number" | ||
}, | ||
"oneOfKey1": { | ||
"oneOf": [ | ||
{ "type": "string" }, | ||
{ "type": "number" } | ||
] | ||
}, | ||
"oneOfKey2": { | ||
"oneOf": [ | ||
{ "type": "string" }, | ||
{ "type": "array", "items": { "type": "string" } } | ||
] | ||
}, | ||
"objectKey1": { | ||
"type": "object", | ||
"properties": { | ||
"stringKey": { | ||
"type": "string" | ||
}, | ||
"objectKey": { | ||
"type": "object", | ||
"properties": { | ||
"stringKey": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"objectKey2": { | ||
"type": "object", | ||
"properties": { | ||
"stringKey": { | ||
"type": "string", | ||
"default": "default objectKey2.stringKey" | ||
} | ||
}, | ||
"additionalProperties": true | ||
}, | ||
"arrayKey1": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"stringKey": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
}, | ||
"arrayKey2": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"stringKey": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"required": ["requiredKey"] | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/@ngtools/json-schema/tests/serializer/schema2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"id": "JsonSchema", | ||
"type": "object", | ||
"properties": { | ||
"a": { | ||
"type": "array", | ||
"items": { | ||
"enum": [ "v1", "v2", "v3" ] | ||
} | ||
} | ||
} | ||
} |
237 changes: 237 additions & 0 deletions
237
packages/@ngtools/json-schema/tests/serializer/schema3.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,237 @@ | ||
{ | ||
"$comment": "Please run `npm run build-config-interface` after changing this file. Thanks!", | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"id": "CliConfig", | ||
"title": "Angular CLI Config Schema", | ||
"type": "object", | ||
"properties": { | ||
"project": { | ||
"description": "The global configuration of the project.", | ||
"type": "object", | ||
"properties": { | ||
"version": { | ||
"type": "string" | ||
}, | ||
"name": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"apps": { | ||
"description": "Properties of the different applications in this project.", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"root": { | ||
"type": "string" | ||
}, | ||
"outDir": { | ||
"type": "string", | ||
"default": "dist/" | ||
}, | ||
"assets": { | ||
"oneOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"default": [] | ||
}, | ||
"deployUrl": { | ||
"type": "string" | ||
}, | ||
"index": { | ||
"type": "string", | ||
"default": "index.html" | ||
}, | ||
"main": { | ||
"type": "string" | ||
}, | ||
"test": { | ||
"type": "string" | ||
}, | ||
"tsconfig": { | ||
"type": "string", | ||
"default": "tsconfig.json" | ||
}, | ||
"prefix": { | ||
"type": "string" | ||
}, | ||
"mobile": { | ||
"type": "boolean" | ||
}, | ||
"styles": { | ||
"description": "Global styles to be included in the build.", | ||
"type": "array", | ||
"items": { | ||
"oneOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"input": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": true | ||
} | ||
] | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"scripts": { | ||
"description": "Global scripts to be included in the build.", | ||
"type": "array", | ||
"items": { | ||
"oneOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"input": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": true, | ||
"required": ["input"] | ||
} | ||
] | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"environments": { | ||
"description": "Name and corresponding file for environment config.", | ||
"type": "object", | ||
"additionalProperties": true | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"addons": { | ||
"description": "Configuration reserved for installed third party addons.", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": {}, | ||
"additionalProperties": true | ||
} | ||
}, | ||
"packages": { | ||
"description": "Configuration reserved for installed third party packages.", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": {}, | ||
"additionalProperties": true | ||
} | ||
}, | ||
"e2e": { | ||
"type": "object", | ||
"properties": { | ||
"protractor": { | ||
"type": "object", | ||
"properties": { | ||
"config": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"test": { | ||
"type": "object", | ||
"properties": { | ||
"karma": { | ||
"type": "object", | ||
"properties": { | ||
"config": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"defaults": { | ||
"type": "object", | ||
"properties": { | ||
"styleExt": { | ||
"type": "string" | ||
}, | ||
"prefixInterfaces": { | ||
"type": "boolean" | ||
}, | ||
"poll": { | ||
"type": "number" | ||
}, | ||
"viewEncapsulation": { | ||
"type": "string" | ||
}, | ||
"changeDetection": { | ||
"type": "string" | ||
}, | ||
"inline": { | ||
"type": "object", | ||
"properties": { | ||
"style": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"template": { | ||
"type": "boolean", | ||
"default": false | ||
} | ||
} | ||
}, | ||
"spec": { | ||
"type": "object", | ||
"properties": { | ||
"class": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"component": { | ||
"type": "boolean", | ||
"default": true | ||
}, | ||
"directive": { | ||
"type": "boolean", | ||
"default": true | ||
}, | ||
"module": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"pipe": { | ||
"type": "boolean", | ||
"default": true | ||
}, | ||
"service": { | ||
"type": "boolean", | ||
"default": true | ||
} | ||
} | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"additionalProperties": false | ||
} |
Oops, something went wrong.