Java Code Examples for io.swagger.models.Info#getLicense()
The following examples show how to use
io.swagger.models.Info#getLicense() .
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: LicenseInfoComponent.java From swagger2markup with Apache License 2.0 | 6 votes |
@Override public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, Parameters params) { Info info = params.info; License license = info.getLicense(); String termOfService = info.getTermsOfService(); if ((license != null && (isNotBlank(license.getName()) || isNotBlank(license.getUrl()))) || isNotBlank(termOfService)) { markupDocBuilder.sectionTitleLevel(params.titleLevel, labels.getLabel(LICENSE_INFORMATION)); MarkupDocBuilder paragraph = copyMarkupDocBuilder(markupDocBuilder); if (license != null) { if (isNotBlank(license.getName())) { paragraph.italicText(labels.getLabel(LICENSE)).textLine(COLON + license.getName()); } if (isNotBlank(license.getUrl())) { paragraph.italicText(labels.getLabel(LICENSE_URL)).textLine(COLON + license.getUrl()); } } paragraph.italicText(labels.getLabel(TERMS_OF_SERVICE)).textLine(COLON + termOfService); markupDocBuilder.paragraph(paragraph.toString(), true); } return markupDocBuilder; }
Example 2
Source File: ClojureClientCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
@Override public void preprocessSwagger(Swagger swagger) { super.preprocessSwagger(swagger); 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 (swagger.getInfo() != null) { Info info = swagger.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 = "swagger-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"; 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); 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 3
Source File: JavascriptClientCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
@Override public void preprocessSwagger(Swagger swagger) { super.preprocessSwagger(swagger); if (swagger.getInfo() != null) { Info info = swagger.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 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 = "swagger-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.LOCAL_VARIABLE_PREFIX, localVariablePrefix); 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); // 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])); } }