Skip to content

Commit

Permalink
Issue swagger-api#2118. Add unit test to check that empty title inlin…
Browse files Browse the repository at this point in the history
…e schemas are gettting proper model name
  • Loading branch information
ludovicianul committed Aug 13, 2024
1 parent 79cb03b commit 582bd15
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/swagger-parser-v3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser-project</artifactId>
<version>2.1.23-SNAPSHOT</version>
<version>2.1.22</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1509,4 +1509,16 @@ public void testSchemaPropertiesBeingPassedToFlattenedModel() {
assertEquals(userAddress.getWriteOnly(), Boolean.FALSE);

}

@Test(description = "https://github.com/swagger-api/swagger-parser/issues/2118")
public void testInlineSchemaWithEmptyTitle() {
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setFlatten(true);
OpenAPI openAPI = new OpenAPIV3Parser().read("issue2118/issue2118.yaml", null, options);

assertNotNull(openAPI);
assertNotNull(openAPI.getComponents().getSchemas().get("MegaPet_creator"));
assertNull(openAPI.getComponents().getSchemas().get(""));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
openapi: "3.0.0"
info:
title: API
description: API
version: 1.0.0
paths:
/pet-types:
post:
description: Creates a new pet in the store. Duplicates are allowed
operationId: addPet
requestBody:
description: Pet to add to the store
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/MegaPet'
responses:
'200':
description: pet response
content:
application/json:
schema:
$ref: '#/components/schemas/MegaPet'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
MegaPet:
properties:
id:
type: integer
format: int64
code:
type: string
format: byte
example: MjIyMjIyMg==
additionalCode:
type: string
format: binary
example: MjIyMjIyMg==
dateOfBirth:
type: string
format: date
example: "2000-12-12"
timeOfVaccination:
type: string
format: date-time
example: 2012-01-24T15:54:14.876Z
age:
type: string
pattern: "[0-9]+"
owner:
type: object
previousOwner:
type: object
example: "prev owner"
metadata:
type: object
maxProperties: 10
additionalProperties:
type: string
maxLength: 256
creator:
title: ''
description: ''
type: object
properties:
id:
description: ''
type: string
example: 63d415e0dd0d828c3a878548
readOnly: true
email:
description: ''
type: string
example: [email protected]
readOnly: true
displayName:
description: ''
type: string
example: Boba Fett
readOnly: true

0 comments on commit 582bd15

Please sign in to comment.