Skip to content

Commit 72094f6

Browse files
Introduce a couple of broken schema parsing
1 parent d206b42 commit 72094f6

File tree

2 files changed

+121
-1
lines changed

2 files changed

+121
-1
lines changed

test/__snapshots__/index.spec.ts.snap

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3690,6 +3690,8 @@ export { OpenAPI } from './core/OpenAPI';
36903690
export type { OpenAPIConfig } from './core/OpenAPI';
36913691

36923692
export type { _default } from './models/_default';
3693+
export type { AnyOfAnyAndNull } from './models/AnyOfAnyAndNull';
3694+
export type { AnyOfArrays } from './models/AnyOfArrays';
36933695
export type { ArrayWithArray } from './models/ArrayWithArray';
36943696
export type { ArrayWithBooleans } from './models/ArrayWithBooleans';
36953697
export type { ArrayWithNumbers } from './models/ArrayWithNumbers';
@@ -3764,6 +3766,8 @@ export type { SimpleString } from './models/SimpleString';
37643766
export type { SimpleStringWithPattern } from './models/SimpleStringWithPattern';
37653767

37663768
export { $_default } from './schemas/$_default';
3769+
export { $AnyOfAnyAndNull } from './schemas/$AnyOfAnyAndNull';
3770+
export { $AnyOfArrays } from './schemas/$AnyOfArrays';
37673771
export { $ArrayWithArray } from './schemas/$ArrayWithArray';
37683772
export { $ArrayWithBooleans } from './schemas/$ArrayWithBooleans';
37693773
export { $ArrayWithNumbers } from './schemas/$ArrayWithNumbers';
@@ -3873,6 +3877,34 @@ export type _default = {
38733877
"
38743878
`;
38753879

3880+
exports[`v3 should generate: test/generated/v3/models/AnyOfAnyAndNull.ts 1`] = `
3881+
"/* generated using openapi-typescript-codegen -- do no edit */
3882+
/* istanbul ignore file */
3883+
/* tslint:disable */
3884+
/* eslint-disable */
3885+
export type AnyOfAnyAndNull = {
3886+
data?: any | null;
3887+
};
3888+
3889+
"
3890+
`;
3891+
3892+
exports[`v3 should generate: test/generated/v3/models/AnyOfArrays.ts 1`] = `
3893+
"/* generated using openapi-typescript-codegen -- do no edit */
3894+
/* istanbul ignore file */
3895+
/* tslint:disable */
3896+
/* eslint-disable */
3897+
export type AnyOfArrays = {
3898+
results?: Array<({
3899+
onePro?: boolean;
3900+
} | {
3901+
anotherProp?: boolean;
3902+
})>;
3903+
};
3904+
3905+
"
3906+
`;
3907+
38763908
exports[`v3 should generate: test/generated/v3/models/ArrayWithArray.ts 1`] = `
38773909
"/* generated using openapi-typescript-codegen -- do no edit */
38783910
/* istanbul ignore file */
@@ -5054,6 +5086,52 @@ export const $_default = {
50545086
"
50555087
`;
50565088

5089+
exports[`v3 should generate: test/generated/v3/schemas/$AnyOfAnyAndNull.ts 1`] = `
5090+
"/* generated using openapi-typescript-codegen -- do no edit */
5091+
/* istanbul ignore file */
5092+
/* tslint:disable */
5093+
/* eslint-disable */
5094+
export const $AnyOfAnyAndNull = {
5095+
properties: {
5096+
data: {
5097+
type: 'any-of',
5098+
contains: [{
5099+
type: 'null',
5100+
}],
5101+
},
5102+
},
5103+
} as const;
5104+
"
5105+
`;
5106+
5107+
exports[`v3 should generate: test/generated/v3/schemas/$AnyOfArrays.ts 1`] = `
5108+
"/* generated using openapi-typescript-codegen -- do no edit */
5109+
/* istanbul ignore file */
5110+
/* tslint:disable */
5111+
/* eslint-disable */
5112+
export const $AnyOfArrays = {
5113+
properties: {
5114+
results: {
5115+
type: 'any-of',
5116+
contains: [{
5117+
properties: {
5118+
onePro: {
5119+
type: 'boolean',
5120+
},
5121+
},
5122+
}, {
5123+
properties: {
5124+
anotherProp: {
5125+
type: 'boolean',
5126+
},
5127+
},
5128+
}],
5129+
},
5130+
},
5131+
} as const;
5132+
"
5133+
`;
5134+
50575135
exports[`v3 should generate: test/generated/v3/schemas/$ArrayWithArray.ts 1`] = `
50585136
"/* generated using openapi-typescript-codegen -- do no edit */
50595137
/* istanbul ignore file */

test/spec/v3.json

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,7 @@
20952095
}
20962096
}
20972097
},
2098-
"Enum1":{
2098+
"Enum1": {
20992099
"enum": [
21002100
"Bird",
21012101
"Dog"
@@ -2290,6 +2290,48 @@
22902290
}
22912291
}
22922292
},
2293+
"AnyOfAnyAndNull": {
2294+
"type": "object",
2295+
"properties": {
2296+
"data": {
2297+
"anyOf": [
2298+
{},
2299+
{
2300+
"type": "null"
2301+
}
2302+
]
2303+
}
2304+
}
2305+
},
2306+
"AnyOfArrays": {
2307+
"type": "object",
2308+
"properties": {
2309+
"results": {
2310+
"items": {
2311+
"anyOf": [
2312+
{
2313+
"type": "object",
2314+
"properties": {
2315+
"oneProp": {
2316+
"type": "boolean"
2317+
}
2318+
}
2319+
},
2320+
{
2321+
"type": "object",
2322+
"properties": {
2323+
"anotherProp": {
2324+
"type": "boolean"
2325+
}
2326+
}
2327+
}
2328+
]
2329+
},
2330+
"type": "array",
2331+
"title": "Results"
2332+
}
2333+
}
2334+
},
22932335
"CompositionBaseModel": {
22942336
"description": "This is a base model with two simple optional properties",
22952337
"type": "object",

0 commit comments

Comments
 (0)