Skip to content

Commit 582bd15

Browse files
committed
Issue swagger-api#2118. Add unit test to check that empty title inline schemas are gettting proper model name
1 parent 79cb03b commit 582bd15

File tree

3 files changed

+110
-1
lines changed

3 files changed

+110
-1
lines changed

modules/swagger-parser-v3/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger.parser.v3</groupId>
55
<artifactId>swagger-parser-project</artifactId>
6-
<version>2.1.23-SNAPSHOT</version>
6+
<version>2.1.22</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/InlineModelResolverTest.java

+12
Original file line numberDiff line numberDiff line change
@@ -1509,4 +1509,16 @@ public void testSchemaPropertiesBeingPassedToFlattenedModel() {
15091509
assertEquals(userAddress.getWriteOnly(), Boolean.FALSE);
15101510

15111511
}
1512+
1513+
@Test(description = "https://github.com/swagger-api/swagger-parser/issues/2118")
1514+
public void testInlineSchemaWithEmptyTitle() {
1515+
ParseOptions options = new ParseOptions();
1516+
options.setResolve(true);
1517+
options.setFlatten(true);
1518+
OpenAPI openAPI = new OpenAPIV3Parser().read("issue2118/issue2118.yaml", null, options);
1519+
1520+
assertNotNull(openAPI);
1521+
assertNotNull(openAPI.getComponents().getSchemas().get("MegaPet_creator"));
1522+
assertNull(openAPI.getComponents().getSchemas().get(""));
1523+
}
15121524
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
openapi: "3.0.0"
2+
info:
3+
title: API
4+
description: API
5+
version: 1.0.0
6+
paths:
7+
/pet-types:
8+
post:
9+
description: Creates a new pet in the store. Duplicates are allowed
10+
operationId: addPet
11+
requestBody:
12+
description: Pet to add to the store
13+
required: true
14+
content:
15+
application/json:
16+
schema:
17+
$ref: '#/components/schemas/MegaPet'
18+
responses:
19+
'200':
20+
description: pet response
21+
content:
22+
application/json:
23+
schema:
24+
$ref: '#/components/schemas/MegaPet'
25+
default:
26+
description: unexpected error
27+
content:
28+
application/json:
29+
schema:
30+
$ref: '#/components/schemas/Error'
31+
components:
32+
schemas:
33+
Error:
34+
required:
35+
- code
36+
- message
37+
properties:
38+
code:
39+
type: integer
40+
format: int32
41+
message:
42+
type: string
43+
MegaPet:
44+
properties:
45+
id:
46+
type: integer
47+
format: int64
48+
code:
49+
type: string
50+
format: byte
51+
example: MjIyMjIyMg==
52+
additionalCode:
53+
type: string
54+
format: binary
55+
example: MjIyMjIyMg==
56+
dateOfBirth:
57+
type: string
58+
format: date
59+
example: "2000-12-12"
60+
timeOfVaccination:
61+
type: string
62+
format: date-time
63+
example: 2012-01-24T15:54:14.876Z
64+
age:
65+
type: string
66+
pattern: "[0-9]+"
67+
owner:
68+
type: object
69+
previousOwner:
70+
type: object
71+
example: "prev owner"
72+
metadata:
73+
type: object
74+
maxProperties: 10
75+
additionalProperties:
76+
type: string
77+
maxLength: 256
78+
creator:
79+
title: ''
80+
description: ''
81+
type: object
82+
properties:
83+
id:
84+
description: ''
85+
type: string
86+
example: 63d415e0dd0d828c3a878548
87+
readOnly: true
88+
email:
89+
description: ''
90+
type: string
91+
92+
readOnly: true
93+
displayName:
94+
description: ''
95+
type: string
96+
example: Boba Fett
97+
readOnly: true

0 commit comments

Comments
 (0)