Skip to content

Commit 5b5639d

Browse files
committed
Add fixture sample
1 parent f3a6b10 commit 5b5639d

13 files changed

Lines changed: 833 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
generatorName: typescript-fetch
2+
outputDir: samples/client/others/typescript-fetch/infinite-recursion-issue
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/typescript-fetch/infinite-recursion-issue.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/typescript-fetch
5+
additionalProperties:
6+
enumPropertyNaming: "original"
7+
enumUnknownDefaultCase: true
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
openapi: 3.0.3
2+
info:
3+
title: Minimal
4+
description: Api to reproduce bug
5+
version: 0.5.1-SNAPSHOT.0
6+
tags:
7+
- name: test
8+
servers:
9+
- url: http://localhost:8080
10+
paths:
11+
/api/v1/test:
12+
get:
13+
tags:
14+
- test
15+
operationId: test
16+
responses:
17+
"200":
18+
description: test operation
19+
content:
20+
application/json:
21+
schema:
22+
type: array
23+
items:
24+
$ref: "#/components/schemas/TestBaseDto"
25+
26+
components:
27+
schemas:
28+
TestObjectType:
29+
type: string
30+
enum:
31+
- TEST1
32+
- TEST2
33+
TestBaseDto:
34+
type: object
35+
properties:
36+
something:
37+
type: string
38+
testObjectType:
39+
$ref: "#/components/schemas/TestObjectType"
40+
discriminator:
41+
propertyName: testObjectType
42+
mapping:
43+
TEST2: '#/components/schemas/ExtendDto'
44+
TEST1: '#/components/schemas/TestBaseDto'
45+
ExtendDto:
46+
allOf:
47+
- $ref: '#/components/schemas/TestBaseDto'
48+
- type: object
49+
properties:
50+
someItems:
51+
type: array
52+
items:
53+
$ref: '#/components/schemas/TestBaseDto'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.openapi-generator-ignore
2+
apis/TestApi.ts
3+
apis/index.ts
4+
index.ts
5+
models/ExtendDto.ts
6+
models/TestBaseDto.ts
7+
models/TestObjectType.ts
8+
models/index.ts
9+
runtime.ts
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.17.0-SNAPSHOT
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
* Minimal
5+
* Api to reproduce bug
6+
*
7+
* The version of the OpenAPI document: 0.5.1-SNAPSHOT.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+
import * as runtime from '../runtime';
17+
import type {
18+
TestBaseDto,
19+
} from '../models/index';
20+
import {
21+
TestBaseDtoFromJSON,
22+
TestBaseDtoToJSON,
23+
} from '../models/index';
24+
25+
/**
26+
*
27+
*/
28+
export class TestApi extends runtime.BaseAPI {
29+
30+
/**
31+
*/
32+
async testRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<TestBaseDto>>> {
33+
const queryParameters: any = {};
34+
35+
const headerParameters: runtime.HTTPHeaders = {};
36+
37+
38+
let urlPath = `/api/v1/test`;
39+
40+
const response = await this.request({
41+
path: urlPath,
42+
method: 'GET',
43+
headers: headerParameters,
44+
query: queryParameters,
45+
}, initOverrides);
46+
47+
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(TestBaseDtoFromJSON));
48+
}
49+
50+
/**
51+
*/
52+
async test(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<TestBaseDto>> {
53+
const response = await this.testRaw(initOverrides);
54+
return await response.value();
55+
}
56+
57+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
export * from './TestApi';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
export * from './runtime';
4+
export * from './apis/index';
5+
export * from './models/index';
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+
* Minimal
5+
* Api to reproduce bug
6+
*
7+
* The version of the OpenAPI document: 0.5.1-SNAPSHOT.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 { mapValues } from '../runtime';
16+
import type { TestBaseDto } from './TestBaseDto';
17+
import {
18+
TestBaseDtoFromJSON,
19+
TestBaseDtoFromJSONTyped,
20+
TestBaseDtoToJSON,
21+
TestBaseDtoToJSONTyped,
22+
} from './TestBaseDto';
23+
import type { TestObjectType } from './TestObjectType';
24+
import {
25+
TestObjectTypeFromJSON,
26+
TestObjectTypeFromJSONTyped,
27+
TestObjectTypeToJSON,
28+
TestObjectTypeToJSONTyped,
29+
} from './TestObjectType';
30+
31+
/**
32+
*
33+
* @export
34+
* @interface ExtendDto
35+
*/
36+
export interface ExtendDto extends TestBaseDto {
37+
/**
38+
*
39+
* @type {Array<TestBaseDto>}
40+
* @memberof ExtendDto
41+
*/
42+
someItems?: Array<TestBaseDto>;
43+
}
44+
45+
46+
47+
/**
48+
* Check if a given object implements the ExtendDto interface.
49+
*/
50+
export function instanceOfExtendDto(value: object): value is ExtendDto {
51+
return true;
52+
}
53+
54+
export function ExtendDtoFromJSON(json: any): ExtendDto {
55+
return ExtendDtoFromJSONTyped(json, false);
56+
}
57+
58+
export function ExtendDtoFromJSONTyped(json: any, ignoreDiscriminator: boolean): ExtendDto {
59+
if (json == null) {
60+
return json;
61+
}
62+
return {
63+
...TestBaseDtoFromJSONTyped(json, true),
64+
'someItems': json['someItems'] == null ? undefined : ((json['someItems'] as Array<any>).map(TestBaseDtoFromJSON)),
65+
};
66+
}
67+
68+
export function ExtendDtoToJSON(json: any): ExtendDto {
69+
return ExtendDtoToJSONTyped(json, false);
70+
}
71+
72+
export function ExtendDtoToJSONTyped(value?: ExtendDto | null, ignoreDiscriminator: boolean = false): any {
73+
if (value == null) {
74+
return value;
75+
}
76+
77+
return {
78+
...TestBaseDtoToJSONTyped(value, true),
79+
'someItems': value['someItems'] == null ? undefined : ((value['someItems'] as Array<any>).map(TestBaseDtoToJSON)),
80+
};
81+
}
82+
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
* Minimal
5+
* Api to reproduce bug
6+
*
7+
* The version of the OpenAPI document: 0.5.1-SNAPSHOT.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 { mapValues } from '../runtime';
16+
import type { TestObjectType } from './TestObjectType';
17+
import {
18+
TestObjectTypeFromJSON,
19+
TestObjectTypeFromJSONTyped,
20+
TestObjectTypeToJSON,
21+
TestObjectTypeToJSONTyped,
22+
} from './TestObjectType';
23+
24+
import { type ExtendDto, ExtendDtoFromJSONTyped, ExtendDtoToJSON, ExtendDtoToJSONTyped } from './ExtendDto';
25+
/**
26+
*
27+
* @export
28+
* @interface TestBaseDto
29+
*/
30+
export interface TestBaseDto {
31+
/**
32+
*
33+
* @type {string}
34+
* @memberof TestBaseDto
35+
*/
36+
something?: string;
37+
/**
38+
*
39+
* @type {TestObjectType}
40+
* @memberof TestBaseDto
41+
*/
42+
testObjectType?: TestObjectType;
43+
}
44+
45+
46+
47+
/**
48+
* Check if a given object implements the TestBaseDto interface.
49+
*/
50+
export function instanceOfTestBaseDto(value: object): value is TestBaseDto {
51+
return true;
52+
}
53+
54+
export function TestBaseDtoFromJSON(json: any): TestBaseDto {
55+
return TestBaseDtoFromJSONTyped(json, false);
56+
}
57+
58+
export function TestBaseDtoFromJSONTyped(json: any, ignoreDiscriminator: boolean): TestBaseDto {
59+
if (json == null) {
60+
return json;
61+
}
62+
if (!ignoreDiscriminator) {
63+
if (json['testObjectType'] === 'TEST2') {
64+
return ExtendDtoFromJSONTyped(json, ignoreDiscriminator);
65+
}
66+
if (json['testObjectType'] === 'TEST1') {
67+
return TestBaseDtoFromJSONTyped(json, true);
68+
}
69+
70+
}
71+
return {
72+
73+
'something': json['something'] == null ? undefined : json['something'],
74+
'testObjectType': json['testObjectType'] == null ? undefined : TestObjectTypeFromJSON(json['testObjectType']),
75+
};
76+
}
77+
78+
export function TestBaseDtoToJSON(json: any): TestBaseDto {
79+
return TestBaseDtoToJSONTyped(json, false);
80+
}
81+
82+
export function TestBaseDtoToJSONTyped(value?: TestBaseDto | null, ignoreDiscriminator: boolean = false): any {
83+
if (value == null) {
84+
return value;
85+
}
86+
87+
if (!ignoreDiscriminator) {
88+
switch (value['testObjectType']) {
89+
case 'TEST2':
90+
return ExtendDtoToJSONTyped(value as ExtendDto, ignoreDiscriminator);
91+
default:
92+
return value;
93+
}
94+
}
95+
96+
return {
97+
98+
'something': value['something'],
99+
'testObjectType': TestObjectTypeToJSON(value['testObjectType']),
100+
};
101+
}
102+

0 commit comments

Comments
 (0)