Skip to content

Commit 79e800a

Browse files
authored
Merge pull request #9336 from swagger-api/issue-9132-master
ref #9132 - Handle UntypedProperty
2 parents 3ceedcc + a9b73cd commit 79e800a

File tree

3 files changed

+341
-0
lines changed

3 files changed

+341
-0
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.regex.Matcher;
88
import java.util.regex.Pattern;
99

10+
import io.swagger.models.properties.UntypedProperty;
1011
import org.apache.commons.lang3.ObjectUtils;
1112
import org.apache.commons.lang3.StringEscapeUtils;
1213
import org.apache.commons.lang3.StringUtils;
@@ -1168,6 +1169,8 @@ public String getSwaggerType(Property p) {
11681169
}
11691170
} else if (p instanceof StringProperty) {
11701171
datatype = "string";
1172+
} else if(p instanceof UntypedProperty){
1173+
datatype = "object";
11711174
} else {
11721175
if (p != null) {
11731176
datatype = p.getType();

modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class DefaultGeneratorTest {
3636

3737
private static final String LIBRARY_COMMENT = "//overloaded template file within library folder to add this comment";
3838
private static final String TEMPLATE_COMMENT = "//overloaded main template file to add this comment";
39+
private static final String MODEL_DEFAULT_API_FILE = "/src/main/java/io/swagger/client/api/DefaultApi.java";
3940

4041
public TemporaryFolder folder = new TemporaryFolder();
4142

@@ -206,6 +207,24 @@ public void testSkipOverwrite() throws Exception {
206207
// assertTrue(pom.exists());
207208
}
208209

210+
@Test
211+
public void testIssue9132() throws Exception {
212+
final File output = folder.getRoot();
213+
214+
final Swagger swagger = new SwaggerParser().read("src/test/resources/2_0/issue-9132.yaml");
215+
CodegenConfig codegenConfig = new JavaClientCodegen();
216+
codegenConfig.setLibrary("jersey1");
217+
codegenConfig.setOutputDir(output.getAbsolutePath());
218+
219+
ClientOptInput clientOptInput = new ClientOptInput().opts(new ClientOpts()).swagger(swagger).config(codegenConfig);
220+
221+
//generate
222+
new DefaultGenerator().opts(clientOptInput).generate();
223+
final File defaultApi = new File(output, MODEL_DEFAULT_API_FILE);
224+
assertTrue(defaultApi.exists());
225+
226+
}
227+
209228
private boolean containsOverloadedComments(File file, String ...search) throws IOException {
210229
for (String line : Files.readAllLines(file.toPath(), Charset.defaultCharset())) {
211230
if (StringUtils.containsAny(line, search)) {
Lines changed: 319 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
---
2+
swagger: '2.0'
3+
info:
4+
title: alip-agent
5+
description: ALIP Agent Summary
6+
version: '1.0'
7+
host: eastus.cloudapp.azure.com
8+
basePath: "/alip-agents"
9+
schemes:
10+
- http
11+
paths:
12+
"/agents/{id}/summary":
13+
get:
14+
description: Get Agent Summary from ALIP
15+
parameters:
16+
- name: client_id
17+
required: true
18+
in: query
19+
type: string
20+
- name: client_secret
21+
required: true
22+
in: query
23+
type: string
24+
- name: id
25+
description: Agent Number
26+
required: true
27+
in: path
28+
default: '131'
29+
type: string
30+
responses:
31+
'200':
32+
description: ''
33+
x-amf-mediaType: application/json
34+
schema:
35+
example:
36+
TXLife:
37+
TXLifeResponse:
38+
TransRefGUID: acbd73e3-e17f-5f66-e320-226f8e4b7c7d
39+
TransExeDate: '2017-09-14'
40+
TransExeTime: '01:34:20'
41+
OLifE:
42+
Party:
43+
"@id": Party_1
44+
EMailAddress:
45+
EMailType:
46+
"@tc": '2'
47+
"$": Personal
48+
49+
PartySysKey: 35
50+
FullName: Lisa Spencer
51+
Address:
52+
- LastUpdate: '2017-09-11'
53+
Zip: 10111
54+
Line3:
55+
EndDate: '2999-12-31'
56+
StartDate: '2014-01-07'
57+
LastUpdateTime: 02:21:16-04:00
58+
Line2: 14th Floor
59+
AddressCountryTC:
60+
"@tc": '1'
61+
"$": USA
62+
City: NEW YORK
63+
AddressSysKey: 2
64+
AddressState: New York
65+
Line1: 449 Fifth Avenue
66+
"@id": Address_1
67+
AddressTypeCode:
68+
"@tc": '2'
69+
"$": Business
70+
AddressStateTC:
71+
"@tc": '37'
72+
"$": NY
73+
AddressCountry: United States of America
74+
- Zip: 08837
75+
AddressCountry: United States of America
76+
LastUpdateTime: 02:43:54-04:00
77+
Line2:
78+
"@id": Address_2
79+
StartDate: '2014-01-09'
80+
City: Edison
81+
AddressTypeCode:
82+
"@tc": '1'
83+
"$": Home
84+
EndDate: '2999-12-31'
85+
Line3:
86+
AddressSysKey: 52466
87+
LastUpdate: '2017-09-12'
88+
AddressCountryTC:
89+
"@tc": '1'
90+
"$": USA
91+
AddressStateTC:
92+
"@tc": '35'
93+
"$": NJ
94+
AddressState: New Jersey
95+
Line1: 500 Main Street Y
96+
OLifEExtension:
97+
VendorCode: 33
98+
Holding:
99+
id: Holding_1
100+
HoldingTypeCode:
101+
tc: 2
102+
content: Policy
103+
HoldingName: "#839438asdfghjk"
104+
Policy:
105+
id: Policy_1
106+
PolNumber: 839438
107+
ProductType:
108+
tc: 1
109+
content: Standard Flexible VUL
110+
isTrad: false
111+
GovtIDTC:
112+
"@tc": '1'
113+
"$": Social Security Number US
114+
GovtID: 126319308
115+
Person:
116+
MiddleName: ''
117+
FirstName: Lisa
118+
Gender:
119+
"@tc": '2'
120+
"$": Female
121+
LastName: Spencer
122+
BirthDate: '1900-01-01'
123+
Phone:
124+
- PhoneTypeCode:
125+
"@tc": '1'
126+
"$": Home
127+
DialNumber:
128+
- PhoneTypeCode:
129+
"@tc": '12'
130+
"$": Mobile
131+
AreaCode: 111
132+
DialNumber: 1111111
133+
- PhoneTypeCode:
134+
"@tc": '2'
135+
"$": Other
136+
AreaCode: 456
137+
DialNumber: 7897656
138+
TransResult:
139+
ResultCode:
140+
"@tc": '1'
141+
"$": Success
142+
TransType:
143+
"@tc": '204'
144+
"$": Agent Party Inquiry
145+
type: object
146+
additionalProperties: true
147+
properties:
148+
TXLife:
149+
type: object
150+
additionalProperties: true
151+
properties:
152+
TXLifeResponse:
153+
type: object
154+
additionalProperties: true
155+
properties:
156+
OLifE:
157+
type: object
158+
additionalProperties: true
159+
properties:
160+
Party:
161+
type: object
162+
additionalProperties: true
163+
properties:
164+
Address:
165+
type: array
166+
additionalProperties: true
167+
items:
168+
type: object
169+
properties:
170+
AddressCountry:
171+
type: string
172+
AddressCountryTC:
173+
properties:
174+
content:
175+
type: string
176+
tc:
177+
type: integer
178+
type: object
179+
additionalProperties: true
180+
AddressKey:
181+
type: integer
182+
AddressState:
183+
type: string
184+
AddressStateTC:
185+
type: object
186+
additionalProperties: true
187+
properties:
188+
content:
189+
type: string
190+
tc:
191+
type: integer
192+
AddressTypeCode:
193+
type: object
194+
additionalProperties: true
195+
properties:
196+
content:
197+
type: string
198+
tc:
199+
type: integer
200+
City:
201+
type: string
202+
EndDate:
203+
type: string
204+
LastUpdate:
205+
type: string
206+
LastUpdateTime:
207+
type: string
208+
Line1:
209+
type: string
210+
Line2:
211+
type: string
212+
Line3:
213+
type: string
214+
StartDate:
215+
type: string
216+
Zip:
217+
type: integer
218+
id:
219+
type: string
220+
EMailAddress:
221+
type: object
222+
additionalProperties: true
223+
properties:
224+
AddrLine:
225+
type: string
226+
EMailType:
227+
type: object
228+
additionalProperties: true
229+
properties:
230+
content:
231+
type: string
232+
tc:
233+
type: integer
234+
FullName:
235+
type: string
236+
GovtID:
237+
type: integer
238+
GovtIDTC:
239+
type: object
240+
additionalProperties: true
241+
properties:
242+
content:
243+
type: string
244+
tc:
245+
type: integer
246+
PartyKey:
247+
type: integer
248+
Person:
249+
type: object
250+
additionalProperties: true
251+
properties:
252+
BirthDate:
253+
type: string
254+
FirstName:
255+
type: string
256+
Gender:
257+
type: object
258+
additionalProperties: true
259+
properties:
260+
content:
261+
type: string
262+
tc:
263+
type: integer
264+
LastName:
265+
type: string
266+
MiddleName:
267+
type: string
268+
Phone:
269+
type: array
270+
additionalProperties: true
271+
items:
272+
type: object
273+
properties:
274+
DialNumber:
275+
type: string
276+
PhoneTypeCode:
277+
type: object
278+
additionalProperties: true
279+
properties:
280+
content:
281+
type: string
282+
tc:
283+
type: integer
284+
id:
285+
type: string
286+
TransExeDate:
287+
type: string
288+
TransExeTime:
289+
type: string
290+
TransRefGUID:
291+
type: string
292+
TransResult:
293+
type: object
294+
additionalProperties: true
295+
properties:
296+
ResultCode:
297+
type: object
298+
additionalProperties: true
299+
properties:
300+
content:
301+
type: string
302+
tc:
303+
type: integer
304+
TransSubType:
305+
type: object
306+
additionalProperties: true
307+
properties:
308+
content:
309+
type: string
310+
tc:
311+
type: integer
312+
TransType:
313+
type: object
314+
additionalProperties: true
315+
properties:
316+
content:
317+
type: string
318+
tc:
319+
type: integer

0 commit comments

Comments
 (0)