io.swagger.config.SwaggerConfig Java Examples

The following examples show how to use io.swagger.config.SwaggerConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwaggerSpecResource.java    From Cheddar with Apache License 2.0 5 votes vote down vote up
protected synchronized Swagger scanResourcesForJaxrsAnnotations(final Application app, final ServletConfig sc) {
    Swagger swagger = null;
    final Scanner scanner = ScannerFactory.getScanner();
    LOGGER.debug("using scanner " + scanner);

    if (scanner != null) {
        SwaggerSerializers.setPrettyPrint(scanner.getPrettyPrint());

        swagger = getSwagger();

        Set<Class<?>> classes = null;
        if (scanner instanceof JaxrsScanner) {
            final JaxrsScanner jaxrsScanner = (JaxrsScanner) scanner;
            classes = jaxrsScanner.classesFromContext(app, sc);
        } else {
            classes = scanner.classes();
        }
        if (classes != null) {
            final Reader reader = new Reader(swagger);
            swagger = reader.read(classes);
            if (scanner instanceof SwaggerConfig) {
                swagger = ((SwaggerConfig) scanner).configure(swagger);
            } else {
                LOGGER.debug("no configurator");
            }
        }
    }
    initialized = true;
    return swagger;
}