use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class SimpleScannerWithDecoratorExtensionTest method scanSimpleResourceWithoutDecorator.
/**
* Test for method annotated without vendor annotation.
*/
@Test(description = "scan a simple resource without custom decorator")
public void scanSimpleResourceWithoutDecorator() {
final Swagger swagger = getSwagger(SimpleResourceWithVendorAnnotation.class);
assertEquals(swagger.getPaths().size(), 2);
final Operation get = getGet(swagger, "/{id}/value");
assertNotNull(get);
assertEquals(get.getParameters().size(), 0);
final Response response = get.getResponses().get(RESPONSE_STATUS_401);
assertNull(response);
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class SubResourceReaderTest method readAnotherResourceWithSubresources.
@Test(description = "scan another resource with subresources")
public void readAnotherResourceWithSubresources() {
final Swagger swagger = getSwagger(TestResource.class);
final Operation get = getGet(swagger, "/test/more/otherStatus");
assertEquals(get.getOperationId(), "otherStatus");
final Parameter qp = get.getParameters().get(0);
assertEquals(qp.getIn(), "query");
assertEquals(qp.getName(), "qp");
assertTrue(get.getProduces().containsAll(Arrays.asList("application/json", "application/xml")));
assertEquals(swagger.getPaths().keySet().size(), 2);
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class RegexPathParamTest method scanSimpleResource.
@Test(description = "scan a simple resource")
public void scanSimpleResource() {
Swagger swagger = new Reader(new Swagger()).read(RegexPathParamResource.class);
Operation get = swagger.getPaths().get("/{report_type}").getGet();
Parameter param = get.getParameters().get(0);
assertEquals(param.getName(), "report_type");
assertEquals(param.getPattern(), "[aA-zZ]+");
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class SimpleReaderTest method scanResourceWithBodyParameters.
@Test(description = "scan a resource with body parameters")
public void scanResourceWithBodyParameters() {
Swagger swagger = getSwagger(ResourceWithBodyParams.class);
BodyParameter param = (BodyParameter) getPostParameters(swagger, "/testShort").get(0);
assertEquals(param.getDescription(), "a short input");
ModelImpl schema = (ModelImpl) param.getSchema();
assertEquals(schema.getType(), "integer");
assertEquals(schema.getFormat(), "int32");
assertEquals(swagger.getDefinitions().keySet(), Arrays.asList("Tag"));
testString(swagger, "/testApiString", "input", "String parameter");
testString(swagger, "/testString", "body", null);
testObject(swagger, "/testApiObject", "input", "Object parameter");
testObject(swagger, "/testObject", "body", null);
List<Operation> operations = new ArrayList<Operation>();
for (Path item : swagger.getPaths().values()) {
Operation op = item.getPost();
if (op.getOperationId().startsWith("testPrimitive")) {
operations.add(op);
}
}
assertEquals(operations.size(), 16);
for (Operation item : operations) {
assertEquals(item.getParameters().size(), 1);
}
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class GenericsTest method checkCollectionsOfStringsAsBodyParameter.
@Test(description = "check collection of strings as body parameter")
public void checkCollectionsOfStringsAsBodyParameter() {
Operation op = getOperation("testStringsInBody");
assertEquals(op.getParameters().size(), 1);
BodyParameter p = getBodyParameter(op, 0);
ArrayModel strArray = (ArrayModel) p.getSchema();
assertEquals(strArray.getItems().getType(), "string");
}
Aggregations