io.swagger.jaxrs.Reader Java Examples

The following examples show how to use io.swagger.jaxrs.Reader. 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: SwaggerDefinition.java    From Web-API with MIT License 6 votes vote down vote up
@Override
public void beforeScan(Reader reader, Swagger swagger) {
    swagger.addParameter("details", constructQueryParameter(
            "details",
            "Add to include additional details, omit or false otherwise"));
    swagger.addParameter("accept", constructQueryParameter(
            "accept",
            "Override the 'Accept' request header (useful for debugging your requests)",
            "json", "xml"));
    swagger.addParameter("pretty", constructQueryParameter(
            "pretty",
            "Add to make the Web-API pretty print the response (useful for debugging your requests)"));

    swagger.response("400", constructResponse(400, "Bad request"));
    swagger.response("401", constructResponse(401, "Unauthorized"));
    swagger.response("403", constructResponse(403, "Access denied"));
    swagger.response("404", constructResponse(404, "Not found"));
    swagger.response("500", constructResponse(500, "Internal server error"));
    swagger.response("501", constructResponse(501, "Not implemented"));
}
 
Example #2
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 #3
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 #4
Source File: SwaggerGenerator.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test
public void generateSwaggerJson() throws Exception {
    Set<Class<?>> classes = new HashSet<>(endpointConfig.getClasses());
    classes.add(RedbeamsApi.class);
    Swagger swagger = new Reader(SwaggerConfigLocator.getInstance().getConfig(SwaggerContextService.CONFIG_ID_DEFAULT).configure(new Swagger()))
            .read(classes);
    Path path = Paths.get("./build/swagger/redbeams.json");
    Files.createDirectories(path.getParent());
    Files.writeString(path, Json.pretty(swagger));
}
 
Example #5
Source File: SwaggerGenerator.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test
public void generateSwaggerJson() throws Exception {
    Set<Class<?>> classes = new HashSet<>(endpointConfig.getClasses());
    classes.add(SdxApi.class);

    Swagger swagger = new Reader(SwaggerConfigLocator.getInstance().getConfig(SwaggerContextService.CONFIG_ID_DEFAULT).configure(new Swagger()))
            .read(classes);
    Path path = Paths.get("./build/swagger/datalake.json");
    Files.createDirectories(path.getParent());
    Files.writeString(path, Json.pretty(swagger));
}
 
Example #6
Source File: GraviteeApiDefinition.java    From gravitee-management-rest-api with Apache License 2.0 5 votes vote down vote up
@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)));
}
 
Example #7
Source File: SwaggerGenerator.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test
public void generateSwaggerJson() throws Exception {
    Set<Class<?>> classes = new HashSet<>(endpointConfig.getClasses());
    classes.add(FreeIpaApi.class);
    Swagger swagger = new Reader(SwaggerConfigLocator.getInstance().getConfig(SwaggerContextService.CONFIG_ID_DEFAULT).configure(new Swagger()))
            .read(classes);
    Path path = Paths.get("./build/swagger/freeipa.json");
    Files.createDirectories(path.getParent());
    Files.writeString(path, Json.pretty(swagger));
}
 
Example #8
Source File: SwaggerModel.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Inject
public SwaggerModel(final ApplicationVersion applicationVersion,
                    final List<SwaggerContributor> contributors)
{
  this.applicationVersion = checkNotNull(applicationVersion);
  this.contributors = checkNotNull(contributors);

  // filter banned types from model, such as Groovy's MetaClass
  ModelConverters.getInstance().addConverter(new ModelFilter());

  this.reader = new Reader(createSwagger());
}
 
Example #9
Source File: SecurityDefinitionConfigurator.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@Override
public void afterScan(Reader reader, Swagger swagger) {
    OAuth2Definition tokenScheme = new OAuth2Definition();
    tokenScheme.setType("oauth2");
    tokenScheme.setFlow("application");
    tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token");
    tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize");
    tokenScheme.addScope("write:everything", "Full access");

    Map<String, SecuritySchemeDefinition> schemes = new HashMap<>();
    schemes.put(TOKEN_AUTH_SCHEME, tokenScheme);

    swagger.setSecurityDefinitions(schemes);
   //TODO: Have to add wso2-scopes to swagger definition from here
}
 
Example #10
Source File: SwaggerGenerator.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test
public void generateSwaggerJson() throws Exception {
    Set<Class<?>> classes = new HashSet<>(endpointConfig.getClasses());
    classes.add(EnvironmentApi.class);
    Swagger swagger = new Reader(SwaggerConfigLocator.getInstance().getConfig(SwaggerContextService.CONFIG_ID_DEFAULT).configure(new Swagger()))
            .read(classes);
    Path path = Paths.get("./build/swagger/environment.json");
    Files.createDirectories(path.getParent());
    Files.writeString(path, Json.pretty(swagger));
}
 
Example #11
Source File: SecurityDefinitionConfigurator.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@Override
public void afterScan(Reader reader, Swagger swagger) {
    OAuth2Definition tokenScheme = new OAuth2Definition();
    tokenScheme.setType("oauth2");
    tokenScheme.setFlow("application");
    tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token");
    tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize");
    tokenScheme.addScope("write:everything", "Full access");

    Map<String, SecuritySchemeDefinition> schemes = new HashMap<>();
    schemes.put(TOKEN_AUTH_SCHEME, tokenScheme);

    swagger.setSecurityDefinitions(schemes);
   //TODO: Have to add wso2-scopes to swagger definition from here
}
 
Example #12
Source File: SwaggerGenerator.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test
public void generateSwaggerJson() throws Exception {
    Set<Class<?>> classes = new HashSet<>(endpointConfig.getClasses());
    classes.add(AutoscaleApi.class);
    Swagger swagger = new Reader(SwaggerConfigLocator.getInstance().getConfig(SwaggerContextService.CONFIG_ID_DEFAULT).configure(new Swagger()))
            .read(classes);
    Path path = Paths.get("./build/swagger/autoscale.json");
    Files.createDirectories(path.getParent());
    Files.writeString(path, Json.pretty(swagger));
}
 
Example #13
Source File: SecurityDefinitionConfigurator.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@Override
public void afterScan(Reader reader, Swagger swagger) {
    OAuth2Definition tokenScheme = new OAuth2Definition();
    tokenScheme.setType("oauth2");
    tokenScheme.setFlow("application");
    tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token");
    tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize");
    tokenScheme.addScope("write:everything", "Full access");

    Map<String, SecuritySchemeDefinition> schemes = new HashMap<>();
    schemes.put(TOKEN_AUTH_SCHEME, tokenScheme);

    swagger.setSecurityDefinitions(schemes);
}
 
Example #14
Source File: SwaggerGenerator.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test
public void generateSwaggerJson() throws Exception {
    Set<Class<?>> classes = new HashSet<>(endpointConfig.getClasses());
    classes.add(CoreApi.class);
    Swagger swagger = new Reader(SwaggerConfigLocator.getInstance().getConfig(SwaggerContextService.CONFIG_ID_DEFAULT).configure(new Swagger()))
            .read(classes);
    Path path = Paths.get("./build/swagger/cb.json");
    Files.createDirectories(path.getParent());
    Files.writeString(path, Json.pretty(swagger));
}
 
Example #15
Source File: SecurityDefinitionConfigurator.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@Override
public void afterScan(Reader reader, Swagger swagger) {
    OAuth2Definition tokenScheme = new OAuth2Definition();
    tokenScheme.setType("oauth2");
    tokenScheme.setFlow("application");
    tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token");
    tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize");
    tokenScheme.addScope("write:everything", "Full access");

    Map<String, SecuritySchemeDefinition> schemes = new HashMap<>();
    schemes.put(TOKEN_AUTH_SCHEME, tokenScheme);

    swagger.setSecurityDefinitions(schemes);
}
 
Example #16
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));
}
 
Example #17
Source File: SwaggerReader.java    From swagger-maven-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public Swagger read(Set<Class<?>> classes) throws GenerateException {
    return new Reader(swagger).read(classes);
}
 
Example #18
Source File: SwaggerParser.java    From james-project with Apache License 2.0 4 votes vote down vote up
private static Swagger getSwagger(String packageName, WebAdminConfiguration configuration) {
    return new Reader(getSwagger(getBeanConfig(packageName, configuration)))
            .read(new Reflections(packageName)
            .getTypesAnnotatedWith(Api.class));
}
 
Example #19
Source File: SwaggerReaderListener.java    From datacollector with Apache License 2.0 4 votes vote down vote up
@Override
public void afterScan(Reader reader, Swagger swagger) {
  swagger.securityDefinition("basic", new BasicAuthDefinition());
}
 
Example #20
Source File: SwaggerReaderListener.java    From datacollector with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeScan(Reader reader, Swagger swagger) {
}
 
Example #21
Source File: MSF4JBeanConfig.java    From msf4j with Apache License 2.0 4 votes vote down vote up
public MSF4JBeanConfig(Reader reader) {
    this.reader = reader;
}
 
Example #22
Source File: GraviteeApiDefinition.java    From gravitee-management-rest-api with Apache License 2.0 4 votes vote down vote up
@Override
public void beforeScan(Reader reader, Swagger swagger) {
}
 
Example #23
Source File: SecurityDefinitionConfigurator.java    From carbon-device-mgt with Apache License 2.0 2 votes vote down vote up
@Override
public void beforeScan(Reader reader, Swagger swagger) {

}
 
Example #24
Source File: SecurityDefinitionConfigurator.java    From carbon-device-mgt with Apache License 2.0 2 votes vote down vote up
@Override
public void beforeScan(Reader reader, Swagger swagger) {

}
 
Example #25
Source File: SecurityDefinitionConfigurator.java    From carbon-device-mgt with Apache License 2.0 2 votes vote down vote up
@Override
public void beforeScan(Reader reader, Swagger swagger) {

}
 
Example #26
Source File: SecurityDefinitionConfigurator.java    From carbon-device-mgt with Apache License 2.0 2 votes vote down vote up
@Override
public void beforeScan(Reader reader, Swagger swagger) {

}