Skip to content

Commit 15ffa56

Browse files
committed
add tests for oneof primitive types
1 parent bbfe479 commit 15ffa56

File tree

5 files changed

+102
-1
lines changed

5 files changed

+102
-1
lines changed

modules/openapi-generator/src/test/resources/3_0/typescript-fetch/oneOf.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,9 @@ components:
9393
- "optionTwo"
9494
type: string
9595
required:
96-
- discriminatorField
96+
- discriminatorField
97+
VariousOneOf:
98+
oneOf:
99+
- type: string
100+
- type: integer
101+
- type: boolean

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ docs/TestArrayResponse.md
88
docs/TestB.md
99
docs/TestDiscriminatorResponse.md
1010
docs/TestResponse.md
11+
docs/VariousOneOf.md
1112
index.ts
1213
models/OptionOne.ts
1314
models/OptionTwo.ts
@@ -16,5 +17,6 @@ models/TestArrayResponse.ts
1617
models/TestB.ts
1718
models/TestDiscriminatorResponse.ts
1819
models/TestResponse.ts
20+
models/VariousOneOf.ts
1921
models/index.ts
2022
runtime.ts
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
# VariousOneOf
3+
4+
5+
## Properties
6+
7+
Name | Type
8+
------------ | -------------
9+
10+
## Example
11+
12+
```typescript
13+
import type { VariousOneOf } from ''
14+
15+
// TODO: Update the object below with actual values
16+
const example = {
17+
} satisfies VariousOneOf
18+
19+
console.log(example)
20+
21+
// Convert the instance to a JSON string
22+
const exampleJSON: string = JSON.stringify(example)
23+
console.log(exampleJSON)
24+
25+
// Parse the JSON string back to an object
26+
const exampleParsed = JSON.parse(exampleJSON) as VariousOneOf
27+
console.log(exampleParsed)
28+
```
29+
30+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
31+
32+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
/**
16+
* @type VariousOneOf
17+
*
18+
* @export
19+
*/
20+
export type VariousOneOf = boolean | number | string;
21+
22+
export function VariousOneOfFromJSON(json: any): VariousOneOf {
23+
return VariousOneOfFromJSONTyped(json, false);
24+
}
25+
26+
export function VariousOneOfFromJSONTyped(json: any, ignoreDiscriminator: boolean): VariousOneOf {
27+
if (json == null) {
28+
return json;
29+
}
30+
if (typeof json === 'boolean') {
31+
return json;
32+
}
33+
if (typeof json === 'number') {
34+
return json;
35+
}
36+
if (typeof json === 'string') {
37+
return json;
38+
}
39+
return {} as any;
40+
}
41+
42+
export function VariousOneOfToJSON(json: any): any {
43+
return VariousOneOfToJSONTyped(json, false);
44+
}
45+
46+
export function VariousOneOfToJSONTyped(value?: VariousOneOf | null, ignoreDiscriminator: boolean = false): any {
47+
if (value == null) {
48+
return value;
49+
}
50+
if (typeof value === 'boolean') {
51+
return value;
52+
}
53+
if (typeof value === 'number') {
54+
return value;
55+
}
56+
if (typeof value === 'string') {
57+
return value;
58+
}
59+
return {};
60+
}
61+

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export * from './TestArrayResponse';
77
export * from './TestB';
88
export * from './TestDiscriminatorResponse';
99
export * from './TestResponse';
10+
export * from './VariousOneOf';

0 commit comments

Comments
 (0)