Search in sources :

Example 36 with Operation

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

the class ChildTypeTest method testChildTypeParameter.

@Test(description = "Tests schema ref is correctly set up for child type parameter")
public void testChildTypeParameter() {
    Operation op = swagger.getPath("/childType/testChildTypeParameter").getPost();
    BodyParameter parameter = getBodyParameter(op, 0);
    Model schema = parameter.getSchema();
    assertEquals(schema.getClass().getName(), RefModel.class.getName());
    assertEquals(((RefModel) schema).getSimpleRef(), "Sub1Bean");
}
Also used : RefModel(io.swagger.models.RefModel) RefModel(io.swagger.models.RefModel) Model(io.swagger.models.Model) Operation(io.swagger.models.Operation) BodyParameter(io.swagger.models.parameters.BodyParameter) Test(org.testng.annotations.Test)

Example 37 with Operation

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

the class CollectionFormatTest method readFormParamTest.

@Test(testName = "check collection format for FormParam")
public void readFormParamTest() {
    Operation operation = getOperation("testFormParam");
    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 38 with Operation

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

the class CollectionFormatTest method readMixedParamTest.

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

Example 39 with Operation

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

the class CollectionFormatTest method readCookieParamTest.

@Test(testName = "check collection format for CookieParam")
public void readCookieParamTest() {
    Operation operation = getOperation("testCookieParam");
    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 40 with Operation

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

the class GenericsTest method check2DArrayAsBodyParameter.

@Test(description = "check 2D array as body parameter")
public void check2DArrayAsBodyParameter() {
    Operation op = getOperation("test2DInBody");
    assertEquals(op.getParameters().size(), 1);
    BodyParameter p = getBodyParameter(op, 0);
    ArrayModel ddArray = (ArrayModel) p.getSchema();
    assertEquals(((RefProperty) ((ArrayProperty) ddArray.getItems()).getItems()).getSimpleRef(), "Tag");
}
Also used : ArrayProperty(io.swagger.models.properties.ArrayProperty) Operation(io.swagger.models.Operation) BodyParameter(io.swagger.models.parameters.BodyParameter) ArrayModel(io.swagger.models.ArrayModel) 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