use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class NetworkReferenceTests method testIssue330.
@Test
public void testIssue330() throws Exception {
new Expectations() {
{
remoteUrl.urlToString("http://server1/resources/swagger.yaml", new ArrayList<AuthorizationValue>());
result = issue_330_yaml;
remoteUrl.urlToString("http://server1/resources/common/paging.yaml", new ArrayList<AuthorizationValue>());
result = issue_330_paging_yaml;
remoteUrl.urlToString("http://server1/resources/common/users.yaml", new ArrayList<AuthorizationValue>());
result = issue_330_users_yaml;
remoteUrl.urlToString("http://server2/resources/common/entities.yaml", new ArrayList<AuthorizationValue>());
result = issue_330_entities_yaml;
}
};
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo("http://server1/resources/swagger.yaml", null, true);
assertNotNull(result.getSwagger());
Swagger swagger = result.getSwagger();
assertNotNull(swagger.getPath("/events"));
assertNotNull(swagger.getDefinitions().get("Address"));
assertNotNull(swagger.getDefinitions().get("Paging"));
assertNotNull(swagger.getDefinitions().get("users"));
assertNotNull(swagger.getDefinitions().get("Phone"));
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class ResponseResolverTest method testIssue211.
@Test
public void testIssue211() throws Exception {
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(spec);
Swagger swagger = result.getSwagger();
assertNotNull(swagger);
assertNotNull(swagger.getPath("/persons").getGet().getResponses().get("200"));
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerParserTest method testPetstore.
@Test
public void testPetstore() throws Exception {
SwaggerParser parser = new SwaggerParser();
SwaggerDeserializationResult result = parser.readWithInfo("src/test/resources/petstore.json", null, true);
assertNotNull(result);
assertTrue(result.getMessages().isEmpty());
Swagger swagger = result.getSwagger();
Map<String, Model> definitions = swagger.getDefinitions();
Set<String> expectedDefinitions = new HashSet<String>();
expectedDefinitions.add("User");
expectedDefinitions.add("Category");
expectedDefinitions.add("Pet");
expectedDefinitions.add("Tag");
expectedDefinitions.add("Order");
expectedDefinitions.add("PetArray");
assertEquals(definitions.keySet(), expectedDefinitions);
Model petModel = definitions.get("Pet");
Set<String> expectedPetProps = new HashSet<String>();
expectedPetProps.add("id");
expectedPetProps.add("category");
expectedPetProps.add("name");
expectedPetProps.add("photoUrls");
expectedPetProps.add("tags");
expectedPetProps.add("status");
assertEquals(petModel.getProperties().keySet(), expectedPetProps);
ArrayModel petArrayModel = (ArrayModel) definitions.get("PetArray");
assertEquals(petArrayModel.getType(), "array");
RefProperty refProp = (RefProperty) petArrayModel.getItems();
assertEquals(refProp.get$ref(), "#/definitions/Pet");
assertNull(petArrayModel.getProperties());
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerParserTest method testIssue.
@Test
public void testIssue() {
String yaml = "swagger: '2.0'\n" + "info:\n" + " description: 'No description provided.'\n" + " version: '2.0'\n" + " title: 'My web service'\n" + " x-endpoint-name: 'default'\n" + "paths:\n" + " x-nothing: 'sorry not supported'\n" + " /foo:\n" + " x-something: 'yes, it is supported'\n" + " get:\n" + " parameters: []\n" + " responses:\n" + " 200:\n" + " description: 'Swagger API document for this service'\n" + "x-some-vendor:\n" + " sometesting: 'bye!'";
SwaggerParser parser = new SwaggerParser();
SwaggerDeserializationResult result = parser.readWithInfo(yaml);
Swagger swagger = result.getSwagger();
assertEquals(((Map) swagger.getVendorExtensions().get("x-some-vendor")).get("sometesting"), "bye!");
assertEquals(swagger.getPath("/foo").getVendorExtensions().get("x-something"), "yes, it is supported");
assertTrue(result.getMessages().size() == 1);
assertEquals(result.getMessages().get(0), "attribute paths.x-nothing is unsupported");
}
use of io.swagger.parser.util.SwaggerDeserializationResult in project swagger-parser by swagger-api.
the class SwaggerParserTest method testIssue243.
@Test
public void testIssue243() {
String yaml = "swagger: \"2.0\"\n" + "info:\n" + " version: 0.0.0\n" + " title: Simple API\n" + "paths:\n" + " /:\n" + " get:\n" + " responses:\n" + " '200':\n" + " description: OK\n" + " schema:\n" + " $ref: \"#/definitions/Simple\"\n" + "definitions:\n" + " Simple:\n" + " type: string";
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(yaml);
assertNotNull(result.getSwagger());
}
Aggregations