Merge remote-tracking branch 'origin/master' into 2.3.0

This commit is contained in:
wing328 2017-06-15 17:14:39 +08:00
commit fee54157c0
282 changed files with 5775 additions and 726 deletions

2
.gitignore vendored
View File

@ -63,6 +63,7 @@ samples/client/petstore/java/hello.txt
samples/client/petstore/java/okhttp-gson/hello.txt
samples/client/petstore/java/jersey1/hello.txt
samples/client/petstore/java/jersey2-java8/hello.txt
samples/client/petstore/java/jersey2/hello.txt
samples/client/petstore/android/default/hello.txt
samples/client/petstore/android/volley/.gradle/
samples/client/petstore/android/volley/build/
@ -159,4 +160,3 @@ samples/client/petstore/typescript-node/npm/npm-debug.log
# aspnetcore
samples/server/petstore/aspnetcore/.vs/

View File

@ -25,7 +25,7 @@
This is the swagger codegen project, which allows generation of API client libraries (SDK generation), server stubs and documentation automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification). Currently, the following languages/frameworks are supported:
- **API clients**: **ActionScript**, **Apex**, **Bash**, **C#** (.net 2.0, 4.0 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Go**, **Groovy**, **Haskell**, **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign), **Kotlin**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **Python**, **Ruby**, **Scala**, **Swift** (2.x, 3.x), **Typescript** (Angular1.x, Angular2.x, Fetch, jQuery, Node)
- **Server stubs**: **C#** (ASP.NET Core, NancyFx), **C++** (Restbed), **Erlang**, **Go**, **Haskell**, **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework), **PHP** (Lumen, Slim, Silex, [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Scala** ([Finch](https://github.com/finagle/finch), Scalatra)
- **Server stubs**: **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell**, **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework), **PHP** (Lumen, Slim, Silex, [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Scala** ([Finch](https://github.com/finagle/finch), Scalatra)
- **API documentation generators**: **HTML**, **Confluence Wiki**
- **Others**: **JMeter**
@ -932,6 +932,7 @@ Here is a list of template creators:
* Server Stubs
* C# ASP.NET5: @jimschubert
* C# NancyFX: @mstefaniuk
* C++ Pistache: @sebymiano
* C++ Restbed: @stkrwork
* Erlang Server: @galaxie
* Go Server: @guohuang

31
bin/pistache-server-petstore.sh Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
SCRIPT="$0"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
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 -l pistache-server -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/pistache-server"
java $JAVA_OPTS -jar $executable $ags

View File

@ -96,6 +96,7 @@ public class CodegenConstants {
public static final String ENSURE_UNIQUE_PARAMS = "ensureUniqueParams";
public static final String ENSURE_UNIQUE_PARAMS_DESC = "Whether to ensure parameter names are unique in an operation (rename parameters that are not).";
public static final String PROJECT_NAME = "projectName";
public static final String PACKAGE_NAME = "packageName";
public static final String PACKAGE_VERSION = "packageVersion";

View File

@ -118,7 +118,7 @@ public class CodegenOperation {
* @return true if act as Restful show method, false otherwise
*/
public boolean isRestfulShow() {
return "GET".equals(httpMethod) && isMemberPath();
return "GET".equalsIgnoreCase(httpMethod) && isMemberPath();
}
/**
@ -127,7 +127,7 @@ public class CodegenOperation {
* @return true if act as Restful create method, false otherwise
*/
public boolean isRestfulCreate() {
return "POST".equals(httpMethod) && "".equals(pathWithoutBaseName());
return "POST".equalsIgnoreCase(httpMethod) && "".equals(pathWithoutBaseName());
}
/**
@ -136,7 +136,7 @@ public class CodegenOperation {
* @return true if act as Restful update method, false otherwise
*/
public boolean isRestfulUpdate() {
return Arrays.asList("PUT", "PATCH").contains(httpMethod) && isMemberPath();
return Arrays.asList("PUT", "PATCH").contains(httpMethod.toUpperCase()) && isMemberPath();
}
/**
@ -145,7 +145,7 @@ public class CodegenOperation {
* @return true if act as Restful destroy method, false otherwise
*/
public boolean isRestfulDestroy() {
return "DELETE".equals(httpMethod) && isMemberPath();
return "DELETE".equalsIgnoreCase(httpMethod) && isMemberPath();
}
/**
@ -173,7 +173,6 @@ public class CodegenOperation {
*/
private boolean isMemberPath() {
if (pathParams.size() != 1) return false;
String id = pathParams.get(0).baseName;
return ("/{" + id + "}").equals(pathWithoutBaseName());
}

View File

@ -141,6 +141,8 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
defaultValue("default_controller"));
cliOptions.add(new CliOption(SUPPORT_PYTHON2, "support python2").
defaultValue("false"));
cliOptions.add(new CliOption("serverPort", "TCP port to listen to in app.run").
defaultValue("8080"));
}
@Override

View File

@ -3,6 +3,7 @@ package io.swagger.codegen.languages;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.*;
import io.swagger.models.properties.*;
import io.swagger.models.Swagger;
import java.util.TreeSet;
import java.util.*;
@ -11,8 +12,14 @@ import java.io.File;
import org.apache.commons.lang3.StringUtils;
public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String USE_ES6 = "useEs6";
protected boolean useEs6;
public JavascriptClosureAngularClientCodegen() {
super();
outputFolder = "generated-code/javascript-closure-angular";
supportsInheritance = false;
setReservedWordsLowerCase(Arrays.asList("abstract",
@ -64,15 +71,11 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
typeMapping.put("binary", "string");
outputFolder = "generated-code/javascript-closure-angular";
modelTemplateFiles.put("model.mustache", ".js");
apiTemplateFiles.put("api.mustache", ".js");
embeddedTemplateDir = templateDir = "Javascript-Closure-Angular";
apiPackage = "API.Client";
modelPackage = "API.Client";
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
.defaultValue(Boolean.TRUE.toString()));
cliOptions.add(new CliOption(USE_ES6,
"use ES6 templates")
.defaultValue(Boolean.FALSE.toString()));
}
@Override
@ -83,6 +86,28 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
}
if (additionalProperties.containsKey(USE_ES6)) {
setUseEs6(convertPropertyToBooleanAndWriteBack(USE_ES6));
}
}
@Override
public void preprocessSwagger(Swagger swagger) {
super.preprocessSwagger(swagger);
if (useEs6) {
embeddedTemplateDir = templateDir = "Javascript-Closure-Angular/es6";
apiPackage = "resources";
apiTemplateFiles.put("api.mustache", ".js");
supportingFiles.add(new SupportingFile("module.mustache", "", "module.js"));
} else {
modelTemplateFiles.put("model.mustache", ".js");
apiTemplateFiles.put("api.mustache", ".js");
embeddedTemplateDir = templateDir = "Javascript-Closure-Angular";
apiPackage = "API.Client";
modelPackage = "API.Client";
}
}
@Override
@ -273,4 +298,7 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
return input.replace("*/", "*_/").replace("/*", "/_*");
}
public void setUseEs6(boolean useEs6) {
this.useEs6 = useEs6;
}
}

View File

@ -0,0 +1,409 @@
package io.swagger.codegen.languages;
import io.swagger.codegen.*;
import io.swagger.models.Model;
import io.swagger.models.Operation;
import io.swagger.models.Response;
import io.swagger.models.Swagger;
import io.swagger.models.properties.*;
import javax.validation.constraints.Null;
import java.io.File;
import java.util.*;
public class PistacheServerCodegen extends DefaultCodegen implements CodegenConfig {
protected String implFolder = "impl";
@Override
public CodegenType getTag() {
return CodegenType.SERVER;
}
@Override
public String getName() {
return "pistache-server";
}
@Override
public String getHelp() {
return "Generates a C++ API server (based on Pistache)";
}
public PistacheServerCodegen() {
super();
apiPackage = "io.swagger.server.api";
modelPackage = "io.swagger.server.model";
modelTemplateFiles.put("model-header.mustache", ".h");
modelTemplateFiles.put("model-source.mustache", ".cpp");
apiTemplateFiles.put("api-header.mustache", ".h");
apiTemplateFiles.put("api-source.mustache", ".cpp");
apiTemplateFiles.put("api-impl-header.mustache", ".h");
apiTemplateFiles.put("api-impl-source.mustache", ".cpp");
apiTemplateFiles.put("main-api-server.mustache", ".cpp");
embeddedTemplateDir = templateDir = "pistache-server";
cliOptions.clear();
reservedWords = new HashSet<>();
supportingFiles.add(new SupportingFile("modelbase-header.mustache", "model", "ModelBase.h"));
supportingFiles.add(new SupportingFile("modelbase-source.mustache", "model", "ModelBase.cpp"));
supportingFiles.add(new SupportingFile("cmake.mustache", "", "CMakeLists.txt"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t"));
typeMapping = new HashMap<String, String>();
typeMapping.put("date", "std::string");
typeMapping.put("DateTime", "std::string");
typeMapping.put("string", "std::string");
typeMapping.put("integer", "int32_t");
typeMapping.put("long", "int64_t");
typeMapping.put("boolean", "bool");
typeMapping.put("array", "std::vector");
typeMapping.put("map", "std::map");
typeMapping.put("file", "std::string");
typeMapping.put("object", "Object");
typeMapping.put("binary", "std::string");
typeMapping.put("number", "double");
typeMapping.put("UUID", "std::string");
super.importMapping = new HashMap<String, String>();
importMapping.put("std::vector", "#include <vector>");
importMapping.put("std::map", "#include <map>");
importMapping.put("std::string", "#include <string>");
importMapping.put("Object", "#include \"Object.h\"");
}
@Override
public void processOpts() {
super.processOpts();
additionalProperties.put("modelNamespaceDeclarations", modelPackage.split("\\."));
additionalProperties.put("modelNamespace", modelPackage.replaceAll("\\.", "::"));
additionalProperties.put("apiNamespaceDeclarations", apiPackage.split("\\."));
additionalProperties.put("apiNamespace", apiPackage.replaceAll("\\.", "::"));
}
/**
* Escapes a reserved word as defined in the `reservedWords` array. Handle
* escaping those terms here. This logic is only called if a variable
* matches the reseved words
*
* @return the escaped term
*/
@Override
public String escapeReservedWord(String name) {
return "_" + name; // add an underscore to the name
}
@Override
public String toModelImport(String name) {
if (importMapping.containsKey(name)) {
return importMapping.get(name);
} else {
return "#include \"" + name + ".h\"";
}
}
@Override
public CodegenModel fromModel(String name, Model model, Map<String, Model> allDefinitions) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions);
Set<String> oldImports = codegenModel.imports;
codegenModel.imports = new HashSet<>();
for (String imp : oldImports) {
String newImp = toModelImport(imp);
if (!newImp.isEmpty()) {
codegenModel.imports.add(newImp);
}
}
return codegenModel;
}
@Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation,
Map<String, Model> definitions, Swagger swagger) {
CodegenOperation op = super.fromOperation(path, httpMethod, operation, definitions, swagger);
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
Response methodResponse = findMethodResponse(operation.getResponses());
if (methodResponse != null) {
if (methodResponse.getSchema() != null) {
CodegenProperty cm = fromProperty("response", methodResponse.getSchema());
op.vendorExtensions.put("x-codegen-response", cm);
if(cm.datatype == "HttpContent") {
op.vendorExtensions.put("x-codegen-response-ishttpcontent", true);
}
}
}
}
String pathForPistache = path.replaceAll("\\{(.*?)}", ":$1");
op.vendorExtensions.put("x-codegen-pistache-path", pathForPistache);
return op;
}
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
String classname = (String) operations.get("classname");
operations.put("classnameSnakeUpperCase", DefaultCodegen.underscore(classname).toUpperCase());
operations.put("classnameSnakeLowerCase", DefaultCodegen.underscore(classname).toLowerCase());
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
boolean consumeJson = false;
boolean isParsingSupported = true;
if (op.bodyParam != null) {
if (op.bodyParam.vendorExtensions == null) {
op.bodyParam.vendorExtensions = new HashMap<>();
}
op.bodyParam.vendorExtensions.put("x-codegen-pistache-isStringOrDate", op.bodyParam.isString || op.bodyParam.isDate);
}
if(op.consumes != null) {
for (Map<String, String> consume : op.consumes) {
if (consume.get("mediaType") != null && consume.get("mediaType").equals("application/json")) {
consumeJson = true;
}
}
}
op.httpMethod = op.httpMethod.substring(0, 1).toUpperCase() + op.httpMethod.substring(1).toLowerCase();
for(CodegenParameter param : op.allParams){
if (param.isFormParam) isParsingSupported=false;
if (param.isFile) isParsingSupported=false;
if (param.isCookieParam) isParsingSupported=false;
//TODO: This changes the info about the real type but it is needed to parse the header params
if (param.isHeaderParam) {
param.dataType = "Optional<Net::Http::Header::Raw>";
param.baseType = "Optional<Net::Http::Header::Raw>";
} else if(param.isQueryParam){
if(param.isPrimitiveType) {
param.dataType = "Optional<" + param.dataType + ">";
} else {
param.dataType = "Optional<" + param.baseType + ">";
param.baseType = "Optional<" + param.baseType + ">";
}
}
}
if (op.vendorExtensions == null) {
op.vendorExtensions = new HashMap<>();
}
op.vendorExtensions.put("x-codegen-pistache-consumesJson", consumeJson);
op.vendorExtensions.put("x-codegen-pistache-isParsingSupported", isParsingSupported);
}
return objs;
}
@Override
public String toModelFilename(String name) {
return initialCaps(name);
}
@Override
public String apiFilename(String templateName, String tag) {
String result = super.apiFilename(templateName, tag);
if ( templateName.endsWith("impl-header.mustache") ) {
int ix = result.lastIndexOf('/');
result = result.substring(0, ix) + result.substring(ix, result.length() - 2) + "Impl.h";
result = result.replace(apiFileFolder(), implFileFolder());
} else if ( templateName.endsWith("impl-source.mustache") ) {
int ix = result.lastIndexOf('/');
result = result.substring(0, ix) + result.substring(ix, result.length() - 4) + "Impl.cpp";
result = result.replace(apiFileFolder(), implFileFolder());
} else if ( templateName.endsWith("api-server.mustache") ) {
int ix = result.lastIndexOf('/');
result = result.substring(0, ix) + result.substring(ix, result.length() - 4) + "MainServer.cpp";
result = result.replace(apiFileFolder(), outputFolder);
}
return result;
}
@Override
public String toApiFilename(String name) {
return initialCaps(name) + "Api";
}
/**
* Optional - type declaration. This is a String which is used by the
* templates to instantiate your types. There is typically special handling
* for different property types
*
* @return a string value used as the `dataType` field for model templates,
* `returnType` for api templates
*/
@Override
public String getTypeDeclaration(Property p) {
String swaggerType = getSwaggerType(p);
if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
}
if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "<std::string, " + getTypeDeclaration(inner) + ">";
}
if (p instanceof StringProperty || p instanceof DateProperty
|| p instanceof DateTimeProperty || p instanceof FileProperty
|| languageSpecificPrimitives.contains(swaggerType)) {
return toModelName(swaggerType);
}
return "std::shared_ptr<" + swaggerType + ">";
}
@Override
public String toDefaultValue(Property p) {
if (p instanceof StringProperty) {
return "\"\"";
} else if (p instanceof BooleanProperty) {
return "false";
} else if (p instanceof DateProperty) {
return "\"\"";
} else if (p instanceof DateTimeProperty) {
return "\"\"";
} else if (p instanceof DoubleProperty) {
return "0.0";
} else if (p instanceof FloatProperty) {
return "0.0f";
} else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) {
return "0";
} else if (p instanceof LongProperty) {
return "0L";
} else if (p instanceof DecimalProperty) {
return "0.0";
} else if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
String inner = getSwaggerType(ap.getAdditionalProperties());
return "std::map<std::string, " + inner + ">()";
} else if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
String inner = getSwaggerType(ap.getItems());
if (!languageSpecificPrimitives.contains(inner)) {
inner = "std::shared_ptr<" + inner + ">";
}
return "std::vector<" + inner + ">()";
} else if (p instanceof RefProperty) {
RefProperty rp = (RefProperty) p;
return "new " + toModelName(rp.getSimpleRef()) + "()";
}
return "nullptr";
}
@Override
public void postProcessParameter(CodegenParameter parameter) {
super.postProcessParameter(parameter);
boolean isPrimitiveType = parameter.isPrimitiveType == Boolean.TRUE;
boolean isListContainer = parameter.isListContainer == Boolean.TRUE;
boolean isString = parameter.isString == Boolean.TRUE;
if (!isPrimitiveType && !isListContainer && !isString && !parameter.dataType.startsWith("std::shared_ptr")) {
parameter.dataType = "std::shared_ptr<" + parameter.dataType + ">";
}
}
/**
* Location to write model files. You can use the modelPackage() as defined
* when the class is instantiated
*/
public String modelFileFolder() {
return (outputFolder + "/model").replace("/", File.separator);
}
/**
* Location to write api files. You can use the apiPackage() as defined when
* the class is instantiated
*/
@Override
public String apiFileFolder() {
return (outputFolder + "/api").replace("/", File.separator);
}
private String implFileFolder() {
return (outputFolder + "/" + implFolder).replace("/", File.separator);
}
/**
* Optional - swagger type conversion. This is used to map swagger types in
* a `Property` 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
* @see io.swagger.models.properties.Property
*/
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if (typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if (languageSpecificPrimitives.contains(type))
return toModelName(type);
} else
type = swaggerType;
return toModelName(type);
}
@Override
public String toModelName(String type) {
if (typeMapping.keySet().contains(type) || typeMapping.values().contains(type)
|| importMapping.values().contains(type) || defaultIncludes.contains(type)
|| languageSpecificPrimitives.contains(type)) {
return type;
} else {
return Character.toUpperCase(type.charAt(0)) + type.substring(1);
}
}
@Override
public String toVarName(String name) {
if (typeMapping.keySet().contains(name) || typeMapping.values().contains(name)
|| importMapping.values().contains(name) || defaultIncludes.contains(name)
|| languageSpecificPrimitives.contains(name)) {
return name;
}
if (name.length() > 1) {
return Character.toUpperCase(name.charAt(0)) + name.substring(1);
}
return name;
}
@Override
public String toApiName(String type) {
return Character.toUpperCase(type.charAt(0)) + type.substring(1) + "Api";
}
@Override
public String escapeQuotationMark(String input) {
// remove " to avoid code injection
return input.replace("\"", "");
}
@Override
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}
}

View File

@ -24,8 +24,9 @@ import org.apache.commons.lang3.StringUtils;
public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String PACKAGE_URL = "packageUrl";
protected String packageName;
protected String packageName; // e.g. petstore_api
protected String packageVersion;
protected String projectName; // for setup.py, e.g. petstore-api
protected String packageUrl;
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
@ -114,6 +115,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
cliOptions.clear();
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "python package name (convention: snake_case).")
.defaultValue("swagger_client"));
cliOptions.add(new CliOption(CodegenConstants.PROJECT_NAME, "python project name in setup.py (e.g. petstore-api)."));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "python package version.")
.defaultValue("1.0.0"));
cliOptions.add(new CliOption(PACKAGE_URL, "python package URL."));
@ -139,6 +141,15 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
setPackageName("swagger_client");
}
if (additionalProperties.containsKey(CodegenConstants.PROJECT_NAME)) {
setProjectName((String) additionalProperties.get(CodegenConstants.PROJECT_NAME));
}
else {
// default: set project based on package name
// e.g. petstore_api (package name) => petstore-api (project name)
setProjectName(packageName.replaceAll("_", "-"));
}
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
}
@ -154,6 +165,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString()));
}
additionalProperties.put(CodegenConstants.PROJECT_NAME, projectName);
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
@ -493,6 +505,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
this.packageName = packageName;
}
public void setProjectName(String projectName) {
this.projectName= projectName;
}
public void setPackageVersion(String packageVersion) {
this.packageVersion = packageVersion;
}

View File

@ -1,5 +1,6 @@
package io.swagger.codegen.languages;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -181,7 +182,7 @@ public class RestbedCodegen extends DefaultCodegen implements CodegenConfig {
* when the class is instantiated
*/
public String modelFileFolder() {
return outputFolder + "/model";
return (outputFolder + "/model").replace("/", File.separator);
}
/**
@ -190,7 +191,7 @@ public class RestbedCodegen extends DefaultCodegen implements CodegenConfig {
*/
@Override
public String apiFileFolder() {
return outputFolder + "/api";
return (outputFolder + "/api").replace("/", File.separator);
}
@Override

View File

@ -1,14 +1,7 @@
package io.swagger.codegen.languages;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenOperation;
import io.swagger.codegen.CodegenParameter;
import io.swagger.codegen.CodegenResponse;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
import com.samskivert.mustache.Mustache;
import io.swagger.codegen.*;
import io.swagger.models.Info;
import org.yaml.snakeyaml.error.Mark;
import io.swagger.codegen.utils.Markdown;
@ -129,6 +122,7 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
response.code = "default";
}
}
op.formParams = postProcessParameterEnum(op.formParams);
}
return objs;
}
@ -215,6 +209,30 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
}
}
/**
* Format to HTML the enums contained in every operations
*
* @param parameterList The whole parameters contained in one operation
* @return String | Html formated enum
*/
public List<CodegenParameter> postProcessParameterEnum(List<CodegenParameter> parameterList) {
String enumFormatted = "";
for(CodegenParameter parameter : parameterList) {
if (parameter.isEnum) {
for (int i = 0; i < parameter._enum.size(); i++) {
String spacer = (i == (parameter._enum.size() - 1)) ? " " : ", ";
if (parameter._enum.get(i) != null)
enumFormatted += "`" + parameter._enum.get(i) + "`" + spacer;
}
Markdown markInstance = new Markdown();
if (!enumFormatted.isEmpty())
parameter.vendorExtensions.put("x-eumFormatted", markInstance.toHtml(enumFormatted));
}
}
return parameterList;
}
private String sanitizePath(String p) {
//prefer replace a ', instead of a fuLL URL encode for readability
return p.replaceAll("'", "%27");

View File

@ -682,8 +682,9 @@ public class ApiClient {
Entity<?> entity = serialize(body, formParams, contentType);
Response response;
Response response = null;
try {
if ("GET".equals(method)) {
response = invocationBuilder.get();
} else if ("POST".equals(method)) {
@ -725,6 +726,13 @@ public class ApiClient {
buildResponseHeaders(response),
respBody);
}
} finally {
try {
response.close();
} catch (Exception e) {
// it's not critical, since the response object is local in method invokeAPI; that's fine, just continue
}
}
}
/**

View File

@ -1,3 +1,8 @@
/**
* NOTE: This class is auto generated by the swagger code generator program ({{{generatorVersion}}}).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
package {{package}};
{{#imports}}import {{import}};

View File

@ -0,0 +1,64 @@
/**
* @fileoverview AUTOMATICALLY GENERATED service for {{package}}.{{classname}}.
* Do not edit this file by hand or your changes will be lost next time it is
* generated.{{#appDescription}}
*
* {{ appDescription }}{{/appDescription}}{{#version}}
* Version: {{version}}{{/version}}{{#appContact}}
* Contact: {{appContact}}{{/appContact}}
{{^hideGenerationTimestamp}}
* Generated at: {{generatedDate}}
{{/hideGenerationTimestamp}}
* Generated by: {{generatorClass}}
*/{{#licenseInfo}}
/**
* @license {{licenseInfo}}{{#licenseUrl}}
* {{licenseUrl}}{{/licenseUrl}}
*/
{{/licenseInfo}}
{{#operations}}
export default class {{classname}} {
/**
{{#description}}
* {{&description}}
{{/description}}
* @constructor
* @param {!angular.$resource} $resource
* @ngInject
*/
constructor($resource) {
this.basePath = '{{basePath}}';
return $resource(null, {}, {
{{#operation}}
'{{operationId}}': this.{{operationId}}(),
{{/operation}}
});
}
{{#operation}}
/**
* {{summary}}
* {{notes}} {{#pathParams}}
* @param {object} { {{paramName}} : !{{{dataType}}}{{^required}}={{/required}} } path parameters required by resource {{/pathParams}}{{#bodyParams}}
* @param {object} { {{paramName}} : !{{{dataType}}}{{^required}}={{/required}} } postData required by resource {{/bodyParams}}
* @param {function} Success Callback
* @param {function} Error Callback
* @return {object}
*/
{{operationId}}() {
return {
method: '{{httpMethod}}',
url: this.basePath + '{{path}}'
{{#pathParams}}
.replace('{' + '{{baseName}}' + '}', ':{{paramName}}')
{{/pathParams}}
}
}
{{/operation}}
}
{{/operations}}

View File

@ -0,0 +1,18 @@
{{#apiInfo}}
{{#apis}}
{{#operations}}
import {{classname}} from './resources/{{classname}}';
{{/operations}}
{{/apis}}
let moduleName = '{{appName}}'.toLowerCase().replace(/\s/g, '.');
export default angular
.module(moduleName, [])
{{#apis}}
{{#operations}}
.service('{{classname}}', {{classname}})
{{/operations}}
{{/apis}};
{{/apiInfo}}

View File

@ -41,6 +41,7 @@ io.swagger.codegen.languages.NodeJSServerCodegen
io.swagger.codegen.languages.ObjcClientCodegen
io.swagger.codegen.languages.PerlClientCodegen
io.swagger.codegen.languages.PhpClientCodegen
io.swagger.codegen.languages.PistacheServerCodegen
io.swagger.codegen.languages.PythonClientCodegen
io.swagger.codegen.languages.Qt5CPPGenerator
io.swagger.codegen.languages.Rails5ServerCodegen

View File

@ -59,11 +59,6 @@
});
}
// load google web fonts
loadGoogleFontCss();
// Bootstrap Scrollspy
$(this).scrollspy({ target: '#scrollingNav', offset: 18 });
@ -105,21 +100,6 @@
//Convert elements with "marked" class to markdown
processMarked();
/**
* Load google fonts.
*/
function loadGoogleFontCss() {
WebFont.load({
active: function() {
// Update scrollspy
$(window).scrollspy('refresh')
},
google: {
families: ['Source Code Pro', 'Source Sans Pro:n4,n6,n7']
}
});
}
});
</script>
<style type="text/css">

View File

@ -258,7 +258,7 @@ var JSONSchemaView = (function () {
}
if (this.isArray) {
var view = new JSONSchemaView(this.schema.items, this.open - 1);
var view = new JSONSchemaView(this.schema.items, Infinity);
inner.appendChild(view.render());
}

View File

@ -2,25 +2,39 @@
<td>
<script>
$(document).ready(function() {
var schemaWrapper = {{{jsonSchema}}};
var schema = schemaWrapper;
<div id="d2e199_{{nickname}}_{{paramName}}">
<div class="json-schema-view">
<div class="primitive">
<span class="type">
{{dataType}}
</span>
{{#dataFormat}}
<span class="format">
({{dataFormat}})
</span>
{{/dataFormat}}
var view = new JSONSchemaView(schema,1);
var result = $('#d2e199_{{nickname}}_{{paramName}}');
result.empty();
result.append(view.render());
});
</script>
<div id="d2e199_{{nickname}}_{{paramName}}"></div>
{{#description}}
<div class="inner description">
{{description}}
</div>
{{/description}}
</div>
{{#isEnum}}
{{#vendorExtensions.x-eumFormatted}}
<div class="inner enums" id="{{nickname}}_{{paramName}}_enum">
<span class="inner">
<b>Enum: </b>{{{vendorExtensions.x-eumFormatted}}}
</span>
</div>
{{/vendorExtensions.x-eumFormatted}}
{{/isEnum}}
{{#required}}
<div class="inner required">
Required
</div>
{{/required}}
</div>
</div>
</td>
</tr>

View File

@ -1,6 +1,11 @@
/* ------------------------------------------------------------------------------------------
* Content
* ------------------------------------------------------------------------------------------ */
@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro');
* {
font-family: 'Source Code Pro', sans-serif;
}
body {
min-width: 980px;
}

View File

@ -0,0 +1,50 @@
# REST API Server for {{appName}}
## Overview
This API Server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) 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 swagger definition. Every handler extracts
the path and body parameters (if any) from the requests and tries to parse and possibly validate them.
Once this step is completed, the main API class calls the corresponding abstract method that should be implemented
by the developer (a basic implementation is provided under the `impl` folder)
- `impl`: As written above, the implementation folder contains, for each API, the corresponding implementation class,
which extends the main API class and implements the abstract methods.
Every method receives the path and body parameters as constant reference variables and a reference to the response
object, that should be filled with the right response and sent at the end of the method with the command:
response.send(returnCode, responseBody, [mimeType])
- `model`: This folder contains the corresponding class for every object schema found in the swagger specification.
The main folder contains also a file with a main that can be used to start the server.
Of course, is you should customize this file based on your needs
## Installation
First of all, you need to download and install the libraries listed [here](#libraries-required).
Once the libraries are installed, in order to compile and run the server please follow the steps below:
```bash
mkdir build
cd build
cmake ..
make
```
Once compiled run the server:
```bash
cd build
./server
```
## Libraries required
- [pistache](http://pistache.io/quickstart)
- [JSON for Modern C++](https://github.com/nlohmann/json/#integration): Please download the `json.hpp` file and
put it under the model folder
## Namespaces
io::swagger::server::api
io::swagger::server::model

View File

@ -0,0 +1,74 @@
{{>licenseInfo}}
{{#operations}}/*
* {{classname}}.h
*
* {{description}}
*/
#ifndef {{classname}}_H_
#define {{classname}}_H_
{{{defaultInclude}}}
#include <pistache/endpoint.h>
#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>
{{#imports}}{{{import}}}
{{/imports}}
{{#apiNamespaceDeclarations}}
namespace {{this}} {
{{/apiNamespaceDeclarations}}
using namespace {{modelNamespace}};
class {{declspec}} {{classname}} {
public:
{{classname}}(Net::Address addr);
virtual ~{{classname}}() {};
void init(size_t thr);
void start();
void shutdown();
const std::string base = "{{basePathWithoutHost}}";
private:
void setupRoutes();
{{#operation}}
void {{operationIdSnakeCase}}_handler(const Net::Rest::Request &request, Net::Http::ResponseWriter response);
{{/operation}}
void {{classnameSnakeLowerCase}}_default_handler(const Net::Rest::Request &request, Net::Http::ResponseWriter response);
std::shared_ptr<Net::Http::Endpoint> httpEndpoint;
Net::Rest::Router router;
{{#operation}}
/// <summary>
/// {{summary}}
/// </summary>
/// <remarks>
/// {{notes}}
/// </remarks>
{{#vendorExtensions.x-codegen-pistache-isParsingSupported}}
{{#allParams}}
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
{{/allParams}}
virtual void {{operationIdSnakeCase}}({{#allParams}}const {{#isPrimitiveType}}{{{dataType}}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{{baseType}}}{{/isPrimitiveType}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Net::Http::ResponseWriter &response) = 0;
{{/vendorExtensions.x-codegen-pistache-isParsingSupported}}
{{^vendorExtensions.x-codegen-pistache-isParsingSupported}}
virtual void {{operationIdSnakeCase}}(const Net::Rest::Request &request, Net::Http::ResponseWriter &response) = 0;
{{/vendorExtensions.x-codegen-pistache-isParsingSupported}}
{{/operation}}
};
{{#apiNamespaceDeclarations}}
}
{{/apiNamespaceDeclarations}}
#endif /* {{classname}}_H_ */
{{/operations}}

View File

@ -0,0 +1,52 @@
{{>licenseInfo}}
{{#operations}}/*
* {{classname}}Impl.h
*
* {{description}}
*/
#ifndef {{classnameSnakeUpperCase}}_IMPL_H_
#define {{classnameSnakeUpperCase}}_IMPL_H_
{{{defaultInclude}}}
#include <pistache/endpoint.h>
#include <pistache/http.h>
#include <pistache/router.h>
#include <memory>
#include <{{classname}}.h>
{{#imports}}{{{import}}}
{{/imports}}
{{#apiNamespaceDeclarations}}
namespace {{this}} {
{{/apiNamespaceDeclarations}}
using namespace {{modelNamespace}};
class {{classname}}Impl : public {{apiNamespace}}::{{classname}} {
public:
{{classname}}Impl(Net::Address addr);
~{{classname}}Impl() { };
{{#operation}}
{{#vendorExtensions.x-codegen-pistache-isParsingSupported}}
void {{operationIdSnakeCase}}({{#allParams}}const {{#isPrimitiveType}}{{{dataType}}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{{baseType}}}{{/isPrimitiveType}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Net::Http::ResponseWriter &response);
{{/vendorExtensions.x-codegen-pistache-isParsingSupported}}
{{^vendorExtensions.x-codegen-pistache-isParsingSupported}}
void {{operationIdSnakeCase}}(const Net::Rest::Request &request, Net::Http::ResponseWriter &response);
{{/vendorExtensions.x-codegen-pistache-isParsingSupported}}
{{/operation}}
};
{{#apiNamespaceDeclarations}}
}
{{/apiNamespaceDeclarations}}
{{/operations}}
#endif

View File

@ -0,0 +1,33 @@
{{>licenseInfo}}
{{#operations}}
#include "{{classname}}Impl.h"
{{#apiNamespaceDeclarations}}
namespace {{this}} {
{{/apiNamespaceDeclarations}}
using namespace {{modelNamespace}};
{{classname}}Impl::{{classname}}Impl(Net::Address addr)
: {{classname}}(addr)
{ }
{{#operation}}
{{#vendorExtensions.x-codegen-pistache-isParsingSupported}}
void {{classname}}Impl::{{operationIdSnakeCase}}({{#allParams}}const {{#isPrimitiveType}}{{{dataType}}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{{baseType}}}{{/isPrimitiveType}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Net::Http::ResponseWriter &response) {
response.send(Net::Http::Code::Ok, "Do some magic\n");
}
{{/vendorExtensions.x-codegen-pistache-isParsingSupported}}
{{^vendorExtensions.x-codegen-pistache-isParsingSupported}}
void {{classname}}Impl::{{operationIdSnakeCase}}(const Net::Rest::Request &request, Net::Http::ResponseWriter &response){
response.send(Net::Http::Code::Ok, "Do some magic\n");
}
{{/vendorExtensions.x-codegen-pistache-isParsingSupported}}
{{/operation}}
{{#apiNamespaceDeclarations}}
}
{{/apiNamespaceDeclarations}}
{{/operations}}

View File

@ -0,0 +1,108 @@
{{>licenseInfo}}
{{#operations}}
#include "{{classname}}.h"
{{#apiNamespaceDeclarations}}
namespace {{this}} {
{{/apiNamespaceDeclarations}}
using namespace {{modelNamespace}};
{{classname}}::{{classname}}(Net::Address addr)
: httpEndpoint(std::make_shared<Net::Http::Endpoint>(addr))
{ };
void {{classname}}::init(size_t thr = 2) {
auto opts = Net::Http::Endpoint::options()
.threads(thr)
.flags(Net::Tcp::Options::InstallSignalHandler);
httpEndpoint->init(opts);
setupRoutes();
}
void {{classname}}::start() {
httpEndpoint->setHandler(router.handler());
httpEndpoint->serve();
}
void {{classname}}::shutdown() {
httpEndpoint->shutdown();
}
void {{classname}}::setupRoutes() {
using namespace Net::Rest;
{{#operation}}
Routes::{{httpMethod}}(router, base + "{{{vendorExtensions.x-codegen-pistache-path}}}", Routes::bind(&{{classname}}::{{operationIdSnakeCase}}_handler, this));
{{/operation}}
// Default handler, called when a route is not found
router.addCustomHandler(Routes::bind(&{{classname}}::{{classnameSnakeLowerCase}}_default_handler, this));
}
{{#operation}}
void {{classname}}::{{operationIdSnakeCase}}_handler(const Net::Rest::Request &request, Net::Http::ResponseWriter response) {
{{#vendorExtensions.x-codegen-pistache-isParsingSupported}}
{{#hasPathParams}}
// Getting the path params
{{#pathParams}}
auto {{paramName}} = request.param(":{{paramName}}").as<{{dataType}}>();
{{/pathParams}}
{{/hasPathParams}}{{#hasBodyParam}}
// Getting the body param
{{#bodyParam}}
{{^isPrimitiveType}}
{{baseType}} {{paramName}};{{/isPrimitiveType}}
{{#isPrimitiveType}}
{{dataType}} {{paramName}};
{{/isPrimitiveType}}
{{/bodyParam}}
{{/hasBodyParam}}{{#hasQueryParams}}
// Getting the query params
{{#queryParams}}
auto {{paramName}} = request.query().get("{{baseName}}");
{{/queryParams}}
{{/hasQueryParams}}{{#hasHeaderParams}}
// Getting the header params
{{#headerParams}}
auto {{paramName}} = request.headers().tryGetRaw("{{baseName}}");
{{/headerParams}}
{{/hasHeaderParams}}
try {
{{#hasBodyParam}}
{{#bodyParam}}
nlohmann::json request_body = nlohmann::json::parse(request.body());
{{^isPrimitiveType}}
{{paramName}}.fromJson(request_body); {{/isPrimitiveType}}
{{#isPrimitiveType}}
// The conversion is done automatically by the json library
{{paramName}} = request_body;
{{/isPrimitiveType}}
{{/bodyParam}}
{{/hasBodyParam}}
this->{{operationIdSnakeCase}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}response);
{{/vendorExtensions.x-codegen-pistache-isParsingSupported}}
{{^vendorExtensions.x-codegen-pistache-isParsingSupported}}
try {
this->{{operationIdSnakeCase}}(request, response);
{{/vendorExtensions.x-codegen-pistache-isParsingSupported}}
} catch (std::runtime_error & e) {
//send a 400 error
response.send(Net::Http::Code::Bad_Request, e.what());
return;
}
}
{{/operation}}
void {{classname}}::{{classnameSnakeLowerCase}}_default_handler(const Net::Rest::Request &request, Net::Http::ResponseWriter response) {
response.send(Net::Http::Code::Not_Found, "The requested method does not exist");
}
{{#apiNamespaceDeclarations}}
}
{{/apiNamespaceDeclarations}}
{{/operations}}

View File

@ -0,0 +1,48 @@
cmake_minimum_required (VERSION 3.2)
project(server)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -std=c++11)
link_directories(/usr/local/lib/)
aux_source_directory(model MODEL_SOURCES)
{{=<% %>=}}
<%#apiInfo.apis%>
<%#operations%>
file(GLOB <%classnameSnakeUpperCase%>_SOURCES
"api/<%classname%>.h"
"api/<%classname%>.cpp"
"impl/<%classname%>Impl.h"
"impl/<%classname%>Impl.cpp"
)
<%/operations%>
<%/apiInfo.apis%>
include_directories(model)
include_directories(api)
include_directories(impl)
<%#apiInfo.apis%>
<%#operations%>
set(<%classnameSnakeUpperCase%>_SERVER_SOURCES
<%classname%>MainServer.cpp
${MODEL_SOURCES}
${<%classnameSnakeUpperCase%>_SOURCES})
<%/operations%>
<%/apiInfo.apis%>
<%#apiInfo.apis%>
<%#operations%>
add_executable(<%classnameSnakeLowerCase%>_server
${<%classnameSnakeUpperCase%>_SERVER_SOURCES})
<%/operations%>
<%/apiInfo.apis%>
<%#apiInfo.apis%>
<%#operations%>
target_link_libraries(<%classnameSnakeLowerCase%>_server net)
<%/operations%>
<%/apiInfo.apis%>
<%={{ }}=%>

View File

@ -0,0 +1,11 @@
/**
* {{{appName}}}
* {{{appDescription}}}
*
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/

View File

@ -0,0 +1,21 @@
{{>licenseInfo}}
{{#operations}}
#include "pistache/endpoint.h"
#include "pistache/http.h"
#include "pistache/router.h"
#include "{{classname}}Impl.h"
using namespace {{apiNamespace}};
int main() {
Net::Address addr(Net::Ipv4::any(), Net::Port(8080));
{{classname}}Impl server(addr);
server.init(2);
server.start();
server.shutdown();
}
{{/operations}}

View File

@ -0,0 +1,68 @@
{{>licenseInfo}}
{{#models}}{{#model}}/*
* {{classname}}.h
*
* {{description}}
*/
#ifndef {{classname}}_H_
#define {{classname}}_H_
{{{defaultInclude}}}
#include "ModelBase.h"
{{#imports}}{{{this}}}
{{/imports}}
{{#modelNamespaceDeclarations}}
namespace {{this}} {
{{/modelNamespaceDeclarations}}
/// <summary>
/// {{description}}
/// </summary>
class {{declspec}} {{classname}}
: public ModelBase
{
public:
{{classname}}();
virtual ~{{classname}}();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
nlohmann::json toJson() const override;
void fromJson(nlohmann::json& json) override;
/////////////////////////////////////////////
/// {{classname}} members
{{#vars}}
/// <summary>
/// {{description}}
/// </summary>
{{^isNotContainer}}{{{datatype}}}& {{getter}}();
{{/isNotContainer}}{{#isNotContainer}}{{{datatype}}} {{getter}}() const;
void {{setter}}({{{datatype}}} value);
{{/isNotContainer}}{{^required}}bool {{baseName}}IsSet() const;
void unset{{name}}();
{{/required}}
{{/vars}}
protected:
{{#vars}}
{{{datatype}}} m_{{name}};
{{^required}}
bool m_{{name}}IsSet;{{/required}}
{{/vars}}
};
{{#modelNamespaceDeclarations}}
}
{{/modelNamespaceDeclarations}}
#endif /* {{classname}}_H_ */
{{/model}}
{{/models}}

View File

@ -0,0 +1,144 @@
{{>licenseInfo}}
{{#models}}{{#model}}
#include "{{classname}}.h"
{{#modelNamespaceDeclarations}}
namespace {{this}} {
{{/modelNamespaceDeclarations}}
{{classname}}::{{classname}}()
{
{{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}m_{{name}} = {{{defaultValue}}};
{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isString}}m_{{name}} = {{{defaultValue}}};
{{/isString}}{{#isDateTime}}m_{{name}} = {{{defaultValue}}};
{{/isDateTime}}{{/isPrimitiveType}}{{/isNotContainer}}{{^required}}m_{{name}}IsSet = false;
{{/required}}{{/vars}}
}
{{classname}}::~{{classname}}()
{
}
void {{classname}}::validate()
{
// TODO: implement validation
}
nlohmann::json {{classname}}::toJson() const
{
nlohmann::json val = nlohmann::json::object();
{{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(m_{{name}}IsSet)
{
val["{{baseName}}"] = m_{{name}};
}
{{/required}}{{#required}}val["{{baseName}}"] = m_{{name}};
{{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{#isListContainer}}{
nlohmann::json jsonArray;
for( auto& item : m_{{name}} )
{
jsonArray.push_back(ModelBase::toJson(item));
}
{{#required}}val["{{baseName}}"] = jsonArray;
{{/required}}{{^required}}
if(jsonArray.size() > 0)
{
val["{{baseName}}"] = jsonArray;
}
{{/required}}
}
{{/isListContainer}}{{^isListContainer}}{{^isPrimitiveType}}{{^required}}if(m_{{name}}IsSet)
{
val["{{baseName}}"] = ModelBase::toJson(m_{{name}});
}
{{/required}}{{#required}}val["{{baseName}}"] = ModelBase::toJson(m_{{name}});
{{/required}}{{/isPrimitiveType}}{{/isListContainer}}{{/vars}}
return val;
}
void {{classname}}::fromJson(nlohmann::json& val)
{
{{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(val.find("{{baseName}}") != val.end())
{
{{setter}}(val.at("{{baseName}}"));
}
{{/required}}{{#required}}{{setter}}(val.at("{{baseName}}"));
{{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{#isListContainer}}{
m_{{name}}.clear();
nlohmann::json jsonArray;
{{^required}}if(val.find("{{baseName}}") != val.end())
{
{{/required}}
for( auto& item : val["{{baseName}}"] )
{
{{#isPrimitiveType}}m_{{name}}.push_back(item);
{{/isPrimitiveType}}{{^isPrimitiveType}}{{#items.isString}}m_{{name}}.push_back(item);
{{/items.isString}}{{^items.isString}}{{#items.isDateTime}}m_{{name}}.push_back(item);
{{/items.isDateTime}}{{^items.isDateTime}}
if(item.is_null())
{
m_{{name}}.push_back( {{{items.datatype}}}(nullptr) );
}
else
{
{{{items.datatype}}} newItem({{{items.defaultValue}}});
newItem->fromJson(item);
m_{{name}}.push_back( newItem );
}
{{/items.isDateTime}}{{/items.isString}}{{/isPrimitiveType}}
}
{{^required}}
}
{{/required}}
}
{{/isListContainer}}{{^isListContainer}}{{^isPrimitiveType}}{{^required}}if(val.find("{{baseName}}") != val.end())
{
{{#isString}}{{setter}}(val.at("{{baseName}}"));
{{/isString}}{{^isString}}{{#isDateTime}}{{setter}}(val.at("{{baseName}}"));
{{/isDateTime}}{{^isDateTime}}if(!val["{{baseName}}"].is_null())
{
{{{datatype}}} newItem({{{defaultValue}}});
newItem->fromJson(val["{{baseName}}"]);
{{setter}}( newItem );
}
{{/isDateTime}}{{/isString}}
}
{{/required}}{{#required}}{{#isString}}{{setter}}(val.at("{{baseName}}"));
{{/isString}}{{^isString}}{{#isDateTime}}{{setter}}(val.at("{{baseName}}"));
{{/isDateTime}}{{/isString}}{{/required}}{{/isPrimitiveType}}{{/isListContainer}}{{/vars}}
}
{{#vars}}{{^isNotContainer}}{{{datatype}}}& {{classname}}::{{getter}}()
{
return m_{{name}};
}
{{/isNotContainer}}{{#isNotContainer}}{{{datatype}}} {{classname}}::{{getter}}() const
{
return m_{{name}};
}
void {{classname}}::{{setter}}({{{datatype}}} value)
{
m_{{name}} = value;
{{^required}}m_{{name}}IsSet = true;{{/required}}
}
{{/isNotContainer}}
{{^required}}bool {{classname}}::{{baseName}}IsSet() const
{
return m_{{name}}IsSet;
}
void {{classname}}::unset{{name}}()
{
m_{{name}}IsSet = false;
}
{{/required}}
{{/vars}}
{{#modelNamespaceDeclarations}}
}
{{/modelNamespaceDeclarations}}
{{/model}}
{{/models}}

View File

@ -0,0 +1,45 @@
{{>licenseInfo}}
/*
* ModelBase.h
*
* This is the base class for all model classes
*/
#ifndef ModelBase_H_
#define ModelBase_H_
{{{defaultInclude}}}
#include "json.hpp"
#include <ctime>
#include <string>
{{#modelNamespaceDeclarations}}
namespace {{this}} {
{{/modelNamespaceDeclarations}}
class {{declspec}} ModelBase
{
public:
ModelBase();
virtual ~ModelBase();
virtual void validate() = 0;
virtual nlohmann::json toJson() const = 0;
virtual void fromJson(nlohmann::json& json) = 0;
static std::string toJson( const std::string& value );
static std::string toJson( const std::time_t& value );
static int32_t toJson( int32_t value );
static int64_t toJson( int64_t value );
static double toJson( double value );
static bool toJson( bool value );
static nlohmann::json toJson( std::shared_ptr<ModelBase> content );
};
{{#modelNamespaceDeclarations}}
}
{{/modelNamespaceDeclarations}}
#endif /* ModelBase_H_ */

View File

@ -0,0 +1,54 @@
{{>licenseInfo}}
#include "ModelBase.h"
{{#modelNamespaceDeclarations}}
namespace {{this}} {
{{/modelNamespaceDeclarations}}
ModelBase::ModelBase()
{
}
ModelBase::~ModelBase()
{
}
std::string ModelBase::toJson( const std::string& value )
{
return value;
}
std::string ModelBase::toJson( const std::time_t& value )
{
char buf[sizeof "2011-10-08T07:07:09Z"];
strftime(buf, sizeof buf, "%FT%TZ", gmtime(&value));
return buf;
}
int32_t ModelBase::toJson( int32_t value )
{
return value;
}
int64_t ModelBase::toJson( int64_t value )
{
return value;
}
double ModelBase::toJson( double value )
{
return value;
}
bool ModelBase::toJson( bool value )
{
return value;
}
nlohmann::json ModelBase::toJson( std::shared_ptr<ModelBase> content )
{
return content.get() ? content->toJson() : nlohmann::json();
}
{{#modelNamespaceDeclarations}}
}
{{/modelNamespaceDeclarations}}

View File

@ -1,4 +1,4 @@
# {{packageName}}
# {{{projectName}}}
{{#appDescription}}
{{{appDescription}}}
{{/appDescription}}

View File

@ -5,7 +5,7 @@
import sys
from setuptools import setup, find_packages
NAME = "{{packageName}}"
NAME = "{{{projectName}}}"
VERSION = "{{packageVersion}}"
{{#apiInfo}}
{{#apis}}

View File

@ -9,6 +9,7 @@ import java.util.Map;
public class PythonClientOptionsProvider implements OptionsProvider {
public static final String PACKAGE_NAME_VALUE = "swagger_client_python";
public static final String PROJECT_NAME_VALUE = "swagger-client-python";
public static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
public static final String PACKAGE_URL_VALUE = "";
@ -22,6 +23,7 @@ public class PythonClientOptionsProvider implements OptionsProvider {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(PythonClientCodegen.PACKAGE_URL, PACKAGE_URL_VALUE)
.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
.put(CodegenConstants.PROJECT_NAME, PROJECT_NAME_VALUE)
.put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, "true")
.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "true")

View File

@ -28,6 +28,8 @@ public class PythonClientOptionsTest extends AbstractOptionsTest {
new Expectations(clientCodegen) {{
clientCodegen.setPackageName(PythonClientOptionsProvider.PACKAGE_NAME_VALUE);
times = 1;
clientCodegen.setProjectName(PythonClientOptionsProvider.PROJECT_NAME_VALUE);
times = 1;
clientCodegen.setPackageVersion(PythonClientOptionsProvider.PACKAGE_VERSION_VALUE);
times = 1;
clientCodegen.setPackageUrl(PythonClientOptionsProvider.PACKAGE_URL_VALUE);

View File

@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@ -23,7 +23,7 @@ object UserApi {
def createUser(body: User): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user", "application/json")
.withBody(body)
.withSuccessResponse[Unit](0)
.withDefaultSuccessResponse[Unit]
/**
*
* Expected answers:
@ -34,7 +34,7 @@ object UserApi {
def createUsersWithArrayInput(body: Seq[User]): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithArray", "application/json")
.withBody(body)
.withSuccessResponse[Unit](0)
.withDefaultSuccessResponse[Unit]
/**
*
* Expected answers:
@ -45,7 +45,7 @@ object UserApi {
def createUsersWithListInput(body: Seq[User]): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithList", "application/json")
.withBody(body)
.withSuccessResponse[Unit](0)
.withDefaultSuccessResponse[Unit]
/**
* This can only be done by the logged in user.
*
@ -105,7 +105,7 @@ object UserApi {
*/
def logoutUser(): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/logout", "application/json")
.withSuccessResponse[Unit](0)
.withDefaultSuccessResponse[Unit]
/**
* This can only be done by the logged in user.
*

View File

@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@ -0,0 +1,10 @@
{
"sfdxSource": true,
"version": "1.0.0",
"sourceFolder": "src/",
"folders": [
"src/classes"
],
"files": [
]
}

View File

@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@ -41,6 +41,7 @@ void ApiResponse::validate()
web::json::value ApiResponse::toJson() const
{
web::json::value val = web::json::value::object();
if(m_CodeIsSet)
@ -62,6 +63,8 @@ web::json::value ApiResponse::toJson() const
void ApiResponse::fromJson(web::json::value& val)
{
if(val.has_field(U("code")))
{
setCode(ModelBase::int32_tFromJson(val[U("code")]));

View File

@ -78,9 +78,9 @@ public:
protected:
int32_t m_Code;
bool m_CodeIsSet;
utility::string_t m_Type;
utility::string_t m_Type;
bool m_TypeIsSet;
utility::string_t m_Message;
utility::string_t m_Message;
bool m_MessageIsSet;
};

View File

@ -39,6 +39,7 @@ void Category::validate()
web::json::value Category::toJson() const
{
web::json::value val = web::json::value::object();
if(m_IdIsSet)
@ -56,6 +57,8 @@ web::json::value Category::toJson() const
void Category::fromJson(web::json::value& val)
{
if(val.has_field(U("id")))
{
setId(ModelBase::int64_tFromJson(val[U("id")]));

View File

@ -71,7 +71,7 @@ public:
protected:
int64_t m_Id;
bool m_IdIsSet;
utility::string_t m_Name;
utility::string_t m_Name;
bool m_NameIsSet;
};

View File

@ -47,6 +47,7 @@ void Order::validate()
web::json::value Order::toJson() const
{
web::json::value val = web::json::value::object();
if(m_IdIsSet)
@ -80,6 +81,8 @@ web::json::value Order::toJson() const
void Order::fromJson(web::json::value& val)
{
if(val.has_field(U("id")))
{
setId(ModelBase::int64_tFromJson(val[U("id")]));

View File

@ -99,15 +99,15 @@ public:
protected:
int64_t m_Id;
bool m_IdIsSet;
int64_t m_PetId;
int64_t m_PetId;
bool m_PetIdIsSet;
int32_t m_Quantity;
int32_t m_Quantity;
bool m_QuantityIsSet;
utility::datetime m_ShipDate;
utility::datetime m_ShipDate;
bool m_ShipDateIsSet;
utility::string_t m_Status;
utility::string_t m_Status;
bool m_StatusIsSet;
bool m_Complete;
bool m_Complete;
bool m_CompleteIsSet;
};

View File

@ -42,6 +42,7 @@ void Pet::validate()
web::json::value Pet::toJson() const
{
web::json::value val = web::json::value::object();
if(m_IdIsSet)
@ -84,6 +85,8 @@ web::json::value Pet::toJson() const
void Pet::fromJson(web::json::value& val)
{
if(val.has_field(U("id")))
{
setId(ModelBase::int64_tFromJson(val[U("id")]));

View File

@ -96,13 +96,13 @@ public:
protected:
int64_t m_Id;
bool m_IdIsSet;
std::shared_ptr<Category> m_Category;
std::shared_ptr<Category> m_Category;
bool m_CategoryIsSet;
utility::string_t m_Name;
utility::string_t m_Name;
std::vector<utility::string_t> m_PhotoUrls;
std::vector<std::shared_ptr<Tag>> m_Tags;
bool m_TagsIsSet;
utility::string_t m_Status;
utility::string_t m_Status;
bool m_StatusIsSet;
};

View File

@ -39,6 +39,7 @@ void Tag::validate()
web::json::value Tag::toJson() const
{
web::json::value val = web::json::value::object();
if(m_IdIsSet)
@ -56,6 +57,8 @@ web::json::value Tag::toJson() const
void Tag::fromJson(web::json::value& val)
{
if(val.has_field(U("id")))
{
setId(ModelBase::int64_tFromJson(val[U("id")]));

View File

@ -71,7 +71,7 @@ public:
protected:
int64_t m_Id;
bool m_IdIsSet;
utility::string_t m_Name;
utility::string_t m_Name;
bool m_NameIsSet;
};

View File

@ -51,6 +51,7 @@ void User::validate()
web::json::value User::toJson() const
{
web::json::value val = web::json::value::object();
if(m_IdIsSet)
@ -92,6 +93,8 @@ web::json::value User::toJson() const
void User::fromJson(web::json::value& val)
{
if(val.has_field(U("id")))
{
setId(ModelBase::int64_tFromJson(val[U("id")]));

View File

@ -113,19 +113,19 @@ public:
protected:
int64_t m_Id;
bool m_IdIsSet;
utility::string_t m_Username;
utility::string_t m_Username;
bool m_UsernameIsSet;
utility::string_t m_FirstName;
utility::string_t m_FirstName;
bool m_FirstNameIsSet;
utility::string_t m_LastName;
utility::string_t m_LastName;
bool m_LastNameIsSet;
utility::string_t m_Email;
utility::string_t m_Email;
bool m_EmailIsSet;
utility::string_t m_Password;
utility::string_t m_Password;
bool m_PasswordIsSet;
utility::string_t m_Phone;
utility::string_t m_Phone;
bool m_PhoneIsSet;
int32_t m_UserStatus;
int32_t m_UserStatus;
bool m_UserStatusIsSet;
};

View File

@ -0,0 +1,30 @@
/*
* Swagger Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using Newtonsoft.Json.Converters;
namespace IO.Swagger.Client
{
/// <summary>
/// Formatter for 'date' swagger formats ss defined by full-date - RFC3339
/// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
/// </summary>
public class SwaggerDateConverter : IsoDateTimeConverter
{
/// <summary>
/// Initializes a new instance of the <see cref="SwaggerDateConverter" /> class.
/// </summary>
public SwaggerDateConverter()
{
// full-date = date-fullyear "-" date-month "-" date-mday
DateTimeFormat = "yyyy-MM-dd";
}
}
}

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -43,11 +44,13 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="map_property", EmitDefaultValue=false)]
public Dictionary<string, string> MapProperty { get; set; }
/// <summary>
/// Gets or Sets MapOfMapProperty
/// </summary>
[DataMember(Name="map_of_map_property", EmitDefaultValue=false)]
public Dictionary<string, Dictionary<string, string>> MapOfMapProperty { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -64,11 +65,13 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="className", EmitDefaultValue=false)]
public string ClassName { get; set; }
/// <summary>
/// Gets or Sets Color
/// </summary>
[DataMember(Name="color", EmitDefaultValue=false)]
public string Color { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -45,16 +46,19 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="code", EmitDefaultValue=false)]
public int? Code { get; set; }
/// <summary>
/// Gets or Sets Type
/// </summary>
[DataMember(Name="type", EmitDefaultValue=false)]
public string Type { get; set; }
/// <summary>
/// Gets or Sets Message
/// </summary>
[DataMember(Name="message", EmitDefaultValue=false)]
public string Message { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -41,6 +42,7 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="ArrayArrayNumber", EmitDefaultValue=false)]
public List<List<decimal?>> ArrayArrayNumber { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -41,6 +42,7 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="ArrayNumber", EmitDefaultValue=false)]
public List<decimal?> ArrayNumber { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -45,16 +46,19 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="array_of_string", EmitDefaultValue=false)]
public List<string> ArrayOfString { get; set; }
/// <summary>
/// Gets or Sets ArrayArrayOfInteger
/// </summary>
[DataMember(Name="array_array_of_integer", EmitDefaultValue=false)]
public List<List<long?>> ArrayArrayOfInteger { get; set; }
/// <summary>
/// Gets or Sets ArrayArrayOfModel
/// </summary>
[DataMember(Name="array_array_of_model", EmitDefaultValue=false)]
public List<List<ReadOnlyFirst>> ArrayArrayOfModel { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -51,32 +52,38 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="smallCamel", EmitDefaultValue=false)]
public string SmallCamel { get; set; }
/// <summary>
/// Gets or Sets CapitalCamel
/// </summary>
[DataMember(Name="CapitalCamel", EmitDefaultValue=false)]
public string CapitalCamel { get; set; }
/// <summary>
/// Gets or Sets SmallSnake
/// </summary>
[DataMember(Name="small_Snake", EmitDefaultValue=false)]
public string SmallSnake { get; set; }
/// <summary>
/// Gets or Sets CapitalSnake
/// </summary>
[DataMember(Name="Capital_Snake", EmitDefaultValue=false)]
public string CapitalSnake { get; set; }
/// <summary>
/// Gets or Sets SCAETHFlowPoints
/// </summary>
[DataMember(Name="SCA_ETH_Flow_Points", EmitDefaultValue=false)]
public string SCAETHFlowPoints { get; set; }
/// <summary>
/// Name of the pet
/// </summary>
/// <value>Name of the pet </value>
[DataMember(Name="ATT_NAME", EmitDefaultValue=false)]
public string ATT_NAME { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -66,16 +67,19 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="className", EmitDefaultValue=false)]
public string ClassName { get; set; }
/// <summary>
/// Gets or Sets Color
/// </summary>
[DataMember(Name="color", EmitDefaultValue=false)]
public string Color { get; set; }
/// <summary>
/// Gets or Sets Declawed
/// </summary>
[DataMember(Name="declawed", EmitDefaultValue=false)]
public bool? Declawed { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -43,11 +44,13 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -41,6 +42,7 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="_class", EmitDefaultValue=false)]
public string _Class { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -66,16 +67,19 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="className", EmitDefaultValue=false)]
public string ClassName { get; set; }
/// <summary>
/// Gets or Sets Color
/// </summary>
[DataMember(Name="color", EmitDefaultValue=false)]
public string Color { get; set; }
/// <summary>
/// Gets or Sets Breed
/// </summary>
[DataMember(Name="breed", EmitDefaultValue=false)]
public string Breed { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -89,6 +90,8 @@ namespace IO.Swagger.Model
this.ArrayEnum = ArrayEnum;
}
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -123,11 +124,15 @@ namespace IO.Swagger.Model
this.OuterEnum = OuterEnum;
}
/// <summary>
/// Gets or Sets OuterEnum
/// </summary>
[DataMember(Name="outerEnum", EmitDefaultValue=false)]
public OuterEnum OuterEnum { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -102,66 +103,80 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="integer", EmitDefaultValue=false)]
public int? Integer { get; set; }
/// <summary>
/// Gets or Sets Int32
/// </summary>
[DataMember(Name="int32", EmitDefaultValue=false)]
public int? Int32 { get; set; }
/// <summary>
/// Gets or Sets Int64
/// </summary>
[DataMember(Name="int64", EmitDefaultValue=false)]
public long? Int64 { get; set; }
/// <summary>
/// Gets or Sets Number
/// </summary>
[DataMember(Name="number", EmitDefaultValue=false)]
public decimal? Number { get; set; }
/// <summary>
/// Gets or Sets _Float
/// </summary>
[DataMember(Name="float", EmitDefaultValue=false)]
public float? _Float { get; set; }
/// <summary>
/// Gets or Sets _Double
/// </summary>
[DataMember(Name="double", EmitDefaultValue=false)]
public double? _Double { get; set; }
/// <summary>
/// Gets or Sets _String
/// </summary>
[DataMember(Name="string", EmitDefaultValue=false)]
public string _String { get; set; }
/// <summary>
/// Gets or Sets _Byte
/// </summary>
[DataMember(Name="byte", EmitDefaultValue=false)]
public byte[] _Byte { get; set; }
/// <summary>
/// Gets or Sets Binary
/// </summary>
[DataMember(Name="binary", EmitDefaultValue=false)]
public byte[] Binary { get; set; }
/// <summary>
/// Gets or Sets Date
/// </summary>
[DataMember(Name="date", EmitDefaultValue=false)]
[JsonConverter(typeof(SwaggerDateConverter))]
public DateTime? Date { get; set; }
/// <summary>
/// Gets or Sets DateTime
/// </summary>
[DataMember(Name="dateTime", EmitDefaultValue=false)]
public DateTime? DateTime { get; set; }
/// <summary>
/// Gets or Sets Uuid
/// </summary>
[DataMember(Name="uuid", EmitDefaultValue=false)]
public Guid? Uuid { get; set; }
/// <summary>
/// Gets or Sets Password
/// </summary>
[DataMember(Name="password", EmitDefaultValue=false)]
public string Password { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -40,11 +41,13 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="bar", EmitDefaultValue=false)]
public string Bar { get; private set; }
/// <summary>
/// Gets or Sets Foo
/// </summary>
[DataMember(Name="foo", EmitDefaultValue=false)]
public string Foo { get; private set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -41,6 +42,7 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="123-list", EmitDefaultValue=false)]
public string _123List { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -69,6 +70,8 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="map_map_of_string", EmitDefaultValue=false)]
public Dictionary<string, Dictionary<string, string>> MapMapOfString { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -45,16 +46,19 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="uuid", EmitDefaultValue=false)]
public Guid? Uuid { get; set; }
/// <summary>
/// Gets or Sets DateTime
/// </summary>
[DataMember(Name="dateTime", EmitDefaultValue=false)]
public DateTime? DateTime { get; set; }
/// <summary>
/// Gets or Sets Map
/// </summary>
[DataMember(Name="map", EmitDefaultValue=false)]
public Dictionary<string, Animal> Map { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -43,11 +44,13 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public int? Name { get; set; }
/// <summary>
/// Gets or Sets _Class
/// </summary>
[DataMember(Name="class", EmitDefaultValue=false)]
public string _Class { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -41,6 +42,7 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="client", EmitDefaultValue=false)]
public string _Client { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -41,6 +42,7 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="return", EmitDefaultValue=false)]
public int? _Return { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -56,21 +57,25 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public int? _Name { get; set; }
/// <summary>
/// Gets or Sets SnakeCase
/// </summary>
[DataMember(Name="snake_case", EmitDefaultValue=false)]
public int? SnakeCase { get; private set; }
/// <summary>
/// Gets or Sets Property
/// </summary>
[DataMember(Name="property", EmitDefaultValue=false)]
public string Property { get; set; }
/// <summary>
/// Gets or Sets _123Number
/// </summary>
[DataMember(Name="123Number", EmitDefaultValue=false)]
public int? _123Number { get; private set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -41,6 +42,7 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="JustNumber", EmitDefaultValue=false)]
public decimal? JustNumber { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -92,26 +93,32 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets PetId
/// </summary>
[DataMember(Name="petId", EmitDefaultValue=false)]
public long? PetId { get; set; }
/// <summary>
/// Gets or Sets Quantity
/// </summary>
[DataMember(Name="quantity", EmitDefaultValue=false)]
public int? Quantity { get; set; }
/// <summary>
/// Gets or Sets ShipDate
/// </summary>
[DataMember(Name="shipDate", EmitDefaultValue=false)]
public DateTime? ShipDate { get; set; }
/// <summary>
/// Gets or Sets Complete
/// </summary>
[DataMember(Name="complete", EmitDefaultValue=false)]
public bool? Complete { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,10 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
<<<<<<< HEAD
=======
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
>>>>>>> origin/master
namespace IO.Swagger.Model
{

View File

@ -18,6 +18,10 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
<<<<<<< HEAD
=======
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
>>>>>>> origin/master
namespace IO.Swagger.Model
{
@ -45,16 +49,28 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="my_number", EmitDefaultValue=false)]
public OuterNumber MyNumber { get; set; }
<<<<<<< HEAD
=======
>>>>>>> origin/master
/// <summary>
/// Gets or Sets MyString
/// </summary>
[DataMember(Name="my_string", EmitDefaultValue=false)]
public OuterString MyString { get; set; }
<<<<<<< HEAD
=======
>>>>>>> origin/master
/// <summary>
/// Gets or Sets MyBoolean
/// </summary>
[DataMember(Name="my_boolean", EmitDefaultValue=false)]
public OuterBoolean MyBoolean { get; set; }
<<<<<<< HEAD
=======
>>>>>>> origin/master
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{

View File

@ -18,6 +18,10 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
<<<<<<< HEAD
=======
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
>>>>>>> origin/master
namespace IO.Swagger.Model
{

View File

@ -18,6 +18,10 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
<<<<<<< HEAD
=======
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
>>>>>>> origin/master
namespace IO.Swagger.Model
{

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -105,26 +106,32 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Category
/// </summary>
[DataMember(Name="category", EmitDefaultValue=false)]
public Category Category { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Gets or Sets PhotoUrls
/// </summary>
[DataMember(Name="photoUrls", EmitDefaultValue=false)]
public List<string> PhotoUrls { get; set; }
/// <summary>
/// Gets or Sets Tags
/// </summary>
[DataMember(Name="tags", EmitDefaultValue=false)]
public List<Tag> Tags { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -41,11 +42,13 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="bar", EmitDefaultValue=false)]
public string Bar { get; private set; }
/// <summary>
/// Gets or Sets Baz
/// </summary>
[DataMember(Name="baz", EmitDefaultValue=false)]
public string Baz { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -41,6 +42,7 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="$special[property.name]", EmitDefaultValue=false)]
public long? SpecialPropertyName { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -43,11 +44,13 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
@ -55,42 +56,50 @@ namespace IO.Swagger.Model
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Username
/// </summary>
[DataMember(Name="username", EmitDefaultValue=false)]
public string Username { get; set; }
/// <summary>
/// Gets or Sets FirstName
/// </summary>
[DataMember(Name="firstName", EmitDefaultValue=false)]
public string FirstName { get; set; }
/// <summary>
/// Gets or Sets LastName
/// </summary>
[DataMember(Name="lastName", EmitDefaultValue=false)]
public string LastName { get; set; }
/// <summary>
/// Gets or Sets Email
/// </summary>
[DataMember(Name="email", EmitDefaultValue=false)]
public string Email { get; set; }
/// <summary>
/// Gets or Sets Password
/// </summary>
[DataMember(Name="password", EmitDefaultValue=false)]
public string Password { get; set; }
/// <summary>
/// Gets or Sets Phone
/// </summary>
[DataMember(Name="phone", EmitDefaultValue=false)]
public string Phone { get; set; }
/// <summary>
/// User Status
/// </summary>
/// <value>User Status</value>
[DataMember(Name="userStatus", EmitDefaultValue=false)]
public int? UserStatus { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>

View File

@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@ -60,11 +60,9 @@ Class | Method | HTTP request | Description
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [ArrayTest](docs/ArrayTest.md)
- [Capitalization](docs/Capitalization.md)
- [Cat](docs/Cat.md)
- [Category](docs/Category.md)
- [ClassModel](docs/ClassModel.md)
- [Client](docs/Client.md)
- [Dog](docs/Dog.md)
- [EnumArrays](docs/EnumArrays.md)
- [EnumClass](docs/EnumClass.md)
- [EnumTest](docs/EnumTest.md)
@ -89,6 +87,8 @@ Class | Method | HTTP request | Description
- [SpecialModelName](docs/SpecialModelName.md)
- [Tag](docs/Tag.md)
- [User](docs/User.md)
- [Cat](docs/Cat.md)
- [Dog](docs/Dog.md)
## Documentation For Authorization

View File

@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@ -671,8 +671,9 @@ public class ApiClient {
Entity<?> entity = serialize(body, formParams, contentType);
Response response;
Response response = null;
try {
if ("GET".equals(method)) {
response = invocationBuilder.get();
} else if ("POST".equals(method)) {
@ -714,6 +715,13 @@ public class ApiClient {
buildResponseHeaders(response),
respBody);
}
} finally {
try {
response.close();
} catch (Exception e) {
// it's not critical, since the response object is local in method invokeAPI; that's fine, just continue
}
}
}
/**

Some files were not shown because too many files have changed in this diff Show More