io.github.swagger2markup.utils.URIUtils Java Examples
The following examples show how to use
io.github.swagger2markup.utils.URIUtils.
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: OpenAPI2MarkupConverter.java From swagger2markup with Apache License 2.0 | 6 votes |
/** * Creates a OpenAPI2MarkupConverter.Builder from a URI. * * @param swaggerUri the URI * @return a OpenAPI2MarkupConverter */ public static Builder from(URI swaggerUri) { Validate.notNull(swaggerUri, "swaggerUri must not be null"); String scheme = swaggerUri.getScheme(); if (scheme != null && swaggerUri.getScheme().startsWith("http")) { try { return from(swaggerUri.toURL()); } catch (MalformedURLException e) { throw new RuntimeException("Failed to convert URI to URL", e); } } else if (scheme != null && swaggerUri.getScheme().startsWith("file")) { return from(Paths.get(swaggerUri)); } else { return from(URIUtils.convertUriWithoutSchemeToFileScheme(swaggerUri)); } }
Example #2
Source File: Swagger2MarkupConverter.java From swagger2markup with Apache License 2.0 | 6 votes |
/** * Creates a Swagger2MarkupConverter.Builder from a URI. * * @param swaggerUri the URI * @return a Swagger2MarkupConverter */ public static Builder from(URI swaggerUri) { Validate.notNull(swaggerUri, "swaggerUri must not be null"); String scheme = swaggerUri.getScheme(); if (scheme != null && swaggerUri.getScheme().startsWith("http")) { try { return from(swaggerUri.toURL()); } catch (MalformedURLException e) { throw new RuntimeException("Failed to convert URI to URL", e); } } else if (scheme != null && swaggerUri.getScheme().startsWith("file")) { return from(Paths.get(swaggerUri)); } else { return from(URIUtils.convertUriWithoutSchemeToFileScheme(swaggerUri)); } }
Example #3
Source File: Schema2MarkupProperties.java From swagger2markup with Apache License 2.0 | 5 votes |
/** * Return the URI property value associated with the given key (never {@code null}). * * @param key the property name to resolve * @return The URI property * @throws IllegalStateException if the key cannot be resolved */ public URI getRequiredURI(String key) { Optional<String> property = getString(key); if (property.isPresent()) { return URIUtils.create(property.get()); } else { throw new IllegalStateException(String.format("required key [%s] not found", key)); } }
Example #4
Source File: Application.java From swagger2markup-cli with Apache License 2.0 | 5 votes |
public void run() { Swagger2MarkupConfig swagger2MarkupConfig = null; if(StringUtils.isNotBlank(configFile)) { Configurations configs = new Configurations(); Configuration config; try { config = configs.properties(configFile); } catch (ConfigurationException e) { throw new IllegalArgumentException("Failed to read configFile", e); } swagger2MarkupConfig = new Swagger2MarkupConfigBuilder(config).build(); } Swagger2MarkupConverter.Builder converterBuilder = Swagger2MarkupConverter.from(URIUtils.create(swaggerInput)); if(swagger2MarkupConfig != null){ converterBuilder.withConfig(swagger2MarkupConfig); } Swagger2MarkupConverter converter = converterBuilder.build(); if(StringUtils.isNotBlank(outputFile)){ converter.toFile(Paths.get(outputFile).toAbsolutePath()); }else if (StringUtils.isNotBlank(outputDir)){ converter.toFolder(Paths.get(outputDir).toAbsolutePath()); }else { throw new IllegalArgumentException("Either outputFile or outputDir option must be used"); } }
Example #5
Source File: Schema2MarkupProperties.java From swagger2markup with Apache License 2.0 | 2 votes |
/** * Return the URI property value associated with the given key, or * {@code defaultValue} if the key cannot be resolved. * * @param key the property name to resolve * @return The URI property * @throws IllegalStateException if the value cannot be mapped to the enum */ public Optional<URI> getURI(String key) { Optional<String> property = getString(key); return property.map(URIUtils::create); }