use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerParserTest method testIssue594.
@Test
public void testIssue594() {
String yaml = "swagger: '2.0'\n" + "paths:\n" + " /test:\n" + " post:\n" + " parameters:\n" + " - name: body\n" + " in: body\n" + " description: Hello world\n" + " schema:\n" + " type: array\n" + " minItems: 1\n" + " maxItems: 1\n" + " items: \n" + " $ref: \"#/definitions/Pet\"\n" + " responses:\n" + " 200:\n" + " description: 'OK'\n";
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(yaml);
assertNotNull(result.getSwagger());
ArrayModel schema = (ArrayModel) ((BodyParameter) result.getSwagger().getPaths().get("/test").getPost().getParameters().get(0)).getSchema();
assertEquals(((RefProperty) schema.getItems()).get$ref(), "#/definitions/Pet");
assertNotNull(schema.getMaxItems());
assertNotNull(schema.getMinItems());
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerParserTest method testLoadNestedItemsReferences.
@Test
public void testLoadNestedItemsReferences() {
SwaggerParser parser = new SwaggerParser();
SwaggerDeserializationResult result = parser.readWithInfo("src/test/resources/nested-items-references/b.yaml", null, true);
Swagger swagger = result.getSwagger();
Map<String, Model> definitions = swagger.getDefinitions();
assertTrue(definitions.containsKey("z"));
assertTrue(definitions.containsKey("w"));
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerParserTest method testCodegenIssue4555.
@Test
public void testCodegenIssue4555() throws Exception {
SwaggerParser parser = new SwaggerParser();
String yaml = "swagger: '2.0'\n" + "\n" + "info:\n" + " title: test\n" + " version: \"0.0.1\"\n" + "\n" + "schemes:\n" + " - http\n" + "produces:\n" + " - application/json\n" + "\n" + "paths:\n" + " /contents/{id}:\n" + " parameters:\n" + " - name: id\n" + " in: path\n" + " description: test\n" + " required: true\n" + " type: integer\n" + "\n" + " get:\n" + " description: test\n" + " responses:\n" + " 200:\n" + " description: OK\n" + " schema:\n" + " $ref: '#/definitions/Content'\n" + "\n" + "definitions:\n" + " Content:\n" + " type: object\n" + " title: \t\ttest";
final SwaggerDeserializationResult result = parser.readWithInfo(yaml);
// can't parse with tabs!
assertNull(result.getSwagger());
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerReaderTest method testIssue206.
@Test(description = "issue 206, not supported yet")
public void testIssue206() {
String spec = "swagger: '2.0'\n" + "paths: {}\n" + "definitions:\n" + " Model:\n" + " properties:\n" + " name:\n" + " type: string\n" + " required: true";
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(spec);
// TODO: when 206 is resolved, enable the assertions here
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerCompatConverter method readWithInfo.
@Override
public SwaggerDeserializationResult readWithInfo(String location, List<AuthorizationValue> auths) {
SwaggerDeserializationResult result = new SwaggerDeserializationResult();
try {
Swagger swagger = read(location, auths);
if (swagger != null) {
result.setSwagger(swagger);
JsonNode jsonNode = Json.mapper().convertValue(swagger, JsonNode.class);
return new Swagger20Parser().readWithInfo(jsonNode);
}
} catch (IOException e) {
// TODO
}
return result;
}
Aggregations