Search in sources :

Example 11 with Operation

use of io.swagger.models.Operation in project swagger-core by swagger-api.

the class ImplicitParametersTest method applyImplicitParametersTest.

@Test(dataProvider = "resourceWithAnnotations")
public void applyImplicitParametersTest(String methodName, int expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContext();
    extension.applyImplicitParameters(context, operation, findMethod(context, methodName));
    Assert.assertEquals(operation.getParameters().size(), expected);
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 12 with Operation

use of io.swagger.models.Operation in project swagger-core by swagger-api.

the class OperationIdTest method applyOperationIdTest.

@Test(dataProvider = "resourceWithNickname")
public void applyOperationIdTest(String methodName, String expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    extension.applyOperationId(operation, ResourceWithAnnotations.class.getMethod(methodName));
    Assert.assertEquals(operation.getOperationId(), expected);
}
Also used : ResourceWithAnnotations(io.swagger.servlet.resources.ResourceWithAnnotations) Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 13 with Operation

use of io.swagger.models.Operation in project swagger-core by swagger-api.

the class ParametersTest method applyParametersTest.

@Test
public void applyParametersTest() {
    final Operation operation = new Operation();
    extension.applyParameters(createDefaultContext(), operation, String.class, new Annotation[] {});
    Assert.assertEquals(operation.getParameters().size(), 0);
}
Also used : Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 14 with Operation

use of io.swagger.models.Operation in project swagger-core by swagger-api.

the class ResponsesTest method applyResponsesTest.

@Test(dataProvider = "resourceWithAnnotations")
public void applyResponsesTest(String methodName, Response expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContext();
    extension.applyResponses(context, operation, findMethod(context, methodName));
    if (expected == null) {
        Assert.assertNull(operation.getResponses());
    } else {
        final Response response = operation.getResponses().get("200");
        Assert.assertEquals(response.getDescription(), expected.getDescription());
    }
}
Also used : Response(io.swagger.models.Response) ReaderContext(io.swagger.servlet.ReaderContext) Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 15 with Operation

use of io.swagger.models.Operation in project swagger-core by swagger-api.

the class ResponsesTest method detailedResponsesTest.

@Test
public void detailedResponsesTest() throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContext();
    extension.applyResponses(context, operation, findMethod(context, "testMethod3"));
    final Map<String, Response> responses = operation.getResponses();
    Assert.assertEquals(responses.size(), 7);
    for (Map.Entry<String, String> entry : ResponsesTest.responses.entrySet()) {
        Assert.assertEquals(responses.get(entry.getKey()).getDescription(), entry.getValue());
    }
}
Also used : Response(io.swagger.models.Response) ReaderContext(io.swagger.servlet.ReaderContext) Operation(io.swagger.models.Operation) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

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