private void convertProtocols(String protocols, Operation operation) { if (protocols == null) { return; } for (String protocol : protocols.split(SEPARATOR)) { if (StringUtils.isEmpty(protocol)) { continue; } operation.addScheme(Scheme.forValue(protocol)); } }
private Scheme convertScheme(io.swagger.annotations.SwaggerDefinition.Scheme annotationScheme) { return Scheme.forValue(annotationScheme.name()); }
protected void updateOperationProtocols(ApiOperation apiOperation, Operation operation) { if(apiOperation == null) { return; } String[] protocols = apiOperation.protocols().split(","); for (String protocol : protocols) { String trimmed = protocol.trim(); if (!trimmed.isEmpty()) { operation.scheme(Scheme.forValue(trimmed)); } } }
public AbstractDocumentSource(Log log, ApiSource apiSource) throws MojoFailureException { LOG = log; this.outputPath = apiSource.getOutputPath(); this.templatePath = apiSource.getTemplatePath(); this.swaggerPath = apiSource.getSwaggerDirectory(); this.modelSubstitute = apiSource.getModelSubstitute(); this.jsonExampleValues = apiSource.isJsonExampleValues(); swagger = new Swagger(); if (apiSource.getSchemes() != null) { for (String scheme : apiSource.getSchemes()) { swagger.scheme(Scheme.forValue(scheme)); } } // read description from file if (apiSource.getDescriptionFile() != null) { try { InputStream is = new FileInputStream(apiSource.getDescriptionFile()); apiSource.getInfo().setDescription(IOUtils.toString(is)); is.close(); } catch (IOException e) { throw new MojoFailureException(e.getMessage(), e); } } swagger.setHost(apiSource.getHost()); swagger.setInfo(apiSource.getInfo()); swagger.setBasePath(apiSource.getBasePath()); swagger.setExternalDocs(apiSource.getExternalDocs()); this.apiSource = apiSource; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
private void convertProtocols(String protocols, Operation operation) { if (protocols == null) { return; } for (String protocol : protocols.split(SEPARATOR)) { if (StringUtils.isEmpty(protocol)) { continue; } operation.addScheme(Scheme.forValue(protocol)); } }
private List<Scheme> toSchemeList(List<Scheme> original,String schemes) { List<Scheme> schemeList = new ArrayList<>(); toList(schemes).forEach((scheme) -> { schemeList.add(Scheme.forValue(scheme)); }); if(original!=null){ original.addAll(schemeList); return original; }else{ return schemeList; } }
private Scheme convertScheme(io.swagger.annotations.SwaggerDefinition.Scheme annotationScheme) { return Scheme.forValue(annotationScheme.name()); }
private void setSwaggerSchemes(Swagger swagger, Set<String> transports) { List<String> swaggerSchemes = Stream.of(Scheme.values()).map(Scheme::name).collect(Collectors.toList()); List<Scheme> schemes = new ArrayList<>(); if (transports.size() != 0) { for (String transport: transports) { if (swaggerSchemes.contains(transport)) { schemes.add(Scheme.forValue(transport)); } } } if (!schemes.isEmpty()) { swagger.setSchemes(schemes); } }
private void setSwaggerSchemes(Swagger swagger, Set<String> transports) { List<String> swaggerSchemes = Stream.of(Scheme.values()).map(Scheme::name).collect(Collectors.toList()); List<Scheme> schemes = new ArrayList<>(); if (transports.size() != 0) { for (String transport: transports) { if (swaggerSchemes.contains(transport)) { schemes.add(Scheme.forValue(transport)); } } } if (!schemes.isEmpty()) { swagger.setSchemes(schemes); } }
private Swagger transformV2(String content, Map<String, String> config) { Swagger swagger = new SwaggerParser().parse(content); if (swagger != null && config != null && config.get("tryItURL") != null) { URI newURI = URI.create(config.get("tryItURL")); swagger.setSchemes(Collections.singletonList(Scheme.forValue(newURI.getScheme()))); swagger.setHost((newURI.getPort() != -1) ? newURI.getHost() + ':' + newURI.getPort() : newURI.getHost()); swagger.setBasePath((newURI.getRawPath().isEmpty()) ? "/" : newURI.getRawPath()); } return swagger; }
private Swagger transformV2(String content, Map<String, String> config) { Swagger swagger = new SwaggerParser().parse(content); if (swagger != null && config != null && config.get("tryItURL") != null) { URI newURI = URI.create(config.get("tryItURL")); swagger.setSchemes(Collections.singletonList(Scheme.forValue(newURI.getScheme()))); swagger.setHost((newURI.getPort() != -1) ? newURI.getHost() + ':' + newURI.getPort() : newURI.getHost()); swagger.setBasePath((newURI.getRawPath().isEmpty()) ? "/" : newURI.getRawPath()); } return swagger; }
@RequestMapping(method = RequestMethod.GET) public @ResponseBody String getSwaggerSpecification(HttpServletRequest request) throws Exception { String host = request.getHeader(HttpHeaders.HOST); String scheme = request.getHeader(HttpHeaders.X_FORWARDED_PROTO); if (scheme == null) { scheme = request.getScheme(); } return new SwaggerSpecificationCreator() .host(host) .basePath(request.getContextPath() + "/ws/rest/v1") .scheme(Scheme.forValue(scheme)) .getJSON(); }
private void configureServerURL(Swagger swagger) { SplitURL split = URLUtils.splitURL(System.getProperty(SpringCXFProperties.SERVER_URL, "localhost")); swagger.scheme(Scheme.forValue(split.getScheme())); swagger.host(split.getHost() + ":" + split.getPort()); swagger.basePath(System.getProperty(SpringCXFProperties.JAXRS_PATH)); }