use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class SimpleReaderTest method scanClassWithExampleQuery.
@Test(description = "scan a resource with query param example")
public void scanClassWithExampleQuery() {
Swagger swagger = getSwagger(ClassWithExamplePost.class);
Parameter param = swagger.getPaths().get("/external/info").getGet().getParameters().get(0);
QueryParameter bp = (QueryParameter) param;
assertNotNull(bp.getExample());
Object value = bp.getExample();
assertEquals("a,b,c", value);
}
use of org.testng.annotations.Test 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 org.testng.annotations.Test 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 org.testng.annotations.Test 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 org.testng.annotations.Test 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");
}
Aggregations