Skip to content

Ensure multiple referenced folders resolve #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2016
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 @@ -4,6 +4,7 @@
import io.swagger.models.Path;
import io.swagger.models.Swagger;
import io.swagger.parser.util.SwaggerDeserializationResult;
import io.swagger.util.Json;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;
Expand Down Expand Up @@ -50,7 +51,6 @@ public void testIssue310() {
assertTrue(swagger.getDefinitions().get("Paging").getProperties().size() == 1);
}


@Test
public void testIssue312() {
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo("./src/test/resources/nested-file-references/issue-312.yaml", null, true);
Expand All @@ -66,4 +66,23 @@ public void testIssue312() {
assertTrue(swagger.getDefinitions().size() == 2);
assertTrue(swagger.getDefinitions().get("Paging").getProperties().size() == 1);
}

@Test
public void testIssue314() {
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo("./src/test/resources/nested-file-references/issue-314.yaml", null, true);
assertNotNull(result.getSwagger());

Swagger swagger = result.getSwagger();
assertNotNull(swagger.getPath("/events"));
Path path = swagger.getPath("/events");
assertNotNull(path.getGet());

Json.prettyPrint(result);
Operation get = path.getGet();
assertEquals(get.getOperationId(), "getEvents");
assertTrue(swagger.getDefinitions().size() == 3);
assertTrue(swagger.getDefinitions().get("Foobar").getProperties().size() == 1);
assertTrue(swagger.getDefinitions().get("StatusResponse").getProperties().size() == 1);
assertTrue(swagger.getDefinitions().get("Paging").getProperties().size() == 1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Foobar:
properties:
message:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
get:
description: A list of events
operationId: getEvents
responses:
200:
description: OK
schema:
required:
- paging
- items
type: object
properties:
paging:
$ref: './common/paging.yaml#/Paging'
items:
$ref: './common2/bar.yaml#/Foobar'
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
swagger: '2.0'
info:
title: Test API
version: '1'
host: example.com
basePath: /api/v1
schemes:
- https
consumes:
- application/json; charset=utf-8
produces:
- application/json; charset=utf-8

paths:
/events:
$ref: './eventsWithItems.yaml'

definitions:
StatusResponse:
properties:
http_code:
type: integer