Search in sources :

Example 26 with Operation

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

the class PostParamTest method findPostOperationWithSingleObject.

@Test(description = "find a Post operation with single object")
public void findPostOperationWithSingleObject() {
    Path petPath = getPath("singleObject");
    assertNotNull(petPath);
    assertNull(petPath.getGet());
    Operation petPost = petPath.getPost();
    assertNotNull(petPost);
    assertEquals(petPost.getParameters().size(), 1);
    BodyParameter petPostBodyParam = (BodyParameter) petPost.getParameters().get(0);
    assertEquals(petPostBodyParam.getName(), BODY);
    assertTrue(petPostBodyParam.getSchema() instanceof Model);
    assertEquals(swagger.getDefinitions().get(PET).getProperties().get("status").getAccess(), "public");
}
Also used : Path(io.swagger.models.Path) Model(io.swagger.models.Model) ArrayModel(io.swagger.models.ArrayModel) Operation(io.swagger.models.Operation) BodyParameter(io.swagger.models.parameters.BodyParameter) Test(org.testng.annotations.Test)

Example 27 with Operation

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

the class ChildTypeTest method testChildTypeResponseOnOperation.

@Test(description = "Tests child type response schema ref is correctly set up when specified on the operation")
public void testChildTypeResponseOnOperation() {
    Operation op = swagger.getPath("/childType/testChildTypeResponseOnOperation").getGet();
    Property schema = op.getResponses().get("200").getSchema();
    assertEquals(schema.getClass().getName(), RefProperty.class.getName());
    assertEquals(((RefProperty) schema).getSimpleRef(), "Sub1Bean");
}
Also used : Operation(io.swagger.models.Operation) RefProperty(io.swagger.models.properties.RefProperty) Property(io.swagger.models.properties.Property) RefProperty(io.swagger.models.properties.RefProperty) Test(org.testng.annotations.Test)

Example 28 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 29 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 30 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)

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