Skip to content

Commit a92afd2

Browse files
authored
Add tests to cover base name (deep object) bug (#14142)
* better deepObject test * add tests to cover baseName (deep object) change
1 parent b8c8f4a commit a92afd2

File tree

3 files changed

+131
-49
lines changed

3 files changed

+131
-49
lines changed

modules/openapi-generator/src/test/java/org/openapitools/codegen/csharpnetcore/CSharpNetCoreClientDeepObjectTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public void deepObject() throws IOException {
5959
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
6060
generator.opts(input).generate();
6161
assertFileContains(Paths.get(outputPath + "/src/Org.OpenAPITools/Api/DefaultApi.cs"),
62-
"options[a]", "options[b]","inputOptions[b]");
62+
"options[id]", "options[name]", "options[category]", "options[tags]",
63+
"options[status]", "options[photoUrls]",
64+
"inputOptions[a]", "inputOptions[b]", "inputOptions[c]");
6365
}
6466
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public void deepObject() throws IOException {
5858
generator.opts(input).generate();
5959

6060
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/client/api/DefaultApi.java"),
61-
"options[a]", "options[b]", "\"csv\", \"options[c]\"", "inputOptions[a]");
61+
"options[id]", "options[name]", "options[status]",
62+
"\"csv\", \"options[tags]\"",
63+
"\"csv\", \"options[photoUrls]\"",
64+
"inputOptions[a]", "inputOptions[b]", "\"csv\", \"inputOptions[c]\"");
6265
}
6366
}
Lines changed: 124 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,124 @@
1-
openapi: 3.0.3
2-
info:
3-
title: deepobject-test
4-
version: 1.0.0
5-
paths:
6-
/test:
7-
get:
8-
operationId: test
9-
parameters:
10-
- name: options
11-
in: query
12-
required: false
13-
style: deepObject
14-
schema:
15-
$ref: '#/components/schemas/Options'
16-
explode: true
17-
- name: inputOptions
18-
in: query
19-
required: false
20-
style: deepObject
21-
schema:
22-
$ref: '#/components/schemas/Options'
23-
explode: true
24-
responses:
25-
'200':
26-
description: OK
27-
content:
28-
text/plain:
29-
schema:
30-
type: string
31-
components:
32-
schemas:
33-
Options:
34-
type: object
35-
properties:
36-
a:
37-
nullable: true
38-
type: string
39-
format: date-time
40-
b:
41-
type: string
42-
nullable: true
43-
format: date-time
44-
c:
45-
type: array
46-
items:
47-
type: string
1+
openapi: 3.0.3
2+
info:
3+
title: deepobject-test
4+
version: 1.0.0
5+
paths:
6+
/test:
7+
get:
8+
operationId: test
9+
parameters:
10+
- name: options
11+
in: query
12+
required: false
13+
style: deepObject
14+
schema:
15+
$ref: '#/components/schemas/Pet'
16+
explode: true
17+
- name: inputOptions
18+
in: query
19+
required: false
20+
style: deepObject
21+
schema:
22+
$ref: '#/components/schemas/Options'
23+
explode: true
24+
responses:
25+
'200':
26+
description: OK
27+
content:
28+
text/plain:
29+
schema:
30+
type: string
31+
post:
32+
operationId: test_post
33+
parameters:
34+
- name: query_object
35+
in: query
36+
required: false
37+
style: form
38+
schema:
39+
$ref: '#/components/schemas/Pet'
40+
explode: true
41+
responses:
42+
'200':
43+
description: OK
44+
content:
45+
text/plain:
46+
schema:
47+
type: string
48+
components:
49+
schemas:
50+
Options:
51+
type: object
52+
properties:
53+
a:
54+
nullable: true
55+
type: string
56+
format: date-time
57+
b:
58+
type: string
59+
nullable: true
60+
format: date-time
61+
c:
62+
type: array
63+
items:
64+
type: string
65+
Category:
66+
type: object
67+
properties:
68+
id:
69+
type: integer
70+
format: int64
71+
example: 1
72+
name:
73+
type: string
74+
example: Dogs
75+
xml:
76+
name: category
77+
Tag:
78+
type: object
79+
properties:
80+
id:
81+
type: integer
82+
format: int64
83+
name:
84+
type: string
85+
xml:
86+
name: tag
87+
Pet:
88+
required:
89+
- name
90+
- photoUrls
91+
type: object
92+
properties:
93+
id:
94+
type: integer
95+
format: int64
96+
example: 10
97+
name:
98+
type: string
99+
example: doggie
100+
category:
101+
$ref: '#/components/schemas/Category'
102+
photoUrls:
103+
type: array
104+
xml:
105+
wrapped: true
106+
items:
107+
type: string
108+
xml:
109+
name: photoUrl
110+
tags:
111+
type: array
112+
xml:
113+
wrapped: true
114+
items:
115+
$ref: '#/components/schemas/Tag'
116+
status:
117+
type: string
118+
description: pet status in the store
119+
enum:
120+
- available
121+
- pending
122+
- sold
123+
xml:
124+
name: pet

0 commit comments

Comments
 (0)