Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,8 @@ public Schema resolveSchema(Schema schema) {
model.addExtension(key, composedSchema.getExtensions().get(key));
}
}
return model;
}

return model;
} else if (composedSchema.getOneOf() != null) {
Schema resolved;
List<Schema> list = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,20 @@ public void testRefAdditionalProperties() throws Exception {
Assert.assertNotNull(openAPI.getComponents().getSchemas().get("result"));
}

@Test
public void testRefAndInlineAllOf(@Injectable final List<AuthorizationValue> auths) throws Exception {
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveFully(true);
OpenAPI openAPI = new OpenAPIV3Parser().read("src/test/resources/allOfAndRef.yaml",auths,options);

Assert.assertNotNull(openAPI);
Assert.assertTrue(openAPI.getComponents().getSchemas().size() == 2);
Assert.assertNotNull(openAPI.getComponents().getSchemas().get("UserEx"));
Assert.assertNotNull(openAPI.getComponents().getSchemas().get("User"));
Assert.assertTrue(openAPI.getPaths().get("/refToAllOf").getGet().getResponses().get("200").getContent().get("application/json").getSchema().getProperties().size() == 2);
}


private static int getDynamicPort() {
return new Random().ints(10000, 20000).findFirst().getAsInt();
Expand Down
35 changes: 35 additions & 0 deletions modules/swagger-parser-v3/src/test/resources/allOfAndRef.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
openapi: 3.0.0
servers: []
info:
version: 0.1.1
title: 'VirtServer, allOf and $ref'
paths:
/refToAllOf:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/UserEx'
components:
schemas:
User:
type: object
properties:
username:
type: string
example: trillian
required:
- username
UserEx:
allOf:
- $ref: '#/components/schemas/User'
- type: object
properties:
id:
type: integer
example: 4
required:
- id