Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
}
}
{{/isNumeric}}
{{#isBoolean}}
if (Array.isArray(json)) {
if (json.every(item => typeof item === 'boolean'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === {{.}}{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
return json;
}
}
{{/isBoolean}}
{{#isString}}
if (Array.isArray(json)) {
if (json.every(item => typeof item === 'string'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === '{{.}}'{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
Expand Down Expand Up @@ -116,6 +123,11 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
return json;
}
{{/isNumeric}}
{{#isBoolean}}
if (typeof json === 'boolean'{{#isEnum}} && ({{#allowableValues}}{{#values}}json === {{.}}{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
return json;
}
{{/isBoolean}}
{{#isString}}
if (typeof json === 'string'{{#isEnum}} && ({{#allowableValues}}{{#values}}json === '{{.}}'{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
return json;
Expand Down Expand Up @@ -194,6 +206,13 @@ export function {{classname}}ToJSONTyped(value?: {{classname}} | null, ignoreDis
}
}
{{/isNumeric}}
{{#isBoolean}}
if (Array.isArray(value)) {
if (value.every(item => typeof item === 'boolean'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === {{.}}{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
return value;
}
}
{{/isBoolean}}
{{#isString}}
if (Array.isArray(value)) {
if (value.every(item => typeof item === 'string'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === '{{.}}'{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
Expand All @@ -219,6 +238,11 @@ export function {{classname}}ToJSONTyped(value?: {{classname}} | null, ignoreDis
return value;
}
{{/isNumeric}}
{{#isBoolean}}
if (typeof value === 'boolean'{{#isEnum}} && ({{#allowableValues}}{{#values}}value === {{.}}{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
return value;
}
{{/isBoolean}}
{{#isString}}
if (typeof value === 'string'{{#isEnum}} && ({{#allowableValues}}{{#values}}value === '{{.}}'{{^-last}} || {{/-last}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@ components:
- "optionTwo"
type: string
required:
- discriminatorField
- discriminatorField
VariousOneOf:
oneOf:
- type: string
- type: integer
- type: boolean
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ docs/TestArrayResponse.md
docs/TestB.md
docs/TestDiscriminatorResponse.md
docs/TestResponse.md
docs/VariousOneOf.md
index.ts
models/OptionOne.ts
models/OptionTwo.ts
Expand All @@ -16,5 +17,6 @@ models/TestArrayResponse.ts
models/TestB.ts
models/TestDiscriminatorResponse.ts
models/TestResponse.ts
models/VariousOneOf.ts
models/index.ts
runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

# VariousOneOf


## Properties

Name | Type
------------ | -------------

## Example

```typescript
import type { VariousOneOf } from ''

// TODO: Update the object below with actual values
const example = {
} satisfies VariousOneOf

console.log(example)

// Convert the instance to a JSON string
const exampleJSON: string = JSON.stringify(example)
console.log(exampleJSON)

// Parse the JSON string back to an object
const exampleParsed = JSON.parse(exampleJSON) as VariousOneOf
console.log(exampleParsed)
```

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)


Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
sdklfj;aklsdjf;ajsdkl
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04) @joscha (2024/10)

I intentionally tried to trigger a build failure by adding the line above but the test (https://github.com/OpenAPITools/openapi-generator/actions/runs/18831317610/job/53723166592?pr=22231) still passed

Do I need to do anything to have samples/client/petstore/typescript-fetch/builds/oneOf/ tested by CI?


/* 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.
*/

/**
* @type VariousOneOf
*
* @export
*/
export type VariousOneOf = boolean | number | string;

export function VariousOneOfFromJSON(json: any): VariousOneOf {
return VariousOneOfFromJSONTyped(json, false);
}

export function VariousOneOfFromJSONTyped(json: any, ignoreDiscriminator: boolean): VariousOneOf {
if (json == null) {
return json;
}
if (typeof json === 'boolean') {
return json;
}
if (typeof json === 'number') {
return json;
}
if (typeof json === 'string') {
return json;
}
return {} as any;
}

export function VariousOneOfToJSON(json: any): any {
return VariousOneOfToJSONTyped(json, false);
}

export function VariousOneOfToJSONTyped(value?: VariousOneOf | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
if (typeof value === 'boolean') {
return value;
}
if (typeof value === 'number') {
return value;
}
if (typeof value === 'string') {
return value;
}
return {};
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * from './TestArrayResponse';
export * from './TestB';
export * from './TestDiscriminatorResponse';
export * from './TestResponse';
export * from './VariousOneOf';
Loading