Search in sources :

Example 91 with Operation

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

the class CollectionFormatTest method readPathParamTest.

@Test(testName = "check collection format for PathParam")
public void readPathParamTest() {
    Operation operation = getOperation("testPathParam");
    assertEquals(getCollectionFormat(operation, 0), CSV);
    assertNull(getCollectionFormat(operation, 1));
    assertEquals(getCollectionFormat(operation, 2), CSV);
}
Also used : Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 92 with Operation

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

the class CollectionFormatTest method readQueryParamTest.

@Test(testName = "check collection format for QueryParam")
public void readQueryParamTest() {
    Operation operation = getOperation("testQueryParam");
    assertEquals(getCollectionFormat(operation, 0), MULTI);
    assertNull(getCollectionFormat(operation, 1));
    assertEquals(getCollectionFormat(operation, 2), MULTI);
}
Also used : Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 93 with Operation

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

the class CollectionFormatTest method readHeaderParamTest.

@Test(testName = "check collection format for HeaderParam")
public void readHeaderParamTest() {
    Operation operation = getOperation("testHeaderParam");
    assertEquals(getCollectionFormat(operation, 0), CSV);
    assertNull(getCollectionFormat(operation, 1));
    assertEquals(getCollectionFormat(operation, 2), CSV);
}
Also used : Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 94 with Operation

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

the class ConsumesProducesTest method applyConsumesProducesTest2.

@Test(dataProvider = "resourceWithoutApiAnnotation")
public void applyConsumesProducesTest2(String methodName, List<String> expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContextWithoutApi();
    final Method method = findMethod(context, methodName);
    extension.applyConsumes(context, operation, method);
    extension.applyProduces(context, operation, method);
    Assert.assertEquals(operation.getConsumes(), expected);
    Assert.assertEquals(operation.getProduces(), expected);
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) Operation(io.swagger.models.Operation) Method(java.lang.reflect.Method) Test(org.testng.annotations.Test)

Example 95 with Operation

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

the class ImplicitParametersTest method detailedTest.

@Test
public void detailedTest() throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContext();
    extension.applyImplicitParameters(context, operation, findMethod(context, "testMethod3"));
    final List<Parameter> parameters = operation.getParameters();
    final Parameter parameter1 = parameters.get(0);
    Assert.assertNotNull(parameter1);
    Assert.assertTrue(parameter1 instanceof PathParameter);
    Assert.assertEquals(parameter1.getName(), "param1");
    Assert.assertEquals(parameter1.getIn(), "path");
    Assert.assertEquals(parameter1.getDescription(), "Param 1");
    Assert.assertTrue(parameter1.getRequired());
    final Parameter parameter5 = parameters.get(4);
    Assert.assertNotNull(parameter5);
    Assert.assertTrue(parameter5 instanceof BodyParameter);
    Assert.assertEquals(parameter5.getName(), "param5");
    Assert.assertEquals(parameter5.getIn(), "body");
    Assert.assertEquals(parameter5.getDescription(), "Param 5");
    Assert.assertFalse(parameter5.getRequired());
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) BodyParameter(io.swagger.models.parameters.BodyParameter) PathParameter(io.swagger.models.parameters.PathParameter) Parameter(io.swagger.models.parameters.Parameter) Operation(io.swagger.models.Operation) BodyParameter(io.swagger.models.parameters.BodyParameter) PathParameter(io.swagger.models.parameters.PathParameter) Test(org.testng.annotations.Test)

Aggregations

Operation (io.swagger.models.Operation)118 Test (org.testng.annotations.Test)80 Swagger (io.swagger.models.Swagger)45 Path (io.swagger.models.Path)39 BodyParameter (io.swagger.models.parameters.BodyParameter)27 Property (io.swagger.models.properties.Property)24 Response (io.swagger.models.Response)23 Parameter (io.swagger.models.parameters.Parameter)20 RefProperty (io.swagger.models.properties.RefProperty)16 ArrayModel (io.swagger.models.ArrayModel)15 Model (io.swagger.models.Model)14 QueryParameter (io.swagger.models.parameters.QueryParameter)13 StringProperty (io.swagger.models.properties.StringProperty)13 HashMap (java.util.HashMap)13 ArrayProperty (io.swagger.models.properties.ArrayProperty)12 ReaderContext (io.swagger.servlet.ReaderContext)12 PathParameter (io.swagger.models.parameters.PathParameter)11 ArrayList (java.util.ArrayList)11 MapProperty (io.swagger.models.properties.MapProperty)10 NicknamedOperation (io.swagger.resources.NicknamedOperation)10