use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerReaderTest method testIssue364.
@Test
public void testIssue364() {
String spec = "swagger: '2.0'\n" + "info:\n" + " title: issue 192\n" + "paths:\n" + " /foo:\n" + " get:\n" + " parameters:\n" + " - name: Code\n" + " in: query\n" + " description: The code\n" + " required: true\n" + " readOnly: true\n" + " allowEmptyValue: true\n" + " responses:\n" + " 200:\n" + " description: 'the pet'";
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(spec);
Swagger swagger = result.getSwagger();
Parameter param = swagger.getPath("/foo").getGet().getParameters().get(0);
assertTrue(param instanceof QueryParameter);
QueryParameter pathParameter = (QueryParameter) param;
assertTrue(pathParameter.isReadOnly());
assertTrue(pathParameter.getAllowEmptyValue());
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerReaderTest method testIssue208.
@Test
public void testIssue208() throws Exception {
String spec = "{\n" + " \"swagger\": \"2.0\",\n" + " \"paths\": {},\n" + " \"definitions\": {\n" + " \"Dog\": {\n" + " \"title\": \"Dog\",\n" + " \"type\": \"object\",\n" + " \"allOf\": [\n" + " {\n" + " \"$ref\": \"#/definitions/Pet\"\n" + " }\n" + " ],\n" + " \"x-color\": \"red\"\n" + " }\n" + " }\n" + "}";
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(spec);
assertNotNull(result);
Swagger swagger = result.getSwagger();
assertNotNull(swagger);
Model dog = swagger.getDefinitions().get("Dog");
assertNotNull(dog);
assertTrue(dog instanceof ComposedModel);
ComposedModel cm = (ComposedModel) dog;
assertEquals(cm.getTitle(), "Dog");
assertTrue(cm.getAllOf().size() == 1);
assertTrue(cm.getAllOf().get(0) instanceof RefModel);
assertNotNull(cm.getVendorExtensions());
assertEquals(cm.getVendorExtensions().get("x-color"), "red");
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerReaderTest method testIssue207.
@Test
public void testIssue207() throws Exception {
String spec = "{\n" + " \"swagger\": \"2.0\",\n" + " \"paths\": {\n" + " \"/foo\": {\n" + " \"get\": {\n" + " \"parameters\": {},\n" + " \"responses\": {\n" + " \"200\": {\n" + " \"description\": \"successful operation\",\n" + " \"schema\": {\n" + " \"type\": \"array\",\n" + " \"items\": {\n" + " \"$ref\": \"#/definitions/Pet\"\n" + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + " },\n" + " \"definitions\": {\n" + " \"Pet\": {\n" + " \"type\": \"object\",\n" + " \"properties\": {\n" + " \"name\": {\n" + " \"type\": \"string\"\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}";
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(spec);
assertNotNull(result);
Response response = result.getSwagger().getPath("/foo").getGet().getResponses().get("200");
assertNotNull(response);
Property schema = response.getSchema();
assertTrue(schema instanceof ArrayProperty);
ArrayProperty ap = (ArrayProperty) schema;
assertTrue(ap.getItems() instanceof RefProperty);
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerReaderTest method testIssue205.
@Test
public void testIssue205() {
String spec = "swagger: '2.0'\n" + "info:\n" + " title: nice\n" + "paths: {}\n" + "definitions:\n" + " Empty:\n" + " type: string\n" + " description: 'Expected empty response could be {}'";
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(spec);
assertTrue(result.getMessages().size() == 0);
Swagger swagger = result.getSwagger();
Model definition = swagger.getDefinitions().get("Empty");
assertNotNull(definition);
assertTrue(definition instanceof ModelImpl);
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerReaderTest method testIssue136.
@Test
public void testIssue136() {
String spec = "swagger: '2.0'\n" + "info:\n" + " title: issue 136\n" + "paths:\n" + " /foo:\n" + " get:\n" + " parameters: []\n" + " responses:\n" + " 200:\n" + " description: 'the pet'\n" + " schema:\n" + " $ref: 'http://petstore.swagger.io/v2/swagger.json#/definitions/Pet'";
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(spec);
Swagger swagger = result.getSwagger();
Property property = swagger.getPath("/foo").getGet().getResponses().get("200").getSchema();
assertNotNull(property);
assertTrue(property instanceof RefProperty);
}
Aggregations