Skip to content

Commit

Permalink
fix(cli): respect unions v1 config in generators.yml (#5565)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Jan 9, 2025
1 parent 7e831ae commit 0af8954
Show file tree
Hide file tree
Showing 7 changed files with 296 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,37 @@
"absoluteFilepath": "/DUMMY_PATH",
"contents": {
"types": {
"EnticingTitle": {
"Shape": {
"discriminated": false,
"docs": undefined,
"encoding": undefined,
"inline": undefined,
"source": {
"openapi": "../openapi.json",
},
"union": [
"Triangle",
"Square",
],
},
"Square": {
"docs": undefined,
"inline": undefined,
"properties": {
"id": {
"type": "optional<string>",
"validation": {
"format": "uuid",
"maxLength": undefined,
"minLength": undefined,
"pattern": undefined,
},
},
"sideLength": "double",
"type": "literal<"square">",
},
"source": {
"openapi": "../openapi.json",
},
},
"Triangle": {
"docs": undefined,
"inline": undefined,
"properties": {
"base": "double",
"height": "double",
"type": "literal<"triangle">",
},
"source": {
"openapi": "../openapi.json",
Expand All @@ -27,12 +45,24 @@
},
},
"rawContents": "types:
EnticingTitle:
Shape:
discriminated: false
union:
- Triangle
- Square
source:
openapi: ../openapi.json
Triangle:
properties:
type: literal<"triangle">
base: double
height: double
source:
openapi: ../openapi.json
Square:
properties:
id:
type: optional<string>
validation:
format: uuid
type: literal<"square">
sideLength: double
source:
openapi: ../openapi.json
",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,59 @@
"paths": {},
"components": {
"schemas": {
"SchemaWithALongNameIsRightHereAndNotSomewhereElse": {
"title": "EnticingTitle",
"Shape": {
"type": "object",
"discriminator": {
"propertyName": "type"
},
"oneOf": [
{
"$ref": "#/components/schemas/Triangle"
},
{
"$ref": "#/components/schemas/Square"
}
]
},
"Triangle": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"triangle"
]
},
"base": {
"type": "number"
},
"height": {
"type": "number"
}
},
"required": [
"type",
"base",
"height"
]
},
"Square": {
"type": "object",
"properties": {
"id": {
"type": {
"type": "string",
"format": "uuid"
"enum": [
"square"
]
},
"sideLength": {
"type": "number"
}
}
},
"required": [
"type",
"sideLength"
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,130 @@
"channel": [],
"groupedSchemas": {
"rootSchemas": {
"SchemaWithALongNameIsRightHereAndNotSomewhereElse": {
"Shape": {
"value": {
"generatedName": "Shape",
"schemas": [
{
"generatedName": "ShapeZero",
"schema": "Triangle",
"source": {
"file": "../openapi.json",
"type": "openapi"
},
"type": "reference"
},
{
"generatedName": "ShapeOne",
"schema": "Square",
"source": {
"file": "../openapi.json",
"type": "openapi"
},
"type": "reference"
}
],
"groupName": [],
"source": {
"file": "../openapi.json",
"type": "openapi"
},
"type": "undisciminated"
},
"type": "oneOf"
},
"Triangle": {
"allOf": [],
"properties": [
{
"conflict": {},
"generatedName": "schemaWithALongNameIsRightHereAndNotSomewhereElseId",
"key": "id",
"generatedName": "triangleType",
"key": "type",
"schema": {
"generatedName": "schemaWithALongNameIsRightHereAndNotSomewhereElseId",
"nameOverride": "EnticingTitle",
"title": "EnticingTitle",
"value": {
"schema": {
"format": "uuid",
"type": "string"
},
"generatedName": "SchemaWithALongNameIsRightHereAndNotSomewhereElseId",
"groupName": [],
"type": "primitive"
"value": "triangle",
"type": "string"
},
"generatedName": "TriangleType",
"groupName": [],
"type": "literal"
},
"audiences": []
},
{
"conflict": {},
"generatedName": "triangleBase",
"key": "base",
"schema": {
"schema": {
"type": "double"
},
"generatedName": "TriangleBase",
"groupName": [],
"type": "primitive"
},
"audiences": []
},
{
"conflict": {},
"generatedName": "triangleHeight",
"key": "height",
"schema": {
"schema": {
"type": "double"
},
"generatedName": "TriangleHeight",
"groupName": [],
"type": "primitive"
},
"audiences": []
}
],
"allOfPropertyConflicts": [],
"generatedName": "Triangle",
"groupName": [],
"additionalProperties": false,
"source": {
"file": "../openapi.json",
"type": "openapi"
},
"type": "object"
},
"Square": {
"allOf": [],
"properties": [
{
"conflict": {},
"generatedName": "squareType",
"key": "type",
"schema": {
"value": {
"value": "square",
"type": "string"
},
"generatedName": "SquareType",
"groupName": [],
"type": "literal"
},
"audiences": []
},
{
"conflict": {},
"generatedName": "squareSideLength",
"key": "sideLength",
"schema": {
"schema": {
"type": "double"
},
"generatedName": "SquareSideLength",
"groupName": [],
"type": "optional"
"type": "primitive"
},
"audiences": []
}
],
"allOfPropertyConflicts": [],
"generatedName": "SchemaWithALongNameIsRightHereAndNotSomewhereElse",
"nameOverride": "EnticingTitle",
"title": "EnticingTitle",
"generatedName": "Square",
"groupName": [],
"additionalProperties": false,
"source": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,37 @@
"absoluteFilepath": "/DUMMY_PATH",
"contents": {
"types": {
"EnticingTitle": {
"Shape": {
"discriminated": false,
"docs": undefined,
"encoding": undefined,
"inline": undefined,
"source": {
"openapi": "../openapi.json",
},
"union": [
"Triangle",
"Square",
],
},
"Square": {
"docs": undefined,
"inline": undefined,
"properties": {
"id": {
"type": "optional<string>",
"validation": {
"format": "uuid",
"maxLength": undefined,
"minLength": undefined,
"pattern": undefined,
},
},
"sideLength": "double",
"type": "literal<"square">",
},
"source": {
"openapi": "../openapi.json",
},
},
"Triangle": {
"docs": undefined,
"inline": undefined,
"properties": {
"base": "double",
"height": "double",
"type": "literal<"triangle">",
},
"source": {
"openapi": "../openapi.json",
Expand All @@ -27,12 +45,24 @@
},
},
"rawContents": "types:
EnticingTitle:
Shape:
discriminated: false
union:
- Triangle
- Square
source:
openapi: ../openapi.json
Triangle:
properties:
type: literal<"triangle">
base: double
height: double
source:
openapi: ../openapi.json
Square:
properties:
id:
type: optional<string>
validation:
format: uuid
type: literal<"square">
sideLength: double
source:
openapi: ../openapi.json
",
Expand Down
Loading

0 comments on commit 0af8954

Please sign in to comment.