forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
175 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
samples/client/petstore/typescript-fetch/builds/oneOf/models/TestArrayResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* testing oneOf without discriminator | ||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | ||
* | ||
* The version of the OpenAPI document: 1.0.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
import type { TestA } from './TestA'; | ||
import { | ||
instanceOfTestA, | ||
TestAFromJSON, | ||
TestAFromJSONTyped, | ||
TestAToJSON, | ||
} from './TestA'; | ||
import type { TestB } from './TestB'; | ||
import { | ||
instanceOfTestB, | ||
TestBFromJSON, | ||
TestBFromJSONTyped, | ||
TestBToJSON, | ||
} from './TestB'; | ||
|
||
/** | ||
* @type TestArrayResponse | ||
* | ||
* @export | ||
*/ | ||
export type TestArrayResponse = Array<TestA> | Array<TestB> | Array<string>; | ||
|
||
export function TestArrayResponseFromJSON(json: any): TestArrayResponse { | ||
return TestArrayResponseFromJSONTyped(json, false); | ||
} | ||
|
||
export function TestArrayResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): TestArrayResponse { | ||
if (json == null) { | ||
return json; | ||
} | ||
if (!(json instanceof Object)){ | ||
return {} as any; | ||
} | ||
if (Array.isArray(json) && json.every(item => item instanceof String)) { | ||
return json as Array<string>; | ||
} | ||
if (Array.isArray(json) && json.every(item => item instanceof Object)) { | ||
if (json.every(item => instanceOfTestB(item as Object))) { | ||
return json.map(value => TestBFromJSONTyped(value, true)); | ||
} | ||
if (json.every(item => instanceOfTestA(item as Object))) { | ||
return json.map(value => TestAFromJSONTyped(value, true)); | ||
} | ||
} | ||
|
||
return {} as any; | ||
} | ||
|
||
export function TestArrayResponseToJSON(json: any): any { | ||
return TestArrayResponseToJSONTyped(json, false); | ||
} | ||
|
||
export function TestArrayResponseToJSONTyped(value?: TestArrayResponse | null, ignoreDiscriminator: boolean = false): any { | ||
if (value == null) { | ||
return value; | ||
} | ||
|
||
|
||
if (!(value instanceof Object)){ | ||
return {}; | ||
} | ||
if (Array.isArray(value) && value.every(item => item instanceof String)) { | ||
return value; | ||
} | ||
if (Array.isArray(value) && value.every(item => item instanceof Object)) { | ||
if (value.every(item => instanceOfTestB(item as Object))) { | ||
return value.map(value => TestBToJSON(value as TestB)); | ||
} | ||
if (value.every(item => instanceOfTestA(item as Object))) { | ||
return value.map(value => TestAToJSON(value as TestA)); | ||
} | ||
} | ||
|
||
return {}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
samples/client/petstore/typescript-fetch/builds/oneOf/models/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export * from './TestA'; | ||
export * from './TestArrayResponse'; | ||
export * from './TestB'; | ||
export * from './TestResponse'; |