Java Code Examples for io.swagger.v3.oas.models.info.Info#setVersion()
The following examples show how to use
io.swagger.v3.oas.models.info.Info#setVersion() .
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: TestUtils.java From openapi-generator with Apache License 2.0 | 6 votes |
public static OpenAPI createOpenAPI() { OpenAPI openAPI = new OpenAPI(); openAPI.setComponents(new Components()); openAPI.setPaths(new Paths()); final Info info = new Info(); info.setDescription("API under test"); info.setVersion("1.0.7"); info.setTitle("My title"); openAPI.setInfo(info); final Server server = new Server(); server.setUrl("https://localhost:9999/root"); openAPI.setServers(Collections.singletonList(server)); return openAPI; }
Example 2
Source File: ApiDocControllerTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
private OpenAPI getDummyOpenApiObject() { List<Server> servers = new ArrayList<>(); servers.add(0, new Server().url("/api/v1/apicatalog")); OpenAPI openAPI = new OpenAPI(); openAPI.setPaths(new Paths()); openAPI.setTags(new ArrayList<>()); openAPI.setOpenapi("3.0.0"); openAPI.setServers(servers); Info info = new Info(); info.setTitle("Service title"); info.setDescription("Service description"); info.setVersion("1.0.0"); openAPI.setInfo(info); return openAPI; }
Example 3
Source File: AbstractApiDocServiceTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
private OpenAPI getDummyOpenApiObject(List<Server> servers) { OpenAPI openAPI = new OpenAPI(); openAPI.setPaths(new Paths()); openAPI.setTags(new ArrayList<>()); openAPI.setOpenapi("3.0.0"); openAPI.setServers(servers); Info info = new Info(); info.setTitle("API Catalog"); info.setDescription("REST API for the API Catalog service which is a component of the API Mediation Layer. Use this API to retrieve information regarding catalog dashboard tiles, tile contents and its status, API documentation and status for the registered services."); info.setVersion("1.0.0"); openAPI.setInfo(info); Tag tag = new Tag(); tag.setName("API Catalog"); tag.setDescription("Current state information"); openAPI.getTags().add(tag); openAPI.getPaths().put("/api1", new PathItem()); openAPI.getPaths().put("/api2", new PathItem()); return openAPI; }
Example 4
Source File: OpenApiObjectGenerator.java From flow with Apache License 2.0 | 6 votes |
private OpenAPI createBasicModel() { OpenAPI openAPI = new OpenAPI(); Info info = new Info(); info.setTitle(configuration.getApplicationTitle()); info.setVersion(configuration.getApplicationApiVersion()); openAPI.setInfo(info); Paths paths = new Paths(); openAPI.setPaths(paths); Server server = new Server(); server.setUrl(configuration.getServerUrl()); server.setDescription(configuration.getServerDescription()); openAPI.setServers(Collections.singletonList(server)); Components components = new Components(); SecurityScheme vaadinConnectOAuth2Scheme = new SecurityScheme() .type(SecurityScheme.Type.OAUTH2) .flows(new OAuthFlows().password(new OAuthFlow() .tokenUrl(VAADIN_CONNECT_OAUTH2_TOKEN_URL) .scopes(new Scopes()))); components.addSecuritySchemes(VAADIN_CONNECT_OAUTH2_SECURITY_SCHEME, vaadinConnectOAuth2Scheme); openAPI.components(components); return openAPI; }
Example 5
Source File: OpenAPIGeneratorTest.java From spring-openapi with MIT License | 5 votes |
private Info createTestInfo() { Info info = new Info(); info.setTitle("Test API"); info.setDescription("Test description"); info.setVersion("1.0.0"); return info; }
Example 6
Source File: GenerateOpenApiSchemaMojo.java From spring-openapi with MIT License | 5 votes |
private Info createInfoFromParameters() { Info info = new Info(); info.setTitle(title); info.setDescription(description); info.setVersion(version); return info; }
Example 7
Source File: ProtoOpenAPI.java From product-microgateway with Apache License 2.0 | 5 votes |
/** * Add the minimal information required for OpenAPI Info segment. * The same name is assigned as the basePath. * * @param name API name */ void addOpenAPIInfo(String name) { Info info = new Info(); info.setTitle(name); //version is mandatory for openAPI //version is set to 1.0.0 as default. info.setVersion(ProtoToOpenAPIConstants.DEFAULT_VERSION); openAPI.setInfo(info); openAPI.addExtension(OpenAPIConstants.BASEPATH, ProtoToOpenAPIConstants.PATH_SEPARATOR + name); }
Example 8
Source File: SwaggerInfo.java From swagger-maven-plugin with MIT License | 5 votes |
public Info createInfoModel() { Info info = new Info(); if (title != null) { info.setTitle(title); } if (version != null) { info.setVersion(version); } if (description != null) { info.setDescription(description); } if (termsOfService != null) { info.setTermsOfService(termsOfService); } if (contact != null) { info.setContact(contact.createContactModel()); } if (license != null) { info.setLicense(license.createLicenseModel()); } if (extensions != null && !extensions.isEmpty()) { info.setExtensions(extensions); } return info; }
Example 9
Source File: MCRRestV2App.java From mycore with GNU General Public License v3.0 | 5 votes |
private void setupOAS() { OpenAPI oas = new OpenAPI(); Info oasInfo = new Info(); oas.setInfo(oasInfo); oasInfo.setVersion(MCRCoreVersion.getVersion()); oasInfo.setTitle(getApplicationName()); License oasLicense = new License(); oasLicense.setName("GNU General Public License, version 3"); oasLicense.setUrl("http://www.gnu.org/licenses/gpl-3.0.txt"); oasInfo.setLicense(oasLicense); URI baseURI = URI.create(MCRFrontendUtil.getBaseURL()); Server oasServer = new Server(); oasServer.setUrl(baseURI.resolve("api").toString()); oas.addServersItem(oasServer); SwaggerConfiguration oasConfig = new SwaggerConfiguration() .openAPI(oas) .resourcePackages(Stream.of(getRestPackages()).collect(Collectors.toSet())) .ignoredRoutes( MCRConfiguration2.getString("MCR.RestAPI.V2.OpenAPI.IgnoredRoutes") .map(MCRConfiguration2::splitValue) .orElseGet(Stream::empty) .collect(Collectors.toSet())) .prettyPrint(true); try { new JaxrsOpenApiContextBuilder() .application(getApplication()) .openApiConfiguration(oasConfig) .buildContext(true); } catch (OpenApiConfigurationException e) { throw new InternalServerErrorException(e); } }
Example 10
Source File: SwaggerConverter.java From swagger-parser with Apache License 2.0 | 5 votes |
public Info convert(io.swagger.models.Info v2Info) { Info info = new Info(); info.setContact(convert(v2Info.getContact())); info.setDescription(v2Info.getDescription()); info.setLicense(convert(v2Info.getLicense())); info.setTermsOfService(v2Info.getTermsOfService()); info.setTitle(v2Info.getTitle()); info.setVersion(v2Info.getVersion()); info.setExtensions(convert(v2Info.getVendorExtensions())); return info; }
Example 11
Source File: OpenAPIDeserializer.java From swagger-parser with Apache License 2.0 | 4 votes |
public Info getInfo(ObjectNode node, String location, ParseResult result) { if (node == null) return null; Info info = new Info(); String value = getString("title", node, true, location, result); if(StringUtils.isNotBlank(value)) { info.setTitle(value); } value = getString("description", node, false, location, result); if(StringUtils.isNotBlank(value)) { info.setDescription(value); } value = getString("termsOfService", node, false, location, result); if(StringUtils.isNotBlank(value)) { info.setTermsOfService(value); } ObjectNode obj = getObject("contact", node, false, "contact", result); Contact contact = getContact(obj, String.format("%s.%s", location, "contact"), result); if(obj != null) { info.setContact(contact); } obj = getObject("license", node, false, location, result); License license = getLicense(obj, String.format("%s.%s", location, "license"), result); if(obj != null) { info.setLicense(license); } value = getString("version", node, true, location, result); if(StringUtils.isNotBlank(value)) { info.setVersion(value); } Map <String,Object> extensions = getExtensions(node); if(extensions != null && extensions.size() > 0) { info.setExtensions(extensions); } Set<String> keys = getKeys(node); for(String key : keys) { if(!INFO_KEYS.contains(key) && !key.startsWith("x-")) { result.extra(location, key, node.get(key)); } } return info; }
Example 12
Source File: OAS3Parser.java From carbon-apimgt with Apache License 2.0 | 4 votes |
/** * This method generates API definition to the given api * * @param swaggerData api * @return API definition in string format * @throws APIManagementException */ @Override public String generateAPIDefinition(SwaggerData swaggerData) throws APIManagementException { OpenAPI openAPI = new OpenAPI(); // create path if null if (openAPI.getPaths() == null) { openAPI.setPaths(new Paths()); } //Create info object Info info = new Info(); info.setTitle(swaggerData.getTitle()); if (swaggerData.getDescription() != null) { info.setDescription(swaggerData.getDescription()); } Contact contact = new Contact(); //Create contact object and map business owner info if (swaggerData.getContactName() != null) { contact.setName(swaggerData.getContactName()); } if (swaggerData.getContactEmail() != null) { contact.setEmail(swaggerData.getContactEmail()); } if (swaggerData.getContactName() != null || swaggerData.getContactEmail() != null) { //put contact object to info object info.setContact(contact); } info.setVersion(swaggerData.getVersion()); openAPI.setInfo(info); updateSwaggerSecurityDefinition(openAPI, swaggerData, "https://test.com"); updateLegacyScopesFromSwagger(openAPI, swaggerData); if (APIConstants.GRAPHQL_API.equals(swaggerData.getTransportType())) { modifyGraphQLSwagger(openAPI); } else { for (SwaggerData.Resource resource : swaggerData.getResources()) { addOrUpdatePathToSwagger(openAPI, resource); } } return Json.pretty(openAPI); }