Skip to content

Commit 515df60

Browse files
committed
chore: update samples
1 parent a04602f commit 515df60

5 files changed

Lines changed: 118 additions & 2 deletions

File tree

samples/client/petstore/typescript-fetch/builds/oneOf/.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apis/DefaultApi.ts
22
apis/index.ts
33
index.ts
44
models/TestA.ts
5+
models/TestArrayResponse.ts
56
models/TestB.ts
67
models/TestResponse.ts
78
models/index.ts

samples/client/petstore/typescript-fetch/builds/oneOf/apis/DefaultApi.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515

1616
import * as runtime from '../runtime';
1717
import type {
18+
TestArrayResponse,
1819
TestResponse,
1920
} from '../models/index';
2021
import {
22+
TestArrayResponseFromJSON,
23+
TestArrayResponseToJSON,
2124
TestResponseFromJSON,
2225
TestResponseToJSON,
2326
} from '../models/index';
@@ -51,4 +54,28 @@ export class DefaultApi extends runtime.BaseAPI {
5154
return await response.value();
5255
}
5356

57+
/**
58+
*/
59+
async testArrayRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<TestArrayResponse>> {
60+
const queryParameters: any = {};
61+
62+
const headerParameters: runtime.HTTPHeaders = {};
63+
64+
const response = await this.request({
65+
path: `/test-array`,
66+
method: 'GET',
67+
headers: headerParameters,
68+
query: queryParameters,
69+
}, initOverrides);
70+
71+
return new runtime.JSONApiResponse(response, (jsonValue) => TestArrayResponseFromJSON(jsonValue));
72+
}
73+
74+
/**
75+
*/
76+
async testArray(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TestArrayResponse> {
77+
const response = await this.testArrayRaw(initOverrides);
78+
return await response.value();
79+
}
80+
5481
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
* testing oneOf without discriminator
5+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6+
*
7+
* The version of the OpenAPI document: 1.0.0
8+
*
9+
*
10+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11+
* https://openapi-generator.tech
12+
* Do not edit the class manually.
13+
*/
14+
15+
import type { TestA } from './TestA';
16+
import {
17+
instanceOfTestA,
18+
TestAFromJSON,
19+
TestAFromJSONTyped,
20+
TestAToJSON,
21+
} from './TestA';
22+
import type { TestB } from './TestB';
23+
import {
24+
instanceOfTestB,
25+
TestBFromJSON,
26+
TestBFromJSONTyped,
27+
TestBToJSON,
28+
} from './TestB';
29+
30+
/**
31+
* @type TestArrayResponse
32+
*
33+
* @export
34+
*/
35+
export type TestArrayResponse = Array<TestA> | Array<TestB> | Array<string>;
36+
37+
export function TestArrayResponseFromJSON(json: any): TestArrayResponse {
38+
return TestArrayResponseFromJSONTyped(json, false);
39+
}
40+
41+
export function TestArrayResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): TestArrayResponse {
42+
if (json == null) {
43+
return json;
44+
}
45+
if (Array.isArray(json)) {
46+
if (json.every(item => typeof item === 'object')) {
47+
if (json.every(item => instanceOfTestA(item))) {
48+
return json.map(value => TestAFromJSONTyped(value, true));
49+
}
50+
if (json.every(item => instanceOfTestB(item))) {
51+
return json.map(value => TestBFromJSONTyped(value, true));
52+
}
53+
}
54+
return json;
55+
}
56+
57+
return {} as any;
58+
}
59+
60+
export function TestArrayResponseToJSON(json: any): any {
61+
return TestArrayResponseToJSONTyped(json, false);
62+
}
63+
64+
export function TestArrayResponseToJSONTyped(value?: TestArrayResponse | null, ignoreDiscriminator: boolean = false): any {
65+
if (value == null) {
66+
return value;
67+
}
68+
if (Array.isArray(value)) {
69+
if (value.every(item => typeof item === 'object')) {
70+
if (value.every(item => instanceOfTestA(item))) {
71+
return value.map(value => TestAToJSON(value as TestA));
72+
}
73+
if (value.every(item => instanceOfTestB(item))) {
74+
return value.map(value => TestBToJSON(value as TestB));
75+
}
76+
}
77+
return value;
78+
}
79+
80+
return {};
81+
}
82+

samples/client/petstore/typescript-fetch/builds/oneOf/models/TestResponse.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
*
3333
* @export
3434
*/
35-
export type TestResponse = TestA | TestB;
35+
export type TestResponse = TestA | TestB | string;
3636

3737
export function TestResponseFromJSON(json: any): TestResponse {
3838
return TestResponseFromJSONTyped(json, false);
@@ -42,6 +42,9 @@ export function TestResponseFromJSONTyped(json: any, ignoreDiscriminator: boolea
4242
if (json == null) {
4343
return json;
4444
}
45+
if (typeof json !== 'object') {
46+
return json;
47+
}
4548
if (instanceOfTestA(json)) {
4649
return TestAFromJSONTyped(json, true);
4750
}
@@ -60,7 +63,9 @@ export function TestResponseToJSONTyped(value?: TestResponse | null, ignoreDiscr
6063
if (value == null) {
6164
return value;
6265
}
63-
66+
if (typeof value !== 'object') {
67+
return value;
68+
}
6469
if (instanceOfTestA(value)) {
6570
return TestAToJSON(value as TestA);
6671
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* tslint:disable */
22
/* eslint-disable */
33
export * from './TestA';
4+
export * from './TestArrayResponse';
45
export * from './TestB';
56
export * from './TestResponse';

0 commit comments

Comments
 (0)