Skip to content

Commit 168a8e6

Browse files
committed
Test generated description
1 parent 7d74fed commit 168a8e6

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed

modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/TypeScriptClientCodegenTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,33 @@ public void testUseErasableSyntaxConfig() throws IOException {
294294
}
295295
}
296296
}
297+
298+
@Test
299+
public void testRefDescription() throws Exception {
300+
final File output = Files.createTempDirectory("typescriptnodeclient_").toFile();
301+
output.deleteOnExit();
302+
303+
final CodegenConfigurator configurator = new CodegenConfigurator()
304+
.setGeneratorName("typescript")
305+
.setInputSpec("src/test/resources/3_0/typescript/ref-description.yaml")
306+
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
307+
308+
final ClientOptInput clientOptInput = configurator.toClientOptInput();
309+
final DefaultGenerator generator = new DefaultGenerator();
310+
final List<File> files = generator.opts(clientOptInput).generate();
311+
files.forEach(File::deleteOnExit);
312+
313+
Path file = Paths.get(output + "/models/PetUpdateRequest.ts");
314+
// verify ref description is found
315+
TestUtils.assertFileContains(
316+
file,
317+
"Reference description of Date schema"
318+
);
319+
// verify component description is not present
320+
TestUtils.assertFileNotContains(
321+
file,
322+
"Component description of Date schema"
323+
);
324+
}
325+
297326
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
openapi: 3.1.0
2+
info:
3+
description: test order parameters
4+
version: 1.0.0
5+
title: Test order parameters
6+
license:
7+
name: Apache-2.0
8+
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
9+
10+
paths:
11+
/pets:
12+
get:
13+
tags:
14+
- default
15+
summary: Finds Pets
16+
deprecated: true
17+
description: Find all pets
18+
operationId: findPets
19+
parameters:
20+
- name: type
21+
in: query
22+
description: type of pet
23+
style: form
24+
explode: false
25+
schema:
26+
type: string
27+
default: available
28+
- name: name
29+
in: query
30+
description: name of pet
31+
required: true
32+
schema:
33+
type: string
34+
- name: age
35+
in: query
36+
description: age of pet
37+
schema:
38+
type: number
39+
format: int32
40+
responses:
41+
'200':
42+
description: successful operation
43+
'400':
44+
description: Invalid status value
45+
46+
patch:
47+
tags:
48+
- default
49+
summary: Update a Pet
50+
description: Partially update an existing pet
51+
operationId: updatePet
52+
requestBody:
53+
required: true
54+
content:
55+
application/json:
56+
schema:
57+
$ref: '#/components/schemas/PetUpdateRequest'
58+
responses:
59+
'200':
60+
description: Pet updated successfully
61+
content:
62+
application/json:
63+
schema:
64+
$ref: '#/components/schemas/Pet'
65+
'400':
66+
description: Invalid input
67+
'404':
68+
description: Pet not found
69+
70+
components:
71+
schemas:
72+
PetUpdateRequest:
73+
type: object
74+
description: Payload for updating a pet
75+
properties:
76+
name:
77+
type: string
78+
description: New name for the pet
79+
age:
80+
type: integer
81+
format: int32
82+
description: Updated age
83+
type:
84+
type: string
85+
description: Type of pet
86+
date:
87+
$ref: "#/components/schemas/Date"
88+
description: Reference description of Date schema
89+
required:
90+
- name
91+
92+
Pet:
93+
type: object
94+
description: Pet object
95+
properties:
96+
id:
97+
type: integer
98+
format: int64
99+
name:
100+
type: string
101+
age:
102+
type: integer
103+
format: int32
104+
type:
105+
type: string
106+
107+
Date:
108+
type: string
109+
format: date
110+
description: Component description of Date schema
111+

0 commit comments

Comments
 (0)