Search in sources :

Example 1 with Reader

use of io.swagger.jaxrs.Reader in project swagger-core by swagger-api.

the class FormDataBodyPartTest method testFormDataBodyPart.

@Test(description = "FormDataBodyPart should be ignored when generating the Swagger document")
public void testFormDataBodyPart() {
    final Swagger swagger = new Reader(new Swagger()).read(ResourceWithFormData.class);
    final List<Parameter> parameters = swagger.getPath("/test/document/{documentName}.json").getPost().getParameters();
    assertEquals(parameters.size(), 3);
    assertEquals(parameters.get(0).getName(), "documentName");
    assertEquals(parameters.get(1).getName(), "input");
    assertEquals(parameters.get(2).getName(), "id");
}
Also used : Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) Parameter(io.swagger.models.parameters.Parameter) Test(org.testng.annotations.Test)

Example 2 with Reader

use of io.swagger.jaxrs.Reader in project swagger-core by swagger-api.

the class ReaderTest method scanImplicitParamInterfaceTest.

@Test(description = "scan indirect implicit params from interface")
public void scanImplicitParamInterfaceTest() {
    final Swagger swagger = new Reader(new Swagger()).read(IndirectImplicitParamsImpl.class);
    assertNotNull(swagger);
    assertEquals(swagger.getPath("/v1/users/{id}").getGet().getParameters().size(), 2);
}
Also used : Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) Test(org.testng.annotations.Test)

Example 3 with Reader

use of io.swagger.jaxrs.Reader in project swagger-core by swagger-api.

the class ReaderTest method scanInterfaceTest.

@Test(description = "scan annotation from interface, issue#1427")
public void scanInterfaceTest() {
    final Swagger swagger = new Reader(new Swagger()).read(AnnotatedInterfaceImpl.class);
    assertNotNull(swagger);
    assertNotNull(swagger.getPath("/v1/users/{id}").getGet());
}
Also used : Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) Test(org.testng.annotations.Test)

Example 4 with Reader

use of io.swagger.jaxrs.Reader in project swagger-core by swagger-api.

the class SwaggerJersey2JaxrsTest method scanClassAnfFieldLevelAnnotations.

@Test(description = "scan class level and field level annotations")
public void scanClassAnfFieldLevelAnnotations() {
    final Swagger swagger = new Reader(new Swagger()).read(ResourceWithKnownInjections.class);
    final List<Parameter> resourceParameters = swagger.getPaths().get("/resource/{id}").getGet().getParameters();
    assertNotNull(resourceParameters);
    assertEquals(resourceParameters.size(), 4);
    assertEquals(getName(resourceParameters, 0), "fieldParam");
    assertEquals(getName(resourceParameters, 1), "skip");
    assertEquals(getName(resourceParameters, 2), "limit");
    assertEquals(getName(resourceParameters, 3), "methodParam");
}
Also used : Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) HeaderParameter(io.swagger.models.parameters.HeaderParameter) FormParameter(io.swagger.models.parameters.FormParameter) Parameter(io.swagger.models.parameters.Parameter) Test(org.testng.annotations.Test)

Example 5 with Reader

use of io.swagger.jaxrs.Reader in project swagger-core by swagger-api.

the class JsonIdentityTest method scan.

@Test(description = "Scan API with operation and response references")
public void scan() throws IOException {
    final Swagger swagger = new Reader(new Swagger()).read(JsonIdentityResource.class);
    final String json = ResourceUtils.loadClassResource(getClass(), "ResourceWithJsonIdentity.json");
    SerializationMatchers.assertEqualsToJson(swagger, json);
}
Also used : Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) Test(org.testng.annotations.Test)

Aggregations

Reader (io.swagger.jaxrs.Reader)33 Swagger (io.swagger.models.Swagger)31 Test (org.testng.annotations.Test)20 Parameter (io.swagger.models.parameters.Parameter)7 QueryParameter (io.swagger.models.parameters.QueryParameter)5 DefaultReaderConfig (io.swagger.jaxrs.config.DefaultReaderConfig)4 Operation (io.swagger.models.Operation)4 FormParameter (io.swagger.models.parameters.FormParameter)4 HeaderParameter (io.swagger.models.parameters.HeaderParameter)4 Test (org.junit.Test)4 Scanner (io.swagger.config.Scanner)3 SwaggerConfig (io.swagger.config.SwaggerConfig)3 Model (io.swagger.models.Model)3 Info (io.swagger.models.Info)2 NicknamedOperation (io.swagger.resources.NicknamedOperation)2 SwaggerDefinition (io.swagger.annotations.SwaggerDefinition)1 JaxrsScanner (io.swagger.jaxrs.config.JaxrsScanner)1 ReaderListener (io.swagger.jaxrs.config.ReaderListener)1 SwaggerContextService (io.swagger.jaxrs.config.SwaggerContextService)1 ArrayModel (io.swagger.models.ArrayModel)1