Search in sources :

Example 21 with Reader

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

the class OverriddenTypeTests method passwordParameterTest.

@Test(description = "add a user-specified format")
public void passwordParameterTest() {
    Swagger swagger = new Reader(new Swagger()).read(Resource469.class);
    QueryParameter qp = (QueryParameter) swagger.getPath("/test").getGet().getParameters().get(0);
    assertEquals(qp.getFormat(), "password");
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) Test(org.testng.annotations.Test)

Example 22 with Reader

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

the class SimpleReaderTest method scanSimpleSelfReferencingSubResource.

@Test(description = "scan a simple self-referencing subresource")
public void scanSimpleSelfReferencingSubResource() {
    DefaultReaderConfig config = new DefaultReaderConfig();
    config.setScanAllResources(true);
    Swagger swagger = new Reader(new Swagger(), config).read(SimpleSelfReferencingSubResource.class);
    assertEquals(swagger.getPaths().size(), 4);
    // these two paths are directly reachable without passing thru a recursive reference
    Operation retrieve = getGet(swagger, "/sub");
    assertNotNull(retrieve);
    assertEquals(retrieve.getParameters().size(), 0);
    retrieve = getGet(swagger, "/sub/leaf");
    assertNotNull(retrieve);
    assertEquals(retrieve.getParameters().size(), 0);
    retrieve = getGet(swagger, "/sub/recurse2");
    assertNotNull(retrieve);
    assertEquals(retrieve.getParameters().size(), 0);
    retrieve = getGet(swagger, "/sub/recurse2/leaf");
    assertNotNull(retrieve);
    assertEquals(retrieve.getParameters().size(), 0);
}
Also used : Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) DefaultReaderConfig(io.swagger.jaxrs.config.DefaultReaderConfig) Operation(io.swagger.models.Operation) NicknamedOperation(io.swagger.resources.NicknamedOperation) Test(org.testng.annotations.Test)

Example 23 with Reader

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

the class ReaderTest method scanMethods.

@Test(description = "scan methods")
public void scanMethods() {
    Method[] methods = SimpleMethods.class.getMethods();
    Reader reader = new Reader(new Swagger());
    for (Method method : methods) {
        if (isValidRestPath(method)) {
            Operation operation = reader.parseMethod(method);
            assertNotNull(operation);
        }
    }
}
Also used : Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) Method(java.lang.reflect.Method) ResourceWithDeprecatedMethod(io.swagger.resources.ResourceWithDeprecatedMethod) Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 24 with Reader

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

the class SwaggerJersey2JaxrsTest 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) HeaderParameter(io.swagger.models.parameters.HeaderParameter) FormParameter(io.swagger.models.parameters.FormParameter) Parameter(io.swagger.models.parameters.Parameter) Test(org.testng.annotations.Test)

Example 25 with Reader

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

the class SwaggerJersey2JaxrsTest method testJacksonFeatures.

@Test(description = "JsonUnwrapped, JsonIgnore, JsonValue should be honoured")
public void testJacksonFeatures() {
    final Swagger swagger = new Reader(new Swagger()).read(ResourceWithJacksonBean.class);
    Model o = swagger.getDefinitions().get("JacksonBean");
    assertEquals(o.getProperties().keySet(), Sets.newHashSet("identity", "bean", "code", "message", "precodesuf", "premessagesuf"));
}
Also used : Swagger(io.swagger.models.Swagger) Model(io.swagger.models.Model) 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