Skip to content

Commit

Permalink
Merge pull request #984 from tdakkota/feat/inline-oneOf
Browse files Browse the repository at this point in the history
feat(gen): inline `oneOf` into object schema
  • Loading branch information
ernado authored Jul 26, 2023
2 parents 8d25530 + e3ad021 commit eb1bcf6
Show file tree
Hide file tree
Showing 37 changed files with 9,132 additions and 294 deletions.
161 changes: 159 additions & 2 deletions _testdata/positive/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,23 @@
}
}
}
},
"/testInlineOneof": {
"get": {
"operationId": "testInlineOneof",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TestInlineOneOf"
}
}
}
}
}
}
}
},
"components": {
Expand Down Expand Up @@ -1423,7 +1440,6 @@
]
},
"OneOfMappingReference": {
"type": "object",
"oneOf": [
{
"$ref": "#/components/schemas/OneOfMappingReferenceA"
Expand Down Expand Up @@ -1816,6 +1832,147 @@
}
}
]
},
"TestInlineOneOf": {
"type": "object",
"properties": {
"inline_discriminator": {
"$ref": "#/components/schemas/InlineDiscriminatorOneOf"
},
"merge_discriminator": {
"$ref": "#/components/schemas/MergeDiscriminatorOneOf"
},
"inline_unique_fields": {
"$ref": "#/components/schemas/InlineUniqueFieldsOneOf"
},
"merge_unique_fields": {
"$ref": "#/components/schemas/MergeUniqueFieldsOneOf"
}
}
},
"InlineDiscriminatorOneOf": {
"type": "object",
"required": [
"common"
],
"properties": {
"common": {
"type": "string"
}
},
"oneOf": [
{
"$ref": "#/components/schemas/InlineOneOfFoo"
},
{
"$ref": "#/components/schemas/InlineOneOfBar"
}
],
"discriminator": {
"propertyName": "kind",
"mapping": {
"foo": "#/components/schemas/InlineOneOfFoo",
"bar": "#/components/schemas/InlineOneOfBar"
}
}
},
"MergeDiscriminatorOneOf": {
"allOf": [
{
"type": "object",
"required": [
"common"
],
"properties": {
"common": {
"type": "string"
}
}
},
{
"oneOf": [
{
"$ref": "#/components/schemas/InlineOneOfFoo"
},
{
"$ref": "#/components/schemas/InlineOneOfBar"
}
],
"discriminator": {
"propertyName": "kind",
"mapping": {
"foo": "#/components/schemas/InlineOneOfFoo",
"bar": "#/components/schemas/InlineOneOfBar"
}
}
}
]
},
"InlineUniqueFieldsOneOf": {
"type": "object",
"required": [
"common"
],
"properties": {
"common": {
"type": "string"
}
},
"oneOf": [
{
"$ref": "#/components/schemas/InlineOneOfFoo"
},
{
"$ref": "#/components/schemas/InlineOneOfBar"
}
]
},
"MergeUniqueFieldsOneOf": {
"allOf": [
{
"type": "object",
"required": [
"common"
],
"properties": {
"common": {
"type": "string"
}
}
},
{
"oneOf": [
{
"$ref": "#/components/schemas/InlineOneOfFoo"
},
{
"$ref": "#/components/schemas/InlineOneOfBar"
}
]
}
]
},
"InlineOneOfFoo": {
"type": "object",
"properties": {
"kind": {
"type": "string"
},
"foo": {
"type": "string"
}
}
},
"InlineOneOfBar": {
"type": "object",
"properties": {
"kind": {
"type": "string"
},
"bar": {
"type": "string"
}
}
}
},
"parameters": {
Expand Down Expand Up @@ -1922,4 +2079,4 @@
}
}
}
}
}
9 changes: 9 additions & 0 deletions examples/ex_2ch/oas_json_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions examples/ex_github/oas_json_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit eb1bcf6

Please sign in to comment.