Search in sources :

Example 96 with Operation

use of io.swagger.models.Operation in project java-chassis by ServiceComb.

the class TestApiImplicitParams method testBody.

@Test
public void testBody() {
    SwaggerGenerator swaggerGenerator = new SwaggerGeneratorForTest(context, ApiImplicitParamsAnnotation.class);
    swaggerGenerator.generate();
    Swagger swagger = swaggerGenerator.getSwagger();
    Path path = swagger.getPaths().get("/testBody");
    Operation operation = path.getOperations().get(0);
    Parameter parameter = operation.getParameters().get(0);
    JavaType javaType = ConverterMgr.findJavaType(swaggerGenerator, parameter);
    Assert.assertEquals(User.class, javaType.getRawClass());
}
Also used : Path(io.swagger.models.Path) JavaType(com.fasterxml.jackson.databind.JavaType) Swagger(io.swagger.models.Swagger) Parameter(io.swagger.models.parameters.Parameter) Operation(io.swagger.models.Operation) SwaggerGeneratorForTest(io.servicecomb.swagger.generator.core.unittest.SwaggerGeneratorForTest) SwaggerGeneratorForTest(io.servicecomb.swagger.generator.core.unittest.SwaggerGeneratorForTest) Test(org.junit.Test)

Example 97 with Operation

use of io.swagger.models.Operation in project java-chassis by ServiceComb.

the class TestApiOperation method testMap.

private void testMap(Path path) {
    Operation operation = path.getPost();
    Property result200 = operation.getResponses().get("200").getSchema();
    Assert.assertEquals(MapProperty.class, result200.getClass());
}
Also used : ApiOperation(io.swagger.annotations.ApiOperation) Operation(io.swagger.models.Operation) MapProperty(io.swagger.models.properties.MapProperty) ExtensionProperty(io.swagger.annotations.ExtensionProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) Property(io.swagger.models.properties.Property)

Example 98 with Operation

use of io.swagger.models.Operation in project java-chassis by ServiceComb.

the class TestApiOperation method testSet.

private void testSet(Path path) {
    Operation operation = path.getPost();
    Property result200 = operation.getResponses().get("200").getSchema();
    Assert.assertEquals(ArrayProperty.class, result200.getClass());
    Assert.assertEquals(true, ((ArrayProperty) result200).getUniqueItems());
}
Also used : ApiOperation(io.swagger.annotations.ApiOperation) Operation(io.swagger.models.Operation) MapProperty(io.swagger.models.properties.MapProperty) ExtensionProperty(io.swagger.annotations.ExtensionProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) Property(io.swagger.models.properties.Property)

Example 99 with Operation

use of io.swagger.models.Operation in project java-chassis by ServiceComb.

the class TestApiOperation method testPrimitive.

private void testPrimitive(Path path) {
    Operation operation = path.getPost();
    Assert.assertEquals(2, operation.getResponses().size());
    Property result200 = operation.getResponses().get("200").getSchema();
    Assert.assertEquals("integer", result200.getType());
    Assert.assertEquals("int32", result200.getFormat());
    Property result202 = operation.getResponses().get("202").getSchema();
    Assert.assertEquals("string", result202.getType());
    Assert.assertEquals(null, result202.getFormat());
}
Also used : ApiOperation(io.swagger.annotations.ApiOperation) Operation(io.swagger.models.Operation) MapProperty(io.swagger.models.properties.MapProperty) ExtensionProperty(io.swagger.annotations.ExtensionProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) Property(io.swagger.models.properties.Property)

Example 100 with Operation

use of io.swagger.models.Operation in project java-chassis by ServiceComb.

the class RequestMappingMethodAnnotationProcessor method process.

@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
    RequestMapping requestMapping = (RequestMapping) annotation;
    Operation operation = operationGenerator.getOperation();
    // path/value是等同的
    this.processPath(requestMapping.path(), operationGenerator);
    this.processPath(requestMapping.value(), operationGenerator);
    this.processMethod(requestMapping.method(), operationGenerator);
    this.processConsumes(requestMapping.consumes(), operation);
    this.processProduces(requestMapping.produces(), operation);
}
Also used : Operation(io.swagger.models.Operation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Operation (io.swagger.models.Operation)106 Test (org.testng.annotations.Test)78 Swagger (io.swagger.models.Swagger)39 Path (io.swagger.models.Path)30 BodyParameter (io.swagger.models.parameters.BodyParameter)24 Property (io.swagger.models.properties.Property)24 Response (io.swagger.models.Response)23 Parameter (io.swagger.models.parameters.Parameter)17 RefProperty (io.swagger.models.properties.RefProperty)16 ArrayModel (io.swagger.models.ArrayModel)15 Model (io.swagger.models.Model)14 StringProperty (io.swagger.models.properties.StringProperty)13 ArrayProperty (io.swagger.models.properties.ArrayProperty)12 ReaderContext (io.swagger.servlet.ReaderContext)12 QueryParameter (io.swagger.models.parameters.QueryParameter)10 MapProperty (io.swagger.models.properties.MapProperty)10 NicknamedOperation (io.swagger.resources.NicknamedOperation)10 PathParameter (io.swagger.models.parameters.PathParameter)8 ApiOperation (io.swagger.annotations.ApiOperation)7 Method (java.lang.reflect.Method)7