use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class SimpleReaderTest method scanClassWithImplicitExamplePost.
@Test(description = "scan a resource with operation implicit post example")
public void scanClassWithImplicitExamplePost() {
Swagger swagger = getSwagger(ClassWithExamplePost.class);
Parameter param = swagger.getPaths().get("/external/info2").getPost().getParameters().get(0);
BodyParameter bp = (BodyParameter) param;
assertNotNull(bp.getExamples());
assertTrue(bp.getExamples().size() == 1);
String value = bp.getExamples().get("application/json");
assertEquals("[\"a\",\"b\"]", value);
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class SimpleReaderTest method scanClassWithExamplePost.
@Test(description = "scan a resource with operation post example")
public void scanClassWithExamplePost() {
Swagger swagger = getSwagger(ClassWithExamplePost.class);
Parameter param = swagger.getPaths().get("/external/info").getPost().getParameters().get(0);
BodyParameter bp = (BodyParameter) param;
assertNotNull(bp.getExamples());
assertTrue(bp.getExamples().size() == 1);
String value = bp.getExamples().get("application/json");
assertEquals("[\"a\",\"b\"]", value);
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class SimpleReaderTest method scanResourceWithResponseStatusReturnType.
@Test(description = "scan a resource with Response.Status return type per 877")
public void scanResourceWithResponseStatusReturnType() {
Swagger swagger = getSwagger(Resource877.class);
assertNotNull(swagger.getTags());
assertEquals(swagger.getTags().size(), 1);
Tag tag = swagger.getTags().get(0);
assertEquals(tag.getName(), "externalinfo");
assertNull(tag.getDescription());
assertNull(tag.getExternalDocs());
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class SwaggerJersey2JaxrsTest method scanClassAnfFieldLevelAnnotations.
@Test(description = "scan class level and field level annotations")
public void scanClassAnfFieldLevelAnnotations() {
final Swagger swagger = new Reader(new Swagger()).read(ResourceWithKnownInjections.class);
final List<Parameter> resourceParameters = swagger.getPaths().get("/resource/{id}").getGet().getParameters();
assertNotNull(resourceParameters);
assertEquals(resourceParameters.size(), 4);
assertEquals(getName(resourceParameters, 0), "fieldParam");
assertEquals(getName(resourceParameters, 1), "skip");
assertEquals(getName(resourceParameters, 2), "limit");
assertEquals(getName(resourceParameters, 3), "methodParam");
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class SwaggerSerializerTest method prettyPrintTest.
@Test
public void prettyPrintTest() throws IOException {
final String json = ResourceUtils.loadClassResource(getClass(), "uber.json");
final Swagger swagger = Json.mapper().readValue(json, Swagger.class);
final String outputStream = OutputReplacer.OUT.run(new OutputReplacer.Function() {
@Override
public void run() {
Json.prettyPrint(swagger);
}
});
SerializationMatchers.assertEqualsToJson(swagger, outputStream);
}
Aggregations