use of io.swagger.parser.SwaggerParser in project syndesis by syndesisio.
the class UnifiedXmlDataShapeGeneratorShapeValidityTest method specifications.
@Parameters
public static Iterable<Object[]> specifications() {
final List<String> specifications = Collections.singletonList("/swagger/petstore.swagger.json");
final List<Object[]> parameters = new ArrayList<>();
specifications.forEach(specification -> {
String specificationContent;
try (InputStream in = UnifiedXmlDataShapeGenerator.class.getResourceAsStream(specification)) {
specificationContent = IOUtils.toString(in, StandardCharsets.UTF_8);
} catch (final IOException e) {
throw new AssertionError("Unable to load swagger specification in path: " + specification, e);
}
final SwaggerParser parser = new SwaggerParser();
final Swagger swagger = parser.parse(specificationContent);
swagger.getPaths().forEach((path, operations) -> {
operations.getOperationMap().forEach((method, operation) -> {
final Optional<BodyParameter> bodyParameter = BaseDataShapeGenerator.findBodyParameter(operation);
if (!bodyParameter.isPresent()) {
// only parameters
return;
}
parameters.add(new Object[] { specificationContent, swagger, operation, specification });
});
});
});
return parameters;
}
use of io.swagger.parser.SwaggerParser in project swagger-parser by swagger-api.
the class LegacyConverterTest method testIssue43.
@Test
public void testIssue43() throws Exception {
new Expectations() {
{
remoteUrl.urlToString("http://gateway.marvel.com/docs", new ArrayList<AuthorizationValue>());
result = marvel_json;
remoteUrl.urlToString("http://gateway.marvel.com/docs/public", new ArrayList<AuthorizationValue>());
result = public_json;
}
};
SwaggerParser parser = new SwaggerParser();
SwaggerDeserializationResult result = parser.readWithInfo("http://gateway.marvel.com/docs", null, true);
Assert.assertNotNull(result.getSwagger());
}
use of io.swagger.parser.SwaggerParser in project swagger-parser by swagger-api.
the class LegacyConverterTest method testIssueFun.
@Test
public void testIssueFun() throws Exception {
new Expectations() {
{
remoteUrl.urlToString("http://localhost:8080/api-docs", new ArrayList<AuthorizationValue>());
result = resources_json;
remoteUrl.urlToString("http://localhost:8080/api-docs/pet", new ArrayList<AuthorizationValue>());
result = pet_json;
remoteUrl.urlToString("http://localhost:8080/api-docs/store", new ArrayList<AuthorizationValue>());
result = store_json;
remoteUrl.urlToString("http://localhost:8080/api-docs/user", new ArrayList<AuthorizationValue>());
result = user_json;
remoteUrl.urlToString("http://localhost:8080/api-docs", null);
result = resources_json;
remoteUrl.urlToString("http://localhost:8080/api-docs/pet", null);
result = pet_json;
remoteUrl.urlToString("http://localhost:8080/api-docs/store", null);
result = store_json;
remoteUrl.urlToString("http://localhost:8080/api-docs/user", null);
result = user_json;
}
};
SwaggerParser parser = new SwaggerParser();
SwaggerDeserializationResult result = parser.readWithInfo("http://localhost:8080/api-docs", null, true);
Swagger swagger = parser.read("http://localhost:8080/api-docs");
Assert.assertNotNull(swagger);
}
use of io.swagger.parser.SwaggerParser in project swagger-parser by swagger-api.
the class ParserExtensionsTest method readAllExtensions.
@Test
public void readAllExtensions() throws Exception {
SwaggerParser parser = new SwaggerParser();
List<SwaggerParserExtension> extensions = parser.getExtensions();
assertTrue(extensions.size() == 2, "Didn't find 2 extensions as expected");
}
use of io.swagger.parser.SwaggerParser in project swagger-parser by swagger-api.
the class SwaggerDeserializerTest method testIssue161.
@Test
public void testIssue161() {
String yaml = "swagger: '2.0'\n" + "paths:\n" + " /users:\n" + " get:\n" + " parameters:\n" + " - in: query\n" + " name: name\n" + " type: string\n" + " minLength: 10\n" + " maxLength: 100\n" + " required: false\n" + " responses:\n" + " default:\n" + " description: ok";
SwaggerParser parser = new SwaggerParser();
SwaggerDeserializationResult result = parser.readWithInfo(yaml);
Set<String> messages = new HashSet<String>(result.getMessages());
assertFalse(messages.contains("attribute paths.'/users'(get).[name].maxLength is unexpected"));
}
Aggregations