use of io.swagger.models.Operation 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.models.Operation in project swagger-core by swagger-api.
the class SimpleReaderTest method scanResourceWithGenerics.
@Test(description = "scan a resource with generics per 653")
public void scanResourceWithGenerics() {
Swagger swagger = getSwagger(Resource653.class);
Operation get = getGet(swagger, "/external/info");
assertNotNull(get);
Map<String, Response> responses = get.getResponses();
assertNotNull(responses);
Response response = responses.get("default");
assertNotNull(response);
assertNull(response.getSchema());
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class ReaderTest method scanMethods.
@Test(description = "scan methods")
public void scanMethods() {
Method[] methods = SimpleMethods.class.getMethods();
Reader reader = new Reader(new Swagger());
for (Method method : methods) {
if (isValidRestPath(method)) {
Operation operation = reader.parseMethod(method);
assertNotNull(operation);
}
}
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class ReaderTest method scanOverriddenMethod.
@Test(description = "scan overridden method in descendantResource")
public void scanOverriddenMethod() {
Swagger swagger = getSwagger(DescendantResource.class);
Operation overriddenMethodWithTypedParam = getGet(swagger, "/pet/{petId1}");
assertNotNull(overriddenMethodWithTypedParam);
assertEquals(overriddenMethodWithTypedParam.getParameters().get(0).getDescription(), "ID of pet to return child");
Operation methodWithoutTypedParam = getGet(swagger, "/pet/{petId2}");
assertNotNull(methodWithoutTypedParam);
Operation overriddenMethodWithoutTypedParam = getGet(swagger, "/pet/{petId3}");
assertNotNull(overriddenMethodWithoutTypedParam);
Operation methodWithoutTypedParamFromDescendant = getGet(swagger, "/pet/{petId4}");
assertNotNull(methodWithoutTypedParamFromDescendant);
Operation methodFromInterface = getGet(swagger, "/pet/{petId5}");
assertNotNull(methodFromInterface);
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class ChildTypeTest method testChildTypeResponse.
@Test(description = "Tests child type response schema ref is correctly set up")
public void testChildTypeResponse() {
Operation op = swagger.getPath("/childType/testChildTypeResponse").getGet();
Property schema = op.getResponses().get("200").getSchema();
assertEquals(schema.getClass().getName(), RefProperty.class.getName());
assertEquals(((RefProperty) schema).getSimpleRef(), "Sub1Bean");
}
Aggregations