Skip to content

Commit

Permalink
Update default value for C++ related generator (#373)
Browse files Browse the repository at this point in the history
* udpate default value for cpp, remove unused imports

* update cpprest template

* update tizen default value

* update cpp restbed default value

* update qt5cpp samples

* update pistache samples

* regenerate restbed ignore file
  • Loading branch information
wing328 authored May 8, 2018
1 parent 13f084e commit a9fa4cd
Show file tree
Hide file tree
Showing 133 changed files with 1,012 additions and 1,080 deletions.
2 changes: 1 addition & 1 deletion bin/tizen-petstore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/openapi-generator/src/main/resources/tizen -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l cpp-tizen -o samples/client/petstore/tizen"
ags="generate -t modules/openapi-generator/src/main/resources/tizen -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l cpp-tizen -o samples/client/petstore/tizen $@"

java $JAVA_OPTS -jar $executable $ags
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,6 @@ private Map<String, Object> buildSupportFileBundle(List<Object> allOperations, L
URL url = URLPathUtils.getServerURL(openAPI);

bundle.put("openAPI", openAPI);
bundle.put("swagger", openAPI); // for backward compatibility
bundle.put("basePath", basePath);
bundle.put("basePathWithoutHost", basePathWithoutHost);
bundle.put("scheme", URLPathUtils.getScheme(url, config));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.*;

import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
List<CodegenOperation> newOpList = new ArrayList<CodegenOperation>();
for (CodegenOperation op : operationList) {
String path = new String(op.path);
String path = op.path;

String[] items = path.split("/", -1);
List<String> splitPath = new ArrayList<String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public String getHelp() {
public CppPistacheServerCodegen() {
super();

apiPackage = "io.swagger.server.api";
modelPackage = "io.swagger.server.model";
apiPackage = "org.openapitools.server.api";
modelPackage = "org.openapitools.server.model";

modelTemplateFiles.put("model-header.mustache", ".h");
modelTemplateFiles.put("model-source.mustache", ".cpp");
Expand Down Expand Up @@ -374,7 +374,7 @@ private String implFileFolder() {
}

/**
* Optional - swagger type conversion. This is used to map swagger types in
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in
* a `Schema` into either language specific types via `typeMapping` or
* into complex models if there is not a mapping.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.parser.util.SchemaTypeUtil;

import java.io.File;
Expand All @@ -39,14 +36,14 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
public static final String CPP_NAMESPACE_DESC = "C++ namespace (convention: name::space::for::api).";
public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate client.pri.";

protected final String PREFIX = "SWG";
protected final String PREFIX = "OAI";
protected Set<String> foundationClasses = new HashSet<String>();
// source folder where to write the files
protected String sourceFolder = "client";
protected String apiVersion = "1.0.0";
protected Map<String, String> namespaces = new HashMap<String, String>();
protected Set<String> systemIncludes = new HashSet<String>();
protected String cppNamespace = "Swagger";
protected String cppNamespace = "OpenAPI";
protected boolean optionalProjectFileFlag = true;

public CppQt5ClientCodegen() {
Expand All @@ -56,7 +53,7 @@ public CppQt5ClientCodegen() {
outputFolder = "generated-code/qt5cpp";

// set modelNamePrefix as default for QT5CPP
if (modelNamePrefix == "") {
if ("".equals(modelNamePrefix)) {
modelNamePrefix = PREFIX;
}

Expand Down Expand Up @@ -143,11 +140,10 @@ public CppQt5ClientCodegen() {
typeMapping.put("boolean", "bool");
typeMapping.put("array", "QList");
typeMapping.put("map", "QMap");
typeMapping.put("file", "SWGHttpRequestInputFileElement");
typeMapping.put("file", "OAIHttpRequestInputFileElement");
typeMapping.put("object", PREFIX + "Object");
//TODO binary should be mapped to byte array
// mapped as "file" type for OAS 3.0
typeMapping.put("binary", "SWGHttpRequestInputFileElement");
typeMapping.put("binary", "OAIHttpRequestInputFileElement");
typeMapping.put("ByteArray", "QByteArray");
// UUID support - possible enhancement : use QUuid instead of QString.
// beware though that Serialisation/deserialisation of QUuid does not
Expand All @@ -157,7 +153,7 @@ public CppQt5ClientCodegen() {

importMapping = new HashMap<String, String>();

importMapping.put("SWGHttpRequestInputFileElement", "#include \"" + PREFIX + "HttpRequest.h\"");
importMapping.put("OAIHttpRequestInputFileElement", "#include \"" + PREFIX + "HttpRequest.h\"");

namespaces = new HashMap<String, String>();

Expand Down Expand Up @@ -354,7 +350,7 @@ public String toDefaultValue(Schema p) {
}

/**
* Optional - swagger type conversion. This is used to map swagger types in a `Schema` into
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in a `Schema` into
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
*
* @return a string value of the type or complex model for this property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import java.util.Map;
import java.util.Set;


public class CppRestClientCodegen extends AbstractCppCodegen {

public static final String DECLSPEC = "declspec";
Expand Down Expand Up @@ -91,8 +90,8 @@ public String getHelp() {
public CppRestClientCodegen() {
super();

apiPackage = "io.swagger.client.api";
modelPackage = "io.swagger.client.model";
apiPackage = "org.openapitools.client.api";
modelPackage = "org.openapitools.client.model";

modelTemplateFiles.put("model-header.mustache", ".h");
modelTemplateFiles.put("model-source.mustache", ".cpp");
Expand Down Expand Up @@ -359,7 +358,7 @@ public void postProcessParameter(CodegenParameter parameter) {
}

/**
* Optional - swagger type conversion. This is used to map swagger types in
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in
* a `Schema` into either language specific types via `typeMapping` or
* into complex models if there is not a mapping.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,11 @@
import java.util.Map;
import java.util.Set;

import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;

import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.parameters.*;
import io.swagger.v3.core.util.Yaml;

public class CppRestbedServerCodegen extends AbstractCppCodegen {

Expand All @@ -50,8 +44,8 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
public CppRestbedServerCodegen() {
super();

apiPackage = "io.swagger.server.api";
modelPackage = "io.swagger.server.model";
apiPackage = "org.openapitools.server.api";
modelPackage = "org.openapitools.server.model";

modelTemplateFiles.put("model-header.mustache", ".h");
modelTemplateFiles.put("model-source.mustache", ".cpp");
Expand Down Expand Up @@ -226,7 +220,7 @@ public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
List<CodegenOperation> newOpList = new ArrayList<CodegenOperation>();
for (CodegenOperation op : operationList) {
String path = new String(op.path);
String path = op.path;

String[] items = path.split("/", -1);
String resourceNameCamelCase = "";
Expand Down Expand Up @@ -349,7 +343,7 @@ public void postProcessParameter(CodegenParameter parameter) {
}

/**
* Optional - swagger type conversion. This is used to map swagger types in
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in
* a `Schema` into either language specific types via `typeMapping` or
* into complex models if there is not a mapping.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,13 @@
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.parser.util.SchemaTypeUtil;

import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;


public class CppTizenClientCodegen extends DefaultCodegen implements CodegenConfig {
protected static String PREFIX = "ArtikCloud";
Expand Down Expand Up @@ -287,7 +281,7 @@ public String escapeReservedWord(String name) {
@Override
public String toOperationId(String operationId) {
// throw exception if method name is empty
if (operationId == "") {
if ("".equals(operationId)) {
throw new RuntimeException("Empty method name (operationId) not allowed");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,13 @@
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenSecurity;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.parameters.*;
import io.swagger.v3.parser.util.SchemaTypeUtil;

import java.io.File;
import java.util.Arrays;
Expand Down Expand Up @@ -373,7 +368,7 @@ private void authParameters(CodegenOperation op) {
private void generateScalaPath(CodegenOperation op) {
op.httpMethod = op.httpMethod.toLowerCase();

String path = new String(op.path);
String path = op.path;

// remove first /
if (path.startsWith("/")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.*;

import java.io.File;
Expand Down Expand Up @@ -249,7 +247,7 @@ public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
String path = new String(op.path);
String path = op.path;
String[] items = path.split("/", -1);
String opsPath = "";
int pathParamIndex = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.core.util.Yaml;

import java.io.File;
import java.util.Arrays;
Expand Down Expand Up @@ -109,9 +106,7 @@ public PhpSlimServerCodegen() {
typeMapping.put("array", "array");
typeMapping.put("list", "array");
typeMapping.put("object", "object");
//TODO binary should be mapped to byte array
// mapped to String as a workaround
typeMapping.put("binary", "string");
typeMapping.put("binary", "\\SplFileObject");

supportingFiles.add(new SupportingFile("README.mustache", packagePath.replace('/', File.separatorChar), "README.md"));
supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Swagger MSF4J generated server
# OpenAPI MSF4J generated server


WSO2 Microservices Framework for Java (MSF4J) is a lightweight high performance framework for developing & running microservices. WSO2 MSF4J is one of the highest performing lightweight Java microservices frameworks. Now swagger code generator will generate micro service skeleton from OpenAPI definition. So you can use this project to convert your OpenAPI definitions to micro service quickly. With this approach you can develop complete micro service within seconds from your OpenAPI definition.
WSO2 Microservices Framework for Java (MSF4J) is a lightweight high performance framework for developing & running microservices. WSO2 MSF4J is one of the highest performing lightweight Java microservices frameworks. Now openapi-generator will generate micro service skeleton from OpenAPI definition. So you can use this project to convert your OpenAPI definitions to micro service quickly. With this approach you can develop complete micro service within seconds from your OpenAPI definition.

MSF4J generator uses java-msf4j as the default library.
Before you build/run service replace .deploy(new PetApi()) with your actual service class name in Application.java file like .deploy(new ApisAPI()) then it will start that service. If you have multiple service classes add them in , separated manner.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
cmake_minimum_required (VERSION 2.8)

#PROJECT's NAME
project(CppRestSwaggerClient)
project(CppRestOpenAPIClient)


# THE LOCATION OF OUTPUT BINARIES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
* {{{appName}}}
* {{{appDescription}}}
*
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
{{#version}}
* OpenAPI spec version: {{{version}}}
{{/version}}
{{#infoEmail}}
* Contact: {{{infoEmail}}}
{{/infoEmail}}
*
* NOTE: This class is auto generated by the swagger code generator {{{generatorVersion}}}.
* NOTE: This class is auto generated by OpenAPI-Generator {{{generatorVersion}}}.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
This API Server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
It uses the [Pistache](https://github.com/oktal/pistache) Framework.


## Files organization
The Pistache C++ REST server generator creates three folders:
- `api`: This folder contains the handlers for each method specified in the OpenAPI definition. Every handler extracts
Expand Down Expand Up @@ -45,6 +44,5 @@ cd build
put it under the model folder

## Namespaces
io::swagger::server::api

io::swagger::server::model
{{{apiPackage}}}
{{{modelPackage}}}
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
if ({{prefix}}HttpRequestWorker::sslDefaultConfiguration != nullptr) {
request.setSslConfiguration(*{{prefix}}HttpRequestWorker::sslDefaultConfiguration);
}
request.setRawHeader("User-Agent", "Swagger-Client");
request.setRawHeader("User-Agent", "{{#httpUserAgent}}{{.}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{apiVersion}}/cpp-qt5{{/httpUserAgent}}");
foreach(QString key, input->headers.keys()) {
request.setRawHeader(key.toStdString().c_str(), input->headers.value(key).toStdString().c_str());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ restbed


## Namespaces
io::swagger::server::api
io::swagger::server::model
{{{apiPackage}}}
{{{modelPackage}}}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
*
* NOTE: This class is auto generated by the swagger code generator {{{generatorVersion}}}.
* NOTE: This class is auto generated by OpenAPI-Generator {{{generatorVersion}}}.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = {{#swagger}}{{#info}}"{{title}} {{version}} Tizen SDK"{{/info}}{{/swagger}}
PROJECT_NAME = {{#openAPI}}{{#info}}"{{title}} {{version}} Tizen SDK"{{/info}}{{/openAPI}}

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = {{#swagger}}{{#info}}{{version}}{{/info}}{{/swagger}}
PROJECT_NUMBER = {{#openAPI}}{{#info}}{{version}}{{/info}}{{/openAPI}}

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.

PROJECT_BRIEF = "An SDK for creating client applications for {{#swagger}}{{#info}}{{title}}{{/info}}{{/swagger}} on Tizen Platform (http://tizen.org/)"
PROJECT_BRIEF = "An SDK for creating client applications for {{#openAPI}}{{#info}}{{title}}{{/info}}{{/openAPI}} on Tizen Platform (http://tizen.org/)"

# With the PROJECT_LOGO tag one can specify an logo or icon that is included in
# the documentation. The maximum height of the logo should not exceed 55 pixels
Expand Down
Loading

0 comments on commit a9fa4cd

Please sign in to comment.