use of io.swagger.jaxrs.config.DefaultReaderConfig in project swagger-core by swagger-api.
the class SimpleReaderTest method scanSimpleResourceWithoutAnnotations.
@Test(description = "scan a simple resource without annotations")
public void scanSimpleResourceWithoutAnnotations() {
DefaultReaderConfig config = new DefaultReaderConfig();
config.setScanAllResources(true);
Swagger swagger = new Reader(new Swagger(), config).read(SimpleResourceWithoutAnnotations.class);
assertEquals(swagger.getPaths().size(), 2);
Operation get = getGet(swagger, "/{id}");
assertNotNull(get);
assertEquals(get.getParameters().size(), 2);
PathParameter param1 = (PathParameter) get.getParameters().get(0);
assertEquals(param1.getIn(), "path");
assertEquals(param1.getName(), "id");
assertTrue(param1.getRequired());
assertNull(param1.getDescription());
assertEquals(param1.getDefaultValue(), "5");
Parameter param2 = get.getParameters().get(1);
assertEquals(param2.getIn(), "query");
assertEquals(param2.getName(), "limit");
assertFalse(param2.getRequired());
assertNull(param2.getDescription());
}
use of io.swagger.jaxrs.config.DefaultReaderConfig in project swagger-core by swagger-api.
the class SimpleReaderTest method scanSimpleSelfReferencingSubResource.
@Test(description = "scan a simple self-referencing subresource")
public void scanSimpleSelfReferencingSubResource() {
DefaultReaderConfig config = new DefaultReaderConfig();
config.setScanAllResources(true);
Swagger swagger = new Reader(new Swagger(), config).read(SimpleSelfReferencingSubResource.class);
assertEquals(swagger.getPaths().size(), 4);
// these two paths are directly reachable without passing thru a recursive reference
Operation retrieve = getGet(swagger, "/sub");
assertNotNull(retrieve);
assertEquals(retrieve.getParameters().size(), 0);
retrieve = getGet(swagger, "/sub/leaf");
assertNotNull(retrieve);
assertEquals(retrieve.getParameters().size(), 0);
retrieve = getGet(swagger, "/sub/recurse2");
assertNotNull(retrieve);
assertEquals(retrieve.getParameters().size(), 0);
retrieve = getGet(swagger, "/sub/recurse2/leaf");
assertNotNull(retrieve);
assertEquals(retrieve.getParameters().size(), 0);
}
use of io.swagger.jaxrs.config.DefaultReaderConfig in project swagger-core by swagger-api.
the class ScannerTest method getSwagger.
private Swagger getSwagger(Class<?> clas) {
DefaultReaderConfig config = new DefaultReaderConfig();
config.setScanAllResources(true);
return new Reader(new Swagger(), config).read(clas);
}
Aggregations