Search in sources :

Example 21 with Swagger

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

the class SubResourceReaderTest method findBodyParam.

@Test(description = "find a body param")
public void findBodyParam() {
    Swagger swagger = getSwagger(Resource942.class);
    assertTrue(swagger.getPath("/test").getPost().getParameters().get(0) instanceof BodyParameter);
}
Also used : Swagger(io.swagger.models.Swagger) BodyParameter(io.swagger.models.parameters.BodyParameter) Test(org.testng.annotations.Test)

Example 22 with Swagger

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

the class SubResourceReaderTest method readResourceWithClassBasedSubresources.

@Test(description = "scan resource with class-based sub-resources")
public void readResourceWithClassBasedSubresources() {
    final Swagger swagger = getSwagger(SubResourceHead.class);
    assertEquals(swagger.getPaths().size(), 3);
    assertEquals(getOperationId(swagger, "/head/noPath"), "getGreeting");
    assertEquals(getOperationId(swagger, "/head/tail/hello"), "getGreeting");
    final Operation echo = getGet(swagger, "/head/tail/{string}");
    assertEquals(echo.getOperationId(), "getEcho");
    assertEquals(echo.getParameters().size(), 1);
}
Also used : Swagger(io.swagger.models.Swagger) Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 23 with Swagger

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

the class SubResourceReaderTest method readResourceWithSubresources.

@Test(description = "scan a resource with subresources")
public void readResourceWithSubresources() {
    final Swagger swagger = getSwagger(ResourceWithSubResources.class);
    assertEquals(getOperationId(swagger, "/employees/{id}"), "getAllEmployees");
    assertEquals(getOperationId(swagger, "/employees/{id}/{id}"), "getSubresourceOperation");
    assertEquals(getOperationId(swagger, "/employees/noPath"), "getGreeting");
}
Also used : Swagger(io.swagger.models.Swagger) Test(org.testng.annotations.Test)

Example 24 with Swagger

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

the class SwaggerConfigLocatorTest method putConfigFirstTime.

@Test(description = "should add given config to map ")
public void putConfigFirstTime() {
    SwaggerConfig config = new SwaggerConfig() {

        @Override
        public Swagger configure(Swagger swagger) {
            return swagger;
        }

        @Override
        public String getFilterClass() {
            return null;
        }
    };
    SwaggerConfigLocator.getInstance().putConfig(id, config);
    assertEquals(SwaggerConfigLocator.getInstance().getConfig(id), config);
}
Also used : SwaggerConfig(io.swagger.config.SwaggerConfig) Swagger(io.swagger.models.Swagger) Test(org.testng.annotations.Test)

Example 25 with Swagger

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

the class SwaggerConfigLocatorTest method putConfigSecondTime.

@Test(description = "shouldn't add given config to map because already set")
public void putConfigSecondTime() {
    putConfigFirstTime();
    SwaggerConfig config = new SwaggerConfig() {

        @Override
        public Swagger configure(Swagger swagger) {
            return swagger;
        }

        @Override
        public String getFilterClass() {
            return null;
        }
    };
    SwaggerConfigLocator.getInstance().putConfig(id, config);
    assertNotEquals(SwaggerConfigLocator.getInstance().getConfig(id), config);
}
Also used : SwaggerConfig(io.swagger.config.SwaggerConfig) Swagger(io.swagger.models.Swagger) Test(org.testng.annotations.Test)

Aggregations

Swagger (io.swagger.models.Swagger)164 Test (org.testng.annotations.Test)114 Operation (io.swagger.models.Operation)39 Parameter (io.swagger.models.parameters.Parameter)30 QueryParameter (io.swagger.models.parameters.QueryParameter)30 BodyParameter (io.swagger.models.parameters.BodyParameter)26 Reader (io.swagger.jaxrs.Reader)23 PathParameter (io.swagger.models.parameters.PathParameter)22 SpecFilter (io.swagger.core.filter.SpecFilter)21 Test (org.junit.Test)19 Path (io.swagger.models.Path)18 Response (io.swagger.models.Response)14 SerializableParameter (io.swagger.models.parameters.SerializableParameter)14 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)10 Model (io.swagger.models.Model)10 NicknamedOperation (io.swagger.resources.NicknamedOperation)10 HeaderParameter (io.swagger.models.parameters.HeaderParameter)9 BeanConfig (io.swagger.jaxrs.config.BeanConfig)8 Map (java.util.Map)8 Info (io.swagger.models.Info)7