use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class ReaderTest method scanImplicitParamOverriddenMethodTest.
@Test(description = "scan indirect implicit params from overridden method")
public void scanImplicitParamOverriddenMethodTest() {
final Swagger swagger = new Reader(new Swagger()).read(IndirectImplicitParamsImpl.class);
assertNotNull(swagger);
assertEquals(swagger.getPath("/v1/users").getPost().getParameters().size(), 2);
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class ReaderTest method scanExternalDocsOnMethod.
@Test(description = "scan external docs on method")
public void scanExternalDocsOnMethod() {
Swagger swagger = getSwagger(ResourceWithExternalDocs.class);
ExternalDocs externalDocsForGet = swagger.getPath("/testString").getGet().getExternalDocs();
assertNull(externalDocsForGet);
ExternalDocs externalDocsForPost = swagger.getPath("/testString").getPost().getExternalDocs();
assertNotNull(externalDocsForPost);
assertEquals("Test Description", externalDocsForPost.getDescription());
assertEquals("https://swagger.io/", externalDocsForPost.getUrl());
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class SimpleReaderTest method scanResourceWithCustomHttpMethodAnnotations.
@Test(description = "scan a resource with custom http method annotations")
public void scanResourceWithCustomHttpMethodAnnotations() {
Swagger swagger = getSwagger(ResourceWithCustomHTTPMethodAnnotations.class);
Operation get = getGet(swagger, "/");
assertNotNull(get);
Operation post = getPost(swagger, "/");
assertNotNull(post);
Operation patch = getPatch(swagger, "/");
assertNotNull(patch);
Operation put = getPut(swagger, "/");
assertNotNull(put);
Operation delete = getDelete(swagger, "/");
assertNotNull(delete);
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class SimpleReaderTest method scanClassWithImplicitExamplePostClass.
@Test(description = "scan a resource with operation implicit post example (dataTypeClass)")
public void scanClassWithImplicitExamplePostClass() {
Swagger swagger = getSwagger(ClassWithExamplePostClass.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 SimpleScannerWithDecoratorExtensionTest method scanSimpleResourceWithDecorator.
/**
* Test for method annotated with vendor annotation which could be used for swagger documentation.
*/
@Test(description = "scan a simple resource with custom decorator")
public void scanSimpleResourceWithDecorator() {
final Swagger swagger = getSwagger(SimpleResourceWithVendorAnnotation.class);
assertEquals(swagger.getPaths().size(), 2);
final Operation get = getGet(swagger, "/{id}");
assertNotNull(get);
assertEquals(get.getParameters().size(), 2);
final Response response = get.getResponses().get(RESPONSE_STATUS_401);
assertNotNull(response);
assertEquals(response.getDescription(), RESPONSE_DESCRIPTION);
}
Aggregations