Skip to content

Commit

Permalink
fix(cli): support extends in json schema generation (#4964)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Oct 21, 2024
1 parent 42b9259 commit bfc7aa0
Show file tree
Hide file tree
Showing 22 changed files with 675 additions and 698 deletions.
14 changes: 11 additions & 3 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
- changelogEntry:
- summary: |
Improved JSON Schema generation for object inheritance:
- Removed the use of `allOf` for representing object extensions
- Properties from parent objects are now directly added to the child object in the JSON Schema
type: fix
irVersion: 53
version: 0.45.0-rc11

- changelogEntry:
- summary: |
Added support for `additionalProperties` on export to JSON Schema.
type: feat
type: fix
irVersion: 53
version: 0.45.0-rc10


- changelogEntry:
- summary: |
Improved JSON Schema generation for object extensions and const values:
- Object extensions are now properly represented using `allOf` in the JSON Schema
- Literal values (string and boolean) are now correctly represented using `const` in the JSON Schema
type: internal
type: fix
irVersion: 53
version: 0.45.0-rc9

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
{
"type": "object",
"allOf": [
{
"$ref": "#/definitions/Parent"
}
],
"properties": {
"parent": {
"type": "string"
},
"child": {
"type": "string"
}
},
"required": [
"parent",
"child"
],
"additionalProperties": false,
"definitions": {
"Parent": {
"type": "object",
"properties": {
"parent": {
"type": "string"
}
},
"required": [
"parent"
],
"additionalProperties": false
}
}
"definitions": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"additionalProperties": false,
"definitions": {
"RootType": {
"a.A": {
"type": "object",
"properties": {
"s": {
Expand All @@ -18,15 +18,6 @@
"s"
],
"additionalProperties": false
},
"a.A": {
"type": "object",
"allOf": [
{
"$ref": "#/definitions/RootType"
}
],
"additionalProperties": false
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
{
"type": "object",
"allOf": [
{
"$ref": "#/definitions/RootType"
"properties": {
"s": {
"type": "string"
}
},
"required": [
"s"
],
"additionalProperties": false,
"definitions": {
"RootType": {
"type": "object",
"properties": {
"s": {
"type": "string"
}
},
"required": [
"s"
],
"additionalProperties": false
}
}
"definitions": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"additionalProperties": false,
"definitions": {
"RootType": {
"a.A": {
"type": "object",
"properties": {
"s": {
Expand All @@ -18,15 +18,6 @@
"s"
],
"additionalProperties": false
},
"a.A": {
"type": "object",
"allOf": [
{
"$ref": "#/definitions/RootType"
}
],
"additionalProperties": false
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
{
"type": "object",
"allOf": [
{
"$ref": "#/definitions/RootType"
"properties": {
"s": {
"type": "string"
}
},
"required": [
"s"
],
"additionalProperties": false,
"definitions": {
"RootType": {
"type": "object",
"properties": {
"s": {
"type": "string"
}
},
"required": [
"s"
],
"additionalProperties": false
}
}
"definitions": {}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
{
"type": "object",
"allOf": [
{
"$ref": "#/definitions/types.Movie"
}
],
"properties": {
"id": {
"$ref": "#/definitions/types.MovieId"
},
"prequel": {
"$ref": "#/definitions/types.MovieId"
},
"title": {
"type": "string"
},
"from": {
"type": "string"
},
"rating": {
"type": "number"
},
"type": {
"const": "movie"
},
"tag": {
"$ref": "#/definitions/commons.types.Tag"
},
"book": {
"type": "string"
},
"metadata": {
"type": "object",
"additionalProperties": {
"type": [
"string",
"number",
"boolean",
"object",
"array",
"null"
]
}
},
"revenue": {
"type": "integer"
},
"cast": {
"type": "array",
"items": {
Expand All @@ -14,6 +49,14 @@
}
},
"required": [
"id",
"title",
"from",
"rating",
"type",
"tag",
"metadata",
"revenue",
"cast"
],
"additionalProperties": false,
Expand All @@ -23,62 +66,6 @@
},
"commons.types.Tag": {
"type": "string"
},
"types.Movie": {
"type": "object",
"properties": {
"id": {
"$ref": "#/definitions/types.MovieId"
},
"prequel": {
"$ref": "#/definitions/types.MovieId"
},
"title": {
"type": "string"
},
"from": {
"type": "string"
},
"rating": {
"type": "number"
},
"type": {
"const": "movie"
},
"tag": {
"$ref": "#/definitions/commons.types.Tag"
},
"book": {
"type": "string"
},
"metadata": {
"type": "object",
"additionalProperties": {
"type": [
"string",
"number",
"boolean",
"object",
"array",
"null"
]
}
},
"revenue": {
"type": "integer"
}
},
"required": [
"id",
"title",
"from",
"rating",
"type",
"tag",
"metadata",
"revenue"
],
"additionalProperties": false
}
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
{
"type": "object",
"allOf": [
{
"$ref": "#/definitions/Docs"
}
],
"properties": {
"docs": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"docs",
"name"
],
"additionalProperties": false,
"definitions": {
"Docs": {
"type": "object",
"properties": {
"docs": {
"type": "string"
}
},
"required": [
"docs"
],
"additionalProperties": false
}
}
"definitions": {}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
{
"type": "object",
"allOf": [
{
"$ref": "#/definitions/Docs"
}
],
"properties": {
"docs": {
"type": "string"
},
"raw": {
"type": "string"
}
},
"required": [
"docs",
"raw"
],
"additionalProperties": false,
"definitions": {
"Docs": {
"type": "object",
"properties": {
"docs": {
"type": "string"
}
},
"required": [
"docs"
],
"additionalProperties": false
}
}
"definitions": {}
}
Loading

0 comments on commit bfc7aa0

Please sign in to comment.