Java Code Examples for io.swagger.jaxrs.config.BeanConfig#getSwagger()
The following examples show how to use
io.swagger.jaxrs.config.BeanConfig#getSwagger() .
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: LogSearchDocumentationGenerator.java From ambari-logsearch with Apache License 2.0 | 5 votes |
private static String generateSwaggerYaml() throws Exception { ApiDocConfig apiDocConfig = new ApiDocConfig(); BeanConfig beanConfig = apiDocConfig.swaggerConfig(); Swagger swagger = beanConfig.getSwagger(); swagger.addSecurityDefinition("basicAuth", new BasicAuthDefinition()); beanConfig.configure(swagger); beanConfig.scanAndRead(); return Yaml.mapper().writeValueAsString(swagger); }
Example 2
Source File: SwaggerServletContextListener.java From EDDI with Apache License 2.0 | 5 votes |
private BeanConfig getBeanConfig() { BeanConfig beanConfig = new BeanConfig(); beanConfig.setHost(getConfig("swagger.host")); beanConfig.setSchemes(getConfig("swagger.schemes").split(",")); beanConfig.setTitle(getConfig("swagger.title")); beanConfig.setVersion(getConfig("swagger.version")); beanConfig.setContact(getConfig("swagger.contact")); beanConfig.setLicense(getConfig("swagger.license")); beanConfig.setBasePath(getConfig("swagger.base_path")); beanConfig.setLicenseUrl(getConfig("swagger.licenseUrl")); beanConfig.setDescription(getConfig("swagger.description")); beanConfig.setPrettyPrint(getConfig("swagger.pretty_print")); beanConfig.setTermsOfServiceUrl(getConfig("swagger.terms_of_service_url")); // Must be called last beanConfig.setResourcePackage(resourcePackages()); beanConfig.setScan(true); Swagger swagger = beanConfig.getSwagger(); if ("basic".equals(getConfig("webServer.securityHandlerType"))) { swagger.securityDefinition("eddi_auth", new BasicAuthDefinition()); } else if ("keycloak".equals(getConfig("webServer.securityHandlerType"))) { OAuth2Definition oAuth2Definition = new OAuth2Definition() .implicit(getConfig("swagger.oauth2.implicitAuthorizationUrl")); oAuth2Definition.setDescription("client_id is 'eddi-engine'"); swagger.securityDefinition("eddi_auth", oAuth2Definition); } return beanConfig; }
Example 3
Source File: SwaggerParser.java From james-project with Apache License 2.0 | 5 votes |
private static Swagger getSwagger(BeanConfig beanConfig) { Swagger swagger = beanConfig.getSwagger(); swagger.addConsumes(JSON_TYPE); swagger.addProduces(JSON_TYPE); return swagger; }
Example 4
Source File: Swagger2Feature.java From cxf with Apache License 2.0 | 4 votes |
@Override protected void addSwaggerResource(Server server, Bus bus) { JAXRSServiceFactoryBean sfb = (JAXRSServiceFactoryBean) server.getEndpoint().get(JAXRSServiceFactoryBean.class.getName()); ServerProviderFactory factory = (ServerProviderFactory)server.getEndpoint().get(ServerProviderFactory.class.getName()); final ApplicationInfo appInfo = DefaultApplicationFactory.createApplicationInfoOrDefault(server, factory, sfb, bus, isScan()); List<Object> swaggerResources = new LinkedList<>(); if (customizer == null) { customizer = new Swagger2Customizer(); } ApiListingResource apiListingResource = new Swagger2ApiListingResource(customizer); swaggerResources.add(apiListingResource); List<Object> providers = new ArrayList<>(); providers.add(new SwaggerSerializers()); if (isRunAsFilter()) { providers.add(new SwaggerContainerRequestFilter(appInfo == null ? null : appInfo.getProvider(), customizer)); } final Properties swaggerProps = getSwaggerProperties(propertiesLocation, bus); final Registration swaggerUiRegistration = getSwaggerUi(bus, swaggerProps, isRunAsFilter()); if (!isRunAsFilter()) { swaggerResources.addAll(swaggerUiRegistration.getResources()); } providers.addAll(swaggerUiRegistration.getProviders()); sfb.setResourceClassesFromBeans(swaggerResources); List<ClassResourceInfo> cris = sfb.getClassResourceInfo(); if (!isRunAsFilter()) { for (ClassResourceInfo cri : cris) { if (ApiListingResource.class.isAssignableFrom(cri.getResourceClass())) { InjectionUtils.injectContextProxies(cri, apiListingResource); } } } customizer.setClassResourceInfos(cris); customizer.setDynamicBasePath(dynamicBasePath); BeanConfig beanConfig = appInfo == null ? new BeanConfig() : new ApplicationBeanConfig(appInfo.getProvider()); initBeanConfig(beanConfig, swaggerProps); Swagger swagger = beanConfig.getSwagger(); if (swagger != null && securityDefinitions != null) { swagger.setSecurityDefinitions(securityDefinitions); } customizer.setBeanConfig(beanConfig); providers.add(new ReaderConfigFilter()); if (beanConfig.isUsePathBasedConfig()) { providers.add(new ServletConfigProvider()); } factory.setUserProviders(providers); }