Java Code Examples for io.swagger.models.Info#getTitle()

The following examples show how to use io.swagger.models.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: ApexClientCodegen.java    From TypeScript-Microservices with MIT License 6 votes vote down vote up
@Override
public void preprocessSwagger(Swagger swagger) {
    Info info = swagger.getInfo();
    String calloutLabel = info.getTitle();
    additionalProperties.put("calloutLabel", calloutLabel);
    String sanitized = sanitizeName(calloutLabel);
    additionalProperties.put("calloutName", sanitized);
    supportingFiles.add(new SupportingFile("namedCredential.mustache", srcPath + "/namedCredentials",
        sanitized + ".namedCredential"
    ));

    if (additionalProperties.get(BUILD_METHOD).equals("sfdx")) {
        generateSfdxSupportingFiles();
    } else if (additionalProperties.get(BUILD_METHOD).equals("ant")) {
        generateAntSupportingFiles();
    }

}
 
Example 2
Source File: StaticHtml2Generator.java    From TypeScript-Microservices with MIT License 6 votes vote down vote up
@Override
public void preprocessSwagger(Swagger swagger) {
    super.preprocessSwagger(swagger);

    if (swagger.getInfo() != null) {
        Info info = swagger.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 = "swagger-js-client";
    }
    if (StringUtils.isBlank(jsModuleName)) {
        jsModuleName = camelize(underscore(jsProjectName));
    }

    additionalProperties.put("jsProjectName", jsProjectName);
    additionalProperties.put("jsModuleName", jsModuleName);

    preparHtmlForGlobalDescription(swagger);
}
 
Example 3
Source File: TopLevelBuilder.java    From api-compiler with Apache License 2.0 6 votes vote down vote up
/**
 * Adds additional information to {@link Service} object.
 *
 * @throws OpenApiConversionException
 */
private void createServiceInfoFromOpenApi(
    Service.Builder serviceBuilder, List<OpenApiFile> openApiFiles)
    throws OpenApiConversionException {
  for (OpenApiFile openApiFile : openApiFiles) {
    //TODO(user): need better way to resolve conflicts here
    if (openApiFile.swagger().getInfo() != null) {
      Info info = openApiFile.swagger().getInfo();
      if (info.getTitle() != null) {
        serviceBuilder.setTitle(info.getTitle());
      }
      if (info.getDescription() != null) {
        serviceBuilder.getDocumentationBuilder().setSummary(info.getDescription());
      }
    }
  }
}
 
Example 4
Source File: ElixirClientCodegen.java    From TypeScript-Microservices with MIT License 5 votes vote down vote up
@Override
public void preprocessSwagger(Swagger swagger) {
     Info info = swagger.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 5
Source File: ClojureClientCodegen.java    From TypeScript-Microservices with MIT License 4 votes vote down vote up
@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 6
Source File: JavascriptClientCodegen.java    From TypeScript-Microservices with MIT License 4 votes vote down vote up
@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]));
    }
}
 
Example 7
Source File: ImportController.java    From restfiddle with Apache License 2.0 4 votes vote down vote up
private void swaggerToRFConverter(String projectId, String name, MultipartFile file) throws IOException {
// MultipartFile file
File tempFile = File.createTempFile("RF_SWAGGER_IMPORT", "JSON");
file.transferTo(tempFile);
Swagger swagger = new SwaggerParser().read(tempFile.getAbsolutePath());

String host = swagger.getHost();
String basePath = swagger.getBasePath();

Info info = swagger.getInfo();
String title = info.getTitle();
String description = info.getDescription();

NodeDTO folderNode = createFolder(projectId, title);
folderNode.setDescription(description);

ConversationDTO conversationDTO;

Map<String, Path> paths = swagger.getPaths();
Set<String> keySet = paths.keySet();
for (Iterator<String> iterator = keySet.iterator(); iterator.hasNext();) {
    String pathKey = iterator.next();
    Path path = paths.get(pathKey);

    Map<HttpMethod, Operation> operationMap = path.getOperationMap();
    Set<HttpMethod> operationsKeySet = operationMap.keySet();
    for (Iterator<HttpMethod> operIterator = operationsKeySet.iterator(); operIterator.hasNext();) {
	HttpMethod httpMethod = operIterator.next();
	Operation operation = operationMap.get(httpMethod);

	conversationDTO = new ConversationDTO();
	RfRequestDTO rfRequestDTO = new RfRequestDTO();
	rfRequestDTO.setApiUrl("http://" + host + basePath + pathKey);
	rfRequestDTO.setMethodType(httpMethod.name());
	operation.getParameters();
	conversationDTO.setRfRequestDTO(rfRequestDTO);
	ConversationDTO createdConversation = conversationController.create(conversationDTO);
	conversationDTO.setId(createdConversation.getId());

	String operationId = operation.getOperationId();
	String summary = operation.getSummary();
	// Request Node
	NodeDTO childNode = new NodeDTO();
	childNode.setName(operationId);
	childNode.setDescription(summary);
	childNode.setProjectId(projectId);
	childNode.setConversationDTO(conversationDTO);
	NodeDTO createdChildNode = nodeController.create(folderNode.getId(), childNode);
	System.out.println("created node : " + createdChildNode.getName());
    }
}
   }