diff --git a/src/__snapshots__/combiners/complex.test.ts.snap b/src/__snapshots__/combiners/complex.test.ts.snap index b9dd472..8a22d44 100644 --- a/src/__snapshots__/combiners/complex.test.ts.snap +++ b/src/__snapshots__/combiners/complex.test.ts.snap @@ -35,7 +35,9 @@ Generated server url{.openapi__request__description} "name": "b", "age": { "c": "c" - } + }, + "type": "string", + "bar": "string" } \`\`\` @@ -92,7 +94,9 @@ Base 200 response "name": "b", "age": { "c": "c" - } + }, + "type": "string", + "bar": "string" } \`\`\` diff --git a/src/__snapshots__/combiners/oneOf.test.ts.snap b/src/__snapshots__/combiners/oneOf.test.ts.snap index 0e4ae25..fed73d6 100644 --- a/src/__snapshots__/combiners/oneOf.test.ts.snap +++ b/src/__snapshots__/combiners/oneOf.test.ts.snap @@ -137,7 +137,9 @@ Generated server url{.openapi__request__description} \`\`\`json { "name": "string", - "age": 0 + "age": 0, + "type": "string", + "baz": "string" } \`\`\` @@ -190,7 +192,9 @@ Cat class \`\`\`json { "name": "string", - "age": 0 + "age": 0, + "type": "string", + "baz": "string" } \`\`\` @@ -251,7 +255,9 @@ Generated server url{.openapi__request__description} "pet": { "type": "string", "baz": "string" - } + }, + "type": "string", + "baz": "string" } \`\`\` @@ -305,7 +311,9 @@ Cat class "pet": { "type": "string", "baz": "string" - } + }, + "type": "string", + "baz": "string" } \`\`\` diff --git a/src/includer/traverse/tables.ts b/src/includer/traverse/tables.ts index dd5172c..f901bc1 100644 --- a/src/includer/traverse/tables.ts +++ b/src/includer/traverse/tables.ts @@ -235,6 +235,13 @@ function findNonNullOneOfElement(schema: OpenJSONSchema): OpenJSONSchema { const merged = RefsService.merge(v); if (Object.keys(merged.properties || {}).length) { + if (v.oneOf?.length) { + const option = v.oneOf[0]; + if (typeof option === 'object' && option.properties) { + v.properties = {...v.properties, ...option.properties} + } + delete v.oneOf; + } return v; }