Java Code Examples for io.swagger.jaxrs.Reader#read()

The following examples show how to use io.swagger.jaxrs.Reader#read() . 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: SpringTimeSwaggerDocsController.java    From springtime with Apache License 2.0 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	swagger = new Swagger();
	Info info = new Info();
	info.setTitle("GreetingService");
	swagger.setInfo(info);

	Map<String, Object> beans = applicationContext.getBeansWithAnnotation(SpringTimeService.class);
	Set<Class<?>> classes = new HashSet<Class<?>>();
	for (Object bean : beans.values()) {
		classes.add(bean.getClass());
	}

	Reader reader = new Reader(swagger, ReaderConfigUtils.getReaderConfig(null));
	swagger = reader.read(classes);
}
 
Example 2
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;
}
 
Example 3
Source File: Java2SwaggerMojo.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void loadSwaggerAnnotation() throws MojoExecutionException {
    Reader reader = new Reader(swagger);
    swagger = reader.read(loadResourceClasses(Api.class));
}