Skip to content

Commit 920eafc

Browse files
authored
[typescript-fetch] add samples of nullable enum (#7754)
* [typescript-fetch] add sample * [typescript-fetch] add sample for nullable enums
1 parent 405aa24 commit 920eafc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+7381
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
generatorName: typescript-fetch
2+
outputDir: samples/client/petstore/typescript-fetch/builds/default-v3.0
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
generatorName: typescript-fetch
2+
outputDir: samples/client/petstore/typescript-fetch/builds/enum
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/typescript-fetch/enum.yaml
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
openapi: 3.0.0
2+
info:
3+
version: 1.0.0
4+
title: Enum test
5+
servers:
6+
- url: http://localhost:3000
7+
paths:
8+
/fake/enum-request-ref:
9+
get:
10+
operationId: fake-enum-request-get-ref
11+
parameters:
12+
- name: string-enum
13+
in: query
14+
schema:
15+
$ref: "#/components/schemas/StringEnum"
16+
- name: nullable-string-enum
17+
in: query
18+
schema:
19+
nullable: true
20+
allOf:
21+
- $ref: "#/components/schemas/StringEnum"
22+
- name: number-enum
23+
in: query
24+
schema:
25+
$ref: "#/components/schemas/NumberEnum"
26+
- name: nullable-number-enum
27+
in: query
28+
schema:
29+
nullable: true
30+
allOf:
31+
- $ref: "#/components/schemas/NumberEnum"
32+
responses:
33+
200:
34+
description: OK
35+
content:
36+
application/json:
37+
schema:
38+
$ref: '#/components/schemas/EnumPatternObject'
39+
post:
40+
operationId: fake-enum-request-post-ref
41+
responses:
42+
200:
43+
description: OK
44+
content:
45+
application/json:
46+
schema:
47+
$ref: '#/components/schemas/EnumPatternObject'
48+
requestBody:
49+
content:
50+
application/json:
51+
schema:
52+
$ref: "#/components/schemas/EnumPatternObject"
53+
/fake/enum-request-inline:
54+
get:
55+
operationId: fake-enum-request-get-inline
56+
parameters:
57+
- name: string-enum
58+
in: query
59+
schema:
60+
type: string
61+
enum:
62+
- one
63+
- two
64+
- three
65+
- name: nullable-string-enum
66+
in: query
67+
schema:
68+
nullable: true
69+
allOf:
70+
- type: string
71+
enum:
72+
- one
73+
- two
74+
- three
75+
- name: number-enum
76+
in: query
77+
schema:
78+
type: number
79+
enum:
80+
- 1
81+
- 2
82+
- 3
83+
- name: nullable-number-enum
84+
in: query
85+
schema:
86+
nullable: true
87+
allOf:
88+
- type: number
89+
enum:
90+
- 1
91+
- 2
92+
- 3
93+
responses:
94+
200:
95+
description: OK
96+
content:
97+
application/json:
98+
schema:
99+
type: object
100+
properties:
101+
string-enum:
102+
type: string
103+
enum:
104+
- one
105+
- two
106+
- three
107+
nullable-string-enum:
108+
nullable: true
109+
allOf:
110+
- type: string
111+
enum:
112+
- one
113+
- two
114+
- three
115+
number-enum:
116+
type: number
117+
enum:
118+
- 1
119+
- 2
120+
- 3
121+
nullable-number-enum:
122+
nullable: true
123+
allOf:
124+
- type: number
125+
enum:
126+
- 1
127+
- 2
128+
- 3
129+
post:
130+
operationId: fake-enum-request-post-inline
131+
responses:
132+
200:
133+
description: OK
134+
content:
135+
application/json:
136+
schema:
137+
type: object
138+
properties:
139+
string-enum:
140+
type: string
141+
enum:
142+
- one
143+
- two
144+
- three
145+
nullable-string-enum:
146+
nullable: true
147+
allOf:
148+
- type: string
149+
enum:
150+
- one
151+
- two
152+
- three
153+
number-enum:
154+
type: number
155+
enum:
156+
- 1
157+
- 2
158+
- 3
159+
nullable-number-enum:
160+
nullable: true
161+
allOf:
162+
- type: number
163+
enum:
164+
- 1
165+
- 2
166+
- 3
167+
requestBody:
168+
content:
169+
application/json:
170+
schema:
171+
type: object
172+
properties:
173+
string-enum:
174+
type: string
175+
enum:
176+
- one
177+
- two
178+
- three
179+
nullable-string-enum:
180+
nullable: true
181+
allOf:
182+
- type: string
183+
enum:
184+
- one
185+
- two
186+
- three
187+
number-enum:
188+
type: number
189+
enum:
190+
- 1
191+
- 2
192+
- 3
193+
nullable-number-enum:
194+
nullable: true
195+
allOf:
196+
- type: number
197+
enum:
198+
- 1
199+
- 2
200+
- 3
201+
components:
202+
schemas:
203+
StringEnum:
204+
type: string
205+
enum:
206+
- one
207+
- two
208+
- three
209+
NumberEnum:
210+
type: number
211+
enum:
212+
- 1
213+
- 2
214+
- 3
215+
EnumPatternObject:
216+
type: object
217+
properties:
218+
string-enum:
219+
$ref: "#/components/schemas/StringEnum"
220+
nullable-string-enum:
221+
nullable: true
222+
allOf:
223+
- $ref: "#/components/schemas/StringEnum"
224+
number-enum:
225+
$ref: "#/components/schemas/NumberEnum"
226+
nullable-number-enum:
227+
nullable: true
228+
allOf:
229+
- $ref: "#/components/schemas/NumberEnum"
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: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
apis/AnotherFakeApi.ts
2+
apis/DefaultApi.ts
3+
apis/FakeApi.ts
4+
apis/FakeClassnameTags123Api.ts
5+
apis/PetApi.ts
6+
apis/StoreApi.ts
7+
apis/UserApi.ts
8+
apis/index.ts
9+
index.ts
10+
models/AdditionalPropertiesClass.ts
11+
models/Animal.ts
12+
models/ArrayOfArrayOfNumberOnly.ts
13+
models/ArrayOfNumberOnly.ts
14+
models/ArrayTest.ts
15+
models/Capitalization.ts
16+
models/Cat.ts
17+
models/CatAllOf.ts
18+
models/Category.ts
19+
models/ClassModel.ts
20+
models/Client.ts
21+
models/Dog.ts
22+
models/DogAllOf.ts
23+
models/EnumArrays.ts
24+
models/EnumClass.ts
25+
models/EnumTest.ts
26+
models/FileSchemaTestClass.ts
27+
models/Foo.ts
28+
models/FormatTest.ts
29+
models/HasOnlyReadOnly.ts
30+
models/HealthCheckResult.ts
31+
models/InlineObject.ts
32+
models/InlineObject1.ts
33+
models/InlineObject2.ts
34+
models/InlineObject3.ts
35+
models/InlineObject4.ts
36+
models/InlineObject5.ts
37+
models/InlineResponseDefault.ts
38+
models/List.ts
39+
models/MapTest.ts
40+
models/MixedPropertiesAndAdditionalPropertiesClass.ts
41+
models/Model200Response.ts
42+
models/ModelApiResponse.ts
43+
models/ModelFile.ts
44+
models/Name.ts
45+
models/NullableClass.ts
46+
models/NumberOnly.ts
47+
models/Order.ts
48+
models/OuterComposite.ts
49+
models/OuterEnum.ts
50+
models/OuterEnumDefaultValue.ts
51+
models/OuterEnumInteger.ts
52+
models/OuterEnumIntegerDefaultValue.ts
53+
models/Pet.ts
54+
models/ReadOnlyFirst.ts
55+
models/Return.ts
56+
models/SpecialModelName.ts
57+
models/Tag.ts
58+
models/User.ts
59+
models/index.ts
60+
runtime.ts
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5.0.0-SNAPSHOT
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
* OpenAPI Petstore
5+
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
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+
import * as runtime from '../runtime';
17+
import {
18+
Client,
19+
ClientFromJSON,
20+
ClientToJSON,
21+
} from '../models';
22+
23+
export interface 123testSpecialTagsRequest {
24+
client: Client;
25+
}
26+
27+
/**
28+
*
29+
*/
30+
export class AnotherFakeApi extends runtime.BaseAPI {
31+
32+
/**
33+
* To test special tags and operation ID starting with number
34+
* To test special tags
35+
*/
36+
async _123testSpecialTagsRaw(requestParameters: 123testSpecialTagsRequest): Promise<runtime.ApiResponse<Client>> {
37+
if (requestParameters.client === null || requestParameters.client === undefined) {
38+
throw new runtime.RequiredError('client','Required parameter requestParameters.client was null or undefined when calling _123testSpecialTags.');
39+
}
40+
41+
const queryParameters: any = {};
42+
43+
const headerParameters: runtime.HTTPHeaders = {};
44+
45+
headerParameters['Content-Type'] = 'application/json';
46+
47+
const response = await this.request({
48+
path: `/another-fake/dummy`,
49+
method: 'PATCH',
50+
headers: headerParameters,
51+
query: queryParameters,
52+
body: ClientToJSON(requestParameters.client),
53+
});
54+
55+
return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue));
56+
}
57+
58+
/**
59+
* To test special tags and operation ID starting with number
60+
* To test special tags
61+
*/
62+
async _123testSpecialTags(requestParameters: 123testSpecialTagsRequest): Promise<Client> {
63+
const response = await this._123testSpecialTagsRaw(requestParameters);
64+
return await response.value();
65+
}
66+
67+
}

0 commit comments

Comments
 (0)