use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class FileReferenceTests method testIssue316.
@Test
public void testIssue316() {
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo("./src/test/resources/nested-file-references/issue-316.yaml", null, true);
assertNotNull(result.getSwagger());
Swagger swagger = result.getSwagger();
assertNotNull(swagger.getPath("/events"));
Path path = swagger.getPath("/events");
assertNotNull(path.getGet());
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("Paging2").getProperties().size() == 2);
Model model = swagger.getDefinitions().get("Paging2");
Property property = model.getProperties().get("foobar");
assertTrue(property instanceof RefProperty);
RefProperty ref = (RefProperty) property;
assertEquals(ref.get$ref(), "#/definitions/Foobar");
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class FileReferenceTests method testRelativeRefIssue421.
@Test
public void testRelativeRefIssue421() {
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo("./src/test/resources/main.yaml", null, true);
assertNotNull(result.getSwagger());
Swagger swagger = result.getSwagger();
assertNotNull(swagger);
assertNotNull(swagger.getPath("pets"));
assertNotNull(swagger.getPath("pets").getGet());
assertNotNull(swagger.getPath("pets").getGet().getResponses());
assertNotNull(swagger.getPath("pets").getGet().getResponses().get("200"));
assertNotNull(swagger.getPath("pets").getGet().getResponses().get("200").getSchema());
assertTrue(swagger.getPath("pets").getGet().getResponses().get("200").getSchema() instanceof RefProperty);
assertEquals(((RefProperty) swagger.getPath("pets").getGet().getResponses().get("200").getSchema()).get$ref(), "#/definitions/Pet");
assertTrue(swagger.getDefinitions().get("Pet") instanceof ModelImpl);
assertTrue(swagger.getDefinitions().get("Pet").getProperties().size() == 2);
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class FileReferenceTests method testIssue336.
@Test
public void testIssue336() {
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo("./src/test/resources/nested-file-references/issue-336.json", null, true);
assertNotNull(result.getSwagger());
Swagger swagger = result.getSwagger();
assertNotNull(swagger.getPaths());
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class NetworkReferenceTests method testIssue335.
@Test
public void testIssue335() throws Exception {
new Expectations() {
{
remoteUrl.urlToString("http://server1/resources/swagger.json", new ArrayList<AuthorizationValue>());
result = issue_335_json;
remoteUrl.urlToString("http://server1/resources/Bar.json", new ArrayList<AuthorizationValue>());
result = issue_335_bar_json;
}
};
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo("http://server1/resources/swagger.json", null, true);
Swagger swagger = result.getSwagger();
assertNotNull(swagger);
assertNotNull(swagger.getDefinitions());
assertNotNull(swagger.getDefinitions().get("BarData"));
assertNotNull(swagger.getDefinitions().get("BarSettingsRequest"));
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class NetworkReferenceTests method testPathReference.
@Test
public void testPathReference() throws Exception {
new Expectations() {
{
remoteUrl.urlToString("http://petstore.swagger.io/v2/swagger.json", new ArrayList<AuthorizationValue>());
result = issue_407_json;
}
};
SwaggerParser parser = new SwaggerParser();
String yaml = "swagger: '2.0'\n" + "info:\n" + " description: |\n" + " version: 1.0.0\n" + " title: testing\n" + "paths:\n" + " /foo:\n" + " $ref: 'http://petstore.swagger.io/v2/swagger.json#/paths/~1pet'\n" + " /bar:\n" + " $ref: 'http://petstore.swagger.io/v2/swagger.json#/paths/~1pet'\n" + "schemes:\n" + " - https\n" + " - http";
final SwaggerDeserializationResult result = parser.readWithInfo(yaml);
Assert.assertNotNull(result.getSwagger());
assertTrue(result.getMessages().size() == 0);
assertTrue(result.getSwagger().getDefinitions().size() == 3);
}
Aggregations