mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
Merge remote-tracking branch 'origin/master' into 2.3.0
This commit is contained in:
commit
45ff39c237
@ -47,6 +47,11 @@ before_install:
|
|||||||
- sudo apt-get update -qq
|
- sudo apt-get update -qq
|
||||||
- sudo apt-get install -qq bats
|
- sudo apt-get install -qq bats
|
||||||
- sudo apt-get install -qq curl
|
- sudo apt-get install -qq curl
|
||||||
|
# Add rebar3 build tool and recent Erlang/OTP for Erlang petstore server tests.
|
||||||
|
# - Travis CI does not support rebar3 [yet](https://github.com/travis-ci/travis-ci/issues/6506#issuecomment-275189490).
|
||||||
|
# - Rely on `kerl` for [pre-compiled versions available](https://docs.travis-ci.com/user/languages/erlang#Choosing-OTP-releases-to-test-against). Rely on installation path chosen by [`travis-erlang-builder`](https://github.com/travis-ci/travis-erlang-builder/blob/e6d016b1a91ca7ecac5a5a46395bde917ea13d36/bin/compile#L18).
|
||||||
|
- . ~/otp/18.2.1/activate && erl -version
|
||||||
|
- curl -f -L -o ./rebar3 https://s3.amazonaws.com/rebar3/rebar3 && chmod +x ./rebar3 && ./rebar3 version && export PATH="${TRAVIS_BUILD_DIR}:$PATH"
|
||||||
|
|
||||||
# show host table to confirm petstore.swagger.io is mapped to localhost
|
# show host table to confirm petstore.swagger.io is mapped to localhost
|
||||||
- cat /etc/hosts
|
- cat /etc/hosts
|
||||||
|
@ -722,7 +722,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
|
|||||||
- [DocRaptor](https://docraptor.com)
|
- [DocRaptor](https://docraptor.com)
|
||||||
- [DocuSign](https://www.docusign.com)
|
- [DocuSign](https://www.docusign.com)
|
||||||
- [Ergon](http://www.ergon.ch/)
|
- [Ergon](http://www.ergon.ch/)
|
||||||
- [EMC](https://www.emc.com/)
|
- [Dell EMC](https://www.emc.com/)
|
||||||
- [eureka](http://eure.jp/)
|
- [eureka](http://eure.jp/)
|
||||||
- [everystory.us](http://everystory.us)
|
- [everystory.us](http://everystory.us)
|
||||||
- [Expected Behavior](http://www.expectedbehavior.com/)
|
- [Expected Behavior](http://www.expectedbehavior.com/)
|
||||||
@ -874,6 +874,7 @@ Here is a list of template creators:
|
|||||||
* Elixir: @niku
|
* Elixir: @niku
|
||||||
* Groovy: @victorgit
|
* Groovy: @victorgit
|
||||||
* Go: @wing328
|
* Go: @wing328
|
||||||
|
* Go (rewritten in 2.3.0): @antihax
|
||||||
* Java (Feign): @davidkiss
|
* Java (Feign): @davidkiss
|
||||||
* Java (Retrofit): @0legg
|
* Java (Retrofit): @0legg
|
||||||
* Java (Retrofi2): @emilianobonassi
|
* Java (Retrofi2): @emilianobonassi
|
||||||
|
@ -6,19 +6,19 @@ set -euo pipefail
|
|||||||
GEN_DIR=${GEN_DIR:-/opt/swagger-codegen}
|
GEN_DIR=${GEN_DIR:-/opt/swagger-codegen}
|
||||||
JAVA_OPTS=${JAVA_OPTS:-"-Xmx1024M -DloggerPath=conf/log4j.properties"}
|
JAVA_OPTS=${JAVA_OPTS:-"-Xmx1024M -DloggerPath=conf/log4j.properties"}
|
||||||
|
|
||||||
codegen="${GEN_DIR}/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
cli="${GEN_DIR}/modules/swagger-codegen-cli"
|
||||||
|
codegen="${cli}/target/swagger-codegen-cli.jar"
|
||||||
|
cmdsrc="${cli}/src/main/java/io/swagger/codegen/cmd"
|
||||||
|
|
||||||
case "$1" in
|
pattern="@Command(name = \"$1\""
|
||||||
generate|help|langs|meta|config-help)
|
if expr "x$1" : 'x[a-z][a-z-]*$' > /dev/null && fgrep -qe "$pattern" "$cmdsrc"/*.java; then
|
||||||
# If ${GEN_DIR} has been mapped elsewhere from default, and that location has not been built
|
# If ${GEN_DIR} has been mapped elsewhere from default, and that location has not been built
|
||||||
if [[ ! -f "${codegen}" ]]; then
|
if [[ ! -f "${codegen}" ]]; then
|
||||||
(cd ${GEN_DIR} && exec mvn -am -pl "modules/swagger-codegen-cli" package)
|
(cd "${GEN_DIR}" && exec mvn -am -pl "modules/swagger-codegen-cli" package)
|
||||||
fi
|
fi
|
||||||
command=$1
|
command=$1
|
||||||
shift
|
shift
|
||||||
exec java ${JAVA_OPTS} -jar ${codegen} ${command} "$@"
|
exec java ${JAVA_OPTS} -jar "${codegen}" "${command}" "$@"
|
||||||
;;
|
else
|
||||||
*) # Any other commands, e.g. docker run imagename ls -la or docker run -it imagename /bin/bash
|
exec "$@"
|
||||||
exec "$@"
|
fi
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
@ -1737,7 +1737,11 @@ public class DefaultCodegen {
|
|||||||
ArrayProperty ap = (ArrayProperty) p;
|
ArrayProperty ap = (ArrayProperty) p;
|
||||||
property.maxItems = ap.getMaxItems();
|
property.maxItems = ap.getMaxItems();
|
||||||
property.minItems = ap.getMinItems();
|
property.minItems = ap.getMinItems();
|
||||||
CodegenProperty cp = fromProperty(property.name, ap.getItems());
|
String itemName = (String) p.getVendorExtensions().get("x-item-name");
|
||||||
|
if (itemName == null) {
|
||||||
|
itemName = property.name;
|
||||||
|
}
|
||||||
|
CodegenProperty cp = fromProperty(itemName, ap.getItems());
|
||||||
updatePropertyForArray(property, cp);
|
updatePropertyForArray(property, cp);
|
||||||
} else if (p instanceof MapProperty) {
|
} else if (p instanceof MapProperty) {
|
||||||
MapProperty ap = (MapProperty) p;
|
MapProperty ap = (MapProperty) p;
|
||||||
|
@ -3,6 +3,7 @@ package io.swagger.codegen;
|
|||||||
import com.samskivert.mustache.Mustache;
|
import com.samskivert.mustache.Mustache;
|
||||||
import com.samskivert.mustache.Template;
|
import com.samskivert.mustache.Template;
|
||||||
import io.swagger.codegen.ignore.CodegenIgnoreProcessor;
|
import io.swagger.codegen.ignore.CodegenIgnoreProcessor;
|
||||||
|
import io.swagger.codegen.utils.ImplementationVersion;
|
||||||
import io.swagger.models.*;
|
import io.swagger.models.*;
|
||||||
import io.swagger.models.auth.OAuth2Definition;
|
import io.swagger.models.auth.OAuth2Definition;
|
||||||
import io.swagger.models.auth.SecuritySchemeDefinition;
|
import io.swagger.models.auth.SecuritySchemeDefinition;
|
||||||
@ -126,8 +127,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
}
|
}
|
||||||
config.processOpts();
|
config.processOpts();
|
||||||
config.preprocessSwagger(swagger);
|
config.preprocessSwagger(swagger);
|
||||||
// TODO need to obtain version from a file instead of hardcoding it
|
config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
|
||||||
config.additionalProperties().put("generatorVersion", "2.2.3-SNAPSHOT");
|
|
||||||
config.additionalProperties().put("generatedDate", DateTime.now().toString());
|
config.additionalProperties().put("generatedDate", DateTime.now().toString());
|
||||||
config.additionalProperties().put("generatorClass", config.getClass().getName());
|
config.additionalProperties().put("generatorClass", config.getClass().getName());
|
||||||
config.additionalProperties().put("inputSpec", config.getInputSpec());
|
config.additionalProperties().put("inputSpec", config.getInputSpec());
|
||||||
@ -581,6 +581,15 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
files.add(ignoreFile);
|
files.add(ignoreFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String swaggerVersionMetadata = config.outputFolder() + File.separator + ".swagger-codegen" + File.separator + "VERSION";
|
||||||
|
File swaggerVersionMetadataFile = new File(swaggerVersionMetadata);
|
||||||
|
try {
|
||||||
|
writeToFile(swaggerVersionMetadata, ImplementationVersion.read());
|
||||||
|
files.add(swaggerVersionMetadataFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("Could not generate supporting file '" + swaggerVersionMetadata + "'", e);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following code adds default LICENSE (Apache-2.0) for all generators
|
* The following code adds default LICENSE (Apache-2.0) for all generators
|
||||||
* To use license other than Apache2.0, update the following file:
|
* To use license other than Apache2.0, update the following file:
|
||||||
|
@ -97,6 +97,7 @@ public class CppRestClientCodegen extends DefaultCodegen implements CodegenConfi
|
|||||||
supportingFiles.add(new SupportingFile("multipart-source.mustache", "", "MultipartFormData.cpp"));
|
supportingFiles.add(new SupportingFile("multipart-source.mustache", "", "MultipartFormData.cpp"));
|
||||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
|
supportingFiles.add(new SupportingFile("cmake-lists.mustache", "", "CMakeLists.txt"));
|
||||||
|
|
||||||
languageSpecificPrimitives = new HashSet<String>(
|
languageSpecificPrimitives = new HashSet<String>(
|
||||||
Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t"));
|
Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t"));
|
||||||
|
@ -17,16 +17,12 @@ import java.util.Arrays;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements CodegenConfig {
|
public class CsharpDotNet2ClientCodegen extends AbstractCSharpCodegen {
|
||||||
public static final String CLIENT_PACKAGE = "clientPackage";
|
public static final String CLIENT_PACKAGE = "clientPackage";
|
||||||
protected String packageName = "IO.Swagger";
|
|
||||||
protected String packageVersion = "1.0.0";
|
|
||||||
protected String clientPackage = "IO.Swagger.Client";
|
protected String clientPackage = "IO.Swagger.Client";
|
||||||
protected String sourceFolder = "src" + File.separator + "main" + File.separator + "CsharpDotNet2";
|
|
||||||
protected String apiDocPath = "docs/";
|
protected String apiDocPath = "docs/";
|
||||||
protected String modelDocPath = "docs/";
|
protected String modelDocPath = "docs/";
|
||||||
|
|
||||||
|
|
||||||
public CsharpDotNet2ClientCodegen() {
|
public CsharpDotNet2ClientCodegen() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@ -34,128 +30,74 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege
|
|||||||
// at the moment
|
// at the moment
|
||||||
importMapping.clear();
|
importMapping.clear();
|
||||||
|
|
||||||
outputFolder = "generated-code" + File.separator + "CsharpDotNet2";
|
|
||||||
modelTemplateFiles.put("model.mustache", ".cs");
|
modelTemplateFiles.put("model.mustache", ".cs");
|
||||||
apiTemplateFiles.put("api.mustache", ".cs");
|
apiTemplateFiles.put("api.mustache", ".cs");
|
||||||
embeddedTemplateDir = templateDir = "CsharpDotNet2";
|
|
||||||
apiPackage = "IO.Swagger.Api";
|
setApiPackage("IO.Swagger.Api");
|
||||||
modelPackage = "IO.Swagger.Model";
|
setModelPackage("IO.Swagger.Model");
|
||||||
|
setSourceFolder("src" + File.separator + "main" + File.separator + this.getName());
|
||||||
|
|
||||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||||
|
|
||||||
setReservedWordsLowerCase(
|
|
||||||
Arrays.asList(
|
|
||||||
// local variable names in API methods (endpoints)
|
|
||||||
"path", "queryParams", "headerParams", "formParams", "fileParams", "postBody",
|
|
||||||
"authSettings", "response", "StatusCode",
|
|
||||||
// C# reserved word
|
|
||||||
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while")
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
languageSpecificPrimitives = new HashSet<String>(
|
|
||||||
Arrays.asList(
|
|
||||||
"String",
|
|
||||||
"string",
|
|
||||||
"bool?",
|
|
||||||
"double?",
|
|
||||||
"int?",
|
|
||||||
"long?",
|
|
||||||
"float?",
|
|
||||||
"byte[]",
|
|
||||||
"List",
|
|
||||||
"Dictionary",
|
|
||||||
"DateTime?",
|
|
||||||
"String",
|
|
||||||
"Boolean",
|
|
||||||
"Double",
|
|
||||||
"Integer",
|
|
||||||
"Long",
|
|
||||||
"Float",
|
|
||||||
"Guid?",
|
|
||||||
"System.IO.Stream", // not really a primitive, we include it to avoid model import
|
|
||||||
"Object")
|
|
||||||
);
|
|
||||||
instantiationTypes.put("array", "List");
|
|
||||||
instantiationTypes.put("map", "Dictionary");
|
|
||||||
|
|
||||||
typeMapping = new HashMap<String, String>();
|
|
||||||
typeMapping.put("string", "string");
|
|
||||||
typeMapping.put("boolean", "bool?");
|
|
||||||
typeMapping.put("integer", "int?");
|
|
||||||
typeMapping.put("float", "float?");
|
|
||||||
typeMapping.put("long", "long?");
|
|
||||||
typeMapping.put("double", "double?");
|
|
||||||
typeMapping.put("number", "double?");
|
|
||||||
typeMapping.put("datetime", "DateTime?");
|
|
||||||
typeMapping.put("date", "DateTime?");
|
|
||||||
typeMapping.put("file", "System.IO.Stream");
|
|
||||||
typeMapping.put("array", "List");
|
|
||||||
typeMapping.put("list", "List");
|
|
||||||
typeMapping.put("map", "Dictionary");
|
|
||||||
typeMapping.put("object", "Object");
|
|
||||||
typeMapping.put("uuid", "Guid?");
|
|
||||||
|
|
||||||
cliOptions.clear();
|
cliOptions.clear();
|
||||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "C# package name (convention: Camel.Case).")
|
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME,
|
||||||
.defaultValue("IO.Swagger"));
|
"C# package name (convention: Camel.Case).")
|
||||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "C# package version.").defaultValue("1.0.0"));
|
.defaultValue(packageName));
|
||||||
cliOptions.add(new CliOption(CLIENT_PACKAGE, "C# client package name (convention: Camel.Case).")
|
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION,
|
||||||
.defaultValue("IO.Swagger.Client"));
|
"C# package version.")
|
||||||
|
.defaultValue(packageVersion));
|
||||||
|
cliOptions.add(new CliOption(CLIENT_PACKAGE,
|
||||||
|
"C# client package name (convention: Camel.Case).")
|
||||||
|
.defaultValue(clientPackage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
|
|
||||||
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
|
||||||
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
|
||||||
apiPackage = packageName + ".Api";
|
|
||||||
modelPackage = packageName + ".Model";
|
|
||||||
clientPackage = packageName + ".Client";
|
|
||||||
} else {
|
|
||||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CLIENT_PACKAGE)) {
|
if (additionalProperties.containsKey(CLIENT_PACKAGE)) {
|
||||||
this.setClientPackage((String) additionalProperties.get(CLIENT_PACKAGE));
|
this.setClientPackage((String) additionalProperties.get(CLIENT_PACKAGE));
|
||||||
} else {
|
} else {
|
||||||
additionalProperties.put(CLIENT_PACKAGE, clientPackage);
|
additionalProperties.put(CLIENT_PACKAGE, getClientPackage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String clientPackage = getClientPackage();
|
||||||
|
final String clientPackagePath = clientPackage.replace(".", java.io.File.separator);
|
||||||
|
|
||||||
additionalProperties.put("apiDocPath", apiDocPath);
|
additionalProperties.put("apiDocPath", apiDocPath);
|
||||||
additionalProperties.put("modelDocPath", modelDocPath);
|
additionalProperties.put("modelDocPath", modelDocPath);
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("Configuration.mustache",
|
supportingFiles.add(new SupportingFile("Configuration.mustache",
|
||||||
sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "Configuration.cs"));
|
sourceFolder + File.separator + clientPackagePath, "Configuration.cs"));
|
||||||
supportingFiles.add(new SupportingFile("ApiClient.mustache",
|
supportingFiles.add(new SupportingFile("ApiClient.mustache",
|
||||||
sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "ApiClient.cs"));
|
sourceFolder + File.separator + clientPackagePath, "ApiClient.cs"));
|
||||||
supportingFiles.add(new SupportingFile("ApiException.mustache",
|
supportingFiles.add(new SupportingFile("ApiException.mustache",
|
||||||
sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "ApiException.cs"));
|
sourceFolder + File.separator + clientPackagePath, "ApiException.cs"));
|
||||||
supportingFiles.add(new SupportingFile("packages.config.mustache", "vendor", "packages.config"));
|
supportingFiles.add(new SupportingFile("packages.config.mustache", "vendor", "packages.config"));
|
||||||
supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "compile-mono.sh"));
|
supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "compile-mono.sh"));
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiPackage() {
|
||||||
|
return packageName + ".Api";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelPackage() {
|
||||||
|
return packageName + ".Model";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClientPackage(){
|
||||||
|
return packageName + ".Client";
|
||||||
|
}
|
||||||
|
|
||||||
public void setClientPackage(String clientPackage) {
|
public void setClientPackage(String clientPackage) {
|
||||||
this.clientPackage = clientPackage;
|
this.clientPackage = clientPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPackageName(String packageName) {
|
|
||||||
this.packageName = packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPackageVersion(String packageVersion) {
|
|
||||||
this.packageVersion = packageVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodegenType getTag() {
|
public CodegenType getTag() {
|
||||||
return CodegenType.CLIENT;
|
return CodegenType.CLIENT;
|
||||||
@ -171,14 +113,6 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege
|
|||||||
return "Generates a C# .Net 2.0 client library.";
|
return "Generates a C# .Net 2.0 client library.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String escapeReservedWord(String name) {
|
|
||||||
if(this.reservedWordsMappings().containsKey(name)) {
|
|
||||||
return this.reservedWordsMappings().get(name);
|
|
||||||
}
|
|
||||||
return "_" + name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiFileFolder() {
|
public String apiFileFolder() {
|
||||||
return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar);
|
return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar);
|
||||||
@ -189,143 +123,6 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege
|
|||||||
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
|
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toVarName(String name) {
|
|
||||||
// replace - with _ e.g. created-at => created_at
|
|
||||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
|
||||||
|
|
||||||
// if it's all uppper case, do nothing
|
|
||||||
if (name.matches("^[A-Z_]*$")) {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// camelize the variable name
|
|
||||||
// pet_id => PetId
|
|
||||||
name = camelize(name);
|
|
||||||
|
|
||||||
// for reserved word or word starting with number, append _
|
|
||||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
|
||||||
name = escapeReservedWord(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toParamName(String name) {
|
|
||||||
// replace - with _ e.g. created-at => created_at
|
|
||||||
name = name.replaceAll("-", "_");
|
|
||||||
|
|
||||||
// if it's all uppper case, do nothing
|
|
||||||
if (name.matches("^[A-Z_]*$")) {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// camelize(lower) the variable name
|
|
||||||
// pet_id => petId
|
|
||||||
name = camelize(name, true);
|
|
||||||
|
|
||||||
// for reserved word or word starting with number, append _
|
|
||||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
|
||||||
name = escapeReservedWord(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toModelName(String name) {
|
|
||||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
|
||||||
name = modelNamePrefix + "_" + name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
|
||||||
name = name + "_" + modelNameSuffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
name = sanitizeName(name);
|
|
||||||
|
|
||||||
// model name cannot use reserved keyword, e.g. return
|
|
||||||
if (isReservedWord(name)) {
|
|
||||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
|
||||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
|
||||||
}
|
|
||||||
|
|
||||||
// model name starts with number
|
|
||||||
if (name.matches("^\\d.*")) {
|
|
||||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
|
||||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
|
||||||
}
|
|
||||||
|
|
||||||
// camelize the model name
|
|
||||||
// phone_number => PhoneNumber
|
|
||||||
return camelize(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toModelFilename(String name) {
|
|
||||||
// should be the same as the model name
|
|
||||||
return toModelName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTypeDeclaration(Property p) {
|
|
||||||
if (p instanceof ArrayProperty) {
|
|
||||||
ArrayProperty ap = (ArrayProperty) p;
|
|
||||||
Property inner = ap.getItems();
|
|
||||||
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
|
|
||||||
} else if (p instanceof MapProperty) {
|
|
||||||
MapProperty mp = (MapProperty) p;
|
|
||||||
Property inner = mp.getAdditionalProperties();
|
|
||||||
|
|
||||||
return getSwaggerType(p) + "<String, " + getTypeDeclaration(inner) + ">";
|
|
||||||
}
|
|
||||||
return super.getTypeDeclaration(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSwaggerType(Property p) {
|
|
||||||
String swaggerType = super.getSwaggerType(p);
|
|
||||||
String type = null;
|
|
||||||
if (typeMapping.containsKey(swaggerType.toLowerCase())) {
|
|
||||||
type = typeMapping.get(swaggerType.toLowerCase());
|
|
||||||
if (languageSpecificPrimitives.contains(type)) {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
type = swaggerType;
|
|
||||||
}
|
|
||||||
return toModelName(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toOperationId(String operationId) {
|
|
||||||
// throw exception if method name is empty (should not occur as an auto-generated method name will be used)
|
|
||||||
if (StringUtils.isEmpty(operationId)) {
|
|
||||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
|
||||||
}
|
|
||||||
|
|
||||||
// method name cannot use reserved keyword, e.g. return
|
|
||||||
if (isReservedWord(operationId)) {
|
|
||||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
|
||||||
operationId = "call_" + operationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return camelize(sanitizeName(operationId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String escapeQuotationMark(String input) {
|
|
||||||
// remove " to avoid code injection
|
|
||||||
return input.replace("\"", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String escapeUnsafeCharacters(String input) {
|
|
||||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apiDocFileFolder() {
|
public String apiDocFileFolder() {
|
||||||
return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar);
|
return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar);
|
||||||
|
@ -29,10 +29,13 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
|
|||||||
public static final String NPM_VERSION = "npmVersion";
|
public static final String NPM_VERSION = "npmVersion";
|
||||||
public static final String NPM_REPOSITORY = "npmRepository";
|
public static final String NPM_REPOSITORY = "npmRepository";
|
||||||
public static final String SNAPSHOT = "snapshot";
|
public static final String SNAPSHOT = "snapshot";
|
||||||
|
public static final String USE_OPAQUE_TOKEN = "useOpaqueToken";
|
||||||
|
public static final String INJECTION_TOKEN = "injectionToken";
|
||||||
|
|
||||||
protected String npmName = null;
|
protected String npmName = null;
|
||||||
protected String npmVersion = "1.0.0";
|
protected String npmVersion = "1.0.0";
|
||||||
protected String npmRepository = null;
|
protected String npmRepository = null;
|
||||||
|
protected String injectionToken = "InjectionToken<string>";
|
||||||
|
|
||||||
public TypeScriptAngular2ClientCodegen() {
|
public TypeScriptAngular2ClientCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -52,6 +55,7 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
|
|||||||
this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package"));
|
this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package"));
|
||||||
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
|
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
|
||||||
this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString()));
|
this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||||
|
this.cliOptions.add(new CliOption(USE_OPAQUE_TOKEN, "When setting this property to true, OpaqueToken is used instead of InjectionToken", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,6 +90,11 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
|
|||||||
if(additionalProperties.containsKey(NPM_NAME)) {
|
if(additionalProperties.containsKey(NPM_NAME)) {
|
||||||
addNpmPackageGeneration();
|
addNpmPackageGeneration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(additionalProperties.containsKey(USE_OPAQUE_TOKEN) && Boolean.valueOf(additionalProperties.get(USE_OPAQUE_TOKEN).toString())) {
|
||||||
|
this.setOpaqueToken();
|
||||||
|
}
|
||||||
|
additionalProperties.put(INJECTION_TOKEN, this.injectionToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addNpmPackageGeneration() {
|
private void addNpmPackageGeneration() {
|
||||||
@ -320,4 +329,8 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
|
|||||||
String name = filename.substring((modelPackage() + "/").length());
|
String name = filename.substring((modelPackage() + "/").length());
|
||||||
return camelize(name);
|
return camelize(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOpaqueToken() {
|
||||||
|
this.injectionToken = "OpaqueToken";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.swagger.codegen.utils;
|
||||||
|
|
||||||
|
public class ImplementationVersion {
|
||||||
|
public static String read() {
|
||||||
|
// Assumes this version is required at runtime. This could be modified to use a properties file like the CLI.
|
||||||
|
String compiledVersion = ImplementationVersion.class.getPackage().getImplementationVersion();
|
||||||
|
if(compiledVersion != null) {
|
||||||
|
return compiledVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "unset";
|
||||||
|
}
|
||||||
|
}
|
@ -16,9 +16,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
{{^useSpringCloudClient}}
|
|
||||||
import java.io.IOException;
|
|
||||||
{{/useSpringCloudClient}}
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
{{#async}}
|
{{#async}}
|
||||||
@ -43,31 +40,20 @@ public interface {{classname}} {
|
|||||||
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} })
|
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} })
|
||||||
@ApiResponses(value = { {{#responses}}
|
@ApiResponses(value = { {{#responses}}
|
||||||
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class){{#hasMore}},{{/hasMore}}{{/responses}} })
|
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class){{#hasMore}},{{/hasMore}}{{/responses}} })
|
||||||
{{#implicitHeaders}}
|
{{#implicitHeaders}}@ApiImplicitParams({
|
||||||
@ApiImplicitParams({
|
|
||||||
{{#headerParams}}{{>implicitHeader}}{{/headerParams}}
|
{{#headerParams}}{{>implicitHeader}}{{/headerParams}}
|
||||||
})
|
}){{/implicitHeaders}}
|
||||||
{{/implicitHeaders}}
|
|
||||||
@RequestMapping(value = "{{{path}}}",{{#singleContentTypes}}
|
@RequestMapping(value = "{{{path}}}",{{#singleContentTypes}}
|
||||||
produces = "{{{vendorExtensions.x-accepts}}}",
|
produces = "{{{vendorExtensions.x-accepts}}}",
|
||||||
consumes = "{{{vendorExtensions.x-contentType}}}",{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}}
|
consumes = "{{{vendorExtensions.x-contentType}}}",{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}}
|
||||||
produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}}
|
produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}}
|
||||||
consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}}
|
consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}}
|
||||||
method = RequestMethod.{{httpMethod}})
|
method = RequestMethod.{{httpMethod}})
|
||||||
{{#useSpringCloudClient}}
|
|
||||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
||||||
// do some magic!
|
// do some magic!
|
||||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}};
|
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}};
|
||||||
}{{/jdk8}}
|
}{{/jdk8}}
|
||||||
|
|
||||||
{{/useSpringCloudClient}}
|
|
||||||
{{^useSpringCloudClient}}
|
|
||||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}} @RequestHeader("Accept") String accept){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}}{{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
|
||||||
// do some magic!
|
|
||||||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}};
|
|
||||||
}{{/jdk8}}
|
|
||||||
|
|
||||||
{{/useSpringCloudClient}}
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
}
|
}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
@ -21,12 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
{{#async}}
|
{{#async}}
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
{{/async}}
|
{{/async}}{{/jdk8-no-delegate}}
|
||||||
{{/jdk8-no-delegate}}
|
|
||||||
{{^useSpringCloudClient}}
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import java.io.IOException;
|
|
||||||
{{/useSpringCloudClient}}
|
|
||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@ -35,72 +30,27 @@ import javax.validation.Valid;
|
|||||||
@Controller
|
@Controller
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
public class {{classname}}Controller implements {{classname}} {
|
public class {{classname}}Controller implements {{classname}} {
|
||||||
private final ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
public {{classname}}Controller(ObjectMapper objectMapper) {
|
|
||||||
this.objectMapper = objectMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
{{#isDelegate}}
|
{{#isDelegate}}
|
||||||
private final {{classname}}Delegate delegate;
|
private final {{classname}}Delegate delegate;
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Autowired
|
@org.springframework.beans.factory.annotation.Autowired
|
||||||
public {{classname}}Controller({{classname}}Delegate delegate) {
|
public {{classname}}Controller({{classname}}Delegate delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}{{/isDelegate}}
|
||||||
|
|
||||||
{{/isDelegate}}
|
{{^jdk8-no-delegate}}{{#operation}}
|
||||||
{{^jdk8-no-delegate}}
|
public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},
|
||||||
{{#operation}}
|
{{/hasMore}}{{/allParams}}) {
|
||||||
public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},
|
// do some magic!{{^isDelegate}}{{^async}}
|
||||||
{{/allParams}}@RequestHeader("Accept") String accept){{#examples}}{{#-first}} throws IOException{{/-first}}{{/examples}} {
|
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);{{/async}}{{#async}}
|
||||||
// do some magic!
|
|
||||||
{{#useSpringCloudClient}}
|
|
||||||
{{^isDelegate}}
|
|
||||||
{{^async}}
|
|
||||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
|
|
||||||
{{/async}}
|
|
||||||
{{#async}}
|
|
||||||
return new Callable<ResponseEntity<{{>returnTypes}}>>() {
|
return new Callable<ResponseEntity<{{>returnTypes}}>>() {
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<{{>returnTypes}}> call() throws Exception {
|
public ResponseEntity<{{>returnTypes}}> call() throws Exception {
|
||||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
|
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
};
|
};{{/async}}{{/isDelegate}}{{#isDelegate}}
|
||||||
{{/async}}
|
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/isDelegate}}
|
||||||
{{/isDelegate}}
|
|
||||||
{{#isDelegate}}
|
|
||||||
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
|
||||||
{{/isDelegate}}
|
|
||||||
{{/useSpringCloudClient}}
|
|
||||||
{{^useSpringCloudClient}}
|
|
||||||
{{^isDelegate}}
|
|
||||||
{{^async}}
|
|
||||||
{{#examples}}
|
|
||||||
|
|
||||||
if (accept != null && accept.contains("{{{contentType}}}")) {
|
|
||||||
return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
{{/examples}}
|
|
||||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
|
|
||||||
{{/async}}
|
|
||||||
{{#async}}
|
|
||||||
return new Callable<ResponseEntity<{{>returnTypes}}>>() {
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<{{>returnTypes}}> call() throws Exception {
|
|
||||||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
{{/async}}
|
|
||||||
{{/isDelegate}}
|
|
||||||
{{#isDelegate}}
|
|
||||||
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
|
||||||
{{/isDelegate}}
|
|
||||||
{{/useSpringCloudClient}}
|
|
||||||
}
|
}
|
||||||
|
{{/operation}}{{/jdk8-no-delegate}}
|
||||||
{{/operation}}
|
|
||||||
{{/jdk8-no-delegate}}
|
|
||||||
}
|
}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{{#required}}
|
{{#required}}
|
||||||
@NotNull
|
@NotNull
|
||||||
{{/required}}
|
{{/required}}{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}}
|
||||||
|
@Valid{{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{#isNotContainer}}{{^isPrimitiveType}}
|
||||||
|
@Valid{{/isPrimitiveType}}{{/isNotContainer}}
|
||||||
{{>beanValidationCore}}
|
{{>beanValidationCore}}
|
||||||
@Valid
|
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
#
|
||||||
|
# {{{appName}}}
|
||||||
|
# {{{appDescription}}}
|
||||||
|
#
|
||||||
|
# OpenAPI spec version: 1.0.0
|
||||||
|
#
|
||||||
|
# https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
#
|
||||||
|
# NOTE: Auto generated by the swagger code generator program.
|
||||||
|
|
||||||
|
cmake_minimum_required (VERSION 2.8)
|
||||||
|
|
||||||
|
#PROJECT's NAME
|
||||||
|
project(CppRestSwaggerClient)
|
||||||
|
|
||||||
|
|
||||||
|
# THE LOCATION OF OUTPUT BINARIES
|
||||||
|
set(CMAKE_LIBRARY_DIR ${PROJECT_SOURCE_DIR}/lib)
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_DIR})
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# BUILD TYPE
|
||||||
|
message("A ${CMAKE_BUILD_TYPE} build configuration is detected")
|
||||||
|
|
||||||
|
# Update require components as necessary
|
||||||
|
#find_package(Boost 1.45.0 REQUIRED COMPONENTS ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
|
||||||
|
|
||||||
|
# build and set path to cpp rest sdk
|
||||||
|
#set(CPPREST_ROOT ${PROJECT_SOURCE_DIR}/../../../developmentTools/3rdParty/cpprest)
|
||||||
|
set(CPPREST_INCLUDE_DIR ${CPPREST_ROOT}/include)
|
||||||
|
set(CPPREST_LIBRARY_DIR ${CPPREST_ROOT}/lib)
|
||||||
|
|
||||||
|
if( NOT DEFINED CPPREST_ROOT )
|
||||||
|
message( FATAL_ERROR "Failed to find cpprest SDK (or missing components). Double check that \"CPPREST_ROOT\" is properly set")
|
||||||
|
endif( NOT DEFINED CPPREST_ROOT )
|
||||||
|
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR} api model ${CPPREST_INCLUDE_DIR})
|
||||||
|
|
||||||
|
#SUPPORTING FILES
|
||||||
|
set(SUPPORTING_FILES "ApiClient" "ApiConfiguration" "ApiException" "HttpContent" "IHttpBody" "JsonBody" "ModelBase" "MultipartFormData")
|
||||||
|
#SOURCE FILES
|
||||||
|
file(GLOB SOURCE_FILES "api/*" "model/*")
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME} ${SUPPORTING_FILES} ${SOURCE_FILES})
|
@ -122,6 +122,10 @@ namespace {{packageName}}.Client
|
|||||||
String contentType)
|
String contentType)
|
||||||
{
|
{
|
||||||
var request = new RestRequest(path, method);
|
var request = new RestRequest(path, method);
|
||||||
|
{{#netStandard}}
|
||||||
|
// disable ResetSharp.Portable built-in serialization
|
||||||
|
request.Serializer = null;
|
||||||
|
{{/netStandard}}
|
||||||
|
|
||||||
// add path parameter, if any
|
// add path parameter, if any
|
||||||
foreach(var param in pathParams)
|
foreach(var param in pathParams)
|
||||||
@ -161,11 +165,21 @@ namespace {{packageName}}.Client
|
|||||||
{
|
{
|
||||||
if (postBody.GetType() == typeof(String))
|
if (postBody.GetType() == typeof(String))
|
||||||
{
|
{
|
||||||
|
{{#netStandard}}
|
||||||
|
request.AddParameter(new Parameter { Value = postBody, Type = ParameterType.RequestBody, ContentType = "application/json" });
|
||||||
|
{{/netStandard}}
|
||||||
|
{{^netStandard}}
|
||||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
||||||
|
{{/netStandard}}
|
||||||
}
|
}
|
||||||
else if (postBody.GetType() == typeof(byte[]))
|
else if (postBody.GetType() == typeof(byte[]))
|
||||||
{
|
{
|
||||||
|
{{#netStandard}}
|
||||||
|
request.AddParameter(new Parameter { Value = postBody, Type = ParameterType.RequestBody, ContentType = contentType });
|
||||||
|
{{/netStandard}}
|
||||||
|
{{^netStandard}}
|
||||||
request.AddParameter(contentType, postBody, ParameterType.RequestBody);
|
request.AddParameter(contentType, postBody, ParameterType.RequestBody);
|
||||||
|
{{/netStandard}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,10 @@
|
|||||||
{{/netStandard}}
|
{{/netStandard}}
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs"/>
|
<Compile Include="Api\**\*.cs"/>
|
||||||
|
<Compile Include="Client\**\*.cs"/>
|
||||||
|
<Compile Include="Model\**\*.cs"/>
|
||||||
|
<Compile Include="Properties\**\*.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
{{^netStandard}}
|
{{^netStandard}}
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{deps, [
|
{deps, [
|
||||||
{jsx, {git, "https://github.com/talentdeficit/jsx.git", {branch, "v2.8.0"}}},
|
{jsx, {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.2"}}},
|
||||||
{jesse, {git, "https://github.com/for-GET/jesse.git", {tag, "1.4.0"}}}
|
{jesse, {git, "https://github.com/for-GET/jesse.git", {tag, "1.4.0"}}}
|
||||||
]}.
|
]}.
|
||||||
|
@ -0,0 +1,361 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ApiClient
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* @category Class
|
||||||
|
* @package {{invokerPackage}}
|
||||||
|
* @author Swagger Codegen team
|
||||||
|
* @link https://github.com/swagger-api/swagger-codegen
|
||||||
|
*/
|
||||||
|
|
||||||
|
{{>partial_header}}
|
||||||
|
/**
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace {{invokerPackage}};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiClient Class Doc Comment
|
||||||
|
*
|
||||||
|
* @category Class
|
||||||
|
* @package {{invokerPackage}}
|
||||||
|
* @author Swagger Codegen team
|
||||||
|
* @link https://github.com/swagger-api/swagger-codegen
|
||||||
|
*/
|
||||||
|
class ApiClient
|
||||||
|
{
|
||||||
|
public static $PATCH = "PATCH";
|
||||||
|
public static $POST = "POST";
|
||||||
|
public static $GET = "GET";
|
||||||
|
public static $HEAD = "HEAD";
|
||||||
|
public static $OPTIONS = "OPTIONS";
|
||||||
|
public static $PUT = "PUT";
|
||||||
|
public static $DELETE = "DELETE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration
|
||||||
|
*
|
||||||
|
* @var Configuration
|
||||||
|
*/
|
||||||
|
protected $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object Serializer
|
||||||
|
*
|
||||||
|
* @var ObjectSerializer
|
||||||
|
*/
|
||||||
|
protected $serializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor of the class
|
||||||
|
*
|
||||||
|
* @param Configuration $config config for this ApiClient
|
||||||
|
*/
|
||||||
|
public function __construct(\{{invokerPackage}}\Configuration $config = null)
|
||||||
|
{
|
||||||
|
if ($config === null) {
|
||||||
|
$config = Configuration::getDefaultConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->config = $config;
|
||||||
|
$this->serializer = new ObjectSerializer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the config
|
||||||
|
*
|
||||||
|
* @return Configuration
|
||||||
|
*/
|
||||||
|
public function getConfig()
|
||||||
|
{
|
||||||
|
return $this->config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the serializer
|
||||||
|
*
|
||||||
|
* @return ObjectSerializer
|
||||||
|
*/
|
||||||
|
public function getSerializer()
|
||||||
|
{
|
||||||
|
return $this->serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get API key (with prefix if set)
|
||||||
|
*
|
||||||
|
* @param string $apiKeyIdentifier name of apikey
|
||||||
|
*
|
||||||
|
* @return string API key with the prefix
|
||||||
|
*/
|
||||||
|
public function getApiKeyWithPrefix($apiKeyIdentifier)
|
||||||
|
{
|
||||||
|
$prefix = $this->config->getApiKeyPrefix($apiKeyIdentifier);
|
||||||
|
$apiKey = $this->config->getApiKey($apiKeyIdentifier);
|
||||||
|
|
||||||
|
if (!isset($apiKey)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($prefix)) {
|
||||||
|
$keyWithPrefix = $prefix." ".$apiKey;
|
||||||
|
} else {
|
||||||
|
$keyWithPrefix = $apiKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $keyWithPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make the HTTP call (Sync)
|
||||||
|
*
|
||||||
|
* @param string $resourcePath path to method endpoint
|
||||||
|
* @param string $method method to call
|
||||||
|
* @param array $queryParams parameters to be place in query URL
|
||||||
|
* @param array $postData parameters to be placed in POST body
|
||||||
|
* @param array $headerParams parameters to be place in request header
|
||||||
|
* @param string $responseType expected response type of the endpoint
|
||||||
|
* @param string $endpointPath path to method endpoint before expanding parameters
|
||||||
|
*
|
||||||
|
* @throws \{{invokerPackage}}\ApiException on a non 2xx response
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null, $endpointPath = null)
|
||||||
|
{
|
||||||
|
$headers = [];
|
||||||
|
|
||||||
|
// construct the http header
|
||||||
|
$headerParams = array_merge(
|
||||||
|
(array)$this->config->getDefaultHeaders(),
|
||||||
|
(array)$headerParams
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($headerParams as $key => $val) {
|
||||||
|
$headers[] = "$key: $val";
|
||||||
|
}
|
||||||
|
|
||||||
|
// form data
|
||||||
|
if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers, true)) {
|
||||||
|
$postData = http_build_query($postData);
|
||||||
|
} elseif ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers, true)) { // json model
|
||||||
|
$postData = json_encode(\{{invokerPackage}}\ObjectSerializer::sanitizeForSerialization($postData));
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $this->config->getHost() . $resourcePath;
|
||||||
|
|
||||||
|
$curl = curl_init();
|
||||||
|
// set timeout, if needed
|
||||||
|
if ($this->config->getCurlTimeout() !== 0) {
|
||||||
|
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout());
|
||||||
|
}
|
||||||
|
// set connect timeout, if needed
|
||||||
|
if ($this->config->getCurlConnectTimeout() != 0) {
|
||||||
|
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->config->getCurlConnectTimeout());
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the result on success, rather than just true
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
|
||||||
|
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
|
||||||
|
// disable SSL verification, if needed
|
||||||
|
if ($this->config->getSSLVerification() === false) {
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config->getCurlProxyHost()) {
|
||||||
|
curl_setopt($curl, CURLOPT_PROXY, $this->config->getCurlProxyHost());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config->getCurlProxyPort()) {
|
||||||
|
curl_setopt($curl, CURLOPT_PROXYPORT, $this->config->getCurlProxyPort());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config->getCurlProxyType()) {
|
||||||
|
curl_setopt($curl, CURLOPT_PROXYTYPE, $this->config->getCurlProxyType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config->getCurlProxyUser()) {
|
||||||
|
curl_setopt($curl, CURLOPT_PROXYUSERPWD, $this->config->getCurlProxyUser() . ':' .$this->config->getCurlProxyPassword());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($queryParams)) {
|
||||||
|
$url = ($url . '?' . http_build_query($queryParams));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config->getAllowEncoding()) {
|
||||||
|
curl_setopt($curl, CURLOPT_ENCODING, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($method === self::$POST) {
|
||||||
|
curl_setopt($curl, CURLOPT_POST, true);
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||||
|
} elseif ($method === self::$HEAD) {
|
||||||
|
curl_setopt($curl, CURLOPT_NOBODY, true);
|
||||||
|
} elseif ($method === self::$OPTIONS) {
|
||||||
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "OPTIONS");
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||||
|
} elseif ($method === self::$PATCH) {
|
||||||
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||||
|
} elseif ($method === self::$PUT) {
|
||||||
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||||
|
} elseif ($method === self::$DELETE) {
|
||||||
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||||
|
} elseif ($method !== self::$GET) {
|
||||||
|
throw new ApiException('Method ' . $method . ' is not recognized.');
|
||||||
|
}
|
||||||
|
curl_setopt($curl, CURLOPT_URL, $url);
|
||||||
|
|
||||||
|
// Set user agent
|
||||||
|
curl_setopt($curl, CURLOPT_USERAGENT, $this->config->getUserAgent());
|
||||||
|
|
||||||
|
// debugging for curl
|
||||||
|
if ($this->config->getDebug()) {
|
||||||
|
error_log("[DEBUG] HTTP Request body ~BEGIN~".PHP_EOL.print_r($postData, true).PHP_EOL."~END~".PHP_EOL, 3, $this->config->getDebugFile());
|
||||||
|
|
||||||
|
curl_setopt($curl, CURLOPT_VERBOSE, 1);
|
||||||
|
curl_setopt($curl, CURLOPT_STDERR, fopen($this->config->getDebugFile(), 'a'));
|
||||||
|
} else {
|
||||||
|
curl_setopt($curl, CURLOPT_VERBOSE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// obtain the HTTP response headers
|
||||||
|
curl_setopt($curl, CURLOPT_HEADER, 1);
|
||||||
|
|
||||||
|
// Make the request
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
|
||||||
|
$http_header = $this->httpParseHeaders(substr($response, 0, $http_header_size));
|
||||||
|
$http_body = substr($response, $http_header_size);
|
||||||
|
$response_info = curl_getinfo($curl);
|
||||||
|
|
||||||
|
// debug HTTP response body
|
||||||
|
if ($this->config->getDebug()) {
|
||||||
|
error_log("[DEBUG] HTTP Response body ~BEGIN~".PHP_EOL.print_r($http_body, true).PHP_EOL."~END~".PHP_EOL, 3, $this->config->getDebugFile());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle the response
|
||||||
|
if ($response_info['http_code'] === 0) {
|
||||||
|
$curl_error_message = curl_error($curl);
|
||||||
|
|
||||||
|
// curl_exec can sometimes fail but still return a blank message from curl_error().
|
||||||
|
if (!empty($curl_error_message)) {
|
||||||
|
$error_message = "API call to $url failed: $curl_error_message";
|
||||||
|
} else {
|
||||||
|
$error_message = "API call to $url failed, but for an unknown reason. " .
|
||||||
|
"This could happen if you are disconnected from the network.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$exception = new ApiException($error_message, 0, null, null);
|
||||||
|
$exception->setResponseObject($response_info);
|
||||||
|
throw $exception;
|
||||||
|
} elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) {
|
||||||
|
// return raw body if response is a file
|
||||||
|
if ($responseType === '\SplFileObject' || $responseType === 'string') {
|
||||||
|
return [$http_body, $response_info['http_code'], $http_header];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = json_decode($http_body);
|
||||||
|
if (json_last_error() > 0) { // if response is a string
|
||||||
|
$data = $http_body;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data = json_decode($http_body);
|
||||||
|
if (json_last_error() > 0) { // if response is a string
|
||||||
|
$data = $http_body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException(
|
||||||
|
"[".$response_info['http_code']."] Error connecting to the API ($url)",
|
||||||
|
$response_info['http_code'],
|
||||||
|
$http_header,
|
||||||
|
$data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return [$data, $response_info['http_code'], $http_header];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the header 'Accept' based on an array of Accept provided
|
||||||
|
*
|
||||||
|
* @param string[] $accept Array of header
|
||||||
|
*
|
||||||
|
* @return string Accept (e.g. application/json)
|
||||||
|
*/
|
||||||
|
public function selectHeaderAccept($accept)
|
||||||
|
{
|
||||||
|
if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) {
|
||||||
|
return null;
|
||||||
|
} elseif (preg_grep("/application\/json/i", $accept)) {
|
||||||
|
return 'application/json';
|
||||||
|
} else {
|
||||||
|
return implode(',', $accept);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the content type based on an array of content-type provided
|
||||||
|
*
|
||||||
|
* @param string[] $content_type Array fo content-type
|
||||||
|
*
|
||||||
|
* @return string Content-Type (e.g. application/json)
|
||||||
|
*/
|
||||||
|
public function selectHeaderContentType($content_type)
|
||||||
|
{
|
||||||
|
if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) {
|
||||||
|
return 'application/json';
|
||||||
|
} elseif (preg_grep("/application\/json/i", $content_type)) {
|
||||||
|
return 'application/json';
|
||||||
|
} else {
|
||||||
|
return implode(',', $content_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array of HTTP response headers
|
||||||
|
*
|
||||||
|
* @param string $raw_headers A string of raw HTTP response headers
|
||||||
|
*
|
||||||
|
* @return string[] Array of HTTP response heaers
|
||||||
|
*/
|
||||||
|
protected function httpParseHeaders($raw_headers)
|
||||||
|
{
|
||||||
|
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
|
||||||
|
$headers = [];
|
||||||
|
$key = '';
|
||||||
|
|
||||||
|
foreach (explode("\n", $raw_headers) as $h) {
|
||||||
|
$h = explode(':', $h, 2);
|
||||||
|
|
||||||
|
if (isset($h[1])) {
|
||||||
|
if (!isset($headers[$h[0]])) {
|
||||||
|
$headers[$h[0]] = trim($h[1]);
|
||||||
|
} elseif (is_array($headers[$h[0]])) {
|
||||||
|
$headers[$h[0]] = array_merge($headers[$h[0]], [trim($h[1])]);
|
||||||
|
} else {
|
||||||
|
$headers[$h[0]] = array_merge([$headers[$h[0]]], [trim($h[1])]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$key = $h[0];
|
||||||
|
} else {
|
||||||
|
if (substr($h[0], 0, 1) === "\t") {
|
||||||
|
$headers[$key] .= "\r\n\t".trim($h[0]);
|
||||||
|
} elseif (!$key) {
|
||||||
|
$headers[0] = trim($h[0]);
|
||||||
|
}
|
||||||
|
trim($h[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $headers;
|
||||||
|
}
|
||||||
|
}
|
@ -88,7 +88,7 @@ use {{invokerPackage}}\ObjectSerializer;
|
|||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
* @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||||
*/
|
*/
|
||||||
public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||||
{
|
{
|
||||||
{{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
{{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
||||||
return $response;{{/returnType}}
|
return $response;{{/returnType}}
|
||||||
@ -110,7 +110,7 @@ use {{invokerPackage}}\ObjectSerializer;
|
|||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
|
* @return array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
|
||||||
*/
|
*/
|
||||||
public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||||
{
|
{
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{#required}}
|
{{#required}}
|
||||||
|
@ -90,7 +90,8 @@ void
|
|||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "{{httpMethod}}");
|
HttpRequestInput input(fullPath, "{{httpMethod}}");
|
||||||
|
|
||||||
{{#formParams}}if ({{paramName}} != nullptr) {
|
{{#formParams}}
|
||||||
|
if ({{paramName}} != nullptr) {
|
||||||
{{^isFile}}input.add_var("{{baseName}}", *{{paramName}});{{/isFile}}{{#isFile}}input.add_file("{{baseName}}", (*{{paramName}}).local_filename, (*{{paramName}}).request_filename, (*{{paramName}}).mime_type);{{/isFile}}
|
{{^isFile}}input.add_var("{{baseName}}", *{{paramName}});{{/isFile}}{{#isFile}}input.add_file("{{baseName}}", (*{{paramName}}).local_filename, (*{{paramName}}).request_filename, (*{{paramName}}).mime_type);{{/isFile}}
|
||||||
}
|
}
|
||||||
{{/formParams}}
|
{{/formParams}}
|
||||||
@ -125,6 +126,9 @@ void
|
|||||||
void
|
void
|
||||||
{{classname}}::{{nickname}}Callback(HttpRequestWorker * worker) {
|
{{classname}}::{{nickname}}Callback(HttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
|
QString error_str = worker->error_str;
|
||||||
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
|
|
||||||
if (worker->error_type == QNetworkReply::NoError) {
|
if (worker->error_type == QNetworkReply::NoError) {
|
||||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||||
}
|
}
|
||||||
@ -132,7 +136,8 @@ void
|
|||||||
msg = "Error: " + worker->error_str;
|
msg = "Error: " + worker->error_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#returnType}}{{#isListContainer}}
|
{{#returnType}}
|
||||||
|
{{#isListContainer}}
|
||||||
{{{returnType}}} output = {{{defaultResponse}}};
|
{{{returnType}}} output = {{{defaultResponse}}};
|
||||||
QString json(worker->response);
|
QString json(worker->response);
|
||||||
QByteArray array (json.toStdString().c_str());
|
QByteArray array (json.toStdString().c_str());
|
||||||
@ -148,12 +153,12 @@ void
|
|||||||
}
|
}
|
||||||
{{/isListContainer}}
|
{{/isListContainer}}
|
||||||
|
|
||||||
{{^isListContainer}}{{#returnTypeIsPrimitive}}
|
{{^isListContainer}}
|
||||||
|
{{#returnTypeIsPrimitive}}
|
||||||
{{{returnType}}} output; // TODO add primitive output support
|
{{{returnType}}} output; // TODO add primitive output support
|
||||||
{{/returnTypeIsPrimitive}}
|
{{/returnTypeIsPrimitive}}
|
||||||
{{#isMapContainer}}
|
{{#isMapContainer}}
|
||||||
{{{returnType}}} output = {{{defaultResponse}}};
|
{{{returnType}}} output = {{{defaultResponse}}};
|
||||||
|
|
||||||
QString json(worker->response);
|
QString json(worker->response);
|
||||||
QByteArray array (json.toStdString().c_str());
|
QByteArray array (json.toStdString().c_str());
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||||
@ -164,21 +169,21 @@ void
|
|||||||
setValue(&val, obj[key], "{{returnBaseType}}", "");
|
setValue(&val, obj[key], "{{returnBaseType}}", "");
|
||||||
output->insert(key, *val);
|
output->insert(key, *val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{{/isMapContainer}}
|
{{/isMapContainer}}
|
||||||
{{^isMapContainer}}
|
{{^isMapContainer}}
|
||||||
{{^returnTypeIsPrimitive}}QString json(worker->response);
|
{{^returnTypeIsPrimitive}}
|
||||||
|
QString json(worker->response);
|
||||||
{{{returnType}}} output = static_cast<{{{returnType}}}>(create(json, QString("{{{returnBaseType}}}")));
|
{{{returnType}}} output = static_cast<{{{returnType}}}>(create(json, QString("{{{returnBaseType}}}")));
|
||||||
{{/returnTypeIsPrimitive}}
|
{{/returnTypeIsPrimitive}}
|
||||||
{{/isMapContainer}}
|
{{/isMapContainer}}
|
||||||
{{/isListContainer}}{{/returnType}}
|
{{/isListContainer}}
|
||||||
|
{{/returnType}}
|
||||||
worker->deleteLater();
|
worker->deleteLater();
|
||||||
|
|
||||||
{{#returnType}}emit {{nickname}}Signal(output);{{/returnType}}
|
emit {{nickname}}Signal({{#returnType}}output{{/returnType}});
|
||||||
{{^returnType}}emit {{nickname}}Signal();{{/returnType}}
|
emit {{nickname}}SignalE({{#returnType}}output, {{/returnType}}error_type, error_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ private:
|
|||||||
signals:
|
signals:
|
||||||
{{#operations}}{{#operation}}void {{nickname}}Signal({{#returnType}}{{{returnType}}} summary{{/returnType}});
|
{{#operations}}{{#operation}}void {{nickname}}Signal({{#returnType}}{{{returnType}}} summary{{/returnType}});
|
||||||
{{/operation}}{{/operations}}
|
{{/operation}}{{/operations}}
|
||||||
|
{{#operations}}{{#operation}}void {{nickname}}SignalE({{#returnType}}{{{returnType}}} summary, {{/returnType}}QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
|
{{/operation}}{{/operations}}
|
||||||
};
|
};
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire{{#usePromiseKit}}
|
import Alamofire{{#usePromiseKit}}
|
||||||
import PromiseKit{{/usePromiseKit}}
|
import PromiseKit{{/usePromiseKit}}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire{{#usePromiseKit}}
|
import Alamofire{{#usePromiseKit}}
|
||||||
import PromiseKit{{/usePromiseKit}}{{#useRxSwift}}
|
import PromiseKit{{/usePromiseKit}}{{#useRxSwift}}
|
||||||
import RxSwift{{/useRxSwift}}
|
import RxSwift{{/useRxSwift}}
|
||||||
|
@ -5,5 +5,5 @@ export * from './{{ classFilename }}';
|
|||||||
import { {{ classname }} } from './{{ classFilename }}';
|
import { {{ classname }} } from './{{ classFilename }}';
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
{{/apis}}
|
{{/apis}}
|
||||||
export const APIS = [{{#apis}}{{#operations}}{{ classname }}, {{/operations}}{{/apis}}];
|
export const APIS = [{{#apis}}{{#operations}}{{ classname }}{{/operations}}{{^-last}}, {{/-last}}{{/apis}}];
|
||||||
{{/apiInfo}}
|
{{/apiInfo}}
|
||||||
|
@ -81,7 +81,7 @@ export class {{classname}} {
|
|||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
{{^isResponseFile}}
|
{{^isResponseFile}}
|
||||||
return response.json();
|
return response.json() || {};
|
||||||
{{/isResponseFile}}
|
{{/isResponseFile}}
|
||||||
{{#isResponseFile}}
|
{{#isResponseFile}}
|
||||||
return response.blob();
|
return response.blob();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { OpaqueToken } from '@angular/core';
|
import { {{{injectionToken}}} } from '@angular/core';
|
||||||
|
|
||||||
export const BASE_PATH = new OpaqueToken('basePath');
|
export const BASE_PATH = new {{{injectionToken}}}('basePath');
|
||||||
export const COLLECTION_FORMATS = {
|
export const COLLECTION_FORMATS = {
|
||||||
'csv': ',',
|
'csv': ',',
|
||||||
'tsv': ' ',
|
'tsv': ' ',
|
||||||
|
@ -274,6 +274,42 @@ public class JavaModelTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(description = "convert a model with an array property with item name")
|
||||||
|
public void arrayModelWithItemNameTest() {
|
||||||
|
final Model model = new ModelImpl()
|
||||||
|
.description("a sample model")
|
||||||
|
.property("children", new ArrayProperty()
|
||||||
|
.description("an array property")
|
||||||
|
.items(new RefProperty("#/definitions/Child"))
|
||||||
|
.vendorExtension("x-item-name", "child"));
|
||||||
|
final DefaultCodegen codegen = new JavaClientCodegen();
|
||||||
|
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||||
|
|
||||||
|
Assert.assertEquals(cm.name, "sample");
|
||||||
|
Assert.assertEquals(cm.classname, "Sample");
|
||||||
|
Assert.assertEquals(cm.description, "a sample model");
|
||||||
|
Assert.assertEquals(cm.vars.size(), 1);
|
||||||
|
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("List", "Child")).size(), 2);
|
||||||
|
|
||||||
|
final CodegenProperty property = cm.vars.get(0);
|
||||||
|
Assert.assertEquals(property.baseName, "children");
|
||||||
|
Assert.assertEquals(property.complexType, "Child");
|
||||||
|
Assert.assertEquals(property.getter, "getChildren");
|
||||||
|
Assert.assertEquals(property.setter, "setChildren");
|
||||||
|
Assert.assertEquals(property.datatype, "List<Child>");
|
||||||
|
Assert.assertEquals(property.name, "children");
|
||||||
|
Assert.assertEquals(property.defaultValue, "new ArrayList<Child>()");
|
||||||
|
Assert.assertEquals(property.baseType, "List");
|
||||||
|
Assert.assertEquals(property.containerType, "array");
|
||||||
|
Assert.assertFalse(property.required);
|
||||||
|
Assert.assertTrue(property.isContainer);
|
||||||
|
Assert.assertFalse(property.isNotContainer);
|
||||||
|
|
||||||
|
final CodegenProperty itemsProperty = property.items;
|
||||||
|
Assert.assertEquals(itemsProperty.baseName,"child");
|
||||||
|
Assert.assertEquals(itemsProperty.name,"child");
|
||||||
|
}
|
||||||
|
|
||||||
@Test(description = "convert an array model")
|
@Test(description = "convert an array model")
|
||||||
public void arrayModelTest() {
|
public void arrayModelTest() {
|
||||||
final Model model = new ArrayModel()
|
final Model model = new ArrayModel()
|
||||||
|
@ -35,6 +35,7 @@ public class TypeScriptAngular2ClientOptionsProvider implements OptionsProvider
|
|||||||
.put(TypeScriptAngular2ClientCodegen.SNAPSHOT, Boolean.FALSE.toString())
|
.put(TypeScriptAngular2ClientCodegen.SNAPSHOT, Boolean.FALSE.toString())
|
||||||
.put(TypeScriptAngular2ClientCodegen.NPM_REPOSITORY, NPM_REPOSITORY)
|
.put(TypeScriptAngular2ClientCodegen.NPM_REPOSITORY, NPM_REPOSITORY)
|
||||||
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
|
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
|
||||||
|
.put(TypeScriptAngular2ClientCodegen.USE_OPAQUE_TOKEN, Boolean.FALSE.toString())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
pom.xml
1
pom.xml
@ -839,6 +839,7 @@
|
|||||||
<module>samples/server/petstore/jaxrs-cxf-cdi</module>
|
<module>samples/server/petstore/jaxrs-cxf-cdi</module>
|
||||||
<module>samples/server/petstore/jaxrs-cxf-non-spring-app</module>
|
<module>samples/server/petstore/jaxrs-cxf-non-spring-app</module>
|
||||||
<!--<module>samples/server/petstore/java-msf4j</module> note: JDK8 only -->
|
<!--<module>samples/server/petstore/java-msf4j</module> note: JDK8 only -->
|
||||||
|
<!-- <module>samples/server/petstore/erlang-server</module> note: make sample compilation work -->
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
@ -216,7 +216,7 @@ namespace IO.Swagger.Api
|
|||||||
|
|
||||||
// to determine the Accept header
|
// to determine the Accept header
|
||||||
String[] localVarHttpHeaderAccepts = new String[] {
|
String[] localVarHttpHeaderAccepts = new String[] {
|
||||||
"application/json",
|
"application/json",
|
||||||
"*_/ ' =end - - "
|
"*_/ ' =end - - "
|
||||||
};
|
};
|
||||||
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
|
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
|
||||||
@ -239,7 +239,6 @@ namespace IO.Swagger.Api
|
|||||||
if (exception != null) throw exception;
|
if (exception != null) throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new ApiResponse<Object>(localVarStatusCode,
|
return new ApiResponse<Object>(localVarStatusCode,
|
||||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
||||||
null);
|
null);
|
||||||
@ -283,7 +282,7 @@ namespace IO.Swagger.Api
|
|||||||
|
|
||||||
// to determine the Accept header
|
// to determine the Accept header
|
||||||
String[] localVarHttpHeaderAccepts = new String[] {
|
String[] localVarHttpHeaderAccepts = new String[] {
|
||||||
"application/json",
|
"application/json",
|
||||||
"*_/ ' =end - - "
|
"*_/ ' =end - - "
|
||||||
};
|
};
|
||||||
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
|
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
|
||||||
@ -306,7 +305,6 @@ namespace IO.Swagger.Api
|
|||||||
if (exception != null) throw exception;
|
if (exception != null) throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new ApiResponse<Object>(localVarStatusCode,
|
return new ApiResponse<Object>(localVarStatusCode,
|
||||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
||||||
null);
|
null);
|
||||||
|
@ -62,7 +62,10 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r
|
|||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs"/>
|
<Compile Include="Api\**\*.cs"/>
|
||||||
|
<Compile Include="Client\**\*.cs"/>
|
||||||
|
<Compile Include="Model\**\*.cs"/>
|
||||||
|
<Compile Include="Properties\**\*.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
@ -119,7 +119,7 @@ namespace IO.Swagger.Model
|
|||||||
/// <param name="validationContext">Validation context</param>
|
/// <param name="validationContext">Validation context</param>
|
||||||
/// <returns>Validation Result</returns>
|
/// <returns>Validation Result</returns>
|
||||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
||||||
{
|
{
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,5 +68,6 @@ Or via OAuth2 module to automaticly refresh tokens and perform user authenticati
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ func NewConfiguration() *Configuration {
|
|||||||
BasePath: "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r",
|
BasePath: "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r",
|
||||||
DefaultHeader: make(map[string]string),
|
DefaultHeader: make(map[string]string),
|
||||||
UserAgent: "Swagger-Codegen/1.0.0/go",
|
UserAgent: "Swagger-Codegen/1.0.0/go",
|
||||||
APIClient: &APIClient{},
|
|
||||||
}
|
}
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,9 @@ SWGFakeApi::testCodeInject */ ' " =end \r\n \n \r(QString* test_c
|
|||||||
void
|
void
|
||||||
SWGFakeApi::testCodeInject */ ' " =end \r\n \n \rCallback(HttpRequestWorker * worker) {
|
SWGFakeApi::testCodeInject */ ' " =end \r\n \n \rCallback(HttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
|
QString error_str = worker->error_str;
|
||||||
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
|
|
||||||
if (worker->error_type == QNetworkReply::NoError) {
|
if (worker->error_type == QNetworkReply::NoError) {
|
||||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||||
}
|
}
|
||||||
@ -63,12 +66,11 @@ SWGFakeApi::testCodeInject */ ' " =end \r\n \n \rCallback(HttpReq
|
|||||||
msg = "Error: " + worker->error_str;
|
msg = "Error: " + worker->error_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
worker->deleteLater();
|
worker->deleteLater();
|
||||||
|
|
||||||
|
|
||||||
emit testCodeInject */ ' " =end \r\n \n \rSignal();
|
emit testCodeInject */ ' " =end \r\n \n \rSignal();
|
||||||
|
emit testCodeInject */ ' " =end \r\n \n \rSignalE(error_type, error_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@ private:
|
|||||||
signals:
|
signals:
|
||||||
void testCodeInject */ ' " =end \r\n \n \rSignal();
|
void testCodeInject */ ' " =end \r\n \n \rSignal();
|
||||||
|
|
||||||
|
void testCodeInject */ ' " =end \r\n \n \rSignalE(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -91,9 +91,9 @@ export class FakeApi {
|
|||||||
method: RequestMethod.Put,
|
method: RequestMethod.Put,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: formParams.toString(),
|
body: formParams.toString(),
|
||||||
search: queryParameters
|
search: queryParameters,
|
||||||
|
withCredentials:this.configuration.withCredentials
|
||||||
});
|
});
|
||||||
|
|
||||||
// https://github.com/swagger-api/swagger-codegen/issues/4037
|
// https://github.com/swagger-api/swagger-codegen/issues/4037
|
||||||
if (extraHttpRequestParams) {
|
if (extraHttpRequestParams) {
|
||||||
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
|
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
|
||||||
|
@ -81,7 +81,7 @@ export class FakeService {
|
|||||||
if (response.status === 204) {
|
if (response.status === 204) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
return response.json();
|
return response.json() || {};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -123,10 +123,10 @@ export class FakeService {
|
|||||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||||
method: RequestMethod.Put,
|
method: RequestMethod.Put,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: formParams,
|
body: formParams.toString(),
|
||||||
search: queryParameters
|
search: queryParameters,
|
||||||
|
withCredentials:this.configuration.withCredentials
|
||||||
});
|
});
|
||||||
|
|
||||||
// https://github.com/swagger-api/swagger-codegen/issues/4037
|
// https://github.com/swagger-api/swagger-codegen/issues/4037
|
||||||
if (extraHttpRequestParams) {
|
if (extraHttpRequestParams) {
|
||||||
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
|
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
|
||||||
|
@ -1,24 +1,26 @@
|
|||||||
export interface ConfigurationParameters {
|
export interface ConfigurationParameters {
|
||||||
apiKeys?: {[ key: string ]: string};
|
apiKeys?: {[ key: string ]: string};
|
||||||
username?: string;
|
username?: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
accessToken?: string;
|
accessToken?: string;
|
||||||
basePath?: string;
|
basePath?: string;
|
||||||
|
withCredentials?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Configuration {
|
export class Configuration {
|
||||||
apiKeys: {[ key: string ]: string};
|
apiKeys: {[ key: string ]: string};
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
accessToken: string | (() => string);
|
accessToken: string | (() => string);
|
||||||
basePath: string;
|
basePath: string;
|
||||||
|
withCredentials: boolean;
|
||||||
|
|
||||||
|
constructor(configurationParameters: ConfigurationParameters = {}) {
|
||||||
constructor(configurationParameters: ConfigurationParameters = {}) {
|
this.apiKeys = configurationParameters.apiKeys;
|
||||||
this.apiKeys = configurationParameters.apiKeys;
|
this.username = configurationParameters.username;
|
||||||
this.username = configurationParameters.username;
|
this.password = configurationParameters.password;
|
||||||
this.password = configurationParameters.password;
|
this.accessToken = configurationParameters.accessToken;
|
||||||
this.accessToken = configurationParameters.accessToken;
|
this.basePath = configurationParameters.basePath;
|
||||||
this.basePath = configurationParameters.basePath;
|
this.withCredentials = configurationParameters.withCredentials;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { OpaqueToken } from '@angular/core';
|
import { InjectionToken<string> } from '@angular/core';
|
||||||
|
|
||||||
export const BASE_PATH = new OpaqueToken('basePath');
|
export const BASE_PATH = new InjectionToken<string>('basePath');
|
||||||
export const COLLECTION_FORMATS = {
|
export const COLLECTION_FORMATS = {
|
||||||
'csv': ',',
|
'csv': ',',
|
||||||
'tsv': ' ',
|
'tsv': ' ',
|
||||||
|
49
samples/client/petstore/cpprest/CMakeLists.txt
Normal file
49
samples/client/petstore/cpprest/CMakeLists.txt
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#
|
||||||
|
# Swagger Petstore
|
||||||
|
# This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
#
|
||||||
|
# OpenAPI spec version: 1.0.0
|
||||||
|
#
|
||||||
|
# https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
#
|
||||||
|
# NOTE: Auto generated by the swagger code generator program.
|
||||||
|
|
||||||
|
cmake_minimum_required (VERSION 2.8)
|
||||||
|
|
||||||
|
#PROJECT's NAME
|
||||||
|
project(CppRestSwaggerClient)
|
||||||
|
|
||||||
|
|
||||||
|
# THE LOCATION OF OUTPUT BINARIES
|
||||||
|
set(CMAKE_LIBRARY_DIR ${PROJECT_SOURCE_DIR}/lib)
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_DIR})
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# BUILD TYPE
|
||||||
|
message("A ${CMAKE_BUILD_TYPE} build configuration is detected")
|
||||||
|
|
||||||
|
# Update require components as necessary
|
||||||
|
#find_package(Boost 1.45.0 REQUIRED COMPONENTS ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
|
||||||
|
|
||||||
|
# build and set path to cpp rest sdk
|
||||||
|
#set(CPPREST_ROOT ${PROJECT_SOURCE_DIR}/../../../developmentTools/3rdParty/cpprest)
|
||||||
|
set(CPPREST_INCLUDE_DIR ${CPPREST_ROOT}/include)
|
||||||
|
set(CPPREST_LIBRARY_DIR ${CPPREST_ROOT}/lib)
|
||||||
|
|
||||||
|
if( NOT DEFINED CPPREST_ROOT )
|
||||||
|
message( FATAL_ERROR "Failed to find cpprest SDK (or missing components). Double check that \"CPPREST_ROOT\" is properly set")
|
||||||
|
endif( NOT DEFINED CPPREST_ROOT )
|
||||||
|
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR} api model ${CPPREST_INCLUDE_DIR})
|
||||||
|
|
||||||
|
#SUPPORTING FILES
|
||||||
|
set(SUPPORTING_FILES "ApiClient" "ApiConfiguration" "ApiException" "HttpContent" "IHttpBody" "JsonBody" "ModelBase" "MultipartFormData")
|
||||||
|
#SOURCE FILES
|
||||||
|
file(GLOB SOURCE_FILES "api/*" "model/*")
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME} ${SUPPORTING_FILES} ${SOURCE_FILES})
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**Code** | **int?** | | [optional] [default to null]
|
**Code** | **int?** | | [optional]
|
||||||
**Type** | **string** | | [optional] [default to null]
|
**Type** | **string** | | [optional]
|
||||||
**Message** | **string** | | [optional] [default to null]
|
**Message** | **string** | | [optional]
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**Id** | **long?** | | [optional] [default to null]
|
**Id** | **long?** | | [optional]
|
||||||
**Name** | **string** | | [optional] [default to null]
|
**Name** | **string** | | [optional]
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**Id** | **long?** | | [optional] [default to null]
|
**Id** | **long?** | | [optional]
|
||||||
**PetId** | **long?** | | [optional] [default to null]
|
**PetId** | **long?** | | [optional]
|
||||||
**Quantity** | **int?** | | [optional] [default to null]
|
**Quantity** | **int?** | | [optional]
|
||||||
**ShipDate** | **DateTime?** | | [optional] [default to null]
|
**ShipDate** | **DateTime?** | | [optional]
|
||||||
**Status** | **string** | Order Status | [optional] [default to null]
|
**Status** | **string** | Order Status | [optional]
|
||||||
**Complete** | **bool?** | | [optional] [default to null]
|
**Complete** | **bool?** | | [optional] [default to false]
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**Id** | **long?** | | [optional] [default to null]
|
**Id** | **long?** | | [optional]
|
||||||
**Category** | [**Category**](Category.md) | | [optional] [default to null]
|
**Category** | [**Category**](Category.md) | | [optional]
|
||||||
**Name** | **string** | | [default to null]
|
**Name** | **string** | |
|
||||||
**PhotoUrls** | **List<string>** | | [default to null]
|
**PhotoUrls** | **List<string>** | |
|
||||||
**Tags** | [**List<Tag>**](Tag.md) | | [optional] [default to null]
|
**Tags** | [**List<Tag>**](Tag.md) | | [optional]
|
||||||
**Status** | **string** | pet status in the store | [optional] [default to null]
|
**Status** | **string** | pet status in the store | [optional]
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ No authorization required
|
|||||||
|
|
||||||
<a name="getinventory"></a>
|
<a name="getinventory"></a>
|
||||||
# **GetInventory**
|
# **GetInventory**
|
||||||
> Dictionary<String, int?> GetInventory ()
|
> Dictionary<string, int?> GetInventory ()
|
||||||
|
|
||||||
Returns pet inventories by status
|
Returns pet inventories by status
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ namespace Example
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Returns pet inventories by status
|
// Returns pet inventories by status
|
||||||
Dictionary<String, int?> result = apiInstance.GetInventory();
|
Dictionary<string, int?> result = apiInstance.GetInventory();
|
||||||
Debug.WriteLine(result);
|
Debug.WriteLine(result);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -121,7 +121,7 @@ This endpoint does not need any parameter.
|
|||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
**Dictionary<String, int?>**
|
**Dictionary<string, int?>**
|
||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**Id** | **long?** | | [optional] [default to null]
|
**Id** | **long?** | | [optional]
|
||||||
**Name** | **string** | | [optional] [default to null]
|
**Name** | **string** | | [optional]
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**Id** | **long?** | | [optional] [default to null]
|
**Id** | **long?** | | [optional]
|
||||||
**Username** | **string** | | [optional] [default to null]
|
**Username** | **string** | | [optional]
|
||||||
**FirstName** | **string** | | [optional] [default to null]
|
**FirstName** | **string** | | [optional]
|
||||||
**LastName** | **string** | | [optional] [default to null]
|
**LastName** | **string** | | [optional]
|
||||||
**Email** | **string** | | [optional] [default to null]
|
**Email** | **string** | | [optional]
|
||||||
**Password** | **string** | | [optional] [default to null]
|
**Password** | **string** | | [optional]
|
||||||
**Phone** | **string** | | [optional] [default to null]
|
**Phone** | **string** | | [optional]
|
||||||
**UserStatus** | **int?** | User Status | [optional] [default to null]
|
**UserStatus** | **int?** | User Status | [optional]
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ namespace IO.Swagger.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Dictionary<String, int?></returns>
|
/// <returns>Dictionary<string, int?></returns>
|
||||||
Dictionary<String, int?> GetInventory ();
|
Dictionary<string, int?> GetInventory ();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -129,8 +129,8 @@ namespace IO.Swagger.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Dictionary<String, int?></returns>
|
/// <returns>Dictionary<string, int?></returns>
|
||||||
public Dictionary<String, int?> GetInventory ()
|
public Dictionary<string, int?> GetInventory ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ namespace IO.Swagger.Api
|
|||||||
else if (((int)response.StatusCode) == 0)
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
|
|
||||||
return (Dictionary<String, int?>) ApiClient.Deserialize(response.Content, typeof(Dictionary<String, int?>), response.Headers);
|
return (Dictionary<string, int?>) ApiClient.Deserialize(response.Content, typeof(Dictionary<string, int?>), response.Headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -62,7 +62,10 @@ Contact: apiteam@swagger.io
|
|||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs"/>
|
<Compile Include="Api\**\*.cs"/>
|
||||||
|
<Compile Include="Client\**\*.cs"/>
|
||||||
|
<Compile Include="Model\**\*.cs"/>
|
||||||
|
<Compile Include="Properties\**\*.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
@ -115,6 +115,8 @@ namespace IO.Swagger.Client
|
|||||||
String contentType)
|
String contentType)
|
||||||
{
|
{
|
||||||
var request = new RestRequest(path, method);
|
var request = new RestRequest(path, method);
|
||||||
|
// disable ResetSharp.Portable built-in serialization
|
||||||
|
request.Serializer = null;
|
||||||
|
|
||||||
// add path parameter, if any
|
// add path parameter, if any
|
||||||
foreach(var param in pathParams)
|
foreach(var param in pathParams)
|
||||||
@ -142,11 +144,11 @@ namespace IO.Swagger.Client
|
|||||||
{
|
{
|
||||||
if (postBody.GetType() == typeof(String))
|
if (postBody.GetType() == typeof(String))
|
||||||
{
|
{
|
||||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
request.AddParameter(new Parameter { Value = postBody, Type = ParameterType.RequestBody, ContentType = "application/json" });
|
||||||
}
|
}
|
||||||
else if (postBody.GetType() == typeof(byte[]))
|
else if (postBody.GetType() == typeof(byte[]))
|
||||||
{
|
{
|
||||||
request.AddParameter(contentType, postBody, ParameterType.RequestBody);
|
request.AddParameter(new Parameter { Value = postBody, Type = ParameterType.RequestBody, ContentType = contentType });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,10 @@ Contact: apiteam@swagger.io
|
|||||||
<None Include="project.json" />
|
<None Include="project.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs"/>
|
<Compile Include="Api\**\*.cs"/>
|
||||||
|
<Compile Include="Client\**\*.cs"/>
|
||||||
|
<Compile Include="Model\**\*.cs"/>
|
||||||
|
<Compile Include="Properties\**\*.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
@ -64,7 +64,10 @@ Contact: apiteam@swagger.io
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs"/>
|
<Compile Include="Api\**\*.cs"/>
|
||||||
|
<Compile Include="Client\**\*.cs"/>
|
||||||
|
<Compile Include="Model\**\*.cs"/>
|
||||||
|
<Compile Include="Properties\**\*.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
<project>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>com.wordnik</groupId>
|
|
||||||
<artifactId>Gopetstore</artifactId>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<name>Gopetstore</name>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-dependencies</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
|
||||||
<version>1.2.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>go-get-testify</id>
|
|
||||||
<phase>pre-integration-test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>exec</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<executable>go</executable>
|
|
||||||
<arguments>
|
|
||||||
<argument>get</argument>
|
|
||||||
<argument>github.com/stretchr/testify/assert</argument>
|
|
||||||
</arguments>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>go-get-sling</id>
|
|
||||||
<phase>pre-integration-test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>exec</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<executable>go</executable>
|
|
||||||
<arguments>
|
|
||||||
<argument>get</argument>
|
|
||||||
<argument>github.com/dghubble/sling</argument>
|
|
||||||
</arguments>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>go-test</id>
|
|
||||||
<phase>integration-test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>exec</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<executable>go</executable>
|
|
||||||
<arguments>
|
|
||||||
<argument>test</argument>
|
|
||||||
<argument>-v</argument>
|
|
||||||
</arguments>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
@ -78,7 +78,7 @@
|
|||||||
<executable>go</executable>
|
<executable>go</executable>
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument>get</argument>
|
<argument>get</argument>
|
||||||
<argument>github.com/go-resty/resty</argument>
|
<argument>gopkg.in/go-resty/resty.v0</argument>
|
||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@ -23,6 +23,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AdditionalPropertiesClass
|
* AdditionalPropertiesClass
|
||||||
@ -78,6 +79,7 @@ public class AdditionalPropertiesClass {
|
|||||||
* Get mapOfMapProperty
|
* Get mapOfMapProperty
|
||||||
* @return mapOfMapProperty
|
* @return mapOfMapProperty
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Map<String, Map<String, String>> getMapOfMapProperty() {
|
public Map<String, Map<String, String>> getMapOfMapProperty() {
|
||||||
return mapOfMapProperty;
|
return mapOfMapProperty;
|
||||||
|
@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animal
|
* Animal
|
||||||
|
@ -18,6 +18,7 @@ import io.swagger.client.model.Animal;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AnimalFarm
|
* AnimalFarm
|
||||||
|
@ -23,6 +23,7 @@ import java.math.BigDecimal;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ArrayOfArrayOfNumberOnly
|
* ArrayOfArrayOfNumberOnly
|
||||||
@ -49,6 +50,7 @@ public class ArrayOfArrayOfNumberOnly {
|
|||||||
* Get arrayArrayNumber
|
* Get arrayArrayNumber
|
||||||
* @return arrayArrayNumber
|
* @return arrayArrayNumber
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public List<List<BigDecimal>> getArrayArrayNumber() {
|
public List<List<BigDecimal>> getArrayArrayNumber() {
|
||||||
return arrayArrayNumber;
|
return arrayArrayNumber;
|
||||||
|
@ -23,6 +23,7 @@ import java.math.BigDecimal;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ArrayOfNumberOnly
|
* ArrayOfNumberOnly
|
||||||
@ -49,6 +50,7 @@ public class ArrayOfNumberOnly {
|
|||||||
* Get arrayNumber
|
* Get arrayNumber
|
||||||
* @return arrayNumber
|
* @return arrayNumber
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public List<BigDecimal> getArrayNumber() {
|
public List<BigDecimal> getArrayNumber() {
|
||||||
return arrayNumber;
|
return arrayNumber;
|
||||||
|
@ -23,6 +23,7 @@ import io.swagger.client.model.ReadOnlyFirst;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ArrayTest
|
* ArrayTest
|
||||||
@ -81,6 +82,7 @@ public class ArrayTest {
|
|||||||
* Get arrayArrayOfInteger
|
* Get arrayArrayOfInteger
|
||||||
* @return arrayArrayOfInteger
|
* @return arrayArrayOfInteger
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public List<List<Long>> getArrayArrayOfInteger() {
|
public List<List<Long>> getArrayArrayOfInteger() {
|
||||||
return arrayArrayOfInteger;
|
return arrayArrayOfInteger;
|
||||||
@ -107,6 +109,7 @@ public class ArrayTest {
|
|||||||
* Get arrayArrayOfModel
|
* Get arrayArrayOfModel
|
||||||
* @return arrayArrayOfModel
|
* @return arrayArrayOfModel
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public List<List<ReadOnlyFirst>> getArrayArrayOfModel() {
|
public List<List<ReadOnlyFirst>> getArrayArrayOfModel() {
|
||||||
return arrayArrayOfModel;
|
return arrayArrayOfModel;
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Capitalization
|
* Capitalization
|
||||||
|
@ -21,6 +21,7 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import io.swagger.client.model.Animal;
|
import io.swagger.client.model.Animal;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cat
|
* Cat
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Category
|
* Category
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for testing model with \"_class\" property
|
* Model for testing model with \"_class\" property
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client
|
* Client
|
||||||
|
@ -21,6 +21,7 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import io.swagger.client.model.Animal;
|
import io.swagger.client.model.Animal;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dog
|
* Dog
|
||||||
|
@ -22,6 +22,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EnumArrays
|
* EnumArrays
|
||||||
|
@ -15,6 +15,7 @@ package io.swagger.client.model;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
@ -21,6 +21,7 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import io.swagger.client.model.OuterEnum;
|
import io.swagger.client.model.OuterEnum;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EnumTest
|
* EnumTest
|
||||||
@ -197,6 +198,7 @@ public class EnumTest {
|
|||||||
* Get outerEnum
|
* Get outerEnum
|
||||||
* @return outerEnum
|
* @return outerEnum
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public OuterEnum getOuterEnum() {
|
public OuterEnum getOuterEnum() {
|
||||||
return outerEnum;
|
return outerEnum;
|
||||||
|
@ -24,6 +24,7 @@ import java.util.UUID;
|
|||||||
import org.threeten.bp.LocalDate;
|
import org.threeten.bp.LocalDate;
|
||||||
import org.threeten.bp.OffsetDateTime;
|
import org.threeten.bp.OffsetDateTime;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FormatTest
|
* FormatTest
|
||||||
@ -139,6 +140,7 @@ public class FormatTest {
|
|||||||
* @return number
|
* @return number
|
||||||
**/
|
**/
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Valid
|
||||||
@DecimalMin("32.1") @DecimalMax("543.2") @ApiModelProperty(required = true, value = "")
|
@DecimalMin("32.1") @DecimalMax("543.2") @ApiModelProperty(required = true, value = "")
|
||||||
public BigDecimal getNumber() {
|
public BigDecimal getNumber() {
|
||||||
return number;
|
return number;
|
||||||
@ -253,6 +255,7 @@ public class FormatTest {
|
|||||||
* @return date
|
* @return date
|
||||||
**/
|
**/
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(required = true, value = "")
|
@ApiModelProperty(required = true, value = "")
|
||||||
public LocalDate getDate() {
|
public LocalDate getDate() {
|
||||||
return date;
|
return date;
|
||||||
@ -271,6 +274,7 @@ public class FormatTest {
|
|||||||
* Get dateTime
|
* Get dateTime
|
||||||
* @return dateTime
|
* @return dateTime
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public OffsetDateTime getDateTime() {
|
public OffsetDateTime getDateTime() {
|
||||||
return dateTime;
|
return dateTime;
|
||||||
@ -289,6 +293,7 @@ public class FormatTest {
|
|||||||
* Get uuid
|
* Get uuid
|
||||||
* @return uuid
|
* @return uuid
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HasOnlyReadOnly
|
* HasOnlyReadOnly
|
||||||
|
@ -23,6 +23,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MapTest
|
* MapTest
|
||||||
@ -83,6 +84,7 @@ public class MapTest {
|
|||||||
* Get mapMapOfString
|
* Get mapMapOfString
|
||||||
* @return mapMapOfString
|
* @return mapMapOfString
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Map<String, Map<String, String>> getMapMapOfString() {
|
public Map<String, Map<String, String>> getMapMapOfString() {
|
||||||
return mapMapOfString;
|
return mapMapOfString;
|
||||||
|
@ -26,6 +26,7 @@ import java.util.Map;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.threeten.bp.OffsetDateTime;
|
import org.threeten.bp.OffsetDateTime;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MixedPropertiesAndAdditionalPropertiesClass
|
* MixedPropertiesAndAdditionalPropertiesClass
|
||||||
@ -50,6 +51,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
* Get uuid
|
* Get uuid
|
||||||
* @return uuid
|
* @return uuid
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
@ -68,6 +70,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
* Get dateTime
|
* Get dateTime
|
||||||
* @return dateTime
|
* @return dateTime
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public OffsetDateTime getDateTime() {
|
public OffsetDateTime getDateTime() {
|
||||||
return dateTime;
|
return dateTime;
|
||||||
@ -94,6 +97,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
* Get map
|
* Get map
|
||||||
* @return map
|
* @return map
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Map<String, Animal> getMap() {
|
public Map<String, Animal> getMap() {
|
||||||
return map;
|
return map;
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for testing model name starting with number
|
* Model for testing model name starting with number
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ModelApiResponse
|
* ModelApiResponse
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for testing reserved words
|
* Model for testing reserved words
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for testing model name same as property name
|
* Model for testing model name same as property name
|
||||||
|
@ -21,6 +21,7 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NumberOnly
|
* NumberOnly
|
||||||
@ -39,6 +40,7 @@ public class NumberOnly {
|
|||||||
* Get justNumber
|
* Get justNumber
|
||||||
* @return justNumber
|
* @return justNumber
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public BigDecimal getJustNumber() {
|
public BigDecimal getJustNumber() {
|
||||||
return justNumber;
|
return justNumber;
|
||||||
|
@ -21,6 +21,7 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.threeten.bp.OffsetDateTime;
|
import org.threeten.bp.OffsetDateTime;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order
|
* Order
|
||||||
@ -141,6 +142,7 @@ public class Order {
|
|||||||
* Get shipDate
|
* Get shipDate
|
||||||
* @return shipDate
|
* @return shipDate
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public OffsetDateTime getShipDate() {
|
public OffsetDateTime getShipDate() {
|
||||||
return shipDate;
|
return shipDate;
|
||||||
|
@ -15,6 +15,7 @@ package io.swagger.client.model;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
@ -24,6 +24,7 @@ import io.swagger.client.model.Tag;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pet
|
* Pet
|
||||||
@ -108,6 +109,7 @@ public class Pet {
|
|||||||
* Get category
|
* Get category
|
||||||
* @return category
|
* @return category
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Category getCategory() {
|
public Category getCategory() {
|
||||||
return category;
|
return category;
|
||||||
@ -177,6 +179,7 @@ public class Pet {
|
|||||||
* Get tags
|
* Get tags
|
||||||
* @return tags
|
* @return tags
|
||||||
**/
|
**/
|
||||||
|
@Valid
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public List<Tag> getTags() {
|
public List<Tag> getTags() {
|
||||||
return tags;
|
return tags;
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ReadOnlyFirst
|
* ReadOnlyFirst
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SpecialModelName
|
* SpecialModelName
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag
|
* Tag
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User
|
* User
|
||||||
|
@ -521,7 +521,7 @@ class FakeApi
|
|||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testEnumParameters($enum_form_string_array = null, $enum_form_string = null, $enum_header_string_array = null, $enum_header_string = null, $enum_query_string_array = null, $enum_query_string = null, $enum_query_integer = null, $enum_query_double = null)
|
public function testEnumParameters($enum_form_string_array = null, $enum_form_string = '-efg', $enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null)
|
||||||
{
|
{
|
||||||
$this->testEnumParametersWithHttpInfo($enum_form_string_array, $enum_form_string, $enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double);
|
$this->testEnumParametersWithHttpInfo($enum_form_string_array, $enum_form_string, $enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double);
|
||||||
}
|
}
|
||||||
@ -543,7 +543,7 @@ class FakeApi
|
|||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @return array of null, HTTP status code, HTTP response headers (array of strings)
|
* @return array of null, HTTP status code, HTTP response headers (array of strings)
|
||||||
*/
|
*/
|
||||||
public function testEnumParametersWithHttpInfo($enum_form_string_array = null, $enum_form_string = null, $enum_header_string_array = null, $enum_header_string = null, $enum_query_string_array = null, $enum_query_string = null, $enum_query_integer = null, $enum_query_double = null)
|
public function testEnumParametersWithHttpInfo($enum_form_string_array = null, $enum_form_string = '-efg', $enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$resourcePath = '/fake';
|
$resourcePath = '/fake';
|
||||||
|
371
samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php
Normal file
371
samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php
Normal file
@ -0,0 +1,371 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ApiClient
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* @category Class
|
||||||
|
* @package Swagger\Client
|
||||||
|
* @author Swagger Codegen team
|
||||||
|
* @link https://github.com/swagger-api/swagger-codegen
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Swagger\Client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ApiClient Class Doc Comment
|
||||||
|
*
|
||||||
|
* @category Class
|
||||||
|
* @package Swagger\Client
|
||||||
|
* @author Swagger Codegen team
|
||||||
|
* @link https://github.com/swagger-api/swagger-codegen
|
||||||
|
*/
|
||||||
|
class ApiClient
|
||||||
|
{
|
||||||
|
public static $PATCH = "PATCH";
|
||||||
|
public static $POST = "POST";
|
||||||
|
public static $GET = "GET";
|
||||||
|
public static $HEAD = "HEAD";
|
||||||
|
public static $OPTIONS = "OPTIONS";
|
||||||
|
public static $PUT = "PUT";
|
||||||
|
public static $DELETE = "DELETE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration
|
||||||
|
*
|
||||||
|
* @var Configuration
|
||||||
|
*/
|
||||||
|
protected $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object Serializer
|
||||||
|
*
|
||||||
|
* @var ObjectSerializer
|
||||||
|
*/
|
||||||
|
protected $serializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor of the class
|
||||||
|
*
|
||||||
|
* @param Configuration $config config for this ApiClient
|
||||||
|
*/
|
||||||
|
public function __construct(\Swagger\Client\Configuration $config = null)
|
||||||
|
{
|
||||||
|
if ($config === null) {
|
||||||
|
$config = Configuration::getDefaultConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->config = $config;
|
||||||
|
$this->serializer = new ObjectSerializer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the config
|
||||||
|
*
|
||||||
|
* @return Configuration
|
||||||
|
*/
|
||||||
|
public function getConfig()
|
||||||
|
{
|
||||||
|
return $this->config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the serializer
|
||||||
|
*
|
||||||
|
* @return ObjectSerializer
|
||||||
|
*/
|
||||||
|
public function getSerializer()
|
||||||
|
{
|
||||||
|
return $this->serializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get API key (with prefix if set)
|
||||||
|
*
|
||||||
|
* @param string $apiKeyIdentifier name of apikey
|
||||||
|
*
|
||||||
|
* @return string API key with the prefix
|
||||||
|
*/
|
||||||
|
public function getApiKeyWithPrefix($apiKeyIdentifier)
|
||||||
|
{
|
||||||
|
$prefix = $this->config->getApiKeyPrefix($apiKeyIdentifier);
|
||||||
|
$apiKey = $this->config->getApiKey($apiKeyIdentifier);
|
||||||
|
|
||||||
|
if (!isset($apiKey)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($prefix)) {
|
||||||
|
$keyWithPrefix = $prefix." ".$apiKey;
|
||||||
|
} else {
|
||||||
|
$keyWithPrefix = $apiKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $keyWithPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make the HTTP call (Sync)
|
||||||
|
*
|
||||||
|
* @param string $resourcePath path to method endpoint
|
||||||
|
* @param string $method method to call
|
||||||
|
* @param array $queryParams parameters to be place in query URL
|
||||||
|
* @param array $postData parameters to be placed in POST body
|
||||||
|
* @param array $headerParams parameters to be place in request header
|
||||||
|
* @param string $responseType expected response type of the endpoint
|
||||||
|
* @param string $endpointPath path to method endpoint before expanding parameters
|
||||||
|
*
|
||||||
|
* @throws \Swagger\Client\ApiException on a non 2xx response
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null, $endpointPath = null)
|
||||||
|
{
|
||||||
|
$headers = [];
|
||||||
|
|
||||||
|
// construct the http header
|
||||||
|
$headerParams = array_merge(
|
||||||
|
(array)$this->config->getDefaultHeaders(),
|
||||||
|
(array)$headerParams
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($headerParams as $key => $val) {
|
||||||
|
$headers[] = "$key: $val";
|
||||||
|
}
|
||||||
|
|
||||||
|
// form data
|
||||||
|
if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers, true)) {
|
||||||
|
$postData = http_build_query($postData);
|
||||||
|
} elseif ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers, true)) { // json model
|
||||||
|
$postData = json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($postData));
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $this->config->getHost() . $resourcePath;
|
||||||
|
|
||||||
|
$curl = curl_init();
|
||||||
|
// set timeout, if needed
|
||||||
|
if ($this->config->getCurlTimeout() !== 0) {
|
||||||
|
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout());
|
||||||
|
}
|
||||||
|
// set connect timeout, if needed
|
||||||
|
if ($this->config->getCurlConnectTimeout() != 0) {
|
||||||
|
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->config->getCurlConnectTimeout());
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the result on success, rather than just true
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
|
||||||
|
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
|
||||||
|
// disable SSL verification, if needed
|
||||||
|
if ($this->config->getSSLVerification() === false) {
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config->getCurlProxyHost()) {
|
||||||
|
curl_setopt($curl, CURLOPT_PROXY, $this->config->getCurlProxyHost());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config->getCurlProxyPort()) {
|
||||||
|
curl_setopt($curl, CURLOPT_PROXYPORT, $this->config->getCurlProxyPort());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config->getCurlProxyType()) {
|
||||||
|
curl_setopt($curl, CURLOPT_PROXYTYPE, $this->config->getCurlProxyType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config->getCurlProxyUser()) {
|
||||||
|
curl_setopt($curl, CURLOPT_PROXYUSERPWD, $this->config->getCurlProxyUser() . ':' .$this->config->getCurlProxyPassword());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($queryParams)) {
|
||||||
|
$url = ($url . '?' . http_build_query($queryParams));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config->getAllowEncoding()) {
|
||||||
|
curl_setopt($curl, CURLOPT_ENCODING, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($method === self::$POST) {
|
||||||
|
curl_setopt($curl, CURLOPT_POST, true);
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||||
|
} elseif ($method === self::$HEAD) {
|
||||||
|
curl_setopt($curl, CURLOPT_NOBODY, true);
|
||||||
|
} elseif ($method === self::$OPTIONS) {
|
||||||
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "OPTIONS");
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||||
|
} elseif ($method === self::$PATCH) {
|
||||||
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||||
|
} elseif ($method === self::$PUT) {
|
||||||
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||||
|
} elseif ($method === self::$DELETE) {
|
||||||
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||||
|
} elseif ($method !== self::$GET) {
|
||||||
|
throw new ApiException('Method ' . $method . ' is not recognized.');
|
||||||
|
}
|
||||||
|
curl_setopt($curl, CURLOPT_URL, $url);
|
||||||
|
|
||||||
|
// Set user agent
|
||||||
|
curl_setopt($curl, CURLOPT_USERAGENT, $this->config->getUserAgent());
|
||||||
|
|
||||||
|
// debugging for curl
|
||||||
|
if ($this->config->getDebug()) {
|
||||||
|
error_log("[DEBUG] HTTP Request body ~BEGIN~".PHP_EOL.print_r($postData, true).PHP_EOL."~END~".PHP_EOL, 3, $this->config->getDebugFile());
|
||||||
|
|
||||||
|
curl_setopt($curl, CURLOPT_VERBOSE, 1);
|
||||||
|
curl_setopt($curl, CURLOPT_STDERR, fopen($this->config->getDebugFile(), 'a'));
|
||||||
|
} else {
|
||||||
|
curl_setopt($curl, CURLOPT_VERBOSE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// obtain the HTTP response headers
|
||||||
|
curl_setopt($curl, CURLOPT_HEADER, 1);
|
||||||
|
|
||||||
|
// Make the request
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
|
||||||
|
$http_header = $this->httpParseHeaders(substr($response, 0, $http_header_size));
|
||||||
|
$http_body = substr($response, $http_header_size);
|
||||||
|
$response_info = curl_getinfo($curl);
|
||||||
|
|
||||||
|
// debug HTTP response body
|
||||||
|
if ($this->config->getDebug()) {
|
||||||
|
error_log("[DEBUG] HTTP Response body ~BEGIN~".PHP_EOL.print_r($http_body, true).PHP_EOL."~END~".PHP_EOL, 3, $this->config->getDebugFile());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle the response
|
||||||
|
if ($response_info['http_code'] === 0) {
|
||||||
|
$curl_error_message = curl_error($curl);
|
||||||
|
|
||||||
|
// curl_exec can sometimes fail but still return a blank message from curl_error().
|
||||||
|
if (!empty($curl_error_message)) {
|
||||||
|
$error_message = "API call to $url failed: $curl_error_message";
|
||||||
|
} else {
|
||||||
|
$error_message = "API call to $url failed, but for an unknown reason. " .
|
||||||
|
"This could happen if you are disconnected from the network.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$exception = new ApiException($error_message, 0, null, null);
|
||||||
|
$exception->setResponseObject($response_info);
|
||||||
|
throw $exception;
|
||||||
|
} elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) {
|
||||||
|
// return raw body if response is a file
|
||||||
|
if ($responseType === '\SplFileObject' || $responseType === 'string') {
|
||||||
|
return [$http_body, $response_info['http_code'], $http_header];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = json_decode($http_body);
|
||||||
|
if (json_last_error() > 0) { // if response is a string
|
||||||
|
$data = $http_body;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data = json_decode($http_body);
|
||||||
|
if (json_last_error() > 0) { // if response is a string
|
||||||
|
$data = $http_body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException(
|
||||||
|
"[".$response_info['http_code']."] Error connecting to the API ($url)",
|
||||||
|
$response_info['http_code'],
|
||||||
|
$http_header,
|
||||||
|
$data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return [$data, $response_info['http_code'], $http_header];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the header 'Accept' based on an array of Accept provided
|
||||||
|
*
|
||||||
|
* @param string[] $accept Array of header
|
||||||
|
*
|
||||||
|
* @return string Accept (e.g. application/json)
|
||||||
|
*/
|
||||||
|
public function selectHeaderAccept($accept)
|
||||||
|
{
|
||||||
|
if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) {
|
||||||
|
return null;
|
||||||
|
} elseif (preg_grep("/application\/json/i", $accept)) {
|
||||||
|
return 'application/json';
|
||||||
|
} else {
|
||||||
|
return implode(',', $accept);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the content type based on an array of content-type provided
|
||||||
|
*
|
||||||
|
* @param string[] $content_type Array fo content-type
|
||||||
|
*
|
||||||
|
* @return string Content-Type (e.g. application/json)
|
||||||
|
*/
|
||||||
|
public function selectHeaderContentType($content_type)
|
||||||
|
{
|
||||||
|
if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) {
|
||||||
|
return 'application/json';
|
||||||
|
} elseif (preg_grep("/application\/json/i", $content_type)) {
|
||||||
|
return 'application/json';
|
||||||
|
} else {
|
||||||
|
return implode(',', $content_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array of HTTP response headers
|
||||||
|
*
|
||||||
|
* @param string $raw_headers A string of raw HTTP response headers
|
||||||
|
*
|
||||||
|
* @return string[] Array of HTTP response heaers
|
||||||
|
*/
|
||||||
|
protected function httpParseHeaders($raw_headers)
|
||||||
|
{
|
||||||
|
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
|
||||||
|
$headers = [];
|
||||||
|
$key = '';
|
||||||
|
|
||||||
|
foreach (explode("\n", $raw_headers) as $h) {
|
||||||
|
$h = explode(':', $h, 2);
|
||||||
|
|
||||||
|
if (isset($h[1])) {
|
||||||
|
if (!isset($headers[$h[0]])) {
|
||||||
|
$headers[$h[0]] = trim($h[1]);
|
||||||
|
} elseif (is_array($headers[$h[0]])) {
|
||||||
|
$headers[$h[0]] = array_merge($headers[$h[0]], [trim($h[1])]);
|
||||||
|
} else {
|
||||||
|
$headers[$h[0]] = array_merge([$headers[$h[0]]], [trim($h[1])]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$key = $h[0];
|
||||||
|
} else {
|
||||||
|
if (substr($h[0], 0, 1) === "\t") {
|
||||||
|
$headers[$key] .= "\r\n\t".trim($h[0]);
|
||||||
|
} elseif (!$key) {
|
||||||
|
$headers[0] = trim($h[0]);
|
||||||
|
}
|
||||||
|
trim($h[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $headers;
|
||||||
|
}
|
||||||
|
}
|
185
samples/client/petstore/powershell/PowerShellClient/.gitignore
vendored
Normal file
185
samples/client/petstore/powershell/PowerShellClient/.gitignore
vendored
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
# Ref: https://gist.github.com/kmorcinek/2710267
|
||||||
|
# Download this file using PowerShell v3 under Windows with the following comand
|
||||||
|
# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
|
||||||
|
[Dd]ebug/
|
||||||
|
[Rr]elease/
|
||||||
|
x64/
|
||||||
|
build/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/packages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/packages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/packages/repositories.config
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.log
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# OS generated files #
|
||||||
|
.DS_Store*
|
||||||
|
ehthumbs.db
|
||||||
|
Icon?
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
*.ncrunch*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.Publish.xml
|
||||||
|
|
||||||
|
# Windows Azure Build Output
|
||||||
|
csx
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Windows Store app package directory
|
||||||
|
AppPackages/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
sql/
|
||||||
|
*.Cache
|
||||||
|
ClientBin/
|
||||||
|
[Ss]tyle[Cc]op.*
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
modulesbin/
|
||||||
|
tempbin/
|
||||||
|
|
||||||
|
# EPiServer Site file (VPP)
|
||||||
|
AppData/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file to a newer
|
||||||
|
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
|
||||||
|
# vim
|
||||||
|
*.txt~
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# svn
|
||||||
|
.svn
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
**/App_Data/*.mdf
|
||||||
|
**/App_Data/*.ldf
|
||||||
|
**/App_Data/*.sdf
|
||||||
|
|
||||||
|
|
||||||
|
#LightSwitch generated files
|
||||||
|
GeneratedArtifacts/
|
||||||
|
_Pvt_Extensions/
|
||||||
|
ModelManifest.xml
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# Windows detritus
|
||||||
|
# =========================
|
||||||
|
|
||||||
|
# Windows image file caches
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
Desktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Mac desktop service store files
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# SASS Compiler cache
|
||||||
|
.sass-cache
|
||||||
|
|
||||||
|
# Visual Studio 2014 CTP
|
||||||
|
**/*.sln.ide
|
@ -0,0 +1,49 @@
|
|||||||
|
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
|
||||||
|
$ClientPath = "$ScriptDir\..\..\csharp\SwaggerClient"
|
||||||
|
$PublicPath = "$ScriptDir\src\IO.Swagger\Public"
|
||||||
|
$BinPath = "$ScriptDir\src\IO.Swagger\Bin"
|
||||||
|
|
||||||
|
Start-Process -FilePath "$ClientPath\build.bat" -WorkingDirectory $ClientPath -Wait -NoNewWindow
|
||||||
|
|
||||||
|
if (!(Test-Path "$ScriptDir\src\IO.Swagger\Bin" -PathType Container)) {
|
||||||
|
New-Item "$ScriptDir\src\IO.Swagger\Bin" -ItemType Directory > $null
|
||||||
|
}
|
||||||
|
|
||||||
|
Copy-Item "$ClientPath\bin\*.dll" $BinPath
|
||||||
|
|
||||||
|
$Manifest = @{
|
||||||
|
Path = "$ScriptDir\src\IO.Swagger\IO.Swagger.psd1"
|
||||||
|
|
||||||
|
Author = 'apiteam@swagger.io'
|
||||||
|
CompanyName = 'swagger.io'
|
||||||
|
Description = 'IO.Swagger - the PowerShell module for the Swagger Petstore'
|
||||||
|
|
||||||
|
RootModule = 'IO.Swagger.psm1'
|
||||||
|
Guid = 'a27b908d-2a20-467f-bc32-af6f3a654ac5' # Has to be static, otherwise each new build will be considered different module
|
||||||
|
|
||||||
|
PowerShellVersion = '3.0'
|
||||||
|
|
||||||
|
RequiredAssemblies = Get-ChildItem "$BinPath\*.dll" | ForEach-Object {
|
||||||
|
Join-Path $_.Directory.Name $_.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionsToExport = Get-ChildItem "$PublicPath\*.ps1" | ForEach-Object {
|
||||||
|
$_.BaseName
|
||||||
|
}
|
||||||
|
|
||||||
|
VariablesToExport = @()
|
||||||
|
AliasesToExport = @()
|
||||||
|
CmdletsToExport = @()
|
||||||
|
|
||||||
|
# Should we use prefix to prevent command name collisions?
|
||||||
|
# https://www.sapien.com/blog/2016/02/15/use-prefixes-to-prevent-command-name-collision/
|
||||||
|
#
|
||||||
|
# Kirk Munro recommends against it:
|
||||||
|
# https://www.sapien.com/blog/2016/02/15/use-prefixes-to-prevent-command-name-collision/#comment-20820
|
||||||
|
#
|
||||||
|
# If not, we'd need to generate functions name with prefix.
|
||||||
|
#
|
||||||
|
# DefaultCommandPrefix = 'PetStore'
|
||||||
|
}
|
||||||
|
|
||||||
|
New-ModuleManifest @Manifest
|
148
samples/client/petstore/powershell/PowerShellClient/README.md
Normal file
148
samples/client/petstore/powershell/PowerShellClient/README.md
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
# IO.Swagger - the PowerShell module for the 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: \" \\
|
||||||
|
|
||||||
|
This PowerShell module is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
||||||
|
|
||||||
|
- API version: 1.0.0
|
||||||
|
- SDK version: 1.0.0
|
||||||
|
- Build package: io.swagger.codegen.languages.CSharpClientCodegen
|
||||||
|
|
||||||
|
<a name="frameworks-supported"></a>
|
||||||
|
## Frameworks supported
|
||||||
|
- PowerShell 3.0 or later
|
||||||
|
- .NET 4.0 or later
|
||||||
|
|
||||||
|
<a name="dependencies"></a>
|
||||||
|
## Dependencies
|
||||||
|
- [RestSharp](https://www.nuget.org/packages/RestSharp) - 105.1.0 or later
|
||||||
|
- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later
|
||||||
|
|
||||||
|
The DLLs included in the package may not be the latest version. We recommend using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:
|
||||||
|
```
|
||||||
|
Install-Package RestSharp
|
||||||
|
Install-Package Newtonsoft.Json
|
||||||
|
```
|
||||||
|
|
||||||
|
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742)
|
||||||
|
|
||||||
|
<a name="installation"></a>
|
||||||
|
## Installation
|
||||||
|
Run the following command to generate the DLL
|
||||||
|
- [Windows] `build.ps1`
|
||||||
|
|
||||||
|
Then import module from the `.\src\IO.Swagger` folder:
|
||||||
|
```posh
|
||||||
|
Import-Module -Name '.\src\IO.Swagger'
|
||||||
|
```
|
||||||
|
<a name="getting-started"></a>
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
```posh
|
||||||
|
Set-ApiCredential -AccessToken 'YOUR_ACCESS_TOKEN'
|
||||||
|
|
||||||
|
New-Pet -Id 1 -Name 'foo' -Category (
|
||||||
|
New-Category -Id 2 -Name 'bar'
|
||||||
|
) -PhotoUrls @(
|
||||||
|
'http://example.com/foo',
|
||||||
|
'http://example.com/bar'
|
||||||
|
) -Tags (
|
||||||
|
New-Tag -Id 3 -Name 'baz'
|
||||||
|
) -Status Available | Update-Pet
|
||||||
|
|
||||||
|
Get-PetById -Id 1
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="documentation-for-api-endpoints"></a>
|
||||||
|
## Documentation for API Endpoints
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||||
|
|
||||||
|
Class | Method | HTTP request | Description
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
*FakeApi* | [**TestClientModel**](docs/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model
|
||||||
|
*FakeApi* | [**TestEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
|
*FakeApi* | [**TestEnumParameters**](docs/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters
|
||||||
|
*PetApi* | [**AddPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
|
||||||
|
*PetApi* | [**DeletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||||
|
*PetApi* | [**FindPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||||
|
*PetApi* | [**FindPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||||
|
*PetApi* | [**GetPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
|
||||||
|
*PetApi* | [**UpdatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
|
||||||
|
*PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||||
|
*PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||||
|
*StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
||||||
|
*StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||||
|
*StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID
|
||||||
|
*StoreApi* | [**PlaceOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
|
||||||
|
*UserApi* | [**CreateUser**](docs/UserApi.md#createuser) | **POST** /user | Create user
|
||||||
|
*UserApi* | [**CreateUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||||
|
*UserApi* | [**CreateUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||||
|
*UserApi* | [**DeleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user
|
||||||
|
*UserApi* | [**GetUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name
|
||||||
|
*UserApi* | [**LoginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system
|
||||||
|
*UserApi* | [**LogoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
|
||||||
|
*UserApi* | [**UpdateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user
|
||||||
|
|
||||||
|
|
||||||
|
<a name="documentation-for-models"></a>
|
||||||
|
## Documentation for Models
|
||||||
|
|
||||||
|
- [Model.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||||
|
- [Model.Animal](docs/Animal.md)
|
||||||
|
- [Model.AnimalFarm](docs/AnimalFarm.md)
|
||||||
|
- [Model.ApiResponse](docs/ApiResponse.md)
|
||||||
|
- [Model.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||||
|
- [Model.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||||
|
- [Model.ArrayTest](docs/ArrayTest.md)
|
||||||
|
- [Model.Capitalization](docs/Capitalization.md)
|
||||||
|
- [Model.Cat](docs/Cat.md)
|
||||||
|
- [Model.Category](docs/Category.md)
|
||||||
|
- [Model.ClassModel](docs/ClassModel.md)
|
||||||
|
- [Model.Dog](docs/Dog.md)
|
||||||
|
- [Model.EnumArrays](docs/EnumArrays.md)
|
||||||
|
- [Model.EnumClass](docs/EnumClass.md)
|
||||||
|
- [Model.EnumTest](docs/EnumTest.md)
|
||||||
|
- [Model.FormatTest](docs/FormatTest.md)
|
||||||
|
- [Model.HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||||
|
- [Model.List](docs/List.md)
|
||||||
|
- [Model.MapTest](docs/MapTest.md)
|
||||||
|
- [Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||||
|
- [Model.Model200Response](docs/Model200Response.md)
|
||||||
|
- [Model.ModelClient](docs/ModelClient.md)
|
||||||
|
- [Model.ModelReturn](docs/ModelReturn.md)
|
||||||
|
- [Model.Name](docs/Name.md)
|
||||||
|
- [Model.NumberOnly](docs/NumberOnly.md)
|
||||||
|
- [Model.Order](docs/Order.md)
|
||||||
|
- [Model.OuterEnum](docs/OuterEnum.md)
|
||||||
|
- [Model.Pet](docs/Pet.md)
|
||||||
|
- [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||||
|
- [Model.SpecialModelName](docs/SpecialModelName.md)
|
||||||
|
- [Model.Tag](docs/Tag.md)
|
||||||
|
- [Model.User](docs/User.md)
|
||||||
|
|
||||||
|
|
||||||
|
<a name="documentation-for-authorization"></a>
|
||||||
|
## Documentation for Authorization
|
||||||
|
|
||||||
|
<a name="api_key"></a>
|
||||||
|
### api_key
|
||||||
|
|
||||||
|
- **Type**: API key
|
||||||
|
- **API key parameter name**: api_key
|
||||||
|
- **Location**: HTTP header
|
||||||
|
|
||||||
|
<a name="http_basic_test"></a>
|
||||||
|
### http_basic_test
|
||||||
|
|
||||||
|
- **Type**: HTTP basic authentication
|
||||||
|
|
||||||
|
<a name="petstore_auth"></a>
|
||||||
|
### petstore_auth
|
||||||
|
|
||||||
|
- **Type**: OAuth
|
||||||
|
- **Flow**: implicit
|
||||||
|
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||||
|
- **Scopes**:
|
||||||
|
- write:pets: modify pets in your account
|
||||||
|
- read:pets: read your pets
|
2
samples/client/petstore/powershell/PowerShellClient/src/IO.Swagger/.gitignore
vendored
Normal file
2
samples/client/petstore/powershell/PowerShellClient/src/IO.Swagger/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Ignore module manifests
|
||||||
|
*.psd1
|
@ -0,0 +1,36 @@
|
|||||||
|
#region Import functions
|
||||||
|
|
||||||
|
$FunctionsToExport = @()
|
||||||
|
$Folders = 'Public', 'Private'
|
||||||
|
|
||||||
|
foreach ($Scope in $Folders) {
|
||||||
|
Get-ChildItem -LiteralPath (
|
||||||
|
Join-Path -Path $PSScriptRoot -ChildPath $Scope
|
||||||
|
) -File -Filter '*.ps1' | ForEach-Object {
|
||||||
|
$File = $_
|
||||||
|
try {
|
||||||
|
Write-Verbose "Dotsourcing file: $File"
|
||||||
|
. $File.FullName
|
||||||
|
|
||||||
|
switch ($Scope) {
|
||||||
|
'Public' {
|
||||||
|
$FunctionsToExport += $File.BaseName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
throw "Can't import functions from file: $File"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Export-ModuleMember -Function $FunctionsToExport
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Initialize APIs
|
||||||
|
|
||||||
|
'Creating object: IO.Swagger.Api.PetApi' | Write-Verbose
|
||||||
|
$Script:PetApi = New-Object -TypeName IO.Swagger.Api.PetApi -ArgumentList @($null)
|
||||||
|
|
||||||
|
#endregion
|
@ -0,0 +1,15 @@
|
|||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Helper function to get common parameters (Verbose, Debug, etc.)
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Get-CommonParameters
|
||||||
|
#>
|
||||||
|
function Get-CommonParameters {
|
||||||
|
function tmp {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param ()
|
||||||
|
}
|
||||||
|
|
||||||
|
(Get-Command -Name tmp -CommandType Function).Parameters.Keys
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Helper function to format debug parameter output.
|
||||||
|
|
||||||
|
.Example
|
||||||
|
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||||
|
#>
|
||||||
|
function Out-DebugParameter {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
|
||||||
|
[AllowEmptyCollection()]
|
||||||
|
$InputObject
|
||||||
|
)
|
||||||
|
|
||||||
|
Begin {
|
||||||
|
$CommonParameters = Get-CommonParameters
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
$InputObject.GetEnumerator() | Where-Object {
|
||||||
|
$CommonParameters -notcontains $_.Key
|
||||||
|
} | Format-Table -AutoSize -Property (
|
||||||
|
@{
|
||||||
|
Name = 'Parameter'
|
||||||
|
Expression = {$_.Key}
|
||||||
|
},
|
||||||
|
@{
|
||||||
|
Name = 'Value'
|
||||||
|
Expression = {$_.Value}
|
||||||
|
}
|
||||||
|
) | Out-String -Stream | ForEach-Object {
|
||||||
|
if ($_.Trim()) {
|
||||||
|
$_
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Find pet by ID.
|
||||||
|
|
||||||
|
.Description
|
||||||
|
Find pet by ID. Returns a single pet.
|
||||||
|
|
||||||
|
.Parameter Id
|
||||||
|
ID of pet to return.
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Get-PetById -Id 1
|
||||||
|
|
||||||
|
.Example
|
||||||
|
1 | Get-PetById
|
||||||
|
|
||||||
|
.Inputs
|
||||||
|
long
|
||||||
|
|
||||||
|
.Outputs
|
||||||
|
IO.Swagger.Model.Pet
|
||||||
|
|
||||||
|
.Notes
|
||||||
|
This function is automatically generated by the Swagger Codegen.
|
||||||
|
|
||||||
|
.Link
|
||||||
|
https://github.com/swagger-api/swagger-codegen
|
||||||
|
#>
|
||||||
|
function Get-PetById {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||||
|
[long]
|
||||||
|
${Id}
|
||||||
|
)
|
||||||
|
|
||||||
|
Process {
|
||||||
|
'Calling method: GetPetById' | Write-Verbose
|
||||||
|
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||||
|
|
||||||
|
$Script:PetApi.GetPetById(
|
||||||
|
${Id}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Creates new IO.Swagger.Model.Category object.
|
||||||
|
|
||||||
|
.Description
|
||||||
|
Creates new IO.Swagger.Model.Category object.
|
||||||
|
|
||||||
|
.Parameter Id
|
||||||
|
ID.
|
||||||
|
|
||||||
|
.Parameter Name
|
||||||
|
Name
|
||||||
|
|
||||||
|
.Example
|
||||||
|
New-Category -Id 1 -Name 'foo'
|
||||||
|
|
||||||
|
.Inputs
|
||||||
|
System.Nullable[long]
|
||||||
|
|
||||||
|
System.String
|
||||||
|
|
||||||
|
.Outputs
|
||||||
|
IO.Swagger.Model.Category
|
||||||
|
|
||||||
|
.Notes
|
||||||
|
This function is automatically generated by the Swagger Codegen.
|
||||||
|
|
||||||
|
.Link
|
||||||
|
https://github.com/swagger-api/swagger-codegen
|
||||||
|
#>
|
||||||
|
function New-Category {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[System.Nullable[long]]
|
||||||
|
${Id},
|
||||||
|
|
||||||
|
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[string]
|
||||||
|
${Name}
|
||||||
|
)
|
||||||
|
|
||||||
|
Process {
|
||||||
|
'Creating object: IO.Swagger.Model.Category' | Write-Verbose
|
||||||
|
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||||
|
|
||||||
|
New-Object -TypeName IO.Swagger.Model.Category -ArgumentList @(
|
||||||
|
${Id},
|
||||||
|
${Name}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Creates new IO.Swagger.Model.Pet object.
|
||||||
|
|
||||||
|
.Description
|
||||||
|
Creates new IO.Swagger.Model.Pet object.
|
||||||
|
|
||||||
|
.Parameter Id
|
||||||
|
ID of pet.
|
||||||
|
|
||||||
|
.Parameter Category
|
||||||
|
Category of pet.
|
||||||
|
|
||||||
|
.Parameter Name
|
||||||
|
Name of pet.
|
||||||
|
|
||||||
|
.Parameter PhotoUrls
|
||||||
|
PhotoUrls.
|
||||||
|
|
||||||
|
.Parameter Tags
|
||||||
|
Tags
|
||||||
|
|
||||||
|
.Parameter Status
|
||||||
|
Status.
|
||||||
|
|
||||||
|
.Example
|
||||||
|
New-Pet -Id 1 -Name 'foo' -Category (
|
||||||
|
New-Category -Id 2 -Name 'bar'
|
||||||
|
) -PhotoUrls @(
|
||||||
|
'http://example.com/foo',
|
||||||
|
'http://example.com/bar'
|
||||||
|
) -Tags (
|
||||||
|
New-Tag -Id 3 -Name 'baz'
|
||||||
|
) -Status 'Available'
|
||||||
|
|
||||||
|
.Inputs
|
||||||
|
System.Nullable[long]
|
||||||
|
|
||||||
|
IO.Swagger.Model.Category
|
||||||
|
|
||||||
|
System.String
|
||||||
|
|
||||||
|
System.Collections.Generic.List[string]
|
||||||
|
|
||||||
|
System.Collections.Generic.List[IO.Swagger.Model.Tag]
|
||||||
|
|
||||||
|
System.Nullable[IO.Swagger.Model.Pet+StatusEnum]
|
||||||
|
|
||||||
|
.Outputs
|
||||||
|
|
||||||
|
.Notes
|
||||||
|
This function is automatically generated by the Swagger Codegen.
|
||||||
|
|
||||||
|
.Link
|
||||||
|
https://github.com/swagger-api/swagger-codegen
|
||||||
|
#>
|
||||||
|
function New-Pet {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[System.Nullable[long]]
|
||||||
|
${Id},
|
||||||
|
|
||||||
|
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[IO.Swagger.Model.Category]
|
||||||
|
${Category},
|
||||||
|
|
||||||
|
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||||
|
[string]
|
||||||
|
${Name},
|
||||||
|
|
||||||
|
[Parameter(Position = 3, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||||
|
[System.Collections.Generic.List[string]]
|
||||||
|
${PhotoUrls},
|
||||||
|
|
||||||
|
[Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[System.Collections.Generic.List[IO.Swagger.Model.Tag]]
|
||||||
|
${Tags},
|
||||||
|
|
||||||
|
[Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[System.Nullable[IO.Swagger.Model.Pet+StatusEnum]]
|
||||||
|
${Status}
|
||||||
|
)
|
||||||
|
|
||||||
|
Process {
|
||||||
|
'Creating object: IO.Swagger.Model.Pet' | Write-Verbose
|
||||||
|
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||||
|
|
||||||
|
New-Object -TypeName IO.Swagger.Model.Pet -ArgumentList @(
|
||||||
|
${Id},
|
||||||
|
${Category},
|
||||||
|
${Name},
|
||||||
|
${PhotoUrls},
|
||||||
|
${Tags},
|
||||||
|
${Status}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Creates new IO.Swagger.Model.Tag object.
|
||||||
|
|
||||||
|
.Description
|
||||||
|
Creates new IO.Swagger.Model.Tag object.
|
||||||
|
|
||||||
|
.Parameter Id
|
||||||
|
ID.
|
||||||
|
|
||||||
|
.Parameter Name
|
||||||
|
Name
|
||||||
|
|
||||||
|
.Example
|
||||||
|
New-Tag -Id 1 -Name 'foo'
|
||||||
|
|
||||||
|
.Inputs
|
||||||
|
System.Nullable[long]
|
||||||
|
|
||||||
|
System.String
|
||||||
|
|
||||||
|
.Outputs
|
||||||
|
IO.Swagger.Model.Tag
|
||||||
|
|
||||||
|
.Notes
|
||||||
|
This function is automatically generated by the Swagger Codegen.
|
||||||
|
|
||||||
|
.Link
|
||||||
|
https://github.com/swagger-api/swagger-codegen
|
||||||
|
#>
|
||||||
|
function New-Tag {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[System.Nullable[long]]
|
||||||
|
${Id},
|
||||||
|
|
||||||
|
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||||
|
[string]
|
||||||
|
${Name}
|
||||||
|
)
|
||||||
|
|
||||||
|
Process {
|
||||||
|
'Creating object: IO.Swagger.Model.Tag' | Write-Verbose
|
||||||
|
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||||
|
|
||||||
|
New-Object -TypeName IO.Swagger.Model.Tag -ArgumentList @(
|
||||||
|
${Id},
|
||||||
|
${Name}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Set PetStore Authorization data.
|
||||||
|
|
||||||
|
.Description
|
||||||
|
Set PetStore Authorization data.
|
||||||
|
|
||||||
|
.Parameter ApiKey
|
||||||
|
API key.
|
||||||
|
|
||||||
|
.Parameter ApiKeyPrefix
|
||||||
|
API Key prefix.
|
||||||
|
|
||||||
|
.Parameter AccessToken
|
||||||
|
Access Token.
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Set-ApiCredential -ApiKey 'foo'
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Set-ApiCredential -ApiKey 'foo' -ApiPrefix 'Bearer'
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Set-ApiCredential -ApiKey 'foo' -ApiPrefix 'Bearer'
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Set-ApiCredential -AccessToken 'YOUR_ACCESS_TOKEN'
|
||||||
|
#>
|
||||||
|
function Set-ApiCredential {
|
||||||
|
[CmdletBinding(DefaultParameterSetName = 'ApiKey')]
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, ParameterSetName = 'ApiKey')]
|
||||||
|
[string]
|
||||||
|
${ApiKey},
|
||||||
|
|
||||||
|
[Parameter(Position = 1, ParameterSetName = 'ApiKey')]
|
||||||
|
[string]
|
||||||
|
${ApiKeyPrefix},
|
||||||
|
|
||||||
|
[Parameter(Position = 2, ParameterSetName = 'AccessToken')]
|
||||||
|
[string]
|
||||||
|
${AccessToken}
|
||||||
|
)
|
||||||
|
|
||||||
|
End {
|
||||||
|
if (${ApiKey}) {
|
||||||
|
([IO.Swagger.Client.Configuration]::Default).ApiKey.Add(
|
||||||
|
'api_key',
|
||||||
|
${ApiKey}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ApiKeyPrefix) {
|
||||||
|
([IO.Swagger.Client.Configuration]::Default).ApiKeyPrefix.Add(
|
||||||
|
'api_key',
|
||||||
|
${ApiKeyPrefix}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (${AccessToken}) {
|
||||||
|
([IO.Swagger.Client.Configuration]::Default).AccessToken = ${AccessToken}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user