Java Code Examples for io.swagger.models.Scheme#forValue()
The following examples show how to use
io.swagger.models.Scheme#forValue() .
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: Reader.java From dorado with Apache License 2.0 | 5 votes |
private static Set<Scheme> parseSchemes(String schemes) { final Set<Scheme> result = EnumSet.noneOf(Scheme.class); for (String item : StringUtils.trimToEmpty(schemes).split(",")) { final Scheme scheme = Scheme.forValue(StringUtils.trimToNull(item)); if (scheme != null) { result.add(scheme); } } return result; }
Example 2
Source File: RpcReaderExtension.java From sofa-rpc with Apache License 2.0 | 5 votes |
private static List<Scheme> parseSchemes(String schemes) { final List<Scheme> result = new ArrayList<Scheme>(); for (String item : StringUtils.trimToEmpty(schemes).split(",")) { final Scheme scheme = Scheme.forValue(StringUtils.trimToNull(item)); if (scheme != null && !result.contains(scheme)) { result.add(scheme); } } return result; }
Example 3
Source File: DubboReaderExtension.java From swagger-dubbo with Apache License 2.0 | 5 votes |
private static List<Scheme> parseSchemes(String schemes) { final List<Scheme> result = new ArrayList<Scheme>(); for (String item : StringUtils.trimToEmpty(schemes).split(",")) { final Scheme scheme = Scheme.forValue(StringUtils.trimToNull(item)); if (scheme != null && !result.contains(scheme)) { result.add(scheme); } } return result; }
Example 4
Source File: ExtendedSwaggerReader.java From msf4j with Apache License 2.0 | 5 votes |
private static Set<Scheme> parseSchemes(String schemes) { final Set<Scheme> result = EnumSet.noneOf(Scheme.class); for (String item : StringUtils.trimToEmpty(schemes).split(",")) { final Scheme scheme = Scheme.forValue(StringUtils.trimToNull(item)); if (scheme != null) { result.add(scheme); } } return result; }
Example 5
Source File: SwaggerDefinitionProcessor.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
private Scheme convertScheme(io.swagger.annotations.SwaggerDefinition.Scheme annotationScheme) { if (SwaggerDefinition.Scheme.DEFAULT.equals(annotationScheme)) { return Scheme.HTTP; } return Scheme.forValue(annotationScheme.name()); }
Example 6
Source File: SwaggerGenMojo.java From herd with Apache License 2.0 | 4 votes |
/** * Gets a new Swagger metadata. * * @return the Swagger metadata. * @throws MojoExecutionException if any problems were encountered. */ private Swagger getSwagger() throws MojoExecutionException { getLog().debug("Creating Swagger Metadata"); // Set up initial Swagger metadata. Swagger swagger = new Swagger(); swagger.setInfo(new Info().title(title).version(version)); swagger.setBasePath(basePath); // Set the schemes. if (!CollectionUtils.isEmpty(schemeParameters)) { List<Scheme> schemes = new ArrayList<>(); for (String schemeParameter : schemeParameters) { Scheme scheme = Scheme.forValue(schemeParameter); if (scheme == null) { throw new MojoExecutionException("Invalid scheme specified: " + schemeParameter); } schemes.add(scheme); } swagger.setSchemes(schemes); } // Add authorization support if specified. if (authType != null) { // Find the definition for the user specified type. SecuritySchemeDefinition securitySchemeDefinition = null; for (SecuritySchemeDefinition possibleDefinition : SECURITY_SCHEME_DEFINITIONS) { if (possibleDefinition.getType().equalsIgnoreCase(authType)) { securitySchemeDefinition = possibleDefinition; break; } } // If we found a match, set it on the swagger object. if (securitySchemeDefinition != null) { // Come up with an authentication name for easy identification (e.g. basicAuthentication, etc.). String securityName = securitySchemeDefinition.getType() + "Authentication"; // Add the security definition. swagger.addSecurityDefinition(securityName, securitySchemeDefinition); // Add the security for everything based on the name of the definition. SecurityRequirement securityRequirement = new SecurityRequirement(); securityRequirement.requirement(securityName); swagger.addSecurity(securityRequirement); } } // Use default paths and definitions. swagger.setPaths(new TreeMap<>()); swagger.setDefinitions(new TreeMap<>()); return swagger; }