Search in sources :

Example 26 with Reader

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

the class ScannerTest method getSwagger.

private Swagger getSwagger(Class<?> clas) {
    DefaultReaderConfig config = new DefaultReaderConfig();
    config.setScanAllResources(true);
    return new Reader(new Swagger(), config).read(clas);
}
Also used : Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) DefaultReaderConfig(io.swagger.jaxrs.config.DefaultReaderConfig)

Example 27 with Reader

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

the class SwaggerJersey2JaxrsTest method testIssue2031.

@Test(description = "Tests issue 2031")
public void testIssue2031() {
    final Swagger swagger = new Reader(new Swagger()).read(Resource2031.class);
    assertNotNull(swagger);
}
Also used : Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) Test(org.testng.annotations.Test)

Example 28 with Reader

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

the class ApiListingJSON method scan.

protected synchronized void scan(Application app) {
    Scanner scanner = ScannerFactory.getScanner();
    LOGGER.debug("using scanner " + scanner);
    if (scanner != null) {
        SwaggerSerializers.setPrettyPrint(scanner.getPrettyPrint());
        Set<Class<?>> classes = null;
        classes = scanner.classes();
        if (classes != null) {
            Reader reader = new Reader(swagger);
            swagger = reader.read(classes);
            if (scanner instanceof SwaggerConfig) {
                swagger = ((SwaggerConfig) scanner).configure(swagger);
            }
        }
    }
    initialized = true;
}
Also used : Scanner(io.swagger.config.Scanner) SwaggerConfig(io.swagger.config.SwaggerConfig) Reader(io.swagger.jaxrs.Reader)

Example 29 with Reader

use of io.swagger.jaxrs.Reader in project ORCID-Source by ORCID.

the class SwaggerJSONResource method scan.

protected synchronized Swagger scan(Application app) {
    Swagger swagger = null;
    Scanner scanner = ScannerFactory.getScanner();
    ModelConverters.getInstance().addConverter(new SwaggerModelConverter());
    LOGGER.debug("[SWAGGER] using scanner " + scanner);
    if (scanner != null) {
        SwaggerSerializers.setPrettyPrint(scanner.getPrettyPrint());
        swagger = (Swagger) context.getAttribute("swagger");
        Set<Class<?>> classes = scanner.classes();
        if (classes != null) {
            Reader reader = new Reader(swagger, ReaderConfigUtils.getReaderConfig(context));
            swagger = reader.read(classes);
            if (scanner instanceof SwaggerConfig) {
                swagger = ((SwaggerConfig) scanner).configure(swagger);
            } else {
                SwaggerConfig configurator = (SwaggerConfig) context.getAttribute("reader");
                if (configurator != null) {
                    LOGGER.debug("configuring swagger with " + configurator);
                    configurator.configure(swagger);
                } else {
                    LOGGER.debug("no configurator");
                }
            }
            context.setAttribute("swagger", swagger);
        }
    }
    initialized = true;
    return swagger;
}
Also used : Scanner(io.swagger.config.Scanner) SwaggerConfig(io.swagger.config.SwaggerConfig) Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader)

Example 30 with Reader

use of io.swagger.jaxrs.Reader in project gravitee-management-rest-api by gravitee-io.

the class GraviteeApiDefinition method afterScan.

@Override
public void afterScan(Reader reader, Swagger swagger) {
    swagger.addSecurityDefinition(TOKEN_AUTH_SCHEME, new BasicAuthDefinition());
    swagger.getPaths().values().stream().forEach(path -> path.getOperations().stream().forEach(operation -> operation.addSecurity(GraviteeApiDefinition.TOKEN_AUTH_SCHEME, null)));
}
Also used : SwaggerDefinition(io.swagger.annotations.SwaggerDefinition) Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) BasicAuthDefinition(io.swagger.models.auth.BasicAuthDefinition) ReaderListener(io.swagger.jaxrs.config.ReaderListener) BasicAuthDefinition(io.swagger.models.auth.BasicAuthDefinition)

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