io.swagger.models.auth.BasicAuthDefinition Java Examples
The following examples show how to use
io.swagger.models.auth.BasicAuthDefinition.
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: SecurityDefinitionDeserializer.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Override public SecuritySchemeDefinition deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { SecuritySchemeDefinition result = null; JsonNode node = jp.getCodec().readTree(jp); JsonNode inNode = node.get("type"); if (inNode != null) { String type = inNode.asText(); if ("basic".equals(type)) { result = Json.mapper().convertValue(node, BasicAuthDefinition.class); } else if ("apiKey".equals(type)) { result = Json.mapper().convertValue(node, ApiKeyAuthDefinition.class); } else if ("oauth2".equals(type)) { result = Json.mapper().convertValue(node, OAuth2Definition.class); } } return result; }
Example #2
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 #3
Source File: ApiDocStorage.java From ambari-logsearch with Apache License 2.0 | 5 votes |
@PostConstruct private void postConstruct() { Thread loadApiDocThread = new Thread("load_swagger_api_doc") { @Override public void run() { logger.info("Start thread to scan REST API doc from endpoints."); Swagger swagger = beanConfig.getSwagger(); swagger.addSecurityDefinition("basicAuth", new BasicAuthDefinition()); beanConfig.configure(swagger); beanConfig.scanAndRead(); setSwagger(swagger); try { String yaml = Yaml.mapper().writeValueAsString(swagger); StringBuilder b = new StringBuilder(); String[] parts = yaml.split("\n"); for (String part : parts) { b.append(part); b.append("\n"); } setSwaggerYaml(b.toString()); } catch (Exception e) { e.printStackTrace(); } logger.info("Scanning REST API endpoints and generating docs has been successful."); } }; loadApiDocThread.setDaemon(true); loadApiDocThread.start(); }
Example #4
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 #5
Source File: GraviteeApiDefinition.java From gravitee-management-rest-api with Apache License 2.0 | 5 votes |
@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 #6
Source File: Main.java From yang2swagger with Eclipse Public License 1.0 | 4 votes |
protected void generate() throws IOException, ReactorException { final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:*.yang"); final SchemaContext context = buildSchemaContext(yangDir, p -> matcher.matches(p.getFileName())); if(log.isInfoEnabled()) { String modulesSting = context.getModules().stream().map(ModuleIdentifier::getName).collect(Collectors.joining(", ")); log.info("Modules found in the {} are {}", yangDir, modulesSting); } final Set<Module> toGenerate = context.getModules().stream().filter(m -> modules == null || modules.contains(m.getName())) .collect(Collectors.toSet()); PathHandlerBuilder pathHandler = new PathHandlerBuilder(); if(!fullCrud) { pathHandler.withoutFullCrud(); } if(useNamespaces) pathHandler = pathHandler.useModuleName(); final SwaggerGenerator generator = new SwaggerGenerator(context, toGenerate) .version(apiVersion) .format(outputFormat).consumes(contentType).produces(contentType) .host("localhost:1234") .pathHandler(pathHandler) .elements(map(elementType)); generator .appendPostProcessor(new CollapseTypes()); if(AuthenticationMechanism.BASIC.equals(authenticationMechanism)) { generator.appendPostProcessor(new AddSecurityDefinitions().withSecurityDefinition("api_sec", new BasicAuthDefinition())); } if(simplified) { generator.appendPostProcessor(new SingleParentInheritenceModel()); } generator.appendPostProcessor(new Rfc4080PayloadWrapper()); generator.appendPostProcessor(new RemoveUnusedDefinitions()); generator.generate(new OutputStreamWriter(out)); }
Example #7
Source File: SwaggerReaderListener.java From datacollector with Apache License 2.0 | 4 votes |
@Override public void afterScan(Reader reader, Swagger swagger) { swagger.securityDefinition("basic", new BasicAuthDefinition()); }
Example #8
Source File: SwaggerContext.java From binder-swagger-java with BSD 2-Clause "Simplified" License | 4 votes |
public static BasicAuthDefinition basicAuth() { return new BasicAuthDefinition(); }