Java Code Examples for io.swagger.v3.oas.models.info.Info#getTitle()
The following examples show how to use
io.swagger.v3.oas.models.info.Info#getTitle() .
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: JavascriptFlowtypedClientCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public void preprocessOpenAPI(OpenAPI openAPI) { super.preprocessOpenAPI(openAPI); if (openAPI.getInfo() != null) { Info info = openAPI.getInfo(); if (StringUtils.isBlank(npmName) && info.getTitle() != null) { // when projectName is not specified, generate it from info.title npmName = sanitizeName(dashize(info.getTitle())); } if (StringUtils.isBlank(npmVersion)) { // when projectVersion is not specified, use info.version npmVersion = escapeUnsafeCharacters(escapeQuotationMark(info.getVersion())); } } // default values if (StringUtils.isBlank(npmName)) { npmName = "openapi-js-client"; } if (StringUtils.isBlank(npmVersion)) { npmVersion = "1.0.0"; } additionalProperties.put(NPM_NAME, npmName); additionalProperties.put(NPM_VERSION, npmVersion); additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); }
Example 2
Source File: ElixirClientCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public void preprocessOpenAPI(OpenAPI openAPI) { Info info = openAPI.getInfo(); if (moduleName == null) { if (info.getTitle() != null) { // default to the appName (from title field) setModuleName(modulized(escapeText(info.getTitle()))); } else { setModuleName(defaultModuleName); } } additionalProperties.put("moduleName", moduleName); if (!additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { additionalProperties.put(CodegenConstants.PACKAGE_NAME, underscored(moduleName)); } supportingFiles.add(new SupportingFile("connection.ex.mustache", sourceFolder(), "connection.ex")); supportingFiles.add(new SupportingFile("request_builder.ex.mustache", sourceFolder(), "request_builder.ex")); supportingFiles.add(new SupportingFile("deserializer.ex.mustache", sourceFolder(), "deserializer.ex")); }
Example 3
Source File: ClojureClientCodegen.java From openapi-generator with Apache License 2.0 | 4 votes |
@Override public void preprocessOpenAPI(OpenAPI openAPI) { super.preprocessOpenAPI(openAPI); if (additionalProperties.containsKey(PROJECT_NAME)) { projectName = ((String) additionalProperties.get(PROJECT_NAME)); } if (additionalProperties.containsKey(PROJECT_DESCRIPTION)) { projectDescription = ((String) additionalProperties.get(PROJECT_DESCRIPTION)); } if (additionalProperties.containsKey(PROJECT_VERSION)) { projectVersion = ((String) additionalProperties.get(PROJECT_VERSION)); } if (additionalProperties.containsKey(BASE_NAMESPACE)) { baseNamespace = ((String) additionalProperties.get(BASE_NAMESPACE)); } if (openAPI.getInfo() != null) { Info info = openAPI.getInfo(); if (projectName == null && info.getTitle() != null) { // when projectName is not specified, generate it from info.title projectName = dashize(info.getTitle()); } if (projectVersion == null) { // when projectVersion is not specified, use info.version projectVersion = info.getVersion(); } if (projectDescription == null) { // when projectDescription is not specified, use info.description projectDescription = info.getDescription(); } if (info.getContact() != null) { Contact contact = info.getContact(); if (additionalProperties.get(PROJECT_URL) == null) { additionalProperties.put(PROJECT_URL, contact.getUrl()); } } if (info.getLicense() != null) { License license = info.getLicense(); if (additionalProperties.get(PROJECT_LICENSE_NAME) == null) { additionalProperties.put(PROJECT_LICENSE_NAME, license.getName()); } if (additionalProperties.get(PROJECT_LICENSE_URL) == null) { additionalProperties.put(PROJECT_LICENSE_URL, license.getUrl()); } } } // default values if (projectName == null) { projectName = "openapi-clj-client"; } if (projectVersion == null) { projectVersion = "1.0.0"; } if (projectDescription == null) { projectDescription = "Client library of " + projectName; } if (baseNamespace == null) { baseNamespace = dashize(projectName); } apiPackage = baseNamespace + ".api"; modelPackage = baseNamespace + ".specs"; additionalProperties.put(PROJECT_NAME, projectName); additionalProperties.put(PROJECT_DESCRIPTION, escapeText(projectDescription)); additionalProperties.put(PROJECT_VERSION, projectVersion); additionalProperties.put(BASE_NAMESPACE, baseNamespace); additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); final String baseNamespaceFolder = sourceFolder + File.separator + namespaceToFolder(baseNamespace); supportingFiles.add(new SupportingFile("project.mustache", "", "project.clj")); supportingFiles.add(new SupportingFile("core.mustache", baseNamespaceFolder, "core.clj")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); }
Example 4
Source File: JavascriptApolloClientCodegen.java From openapi-generator with Apache License 2.0 | 4 votes |
@Override public void preprocessOpenAPI(OpenAPI openAPI) { super.preprocessOpenAPI(openAPI); if (openAPI.getInfo() != null) { Info info = openAPI.getInfo(); if (StringUtils.isBlank(projectName) && info.getTitle() != null) { // when projectName is not specified, generate it from info.title projectName = sanitizeName(dashize(info.getTitle())); } if (StringUtils.isBlank(projectVersion)) { // when projectVersion is not specified, use info.version projectVersion = escapeUnsafeCharacters(escapeQuotationMark(info.getVersion())); } if (projectDescription == null) { // when projectDescription is not specified, use info.description if (StringUtils.isEmpty(info.getDescription())) { projectDescription = "JS API client generated by OpenAPI Generator"; } else { projectDescription = sanitizeName(info.getDescription()); } } // when licenceName is not specified, use info.license if (additionalProperties.get(CodegenConstants.LICENSE_NAME) == null && info.getLicense() != null) { License license = info.getLicense(); licenseName = license.getName(); } } // default values if (StringUtils.isBlank(projectName)) { projectName = "openapi-js-client"; } if (StringUtils.isBlank(moduleName)) { moduleName = camelize(underscore(projectName)); } if (StringUtils.isBlank(projectVersion)) { projectVersion = "1.0.0"; } if (projectDescription == null) { projectDescription = "Client library of " + projectName; } if (StringUtils.isBlank(licenseName)) { licenseName = "Unlicense"; } additionalProperties.put(PROJECT_NAME, projectName); additionalProperties.put(MODULE_NAME, moduleName); additionalProperties.put(PROJECT_DESCRIPTION, escapeText(projectDescription)); additionalProperties.put(PROJECT_VERSION, projectVersion); additionalProperties.put(CodegenConstants.LICENSE_NAME, licenseName); additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder); additionalProperties.put(USE_INHERITANCE, supportsInheritance); additionalProperties.put(EMIT_JS_DOC, emitJSDoc); additionalProperties.put(NPM_REPOSITORY, npmRepository); // make api and model doc path available in mustache template additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("modelDocPath", modelDocPath); String[][] supportingTemplateFiles = JAVASCRIPT_SUPPORTING_FILES; for (String[] supportingTemplateFile : supportingTemplateFiles) { supportingFiles.add(new SupportingFile(supportingTemplateFile[0], "", supportingTemplateFile[1])); } supportingFiles.add(new SupportingFile("index.mustache", createPath(sourceFolder, invokerPackage), "index.js")); supportingFiles.add(new SupportingFile("ApiClient.mustache", createPath(sourceFolder, invokerPackage), "ApiClient.js")); }
Example 5
Source File: JavascriptClientCodegen.java From openapi-generator with Apache License 2.0 | 4 votes |
@Override public void preprocessOpenAPI(OpenAPI openAPI) { super.preprocessOpenAPI(openAPI); if (openAPI.getInfo() != null) { Info info = openAPI.getInfo(); if (StringUtils.isBlank(projectName) && info.getTitle() != null) { // when projectName is not specified, generate it from info.title projectName = sanitizeName(dashize(info.getTitle())); } if (StringUtils.isBlank(projectVersion)) { // when projectVersion is not specified, use info.version projectVersion = escapeUnsafeCharacters(escapeQuotationMark(info.getVersion())); } if (projectDescription == null) { // when projectDescription is not specified, use info.description if (StringUtils.isEmpty(info.getDescription())) { projectDescription = "JS API client generated by OpenAPI Generator"; } else { projectDescription = sanitizeName(info.getDescription()); } } // when licenceName is not specified, use info.license if (additionalProperties.get(CodegenConstants.LICENSE_NAME) == null && info.getLicense() != null) { License license = info.getLicense(); licenseName = license.getName(); } } // default values if (StringUtils.isBlank(projectName)) { projectName = "openapi-js-client"; } if (StringUtils.isBlank(moduleName)) { moduleName = camelize(underscore(projectName)); } if (StringUtils.isBlank(projectVersion)) { projectVersion = "1.0.0"; } if (projectDescription == null) { projectDescription = "Client library of " + projectName; } if (StringUtils.isBlank(licenseName)) { licenseName = "Unlicense"; } additionalProperties.put(PROJECT_NAME, projectName); additionalProperties.put(MODULE_NAME, moduleName); additionalProperties.put(PROJECT_DESCRIPTION, escapeText(projectDescription)); additionalProperties.put(PROJECT_VERSION, projectVersion); additionalProperties.put(CodegenConstants.LICENSE_NAME, licenseName); additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder); additionalProperties.put(USE_PROMISES, usePromises); additionalProperties.put(USE_INHERITANCE, supportsInheritance); additionalProperties.put(EMIT_MODEL_METHODS, emitModelMethods); additionalProperties.put(EMIT_JS_DOC, emitJSDoc); additionalProperties.put(USE_ES6, useES6); additionalProperties.put(NPM_REPOSITORY, npmRepository); // make api and model doc path available in mustache template additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("modelDocPath", modelDocPath); String[][] supportingTemplateFiles = JAVASCRIPT_SUPPORTING_FILES; if (useES6) { supportingTemplateFiles = JAVASCRIPT_ES6_SUPPORTING_FILES; } for (String[] supportingTemplateFile : supportingTemplateFiles) { supportingFiles.add(new SupportingFile(supportingTemplateFile[0], "", supportingTemplateFile[1])); } supportingFiles.add(new SupportingFile("index.mustache", createPath(sourceFolder, invokerPackage), "index.js")); supportingFiles.add(new SupportingFile("ApiClient.mustache", createPath(sourceFolder, invokerPackage), "ApiClient.js")); }
Example 6
Source File: StaticHtml2Generator.java From openapi-generator with Apache License 2.0 | 4 votes |
@Override public void preprocessOpenAPI(OpenAPI openAPI) { super.preprocessOpenAPI(openAPI); if (openAPI.getInfo() != null) { Info info = openAPI.getInfo(); if (StringUtils.isBlank(jsProjectName) && info.getTitle() != null) { // when jsProjectName is not specified, generate it from info.title jsProjectName = sanitizeName(dashize(info.getTitle())); } } // default values if (StringUtils.isBlank(jsProjectName)) { jsProjectName = "openapi-js-client"; } if (StringUtils.isBlank(jsModuleName)) { jsModuleName = camelize(underscore(jsProjectName)); } additionalProperties.put("jsProjectName", jsProjectName); additionalProperties.put("jsModuleName", jsModuleName); preparHtmlForGlobalDescription(openAPI); Map<String, Object> vendorExtensions = openAPI.getExtensions(); if (vendorExtensions != null) { for (Map.Entry<String, Object> vendorExtension : vendorExtensions.entrySet()) { // Vendor extensions could be Maps (objects). If we wanted to iterate through them in our template files // without knowing the keys beforehand, the default `toString` method renders them unusable. Instead, we // convert them to JSON strings now, which means we can easily use them later. if (vendorExtension.getValue() instanceof Map) { this.vendorExtensions().put(vendorExtension.getKey(), Json.mapper().convertValue(vendorExtension.getValue(), JsonNode.class)); } else { this.vendorExtensions().put(vendorExtension.getKey(), vendorExtension.getValue()); } } } openAPI.setExtensions(this.vendorExtensions); }
Example 7
Source File: NodeJSExpressServerCodegen.java From openapi-generator with Apache License 2.0 | 4 votes |
@Override public void preprocessOpenAPI(OpenAPI openAPI) { URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides()); String host = URLPathUtils.getProtocolAndHost(url); String port = URLPathUtils.getPort(url, defaultServerPort); String basePath = url.getPath(); if (additionalProperties.containsKey(SERVER_PORT)) { port = additionalProperties.get(SERVER_PORT).toString(); } this.additionalProperties.put(SERVER_PORT, port); if (openAPI.getInfo() != null) { Info info = openAPI.getInfo(); if (info.getTitle() != null) { // when info.title is defined, use it for projectName // used in package.json projectName = info.getTitle() .replaceAll("[^a-zA-Z0-9]", "-") .replaceAll("^[-]*", "") .replaceAll("[-]*$", "") .replaceAll("[-]{2,}", "-") .toLowerCase(Locale.ROOT); this.additionalProperties.put("projectName", projectName); } } // need vendor extensions Paths paths = openAPI.getPaths(); if (paths != null) { for (String pathname : paths.keySet()) { PathItem path = paths.get(pathname); Map<HttpMethod, Operation> operationMap = path.readOperationsMap(); if (operationMap != null) { for (HttpMethod method : operationMap.keySet()) { Operation operation = operationMap.get(method); String tag = "default"; if (operation.getTags() != null && operation.getTags().size() > 0) { tag = toApiName(operation.getTags().get(0)); } if (operation.getOperationId() == null) { operation.setOperationId(getOrGenerateOperationId(operation, pathname, method.toString())); } // add x-openapi-router-controller // if (operation.getExtensions() == null || // operation.getExtensions().get("x-openapi-router-controller") == null) { // operation.addExtension("x-openapi-router-controller", sanitizeTag(tag) + "Controller"); // } // // add x-openapi-router-service // if (operation.getExtensions() == null || // operation.getExtensions().get("x-openapi-router-service") == null) { // operation.addExtension("x-openapi-router-service", sanitizeTag(tag) + "Service"); // } if (operation.getExtensions() == null || operation.getExtensions().get("x-eov-operation-handler") == null) { operation.addExtension("x-eov-operation-handler", "controllers/" + sanitizeTag(tag) + "Controller"); } } } } } }
Example 8
Source File: DefaultGenerator.java From openapi-generator with Apache License 2.0 | 4 votes |
private void configureOpenAPIInfo() { Info info = this.openAPI.getInfo(); if (info == null) { return; } if (info.getTitle() != null) { config.additionalProperties().put("appName", config.escapeText(info.getTitle())); } if (info.getVersion() != null) { config.additionalProperties().put("appVersion", config.escapeText(info.getVersion())); } else { LOGGER.error("Missing required field info version. Default appVersion set to 1.0.0"); config.additionalProperties().put("appVersion", "1.0.0"); } if (StringUtils.isEmpty(info.getDescription())) { // set a default description if none if provided config.additionalProperties().put("appDescription", "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"); config.additionalProperties().put("appDescriptionWithNewLines", config.additionalProperties().get("appDescription")); config.additionalProperties().put("unescapedAppDescription", "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"); } else { config.additionalProperties().put("appDescription", config.escapeText(info.getDescription())); config.additionalProperties().put("appDescriptionWithNewLines", config.escapeTextWhileAllowingNewLines(info.getDescription())); config.additionalProperties().put("unescapedAppDescription", info.getDescription()); } if (info.getContact() != null) { Contact contact = info.getContact(); if (contact.getEmail() != null) { config.additionalProperties().put("infoEmail", config.escapeText(contact.getEmail())); } if (contact.getName() != null) { config.additionalProperties().put("infoName", config.escapeText(contact.getName())); } if (contact.getUrl() != null) { config.additionalProperties().put("infoUrl", config.escapeText(contact.getUrl())); } } if (info.getLicense() != null) { License license = info.getLicense(); if (license.getName() != null) { config.additionalProperties().put("licenseInfo", config.escapeText(license.getName())); } if (license.getUrl() != null) { config.additionalProperties().put("licenseUrl", config.escapeText(license.getUrl())); } } if (info.getVersion() != null) { config.additionalProperties().put("version", config.escapeText(info.getVersion())); } else { LOGGER.error("Missing required field info version. Default version set to 1.0.0"); config.additionalProperties().put("version", "1.0.0"); } if (info.getTermsOfService() != null) { config.additionalProperties().put("termsOfService", config.escapeText(info.getTermsOfService())); } }
Example 9
Source File: OverviewDocument.java From swagger2markup with Apache License 2.0 | 4 votes |
private void addDocumentTitle(Document rootDocument, Info apiInfo) { String title = apiInfo.getTitle(); if (StringUtils.isNotBlank(title)) { rootDocument.setTitle(title); } }