diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java index e165f491eb3..3ef4e2d8cec 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java @@ -157,6 +157,9 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi @Override public String toVarName(String name) { + // sanitize name + name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. + // 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'. @@ -302,6 +305,8 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "ApiException.java")); supportingFiles.add(new SupportingFile("Pair.mustache", (sourceFolder + File.separator + invokerPackage).replace(".", File.separator), "Pair.java")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); } private void addSupportingFilesForVolley() { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index c4d2911e519..4c4f37e4342 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -210,6 +210,9 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "compile-mono.sh")); supportingFiles.add(new SupportingFile("packages.config.mustache", "vendor" + java.io.File.separator, "packages.config")); supportingFiles.add(new SupportingFile("README.md", "", "README.md")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + if (optionalAssemblyInfoFlag) { supportingFiles.add(new SupportingFile("AssemblyInfo.mustache", packageFolder + File.separator + "Properties", "AssemblyInfo.cs")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ClojureClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ClojureClientCodegen.java index bf55e573644..2c60a30754b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ClojureClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ClojureClientCodegen.java @@ -143,6 +143,8 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi final String baseNamespaceFolder = sourceFolder + File.separator + namespaceToFolder(baseNamespace); supportingFiles.add(new SupportingFile("project.mustache", "", "project.clj")); supportingFiles.add(new SupportingFile("core.mustache", baseNamespaceFolder, "core.clj")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); } @Override diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java index f32731b4754..cb2547b67a0 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java @@ -150,6 +150,9 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("auth/http_basic_auth.mustache", authFolder, "http_basic_auth.dart")); supportingFiles.add(new SupportingFile("auth/api_key_auth.mustache", authFolder, "api_key_auth.dart")); supportingFiles.add(new SupportingFile("auth/oauth.mustache", authFolder, "oauth.dart")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java index f68f57d38ac..b5699a93a34 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java @@ -153,6 +153,8 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig + File.separator + "lib" + File.separator + "ext", "flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc")); supportingFiles.add(new SupportingFile("flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); } private static String dropDots(String str) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java index 9f2f527dadd..007b3a8f36b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java @@ -129,6 +129,8 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { apiPackage = packageName; supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); } @Override diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 1d6633fc39a..429d7fcdf93 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -301,6 +301,10 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { importMapping.put("LocalDate", "java.time.LocalDate"); importMapping.put("LocalDateTime", "java.time.LocalDateTime"); } + + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + } private boolean usesAnyRetrofitLibrary() { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java index 9e9ec3100a9..a9db1b3bfdc 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java @@ -241,6 +241,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); supportingFiles.add(new SupportingFile("index.mustache", sourceFolder, "index.js")); supportingFiles.add(new SupportingFile("ApiClient.mustache", sourceFolder, "ApiClient.js")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); } @Override diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java index e535dc8892d..a8060e53211 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java @@ -220,6 +220,10 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("Configuration-header.mustache", swaggerFolder, classPrefix + "Configuration.h")); supportingFiles.add(new SupportingFile("podspec.mustache", "", podName + ".podspec")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + + } @Override diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index 0fbbf5d3c6c..7924c55a59c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -225,6 +225,8 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("autoload.mustache", getPackagePath(), "autoload.php")); supportingFiles.add(new SupportingFile("README.mustache", getPackagePath(), "README.md")); supportingFiles.add(new SupportingFile(".travis.yml", getPackagePath(), ".travis.yml")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + } @Override diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index 52ea0ce20e4..88643044dfc 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -110,6 +110,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig supportingFiles.add(new SupportingFile("__init__package.mustache", swaggerFolder, "__init__.py")); supportingFiles.add(new SupportingFile("__init__model.mustache", modelPackage, "__init__.py")); supportingFiles.add(new SupportingFile("__init__api.mustache", apiPackage, "__init__.py")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); } private static String dropDots(String str) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index 5c03720a20d..75e2984949d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -220,6 +220,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("configuration.mustache", gemFolder, "configuration.rb")); supportingFiles.add(new SupportingFile("version.mustache", gemFolder, "version.rb")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java index 51d9614728c..4f9f1695871 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java @@ -72,6 +72,8 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("apiInvoker.mustache", (sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.scala")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); importMapping.remove("List"); importMapping.remove("Set"); @@ -110,6 +112,7 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig "Long", "Float", "Object", + "Any", "List", "Map") ); @@ -255,4 +258,60 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig return objs; } + @Override + public String toVarName(String name) { + // sanitize name + name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. + + if("_".equals(name)) { + name = "_u"; + } + + // if it's all uppper case, do nothing + if (name.matches("^[A-Z_]*$")) { + return name; + } + + // camelize (lower first character) 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 toParamName(String name) { + // should be the same as variable name + return toVarName(name); + } + + @Override + public String toModelName(final String name) { + final String sanitizedName = sanitizeName(modelNamePrefix + name + modelNameSuffix); + + // camelize the model name + // phone_number => PhoneNumber + final String camelizedName = camelize(sanitizedName); + + // model name cannot use reserved keyword, e.g. return + if (isReservedWord(camelizedName)) { + final String modelName = "Model" + camelizedName; + LOGGER.warn(camelizedName + " (reserved word) cannot be used as model name. Renamed to " + modelName); + return modelName; + } + + return camelizedName; + } + + @Override + public String toModelFilename(String name) { + // should be the same as the model name + return toModelName(name); + } + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java index 16d332e4489..f66822aa5b9 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java @@ -195,6 +195,9 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("Extensions.mustache", sourceFolder, "Extensions.swift")); supportingFiles.add(new SupportingFile("Models.mustache", sourceFolder, "Models.swift")); supportingFiles.add(new SupportingFile("APIs.mustache", sourceFolder, "APIs.swift")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + } @Override diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java index 1e1acd65c08..6237331cf80 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java @@ -19,6 +19,10 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode public void processOpts() { super.processOpts(); supportingFiles.add(new SupportingFile("api.d.mustache", apiPackage().replace('.', File.separatorChar), "api.d.ts")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + //supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + + } public TypeScriptAngularClientCodegen() { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptNodeClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptNodeClientCodegen.java index 77371a7fb58..e590a60b323 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptNodeClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptNodeClientCodegen.java @@ -18,6 +18,8 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen public void processOpts() { super.processOpts(); supportingFiles.add(new SupportingFile("api.mustache", null, "api.ts")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + //supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); } public TypeScriptNodeClientCodegen() { diff --git a/modules/swagger-codegen/src/main/resources/Java/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/Java/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/Java/gitignore.mustache b/modules/swagger-codegen/src/main/resources/Java/gitignore.mustache new file mode 100644 index 00000000000..32858aad3c3 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/gitignore.mustache @@ -0,0 +1,12 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* diff --git a/modules/swagger-codegen/src/main/resources/Javascript/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/Javascript/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Javascript/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/Javascript/gitignore.mustache b/modules/swagger-codegen/src/main/resources/Javascript/gitignore.mustache new file mode 100644 index 00000000000..e920c16718d --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Javascript/gitignore.mustache @@ -0,0 +1,33 @@ +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +node_modules + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Angular/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Angular/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-node/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-node/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/TypeScript-node/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/android/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/android/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/android/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/android/gitignore.mustache b/modules/swagger-codegen/src/main/resources/android/gitignore.mustache new file mode 100644 index 00000000000..a8363b06f95 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/android/gitignore.mustache @@ -0,0 +1,39 @@ +# Built application files +*.apk +*.ap_ + +# Files for the Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# Intellij +*.iml + +#Keystore files +*.jks diff --git a/modules/swagger-codegen/src/main/resources/clojure/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/clojure/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/clojure/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/clojure/gitignore.mustache b/modules/swagger-codegen/src/main/resources/clojure/gitignore.mustache new file mode 100644 index 00000000000..47fed6c20d9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/clojure/gitignore.mustache @@ -0,0 +1,12 @@ +pom.xml +pom.xml.asc +*jar +/lib/ +/classes/ +/target/ +/checkouts/ +.lein-deps-sum +.lein-repl-history +.lein-plugins/ +.lein-failures +.nrepl-port diff --git a/modules/swagger-codegen/src/main/resources/csharp/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/csharp/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/csharp/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/csharp/gitignore.mustache b/modules/swagger-codegen/src/main/resources/csharp/gitignore.mustache new file mode 100644 index 00000000000..754beb8bedc --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/csharp/gitignore.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/dart/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/dart/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/dart/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/dart/gitignore.mustache b/modules/swagger-codegen/src/main/resources/dart/gitignore.mustache new file mode 100644 index 00000000000..7c280441649 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/dart/gitignore.mustache @@ -0,0 +1,27 @@ +# See https://www.dartlang.org/tools/private-files.html + +# Files and directories created by pub +.buildlog +.packages +.project +.pub/ +build/ +**/packages/ + +# Files created by dart2js +# (Most Dart developers will use pub build to compile Dart, use/modify these +# rules if you intend to use dart2js directly +# Convention is to use extension '.dart.js' for Dart compiled to Javascript to +# differentiate from explicit Javascript files) +*.dart.js +*.part.js +*.js.deps +*.js.map +*.info.json + +# Directory created by dartdoc +doc/api/ + +# Don't commit pubspec lock file +# (Library packages only! Remove pattern if developing an application package) +pubspec.lock diff --git a/modules/swagger-codegen/src/main/resources/flash/.gitignore b/modules/swagger-codegen/src/main/resources/flash/.gitignore new file mode 100644 index 00000000000..f112f7fb78f --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/flash/.gitignore @@ -0,0 +1,11 @@ +# Build and Release Folders +bin/ +bin-debug/ +bin-release/ + +# Other files and folders +.settings/ + +# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties` +# should NOT be excluded as they contain compiler settings and other important +# information for Eclipse / Flash Builder. diff --git a/modules/swagger-codegen/src/main/resources/go/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/go/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/go/gitignore.mustache b/modules/swagger-codegen/src/main/resources/go/gitignore.mustache new file mode 100644 index 00000000000..daf913b1b34 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go/gitignore.mustache @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/modules/swagger-codegen/src/main/resources/objc/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/objc/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/objc/gitignore.mustache b/modules/swagger-codegen/src/main/resources/objc/gitignore.mustache new file mode 100644 index 00000000000..79d9331b6d4 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/gitignore.mustache @@ -0,0 +1,53 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md + +fastlane/report.xml +fastlane/screenshots diff --git a/modules/swagger-codegen/src/main/resources/php/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/php/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/python/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/python/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/python/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/python/gitignore.mustache b/modules/swagger-codegen/src/main/resources/python/gitignore.mustache new file mode 100644 index 00000000000..1dbc687de01 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/python/gitignore.mustache @@ -0,0 +1,62 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints diff --git a/modules/swagger-codegen/src/main/resources/ruby/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/ruby/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/ruby/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/scala/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/scala/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/scala/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/scala/gitignore.mustache b/modules/swagger-codegen/src/main/resources/scala/gitignore.mustache new file mode 100644 index 00000000000..c58d83b3189 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/scala/gitignore.mustache @@ -0,0 +1,17 @@ +*.class +*.log + +# sbt specific +.cache +.history +.lib/ +dist/* +target/ +lib_managed/ +src_managed/ +project/boot/ +project/plugins/project/ + +# Scala-IDE specific +.scala_dependencies +.worksheet diff --git a/modules/swagger-codegen/src/main/resources/swift/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/swift/git_push.sh.mustache new file mode 100755 index 00000000000..e153ce23ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/swift/git_push.sh.mustache @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/modules/swagger-codegen/src/main/resources/swift/gitignore.mustache b/modules/swagger-codegen/src/main/resources/swift/gitignore.mustache new file mode 100644 index 00000000000..5e5d5cebcf4 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/swift/gitignore.mustache @@ -0,0 +1,63 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md + +fastlane/report.xml +fastlane/screenshots diff --git a/samples/client/petstore/android/default/.gitignore b/samples/client/petstore/android/default/.gitignore new file mode 100644 index 00000000000..a8363b06f95 --- /dev/null +++ b/samples/client/petstore/android/default/.gitignore @@ -0,0 +1,39 @@ +# Built application files +*.apk +*.ap_ + +# Files for the Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# Intellij +*.iml + +#Keystore files +*.jks diff --git a/samples/client/petstore/android/default/git_push.sh b/samples/client/petstore/android/default/git_push.sh new file mode 100644 index 00000000000..1a36388db02 --- /dev/null +++ b/samples/client/petstore/android/default/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="YOUR_GIT_USR_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="YOUR_GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/JsonUtil.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/JsonUtil.java index 8a45f846f19..1335ccd320f 100644 --- a/samples/client/petstore/android/default/src/main/java/io/swagger/client/JsonUtil.java +++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/JsonUtil.java @@ -35,24 +35,40 @@ public class JsonUtil { public static Type getListTypeForDeserialization(Class cls) { String className = cls.getSimpleName(); + if ("Category".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); + } + + if ("InlineResponse200".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); + } + + if ("ModelReturn".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); + } + + if ("Name".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); + } + if ("Order".equalsIgnoreCase(className)) { return new TypeToken>(){}.getType(); } - if ("User".equalsIgnoreCase(className)) { - return new TypeToken>(){}.getType(); + if ("Pet".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); } - if ("Category".equalsIgnoreCase(className)) { - return new TypeToken>(){}.getType(); + if ("SpecialModelName".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); } if ("Tag".equalsIgnoreCase(className)) { return new TypeToken>(){}.getType(); } - if ("Pet".equalsIgnoreCase(className)) { - return new TypeToken>(){}.getType(); + if ("User".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); } return new TypeToken>(){}.getType(); @@ -61,26 +77,42 @@ public class JsonUtil { public static Type getTypeForDeserialization(Class cls) { String className = cls.getSimpleName(); - if ("Order".equalsIgnoreCase(className)) { - return new TypeToken(){}.getType(); - } - - if ("User".equalsIgnoreCase(className)) { - return new TypeToken(){}.getType(); - } - if ("Category".equalsIgnoreCase(className)) { return new TypeToken(){}.getType(); } - if ("Tag".equalsIgnoreCase(className)) { - return new TypeToken(){}.getType(); + if ("InlineResponse200".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + + if ("ModelReturn".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + + if ("Name".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + + if ("Order".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); } if ("Pet".equalsIgnoreCase(className)) { return new TypeToken(){}.getType(); } + if ("SpecialModelName".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + + if ("Tag".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + + if ("User".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + return new TypeToken(){}.getType(); } diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/PetApi.java index 14811fb36be..41dac192d82 100644 --- a/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/PetApi.java @@ -9,6 +9,7 @@ import io.swagger.client.model.*; import java.util.*; import io.swagger.client.model.Pet; +import io.swagger.client.model.InlineResponse200; import java.io.File; import org.apache.http.entity.mime.MultipartEntityBuilder; @@ -38,59 +39,6 @@ public class PetApi { } - /** - * Update an existing pet - * - * @param body Pet object that needs to be added to the store - * @return void - */ - public void updatePet (Pet body) throws ApiException { - Object localVarPostBody = body; - - - // create path and map variables - String localVarPath = "/pet".replaceAll("\\{format\\}","json"); - - // query params - List localVarQueryParams = new ArrayList(); - // header params - Map localVarHeaderParams = new HashMap(); - // form params - Map localVarFormParams = new HashMap(); - - - - - - String[] localVarContentTypes = { - "application/json","application/xml" - }; - String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; - - if (localVarContentType.startsWith("multipart/form-data")) { - // file uploading - MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - - localVarPostBody = localVarBuilder.build(); - } else { - // normal form params - - } - - try { - String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); - if(localVarResponse != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } - } - /** * Add a new pet to the store * @@ -144,6 +92,120 @@ public class PetApi { } } + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param body Pet object in the form of byte array + * @return void + */ + public void addPetUsingByteArray (byte[] body) throws ApiException { + Object localVarPostBody = body; + + + // create path and map variables + String localVarPath = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + // header params + Map localVarHeaderParams = new HashMap(); + // form params + Map localVarFormParams = new HashMap(); + + + + + + String[] localVarContentTypes = { + "application/json","application/xml" + }; + String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; + + if (localVarContentType.startsWith("multipart/form-data")) { + // file uploading + MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); + + + localVarPostBody = localVarBuilder.build(); + } else { + // normal form params + + } + + try { + String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); + if(localVarResponse != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + throw ex; + } + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + * @return void + */ + public void deletePet (Long petId, String apiKey) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet"); + } + + + // create path and map variables + String localVarPath = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + // header params + Map localVarHeaderParams = new HashMap(); + // form params + Map localVarFormParams = new HashMap(); + + + + + localVarHeaderParams.put("api_key", ApiInvoker.parameterToString(apiKey)); + + + String[] localVarContentTypes = { + + }; + String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; + + if (localVarContentType.startsWith("multipart/form-data")) { + // file uploading + MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); + + + localVarPostBody = localVarBuilder.build(); + } else { + // normal form params + + } + + try { + String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); + if(localVarResponse != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + throw ex; + } + } + /** * Finds Pets by status * Multiple status values can be provided with comma separated strings @@ -312,6 +374,175 @@ public class PetApi { } } + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return InlineResponse200 + */ + public InlineResponse200 getPetByIdInObject (Long petId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdInObject"); + } + + + // create path and map variables + String localVarPath = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + // header params + Map localVarHeaderParams = new HashMap(); + // form params + Map localVarFormParams = new HashMap(); + + + + + + String[] localVarContentTypes = { + + }; + String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; + + if (localVarContentType.startsWith("multipart/form-data")) { + // file uploading + MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); + + + localVarPostBody = localVarBuilder.build(); + } else { + // normal form params + + } + + try { + String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); + if(localVarResponse != null){ + return (InlineResponse200) ApiInvoker.deserialize(localVarResponse, "", InlineResponse200.class); + } + else { + return null; + } + } catch (ApiException ex) { + throw ex; + } + } + + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return byte[] + */ + public byte[] petPetIdtestingByteArraytrueGet (Long petId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling petPetIdtestingByteArraytrueGet"); + } + + + // create path and map variables + String localVarPath = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + // header params + Map localVarHeaderParams = new HashMap(); + // form params + Map localVarFormParams = new HashMap(); + + + + + + String[] localVarContentTypes = { + + }; + String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; + + if (localVarContentType.startsWith("multipart/form-data")) { + // file uploading + MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); + + + localVarPostBody = localVarBuilder.build(); + } else { + // normal form params + + } + + try { + String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); + if(localVarResponse != null){ + return (byte[]) ApiInvoker.deserialize(localVarResponse, "", byte[].class); + } + else { + return null; + } + } catch (ApiException ex) { + throw ex; + } + } + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + * @return void + */ + public void updatePet (Pet body) throws ApiException { + Object localVarPostBody = body; + + + // create path and map variables + String localVarPath = "/pet".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + // header params + Map localVarHeaderParams = new HashMap(); + // form params + Map localVarFormParams = new HashMap(); + + + + + + String[] localVarContentTypes = { + "application/json","application/xml" + }; + String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; + + if (localVarContentType.startsWith("multipart/form-data")) { + // file uploading + MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); + + + localVarPostBody = localVarBuilder.build(); + } else { + // normal form params + + } + + try { + String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); + if(localVarResponse != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + throw ex; + } + } + /** * Updates a pet in the store with form data * @@ -382,67 +613,6 @@ public class PetApi { } } - /** - * Deletes a pet - * - * @param petId Pet id to delete - * @param apiKey - * @return void - */ - public void deletePet (Long petId, String apiKey) throws ApiException { - Object localVarPostBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { - throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet"); - } - - - // create path and map variables - String localVarPath = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); - - // query params - List localVarQueryParams = new ArrayList(); - // header params - Map localVarHeaderParams = new HashMap(); - // form params - Map localVarFormParams = new HashMap(); - - - - - localVarHeaderParams.put("api_key", ApiInvoker.parameterToString(apiKey)); - - - String[] localVarContentTypes = { - - }; - String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; - - if (localVarContentType.startsWith("multipart/form-data")) { - // file uploading - MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - - localVarPostBody = localVarBuilder.build(); - } else { - // normal form params - - } - - try { - String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); - if(localVarResponse != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } - } - /** * uploads an image * @@ -513,115 +683,4 @@ public class PetApi { } } - /** - * Fake endpoint to test byte array return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched - * @return byte[] - */ - public byte[] petPetIdtestingByteArraytrueGet (Long petId) throws ApiException { - Object localVarPostBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { - throw new ApiException(400, "Missing the required parameter 'petId' when calling petPetIdtestingByteArraytrueGet"); - } - - - // create path and map variables - String localVarPath = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); - - // query params - List localVarQueryParams = new ArrayList(); - // header params - Map localVarHeaderParams = new HashMap(); - // form params - Map localVarFormParams = new HashMap(); - - - - - - String[] localVarContentTypes = { - - }; - String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; - - if (localVarContentType.startsWith("multipart/form-data")) { - // file uploading - MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - - localVarPostBody = localVarBuilder.build(); - } else { - // normal form params - - } - - try { - String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); - if(localVarResponse != null){ - return (byte[]) ApiInvoker.deserialize(localVarResponse, "", byte[].class); - } - else { - return null; - } - } catch (ApiException ex) { - throw ex; - } - } - - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store - * - * @param body Pet object in the form of byte array - * @return void - */ - public void addPetUsingByteArray (byte[] body) throws ApiException { - Object localVarPostBody = body; - - - // create path and map variables - String localVarPath = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json"); - - // query params - List localVarQueryParams = new ArrayList(); - // header params - Map localVarHeaderParams = new HashMap(); - // form params - Map localVarFormParams = new HashMap(); - - - - - - String[] localVarContentTypes = { - "application/json","application/xml" - }; - String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; - - if (localVarContentType.startsWith("multipart/form-data")) { - // file uploading - MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - - localVarPostBody = localVarBuilder.build(); - } else { - // normal form params - - } - - try { - String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); - if(localVarResponse != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } - } - } diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/StoreApi.java index 6c28905e377..d5ecbca1ab3 100644 --- a/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/StoreApi.java @@ -38,6 +38,64 @@ public class StoreApi { } + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted + * @return void + */ + public void deleteOrder (String orderId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder"); + } + + + // create path and map variables + String localVarPath = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + // header params + Map localVarHeaderParams = new HashMap(); + // form params + Map localVarFormParams = new HashMap(); + + + + + + String[] localVarContentTypes = { + + }; + String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; + + if (localVarContentType.startsWith("multipart/form-data")) { + // file uploading + MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); + + + localVarPostBody = localVarBuilder.build(); + } else { + // normal form params + + } + + try { + String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); + if(localVarResponse != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + throw ex; + } + } + /** * Finds orders by status * A single status value can be provided as a string @@ -146,17 +204,16 @@ public class StoreApi { } /** - * Place an order for a pet - * - * @param body order placed for purchasing the pet - * @return Order + * Fake endpoint to test arbitrary object return by 'Get inventory' + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Object */ - public Order placeOrder (Order body) throws ApiException { - Object localVarPostBody = body; + public Object getInventoryInObject () throws ApiException { + Object localVarPostBody = null; // create path and map variables - String localVarPath = "/store/order".replaceAll("\\{format\\}","json"); + String localVarPath = "/store/inventory?response=arbitrary_object".replaceAll("\\{format\\}","json"); // query params List localVarQueryParams = new ArrayList(); @@ -186,9 +243,9 @@ public class StoreApi { } try { - String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); + String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); if(localVarResponse != null){ - return (Order) ApiInvoker.deserialize(localVarResponse, "", Order.class); + return (Object) ApiInvoker.deserialize(localVarResponse, "", Object.class); } else { return null; @@ -257,22 +314,17 @@ public class StoreApi { } /** - * Delete purchase order by ID - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @param orderId ID of the order that needs to be deleted - * @return void + * Place an order for a pet + * + * @param body order placed for purchasing the pet + * @return Order */ - public void deleteOrder (String orderId) throws ApiException { - Object localVarPostBody = null; - - // verify the required parameter 'orderId' is set - if (orderId == null) { - throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder"); - } + public Order placeOrder (Order body) throws ApiException { + Object localVarPostBody = body; // create path and map variables - String localVarPath = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); + String localVarPath = "/store/order".replaceAll("\\{format\\}","json"); // query params List localVarQueryParams = new ArrayList(); @@ -302,12 +354,12 @@ public class StoreApi { } try { - String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); + String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); if(localVarResponse != null){ - return ; + return (Order) ApiInvoker.deserialize(localVarResponse, "", Order.class); } else { - return ; + return null; } } catch (ApiException ex) { throw ex; diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/UserApi.java index 06934022874..a28410fd0a9 100644 --- a/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/UserApi.java @@ -197,6 +197,122 @@ public class UserApi { } } + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + * @return void + */ + public void deleteUser (String username) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser"); + } + + + // create path and map variables + String localVarPath = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + // header params + Map localVarHeaderParams = new HashMap(); + // form params + Map localVarFormParams = new HashMap(); + + + + + + String[] localVarContentTypes = { + + }; + String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; + + if (localVarContentType.startsWith("multipart/form-data")) { + // file uploading + MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); + + + localVarPostBody = localVarBuilder.build(); + } else { + // normal form params + + } + + try { + String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); + if(localVarResponse != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + throw ex; + } + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + * @return User + */ + public User getUserByName (String username) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName"); + } + + + // create path and map variables + String localVarPath = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + // header params + Map localVarHeaderParams = new HashMap(); + // form params + Map localVarFormParams = new HashMap(); + + + + + + String[] localVarContentTypes = { + + }; + String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; + + if (localVarContentType.startsWith("multipart/form-data")) { + // file uploading + MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); + + + localVarPostBody = localVarBuilder.build(); + } else { + // normal form params + + } + + try { + String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); + if(localVarResponse != null){ + return (User) ApiInvoker.deserialize(localVarResponse, "", User.class); + } + else { + return null; + } + } catch (ApiException ex) { + throw ex; + } + } + /** * Logs user into the system * @@ -307,64 +423,6 @@ public class UserApi { } } - /** - * Get user by user name - * - * @param username The name that needs to be fetched. Use user1 for testing. - * @return User - */ - public User getUserByName (String username) throws ApiException { - Object localVarPostBody = null; - - // verify the required parameter 'username' is set - if (username == null) { - throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName"); - } - - - // create path and map variables - String localVarPath = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); - - // query params - List localVarQueryParams = new ArrayList(); - // header params - Map localVarHeaderParams = new HashMap(); - // form params - Map localVarFormParams = new HashMap(); - - - - - - String[] localVarContentTypes = { - - }; - String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; - - if (localVarContentType.startsWith("multipart/form-data")) { - // file uploading - MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - - localVarPostBody = localVarBuilder.build(); - } else { - // normal form params - - } - - try { - String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); - if(localVarResponse != null){ - return (User) ApiInvoker.deserialize(localVarResponse, "", User.class); - } - else { - return null; - } - } catch (ApiException ex) { - throw ex; - } - } - /** * Updated user * This can only be done by the logged in user. @@ -424,62 +482,4 @@ public class UserApi { } } - /** - * Delete user - * This can only be done by the logged in user. - * @param username The name that needs to be deleted - * @return void - */ - public void deleteUser (String username) throws ApiException { - Object localVarPostBody = null; - - // verify the required parameter 'username' is set - if (username == null) { - throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser"); - } - - - // create path and map variables - String localVarPath = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); - - // query params - List localVarQueryParams = new ArrayList(); - // header params - Map localVarHeaderParams = new HashMap(); - // form params - Map localVarFormParams = new HashMap(); - - - - - - String[] localVarContentTypes = { - - }; - String localVarContentType = localVarContentTypes.length > 0 ? localVarContentTypes[0] : "application/json"; - - if (localVarContentType.startsWith("multipart/form-data")) { - // file uploading - MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - - localVarPostBody = localVarBuilder.build(); - } else { - // normal form params - - } - - try { - String localVarResponse = apiInvoker.invokeAPI(basePath, localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarContentType); - if(localVarResponse != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } - } - } diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 00000000000..c4fd8ce357d --- /dev/null +++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,112 @@ +package io.swagger.client.model; + +import io.swagger.client.model.Tag; +import java.util.*; + +import io.swagger.annotations.*; +import com.google.gson.annotations.SerializedName; + + +@ApiModel(description = "") +public class InlineResponse200 { + + @SerializedName("tags") + private List tags = null; + @SerializedName("id") + private Long id = null; + @SerializedName("category") + private Object category = null; + public enum StatusEnum { + available, pending, sold, + }; + @SerializedName("status") + private StatusEnum status = null; + @SerializedName("name") + private String name = null; + @SerializedName("photoUrls") + private List photoUrls = null; + + + /** + **/ + @ApiModelProperty(value = "") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + /** + **/ + @ApiModelProperty(value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + @ApiModelProperty(value = "") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" tags: ").append(tags).append("\n"); + sb.append(" id: ").append(id).append("\n"); + sb.append(" category: ").append(category).append("\n"); + sb.append(" status: ").append(status).append("\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append(" photoUrls: ").append(photoUrls).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/ModelReturn.java new file mode 100644 index 00000000000..24763f3acb4 --- /dev/null +++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/ModelReturn.java @@ -0,0 +1,36 @@ +package io.swagger.client.model; + + +import io.swagger.annotations.*; +import com.google.gson.annotations.SerializedName; + + +@ApiModel(description = "") +public class ModelReturn { + + @SerializedName("return") + private Integer _return = null; + + + /** + **/ + @ApiModelProperty(value = "") + public Integer getReturn() { + return _return; + } + public void setReturn(Integer _return) { + this._return = _return; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelReturn {\n"); + + sb.append(" _return: ").append(_return).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Name.java new file mode 100644 index 00000000000..5c308de749f --- /dev/null +++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Name.java @@ -0,0 +1,36 @@ +package io.swagger.client.model; + + +import io.swagger.annotations.*; +import com.google.gson.annotations.SerializedName; + + +@ApiModel(description = "") +public class Name { + + @SerializedName("name") + private Integer name = null; + + + /** + **/ + @ApiModelProperty(value = "") + public Integer getName() { + return name; + } + public void setName(Integer name) { + this.name = name; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Name {\n"); + + sb.append(" name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/SpecialModelName.java new file mode 100644 index 00000000000..d804bdd8765 --- /dev/null +++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -0,0 +1,36 @@ +package io.swagger.client.model; + + +import io.swagger.annotations.*; +import com.google.gson.annotations.SerializedName; + + +@ApiModel(description = "") +public class SpecialModelName { + + @SerializedName("$special[property.name]") + private Long specialPropertyName = null; + + + /** + **/ + @ApiModelProperty(value = "") + public Long getSpecialPropertyName() { + return specialPropertyName; + } + public void setSpecialPropertyName(Long specialPropertyName) { + this.specialPropertyName = specialPropertyName; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SpecialModelName {\n"); + + sb.append(" specialPropertyName: ").append(specialPropertyName).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/client/petstore/clojure/.gitignore b/samples/client/petstore/clojure/.gitignore index 055b6ac4772..47fed6c20d9 100644 --- a/samples/client/petstore/clojure/.gitignore +++ b/samples/client/petstore/clojure/.gitignore @@ -1,10 +1,12 @@ -/target -/classes -/checkouts +pom.xml pom.xml.asc -*.jar -*.class -/.lein-* -/.nrepl-port -.hgignore -.hg/ +*jar +/lib/ +/classes/ +/target/ +/checkouts/ +.lein-deps-sum +.lein-repl-history +.lein-plugins/ +.lein-failures +.nrepl-port diff --git a/samples/client/petstore/clojure/git_push.sh b/samples/client/petstore/clojure/git_push.sh new file mode 100644 index 00000000000..1a36388db02 --- /dev/null +++ b/samples/client/petstore/clojure/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="YOUR_GIT_USR_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="YOUR_GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj b/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj index aaa6e0768e4..a455838c8fc 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj @@ -2,28 +2,6 @@ (:require [swagger-petstore.core :refer [call-api check-required-params with-collection-format]]) (:import (java.io File))) -(defn update-pet-with-http-info - "Update an existing pet - " - ([] (update-pet-with-http-info nil)) - ([{:keys [body ]}] - (call-api "/pet" :put - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types ["application/json" "application/xml"] - :accepts ["application/json" "application/xml"] - :auth-names ["petstore_auth"]}))) - -(defn update-pet - "Update an existing pet - " - ([] (update-pet nil)) - ([optional-params] - (:data (update-pet-with-http-info optional-params)))) - (defn add-pet-with-http-info "Add a new pet to the store " @@ -46,6 +24,49 @@ ([optional-params] (:data (add-pet-with-http-info optional-params)))) +(defn add-pet-using-byte-array-with-http-info + "Fake endpoint to test byte array in body parameter for adding a new pet to the store + " + ([] (add-pet-using-byte-array-with-http-info nil)) + ([{:keys [body ]}] + (call-api "/pet?testing_byte_array=true" :post + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types ["application/json" "application/xml"] + :accepts ["application/json" "application/xml"] + :auth-names ["petstore_auth"]}))) + +(defn add-pet-using-byte-array + "Fake endpoint to test byte array in body parameter for adding a new pet to the store + " + ([] (add-pet-using-byte-array nil)) + ([optional-params] + (:data (add-pet-using-byte-array-with-http-info optional-params)))) + +(defn delete-pet-with-http-info + "Deletes a pet + " + ([pet-id ] (delete-pet-with-http-info pet-id nil)) + ([pet-id {:keys [api-key ]}] + (call-api "/pet/{petId}" :delete + {:path-params {"petId" pet-id } + :header-params {"api_key" api-key } + :query-params {} + :form-params {} + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names ["petstore_auth"]}))) + +(defn delete-pet + "Deletes a pet + " + ([pet-id ] (delete-pet pet-id nil)) + ([pet-id optional-params] + (:data (delete-pet-with-http-info pet-id optional-params)))) + (defn find-pets-by-status-with-http-info "Finds Pets by status Multiple status values can be provided with comma separated strings" @@ -99,7 +120,7 @@ :form-params {} :content-types [] :accepts ["application/json" "application/xml"] - :auth-names ["petstore_auth" "api_key"]})) + :auth-names ["api_key" "petstore_auth"]})) (defn get-pet-by-id "Find pet by ID @@ -107,6 +128,66 @@ [pet-id ] (:data (get-pet-by-id-with-http-info pet-id))) +(defn get-pet-by-id-in-object-with-http-info + "Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions" + [pet-id ] + (call-api "/pet/{petId}?response=inline_arbitrary_object" :get + {:path-params {"petId" pet-id } + :header-params {} + :query-params {} + :form-params {} + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names ["api_key" "petstore_auth"]})) + +(defn get-pet-by-id-in-object + "Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions" + [pet-id ] + (:data (get-pet-by-id-in-object-with-http-info pet-id))) + +(defn pet-pet-idtesting-byte-arraytrue-get-with-http-info + "Fake endpoint to test byte array return by 'Find pet by ID' + Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions" + [pet-id ] + (call-api "/pet/{petId}?testing_byte_array=true" :get + {:path-params {"petId" pet-id } + :header-params {} + :query-params {} + :form-params {} + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names ["api_key" "petstore_auth"]})) + +(defn pet-pet-idtesting-byte-arraytrue-get + "Fake endpoint to test byte array return by 'Find pet by ID' + Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions" + [pet-id ] + (:data (pet-pet-idtesting-byte-arraytrue-get-with-http-info pet-id))) + +(defn update-pet-with-http-info + "Update an existing pet + " + ([] (update-pet-with-http-info nil)) + ([{:keys [body ]}] + (call-api "/pet" :put + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types ["application/json" "application/xml"] + :accepts ["application/json" "application/xml"] + :auth-names ["petstore_auth"]}))) + +(defn update-pet + "Update an existing pet + " + ([] (update-pet nil)) + ([optional-params] + (:data (update-pet-with-http-info optional-params)))) + (defn update-pet-with-form-with-http-info "Updates a pet in the store with form data " @@ -128,27 +209,6 @@ ([pet-id optional-params] (:data (update-pet-with-form-with-http-info pet-id optional-params)))) -(defn delete-pet-with-http-info - "Deletes a pet - " - ([pet-id ] (delete-pet-with-http-info pet-id nil)) - ([pet-id {:keys [api-key ]}] - (call-api "/pet/{petId}" :delete - {:path-params {"petId" pet-id } - :header-params {"api_key" api-key } - :query-params {} - :form-params {} - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names ["petstore_auth"]}))) - -(defn delete-pet - "Deletes a pet - " - ([pet-id ] (delete-pet pet-id nil)) - ([pet-id optional-params] - (:data (delete-pet-with-http-info pet-id optional-params)))) - (defn upload-file-with-http-info "uploads an image " @@ -169,44 +229,3 @@ ([pet-id ] (upload-file pet-id nil)) ([pet-id optional-params] (:data (upload-file-with-http-info pet-id optional-params)))) - -(defn pet-pet-idtesting-byte-arraytrue-get-with-http-info - "Fake endpoint to test byte array return by 'Find pet by ID' - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions" - [pet-id ] - (call-api "/pet/{petId}?testing_byte_array=true" :get - {:path-params {"petId" pet-id } - :header-params {} - :query-params {} - :form-params {} - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names ["petstore_auth" "api_key"]})) - -(defn pet-pet-idtesting-byte-arraytrue-get - "Fake endpoint to test byte array return by 'Find pet by ID' - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions" - [pet-id ] - (:data (pet-pet-idtesting-byte-arraytrue-get-with-http-info pet-id))) - -(defn add-pet-using-byte-array-with-http-info - "Fake endpoint to test byte array in body parameter for adding a new pet to the store - " - ([] (add-pet-using-byte-array-with-http-info nil)) - ([{:keys [body ]}] - (call-api "/pet?testing_byte_array=true" :post - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types ["application/json" "application/xml"] - :accepts ["application/json" "application/xml"] - :auth-names ["petstore_auth"]}))) - -(defn add-pet-using-byte-array - "Fake endpoint to test byte array in body parameter for adding a new pet to the store - " - ([] (add-pet-using-byte-array nil)) - ([optional-params] - (:data (add-pet-using-byte-array-with-http-info optional-params)))) diff --git a/samples/client/petstore/clojure/src/swagger_petstore/api/store.clj b/samples/client/petstore/clojure/src/swagger_petstore/api/store.clj index 1ccf78d4c3b..1e3cc25e4a6 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/api/store.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/api/store.clj @@ -2,6 +2,25 @@ (:require [swagger-petstore.core :refer [call-api check-required-params with-collection-format]]) (:import (java.io File))) +(defn delete-order-with-http-info + "Delete purchase order by ID + For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors" + [order-id ] + (call-api "/store/order/{orderId}" :delete + {:path-params {"orderId" order-id } + :header-params {} + :query-params {} + :form-params {} + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names []})) + +(defn delete-order + "Delete purchase order by ID + For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors" + [order-id ] + (:data (delete-order-with-http-info order-id))) + (defn find-orders-by-status-with-http-info "Finds orders by status A single status value can be provided as a string" @@ -42,6 +61,44 @@ [] (:data (get-inventory-with-http-info))) +(defn get-inventory-in-object-with-http-info + "Fake endpoint to test arbitrary object return by 'Get inventory' + Returns an arbitrary object which is actually a map of status codes to quantities" + [] + (call-api "/store/inventory?response=arbitrary_object" :get + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names ["api_key"]})) + +(defn get-inventory-in-object + "Fake endpoint to test arbitrary object return by 'Get inventory' + Returns an arbitrary object which is actually a map of status codes to quantities" + [] + (:data (get-inventory-in-object-with-http-info))) + +(defn get-order-by-id-with-http-info + "Find purchase order by ID + For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions" + [order-id ] + (call-api "/store/order/{orderId}" :get + {:path-params {"orderId" order-id } + :header-params {} + :query-params {} + :form-params {} + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names ["test_api_key_header" "test_api_key_query"]})) + +(defn get-order-by-id + "Find purchase order by ID + For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions" + [order-id ] + (:data (get-order-by-id-with-http-info order-id))) + (defn place-order-with-http-info "Place an order for a pet " @@ -63,41 +120,3 @@ ([] (place-order nil)) ([optional-params] (:data (place-order-with-http-info optional-params)))) - -(defn get-order-by-id-with-http-info - "Find purchase order by ID - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions" - [order-id ] - (call-api "/store/order/{orderId}" :get - {:path-params {"orderId" order-id } - :header-params {} - :query-params {} - :form-params {} - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names ["test_api_key_query" "test_api_key_header"]})) - -(defn get-order-by-id - "Find purchase order by ID - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions" - [order-id ] - (:data (get-order-by-id-with-http-info order-id))) - -(defn delete-order-with-http-info - "Delete purchase order by ID - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors" - [order-id ] - (call-api "/store/order/{orderId}" :delete - {:path-params {"orderId" order-id } - :header-params {} - :query-params {} - :form-params {} - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names []})) - -(defn delete-order - "Delete purchase order by ID - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors" - [order-id ] - (:data (delete-order-with-http-info order-id))) diff --git a/samples/client/petstore/clojure/src/swagger_petstore/api/user.clj b/samples/client/petstore/clojure/src/swagger_petstore/api/user.clj index c25d97aa7c4..07b016d641a 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/api/user.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/api/user.clj @@ -68,6 +68,44 @@ ([optional-params] (:data (create-users-with-list-input-with-http-info optional-params)))) +(defn delete-user-with-http-info + "Delete user + This can only be done by the logged in user." + [username ] + (call-api "/user/{username}" :delete + {:path-params {"username" username } + :header-params {} + :query-params {} + :form-params {} + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names []})) + +(defn delete-user + "Delete user + This can only be done by the logged in user." + [username ] + (:data (delete-user-with-http-info username))) + +(defn get-user-by-name-with-http-info + "Get user by user name + " + [username ] + (call-api "/user/{username}" :get + {:path-params {"username" username } + :header-params {} + :query-params {} + :form-params {} + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names []})) + +(defn get-user-by-name + "Get user by user name + " + [username ] + (:data (get-user-by-name-with-http-info username))) + (defn login-user-with-http-info "Logs user into the system " @@ -108,25 +146,6 @@ [] (:data (logout-user-with-http-info))) -(defn get-user-by-name-with-http-info - "Get user by user name - " - [username ] - (call-api "/user/{username}" :get - {:path-params {"username" username } - :header-params {} - :query-params {} - :form-params {} - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names []})) - -(defn get-user-by-name - "Get user by user name - " - [username ] - (:data (get-user-by-name-with-http-info username))) - (defn update-user-with-http-info "Updated user This can only be done by the logged in user." @@ -148,22 +167,3 @@ ([username ] (update-user username nil)) ([username optional-params] (:data (update-user-with-http-info username optional-params)))) - -(defn delete-user-with-http-info - "Delete user - This can only be done by the logged in user." - [username ] - (call-api "/user/{username}" :delete - {:path-params {"username" username } - :header-params {} - :query-params {} - :form-params {} - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names []})) - -(defn delete-user - "Delete user - This can only be done by the logged in user." - [username ] - (:data (delete-user-with-http-info username))) diff --git a/samples/client/petstore/clojure/src/swagger_petstore/core.clj b/samples/client/petstore/clojure/src/swagger_petstore/core.clj index 2d8f596cfc8..f01f3061e0d 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/core.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/core.clj @@ -8,12 +8,12 @@ (java.text SimpleDateFormat))) (def auth-definitions - {"petstore_auth" {:type :oauth2} - "test_api_client_id" {:type :api-key :in :header :param-name "x-test_api_client_id"} - "test_api_client_secret" {:type :api-key :in :header :param-name "x-test_api_client_secret"} + {"test_api_key_header" {:type :api-key :in :header :param-name "test_api_key_header"} "api_key" {:type :api-key :in :header :param-name "api_key"} + "test_api_client_secret" {:type :api-key :in :header :param-name "x-test_api_client_secret"} + "test_api_client_id" {:type :api-key :in :header :param-name "x-test_api_client_id"} "test_api_key_query" {:type :api-key :in :query :param-name "test_api_key_query"} - "test_api_key_header" {:type :api-key :in :header :param-name "test_api_key_header"}}) + "petstore_auth" {:type :oauth2}}) (def default-api-context "Default API context." @@ -21,12 +21,12 @@ :date-format "yyyy-MM-dd" :datetime-format "yyyy-MM-dd'T'HH:mm:ss.SSSXXX" :debug false - :auths {"petstore_auth" nil - "test_api_client_id" nil - "test_api_client_secret" nil + :auths {"test_api_key_header" nil "api_key" nil + "test_api_client_secret" nil + "test_api_client_id" nil "test_api_key_query" nil - "test_api_key_header" nil}}) + "petstore_auth" nil}}) (def ^:dynamic *api-context* "Dynamic API context to be applied in API calls." diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/InlineResponse200Tests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/InlineResponse200Tests.cs new file mode 100644 index 00000000000..34cd5b1beb5 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/InlineResponse200Tests.cs @@ -0,0 +1,111 @@ +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing InlineResponse200 + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class InlineResponse200Tests + { + private InlineResponse200 instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + instance = new InlineResponse200(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of InlineResponse200 + /// + [Test] + public void InlineResponse200InstanceTest() + { + Assert.IsInstanceOf (instance, "instance is a InlineResponse200"); + } + + + /// + /// Test the property 'Tags' + /// + [Test] + public void TagsTest() + { + // TODO: unit test for the property 'Tags' + } + + /// + /// Test the property 'Id' + /// + [Test] + public void IdTest() + { + // TODO: unit test for the property 'Id' + } + + /// + /// Test the property 'Category' + /// + [Test] + public void CategoryTest() + { + // TODO: unit test for the property 'Category' + } + + /// + /// Test the property 'Status' + /// + [Test] + public void StatusTest() + { + // TODO: unit test for the property 'Status' + } + + /// + /// Test the property 'Name' + /// + [Test] + public void NameTest() + { + // TODO: unit test for the property 'Name' + } + + /// + /// Test the property 'PhotoUrls' + /// + [Test] + public void PhotoUrlsTest() + { + // TODO: unit test for the property 'PhotoUrls' + } + + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/ModelReturnTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/ModelReturnTests.cs new file mode 100644 index 00000000000..ed64fa0d8c8 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/ModelReturnTests.cs @@ -0,0 +1,66 @@ +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing ModelReturn + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class ModelReturnTests + { + private ModelReturn instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + instance = new ModelReturn(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of ModelReturn + /// + [Test] + public void ModelReturnInstanceTest() + { + Assert.IsInstanceOf (instance, "instance is a ModelReturn"); + } + + + /// + /// Test the property '_Return' + /// + [Test] + public void _ReturnTest() + { + // TODO: unit test for the property '_Return' + } + + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs new file mode 100644 index 00000000000..4937b2affa2 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs @@ -0,0 +1,66 @@ +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing Name + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class NameTests + { + private Name instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + instance = new Name(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of Name + /// + [Test] + public void NameInstanceTest() + { + Assert.IsInstanceOf (instance, "instance is a Name"); + } + + + /// + /// Test the property '_Name' + /// + [Test] + public void _NameTest() + { + // TODO: unit test for the property '_Name' + } + + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/SpecialModelNameTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/SpecialModelNameTests.cs new file mode 100644 index 00000000000..92acadc9404 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/SpecialModelNameTests.cs @@ -0,0 +1,66 @@ +using NUnit.Framework; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using IO.Swagger.Api; +using IO.Swagger.Model; +using IO.Swagger.Client; +using System.Reflection; + +namespace IO.Swagger.Test +{ + /// + /// Class for testing SpecialModelName + /// + /// + /// This file is automatically generated by Swagger Codegen. + /// Please update the test case below to test the model. + /// + [TestFixture] + public class SpecialModelNameTests + { + private SpecialModelName instance; + + /// + /// Setup before each test + /// + [SetUp] + public void Init() + { + instance = new SpecialModelName(); + } + + /// + /// Clean up after each test + /// + [TearDown] + public void Cleanup() + { + + } + + /// + /// Test an instance of SpecialModelName + /// + [Test] + public void SpecialModelNameInstanceTest() + { + Assert.IsInstanceOf (instance, "instance is a SpecialModelName"); + } + + + /// + /// Test the property 'SpecialPropertyName' + /// + [Test] + public void SpecialPropertyNameTest() + { + // TODO: unit test for the property 'SpecialPropertyName' + } + + + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/.gitignore b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/.gitignore index 08d9d469ba8..754beb8bedc 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/.gitignore +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/.gitignore @@ -1,2 +1,185 @@ -vendor/Newtonsoft.Json.8.0.2/ -vendor/RestSharp.105.2.3/ \ No newline at end of file +# 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 diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/git_push.sh b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/git_push.sh new file mode 100644 index 00000000000..1a36388db02 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="YOUR_GIT_USR_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="YOUR_GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/go/.gitignore b/samples/client/petstore/go/.gitignore new file mode 100644 index 00000000000..daf913b1b34 --- /dev/null +++ b/samples/client/petstore/go/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/samples/client/petstore/go/git_push.sh b/samples/client/petstore/go/git_push.sh new file mode 100644 index 00000000000..1a36388db02 --- /dev/null +++ b/samples/client/petstore/go/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="YOUR_GIT_USR_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="YOUR_GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/go/swagger/InlineResponse200.go b/samples/client/petstore/go/swagger/InlineResponse200.go new file mode 100644 index 00000000000..2fd550dcb82 --- /dev/null +++ b/samples/client/petstore/go/swagger/InlineResponse200.go @@ -0,0 +1,14 @@ +package swagger + +import ( +) + +type InlineResponse200 struct { + Tags []Tag `json:"tags,omitempty"` + Id int64 `json:"id,omitempty"` + Category Object `json:"category,omitempty"` + Status string `json:"status,omitempty"` + Name string `json:"name,omitempty"` + PhotoUrls []string `json:"photoUrls,omitempty"` + +} diff --git a/samples/client/petstore/go/swagger/ModelReturn.go b/samples/client/petstore/go/swagger/ModelReturn.go new file mode 100644 index 00000000000..daac97e1763 --- /dev/null +++ b/samples/client/petstore/go/swagger/ModelReturn.go @@ -0,0 +1,9 @@ +package swagger + +import ( +) + +type ModelReturn struct { + Return_ int32 `json:"return,omitempty"` + +} diff --git a/samples/client/petstore/go/swagger/Name.go b/samples/client/petstore/go/swagger/Name.go new file mode 100644 index 00000000000..5c0d7bc6d44 --- /dev/null +++ b/samples/client/petstore/go/swagger/Name.go @@ -0,0 +1,9 @@ +package swagger + +import ( +) + +type Name struct { + Name int32 `json:"name,omitempty"` + +} diff --git a/samples/client/petstore/go/swagger/PetApi.go b/samples/client/petstore/go/swagger/PetApi.go index 51b32061e0f..3e7b3a77315 100644 --- a/samples/client/petstore/go/swagger/PetApi.go +++ b/samples/client/petstore/go/swagger/PetApi.go @@ -3,6 +3,8 @@ package swagger import ( "strings" "fmt" + "encoding/json" + "errors" "github.com/dghubble/sling" "os" ) @@ -24,13 +26,498 @@ func NewPetApiWithBasePath(basePath string) *PetApi{ } /** - * Update an existing pet + * Add a new pet to the store * - * @param Body Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store * @return void */ -//func (a PetApi) UpdatePet (Body Pet) (error) { -func (a PetApi) UpdatePet (Body Pet) (error) { +//func (a PetApi) AddPet (body Pet) (error) { +func (a PetApi) AddPet (body Pet) (error) { + + _sling := sling.New().Post(a.basePath) + + // create path and map variables + path := "/v2/pet" + + _sling = _sling.Path(path) + + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + +// body params + _sling = _sling.BodyJSON(body) + + + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(nil, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return err +} +/** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param body Pet object in the form of byte array + * @return void + */ +//func (a PetApi) AddPetUsingByteArray (body string) (error) { +func (a PetApi) AddPetUsingByteArray (body string) (error) { + + _sling := sling.New().Post(a.basePath) + + // create path and map variables + path := "/v2/pet?testing_byte_array=true" + + _sling = _sling.Path(path) + + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + +// body params + _sling = _sling.BodyJSON(body) + + + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(nil, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return err +} +/** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + * @return void + */ +//func (a PetApi) DeletePet (petId int64, apiKey string) (error) { +func (a PetApi) DeletePet (petId int64, apiKey string) (error) { + + _sling := sling.New().Delete(a.basePath) + + // create path and map variables + path := "/v2/pet/{petId}" + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + + _sling = _sling.Path(path) + + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + // header params "api_key" + _sling = _sling.Set("api_key", apiKey) + + + + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(nil, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return err +} +/** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for query + * @return []Pet + */ +//func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { +func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { + + _sling := sling.New().Get(a.basePath) + + // create path and map variables + path := "/v2/pet/findByStatus" + + _sling = _sling.Path(path) + + type QueryParams struct { + status []string `url:"status,omitempty"` + +} + _sling = _sling.QueryStruct(&QueryParams{ status: status }) + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + + + var successPayload = new([]Pet) + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(successPayload, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return *successPayload, err +} +/** + * Finds Pets by tags + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by + * @return []Pet + */ +//func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { +func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { + + _sling := sling.New().Get(a.basePath) + + // create path and map variables + path := "/v2/pet/findByTags" + + _sling = _sling.Path(path) + + type QueryParams struct { + tags []string `url:"tags,omitempty"` + +} + _sling = _sling.QueryStruct(&QueryParams{ tags: tags }) + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + + + var successPayload = new([]Pet) + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(successPayload, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return *successPayload, err +} +/** + * Find pet by ID + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return Pet + */ +//func (a PetApi) GetPetById (petId int64) (Pet, error) { +func (a PetApi) GetPetById (petId int64) (Pet, error) { + + _sling := sling.New().Get(a.basePath) + + // create path and map variables + path := "/v2/pet/{petId}" + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + + _sling = _sling.Path(path) + + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + + + var successPayload = new(Pet) + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(successPayload, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return *successPayload, err +} +/** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return InlineResponse200 + */ +//func (a PetApi) GetPetByIdInObject (petId int64) (InlineResponse200, error) { +func (a PetApi) GetPetByIdInObject (petId int64) (InlineResponse200, error) { + + _sling := sling.New().Get(a.basePath) + + // create path and map variables + path := "/v2/pet/{petId}?response=inline_arbitrary_object" + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + + _sling = _sling.Path(path) + + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + + + var successPayload = new(InlineResponse200) + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(successPayload, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return *successPayload, err +} +/** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return string + */ +//func (a PetApi) PetPetIdtestingByteArraytrueGet (petId int64) (string, error) { +func (a PetApi) PetPetIdtestingByteArraytrueGet (petId int64) (string, error) { + + _sling := sling.New().Get(a.basePath) + + // create path and map variables + path := "/v2/pet/{petId}?testing_byte_array=true" + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + + _sling = _sling.Path(path) + + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + + + var successPayload = new(string) + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(successPayload, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return *successPayload, err +} +/** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + * @return void + */ +//func (a PetApi) UpdatePet (body Pet) (error) { +func (a PetApi) UpdatePet (body Pet) (error) { _sling := sling.New().Put(a.basePath) @@ -47,163 +534,58 @@ func (a PetApi) UpdatePet (Body Pet) (error) { } // body params - _sling = _sling.BodyJSON(Body) + _sling = _sling.BodyJSON(body) - _, err := _sling.ReceiveSuccess(nil) - //fmt.Println("UpdatePet response: void, ", resp, err) - return err -} -/** - * Add a new pet to the store - * - * @param Body Pet object that needs to be added to the store - * @return void - */ -//func (a PetApi) AddPet (Body Pet) (error) { -func (a PetApi) AddPet (Body Pet) (error) { + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} - _sling := sling.New().Post(a.basePath) + httpResponse, err := _sling.Receive(nil, &failurePayload) - // create path and map variables - path := "/v2/pet" - - _sling = _sling.Path(path) - - // accept header - accepts := []string { "application/json", "application/xml" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } } + } -// body params - _sling = _sling.BodyJSON(Body) - - - - _, err := _sling.ReceiveSuccess(nil) - //fmt.Println("AddPet response: void, ", resp, err) - return err -} -/** - * Finds Pets by status - * Multiple status values can be provided with comma seperated strings - * @param Status Status values that need to be considered for filter - * @return []Pet - */ -//func (a PetApi) FindPetsByStatus (Status []string) ([]Pet, error) { -func (a PetApi) FindPetsByStatus (Status []string) ([]Pet, error) { - - _sling := sling.New().Get(a.basePath) - - // create path and map variables - path := "/v2/pet/findByStatus" - - _sling = _sling.Path(path) - - type QueryParams struct { - Status []string `url:"status,omitempty"` - -} - _sling = _sling.QueryStruct(&QueryParams{ Status: Status }) - // accept header - accepts := []string { "application/json", "application/xml" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept - } - - - - response := new([]Pet) - _, err := _sling.ReceiveSuccess(response) - //fmt.Println("FindPetsByStatus response: ", response, resp, err) - return *response, err -} -/** - * Finds Pets by tags - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * @param Tags Tags to filter by - * @return []Pet - */ -//func (a PetApi) FindPetsByTags (Tags []string) ([]Pet, error) { -func (a PetApi) FindPetsByTags (Tags []string) ([]Pet, error) { - - _sling := sling.New().Get(a.basePath) - - // create path and map variables - path := "/v2/pet/findByTags" - - _sling = _sling.Path(path) - - type QueryParams struct { - Tags []string `url:"tags,omitempty"` - -} - _sling = _sling.QueryStruct(&QueryParams{ Tags: Tags }) - // accept header - accepts := []string { "application/json", "application/xml" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept - } - - - - response := new([]Pet) - _, err := _sling.ReceiveSuccess(response) - //fmt.Println("FindPetsByTags response: ", response, resp, err) - return *response, err -} -/** - * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param PetId ID of pet that needs to be fetched - * @return Pet - */ -//func (a PetApi) GetPetById (PetId int64) (Pet, error) { -func (a PetApi) GetPetById (PetId int64) (Pet, error) { - - _sling := sling.New().Get(a.basePath) - - // create path and map variables - path := "/v2/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", PetId), -1) - - _sling = _sling.Path(path) - - // accept header - accepts := []string { "application/json", "application/xml" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept - } - - - - response := new(Pet) - _, err := _sling.ReceiveSuccess(response) - //fmt.Println("GetPetById response: ", response, resp, err) - return *response, err + return err } /** * Updates a pet in the store with form data * - * @param PetId ID of pet that needs to be updated - * @param Name Updated name of the pet - * @param Status Updated status of the pet + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet * @return void */ -//func (a PetApi) UpdatePetWithForm (PetId string, Name string, Status string) (error) { -func (a PetApi) UpdatePetWithForm (PetId string, Name string, Status string) (error) { +//func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (error) { +func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (error) { _sling := sling.New().Post(a.basePath) // create path and map variables path := "/v2/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", PetId), -1) + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) _sling = _sling.Path(path) @@ -215,96 +597,61 @@ func (a PetApi) UpdatePetWithForm (PetId string, Name string, Status string) (er } type FormParams struct { - Name string `url:"name,omitempty"` - Status string `url:"status,omitempty"` + name string `url:"name,omitempty"` + status string `url:"status,omitempty"` } - _sling = _sling.BodyForm(&FormParams{ Name: Name,Status: Status }) + _sling = _sling.BodyForm(&FormParams{ name: name,status: status }) - _, err := _sling.ReceiveSuccess(nil) - //fmt.Println("UpdatePetWithForm response: void, ", resp, err) - return err -} -/** - * Deletes a pet - * - * @param PetId Pet id to delete - * @param ApiKey - * @return void - */ -//func (a PetApi) DeletePet (PetId int64, ApiKey string) (error) { -func (a PetApi) DeletePet (PetId int64, ApiKey string) (error) { + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} - _sling := sling.New().Delete(a.basePath) + httpResponse, err := _sling.Receive(nil, &failurePayload) - // create path and map variables - path := "/v2/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", PetId), -1) - - _sling = _sling.Path(path) - - // accept header - accepts := []string { "application/json", "application/xml" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } } - // header params "api_key" - _sling = _sling.Set("api_key", ApiKey) + } - - - - _, err := _sling.ReceiveSuccess(nil) - //fmt.Println("DeletePet response: void, ", resp, err) - return err -} -/** - * downloads an image - * - * @return *os.File - */ -//func (a PetApi) DownloadFile () (*os.File, error) { -func (a PetApi) DownloadFile () (*os.File, error) { - - _sling := sling.New().Get(a.basePath) - - // create path and map variables - path := "/v2/pet/{petId}/downloadImage" - - _sling = _sling.Path(path) - - // accept header - accepts := []string { "application/octet-stream" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept - } - - - - response := new(*os.File) - _, err := _sling.ReceiveSuccess(response) - //fmt.Println("DownloadFile response: ", response, resp, err) - return *response, err + return err } /** * uploads an image * - * @param PetId ID of pet to update - * @param AdditionalMetadata Additional data to pass to server - * @param File file to upload + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload * @return void */ -//func (a PetApi) UploadFile (PetId int64, AdditionalMetadata string, File *os.File) (error) { -func (a PetApi) UploadFile (PetId int64, AdditionalMetadata string, File *os.File) (error) { +//func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (error) { +func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (error) { _sling := sling.New().Post(a.basePath) // create path and map variables path := "/v2/pet/{petId}/uploadImage" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", PetId), -1) + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) _sling = _sling.Path(path) @@ -316,14 +663,42 @@ func (a PetApi) UploadFile (PetId int64, AdditionalMetadata string, File *os.Fil } type FormParams struct { - AdditionalMetadata string `url:"additionalMetadata,omitempty"` - File *os.File `url:"file,omitempty"` + additionalMetadata string `url:"additionalMetadata,omitempty"` + file *os.File `url:"file,omitempty"` } - _sling = _sling.BodyForm(&FormParams{ AdditionalMetadata: AdditionalMetadata,File: File }) + _sling = _sling.BodyForm(&FormParams{ additionalMetadata: additionalMetadata,file: file }) - _, err := _sling.ReceiveSuccess(nil) - //fmt.Println("UploadFile response: void, ", resp, err) - return err + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(nil, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return err } diff --git a/samples/client/petstore/go/swagger/SpecialModelName.go b/samples/client/petstore/go/swagger/SpecialModelName.go new file mode 100644 index 00000000000..fcf30882303 --- /dev/null +++ b/samples/client/petstore/go/swagger/SpecialModelName.go @@ -0,0 +1,9 @@ +package swagger + +import ( +) + +type SpecialModelName struct { + $Special[propertyName] int64 `json:"$special[property.name],omitempty"` + +} diff --git a/samples/client/petstore/go/swagger/StoreApi.go b/samples/client/petstore/go/swagger/StoreApi.go index c43d320077c..b23c0f3d622 100644 --- a/samples/client/petstore/go/swagger/StoreApi.go +++ b/samples/client/petstore/go/swagger/StoreApi.go @@ -3,6 +3,8 @@ package swagger import ( "strings" "fmt" + "encoding/json" + "errors" "github.com/dghubble/sling" ) @@ -22,6 +24,128 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{ } } +/** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted + * @return void + */ +//func (a StoreApi) DeleteOrder (orderId string) (error) { +func (a StoreApi) DeleteOrder (orderId string) (error) { + + _sling := sling.New().Delete(a.basePath) + + // create path and map variables + path := "/v2/store/order/{orderId}" + path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + + _sling = _sling.Path(path) + + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + + + + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(nil, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return err +} +/** + * Finds orders by status + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query + * @return []Order + */ +//func (a StoreApi) FindOrdersByStatus (status string) ([]Order, error) { +func (a StoreApi) FindOrdersByStatus (status string) ([]Order, error) { + + _sling := sling.New().Get(a.basePath) + + // create path and map variables + path := "/v2/store/findByStatus" + + _sling = _sling.Path(path) + + type QueryParams struct { + status string `url:"status,omitempty"` + +} + _sling = _sling.QueryStruct(&QueryParams{ status: status }) + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + + + var successPayload = new([]Order) + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(successPayload, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return *successPayload, err +} /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -45,20 +169,164 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { } + var successPayload = new(map[string]int32) - response := new(map[string]int32) - _, err := _sling.ReceiveSuccess(response) - //fmt.Println("GetInventory response: ", response, resp, err) - return *response, err + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(successPayload, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return *successPayload, err +} +/** + * Fake endpoint to test arbitrary object return by 'Get inventory' + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Object + */ +//func (a StoreApi) GetInventoryInObject () (Object, error) { +func (a StoreApi) GetInventoryInObject () (Object, error) { + + _sling := sling.New().Get(a.basePath) + + // create path and map variables + path := "/v2/store/inventory?response=arbitrary_object" + + _sling = _sling.Path(path) + + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + + + var successPayload = new(Object) + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(successPayload, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return *successPayload, err +} +/** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param orderId ID of pet that needs to be fetched + * @return Order + */ +//func (a StoreApi) GetOrderById (orderId string) (Order, error) { +func (a StoreApi) GetOrderById (orderId string) (Order, error) { + + _sling := sling.New().Get(a.basePath) + + // create path and map variables + path := "/v2/store/order/{orderId}" + path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + + _sling = _sling.Path(path) + + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + + + var successPayload = new(Order) + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(successPayload, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return *successPayload, err } /** * Place an order for a pet * - * @param Body order placed for purchasing the pet + * @param body order placed for purchasing the pet * @return Order */ -//func (a StoreApi) PlaceOrder (Body Order) (Order, error) { -func (a StoreApi) PlaceOrder (Body Order) (Order, error) { +//func (a StoreApi) PlaceOrder (body Order) (Order, error) { +func (a StoreApi) PlaceOrder (body Order) (Order, error) { _sling := sling.New().Post(a.basePath) @@ -75,73 +343,39 @@ func (a StoreApi) PlaceOrder (Body Order) (Order, error) { } // body params - _sling = _sling.BodyJSON(Body) + _sling = _sling.BodyJSON(body) + var successPayload = new(Order) - response := new(Order) - _, err := _sling.ReceiveSuccess(response) - //fmt.Println("PlaceOrder response: ", response, resp, err) - return *response, err -} -/** - * Find purchase order by ID - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @param OrderId ID of pet that needs to be fetched - * @return Order - */ -//func (a StoreApi) GetOrderById (OrderId string) (Order, error) { -func (a StoreApi) GetOrderById (OrderId string) (Order, error) { + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} - _sling := sling.New().Get(a.basePath) + httpResponse, err := _sling.Receive(successPayload, &failurePayload) - // create path and map variables - path := "/v2/store/order/{orderId}" - path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", OrderId), -1) - - _sling = _sling.Path(path) - - // accept header - accepts := []string { "application/json", "application/xml" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } } + } - - - response := new(Order) - _, err := _sling.ReceiveSuccess(response) - //fmt.Println("GetOrderById response: ", response, resp, err) - return *response, err -} -/** - * Delete purchase order by ID - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @param OrderId ID of the order that needs to be deleted - * @return void - */ -//func (a StoreApi) DeleteOrder (OrderId string) (error) { -func (a StoreApi) DeleteOrder (OrderId string) (error) { - - _sling := sling.New().Delete(a.basePath) - - // create path and map variables - path := "/v2/store/order/{orderId}" - path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", OrderId), -1) - - _sling = _sling.Path(path) - - // accept header - accepts := []string { "application/json", "application/xml" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept - } - - - - - _, err := _sling.ReceiveSuccess(nil) - //fmt.Println("DeleteOrder response: void, ", resp, err) - return err + return *successPayload, err } diff --git a/samples/client/petstore/go/swagger/UserApi.go b/samples/client/petstore/go/swagger/UserApi.go index 9907453bd39..53aaf4c85ca 100644 --- a/samples/client/petstore/go/swagger/UserApi.go +++ b/samples/client/petstore/go/swagger/UserApi.go @@ -3,6 +3,8 @@ package swagger import ( "strings" "fmt" + "encoding/json" + "errors" "github.com/dghubble/sling" ) @@ -25,11 +27,11 @@ func NewUserApiWithBasePath(basePath string) *UserApi{ /** * Create user * This can only be done by the logged in user. - * @param Body Created user object + * @param body Created user object * @return void */ -//func (a UserApi) CreateUser (Body User) (error) { -func (a UserApi) CreateUser (Body User) (error) { +//func (a UserApi) CreateUser (body User) (error) { +func (a UserApi) CreateUser (body User) (error) { _sling := sling.New().Post(a.basePath) @@ -46,22 +48,50 @@ func (a UserApi) CreateUser (Body User) (error) { } // body params - _sling = _sling.BodyJSON(Body) + _sling = _sling.BodyJSON(body) - _, err := _sling.ReceiveSuccess(nil) - //fmt.Println("CreateUser response: void, ", resp, err) - return err + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(nil, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return err } /** * Creates list of users with given input array * - * @param Body List of user object + * @param body List of user object * @return void */ -//func (a UserApi) CreateUsersWithArrayInput (Body []User) (error) { -func (a UserApi) CreateUsersWithArrayInput (Body []User) (error) { +//func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { +func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { _sling := sling.New().Post(a.basePath) @@ -78,22 +108,50 @@ func (a UserApi) CreateUsersWithArrayInput (Body []User) (error) { } // body params - _sling = _sling.BodyJSON(Body) + _sling = _sling.BodyJSON(body) - _, err := _sling.ReceiveSuccess(nil) - //fmt.Println("CreateUsersWithArrayInput response: void, ", resp, err) - return err + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(nil, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return err } /** * Creates list of users with given input array * - * @param Body List of user object + * @param body List of user object * @return void */ -//func (a UserApi) CreateUsersWithListInput (Body []User) (error) { -func (a UserApi) CreateUsersWithListInput (Body []User) (error) { +//func (a UserApi) CreateUsersWithListInput (body []User) (error) { +func (a UserApi) CreateUsersWithListInput (body []User) (error) { _sling := sling.New().Post(a.basePath) @@ -110,37 +168,59 @@ func (a UserApi) CreateUsersWithListInput (Body []User) (error) { } // body params - _sling = _sling.BodyJSON(Body) + _sling = _sling.BodyJSON(body) - _, err := _sling.ReceiveSuccess(nil) - //fmt.Println("CreateUsersWithListInput response: void, ", resp, err) - return err + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(nil, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return err } /** - * Logs user into the system - * - * @param Username The user name for login - * @param Password The password for login in clear text - * @return string + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + * @return void */ -//func (a UserApi) LoginUser (Username string, Password string) (string, error) { -func (a UserApi) LoginUser (Username string, Password string) (string, error) { +//func (a UserApi) DeleteUser (username string) (error) { +func (a UserApi) DeleteUser (username string) (error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Delete(a.basePath) // create path and map variables - path := "/v2/user/login" + path := "/v2/user/{username}" + path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) _sling = _sling.Path(path) - type QueryParams struct { - Username string `url:"username,omitempty"` - Password string `url:"password,omitempty"` - -} - _sling = _sling.QueryStruct(&QueryParams{ Username: Username,Password: Password }) // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -150,10 +230,162 @@ func (a UserApi) LoginUser (Username string, Password string) (string, error) { - response := new(string) - _, err := _sling.ReceiveSuccess(response) - //fmt.Println("LoginUser response: ", response, resp, err) - return *response, err + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(nil, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return err +} +/** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + * @return User + */ +//func (a UserApi) GetUserByName (username string) (User, error) { +func (a UserApi) GetUserByName (username string) (User, error) { + + _sling := sling.New().Get(a.basePath) + + // create path and map variables + path := "/v2/user/{username}" + path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + + _sling = _sling.Path(path) + + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + + + var successPayload = new(User) + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(successPayload, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return *successPayload, err +} +/** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + * @return string + */ +//func (a UserApi) LoginUser (username string, password string) (string, error) { +func (a UserApi) LoginUser (username string, password string) (string, error) { + + _sling := sling.New().Get(a.basePath) + + // create path and map variables + path := "/v2/user/login" + + _sling = _sling.Path(path) + + type QueryParams struct { + username string `url:"username,omitempty"` + password string `url:"password,omitempty"` + +} + _sling = _sling.QueryStruct(&QueryParams{ username: username,password: password }) + // accept header + accepts := []string { "application/json", "application/xml" } + for key := range accepts { + _sling = _sling.Set("Accept", accepts[key]) + break // only use the first Accept + } + + + var successPayload = new(string) + + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} + + httpResponse, err := _sling.Receive(successPayload, &failurePayload) + + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } + } + } + + return *successPayload, err } /** * Logs out current logged in user session @@ -180,56 +412,53 @@ func (a UserApi) LogoutUser () (error) { - _, err := _sling.ReceiveSuccess(nil) - //fmt.Println("LogoutUser response: void, ", resp, err) - return err -} -/** - * Get user by user name - * - * @param Username The name that needs to be fetched. Use user1 for testing. - * @return User - */ -//func (a UserApi) GetUserByName (Username string) (User, error) { -func (a UserApi) GetUserByName (Username string) (User, error) { + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} - _sling := sling.New().Get(a.basePath) + httpResponse, err := _sling.Receive(nil, &failurePayload) - // create path and map variables - path := "/v2/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", Username), -1) - - _sling = _sling.Path(path) - - // accept header - accepts := []string { "application/json", "application/xml" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } } + } - - - response := new(User) - _, err := _sling.ReceiveSuccess(response) - //fmt.Println("GetUserByName response: ", response, resp, err) - return *response, err + return err } /** * Updated user * This can only be done by the logged in user. - * @param Username name that need to be deleted - * @param Body Updated user object + * @param username name that need to be deleted + * @param body Updated user object * @return void */ -//func (a UserApi) UpdateUser (Username string, Body User) (error) { -func (a UserApi) UpdateUser (Username string, Body User) (error) { +//func (a UserApi) UpdateUser (username string, body User) (error) { +func (a UserApi) UpdateUser (username string, body User) (error) { _sling := sling.New().Put(a.basePath) // create path and map variables path := "/v2/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", Username), -1) + path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) _sling = _sling.Path(path) @@ -241,42 +470,39 @@ func (a UserApi) UpdateUser (Username string, Body User) (error) { } // body params - _sling = _sling.BodyJSON(Body) + _sling = _sling.BodyJSON(body) - _, err := _sling.ReceiveSuccess(nil) - //fmt.Println("UpdateUser response: void, ", resp, err) - return err -} -/** - * Delete user - * This can only be done by the logged in user. - * @param Username The name that needs to be deleted - * @return void - */ -//func (a UserApi) DeleteUser (Username string) (error) { -func (a UserApi) DeleteUser (Username string) (error) { + // We use this map (below) so that any arbitrary error JSON can be handled. + // FIXME: This is in the absence of this Go generator honoring the non-2xx + // response (error) models, which needs to be implemented at some point. + var failurePayload map[string]interface{} - _sling := sling.New().Delete(a.basePath) + httpResponse, err := _sling.Receive(nil, &failurePayload) - // create path and map variables - path := "/v2/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", Username), -1) - - _sling = _sling.Path(path) - - // accept header - accepts := []string { "application/json", "application/xml" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + if err == nil { + // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) + if failurePayload != nil { + // If the failurePayload is present, there likely was some kind of non-2xx status + // returned (and a JSON payload error present) + var str []byte + str, err = json.Marshal(failurePayload) + if err == nil { // For safety, check for an error marshalling... probably superfluous + // This will return the JSON error body as a string + err = errors.New(string(str)) + } + } else { + // So, there was no network-type error, and nothing in the failure payload, + // but we should still check the status code + if httpResponse == nil { + // This should never happen... + err = errors.New("No HTTP Response received.") + } else if code := httpResponse.StatusCode; 200 > code || code > 299 { + err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) + } } + } - - - - _, err := _sling.ReceiveSuccess(nil) - //fmt.Println("DeleteUser response: void, ", resp, err) - return err + return err } diff --git a/samples/client/petstore/java/default/.gitignore b/samples/client/petstore/java/default/.gitignore new file mode 100644 index 00000000000..32858aad3c3 --- /dev/null +++ b/samples/client/petstore/java/default/.gitignore @@ -0,0 +1,12 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* diff --git a/samples/client/petstore/java/default/git_push.sh b/samples/client/petstore/java/default/git_push.sh new file mode 100644 index 00000000000..1a36388db02 --- /dev/null +++ b/samples/client/petstore/java/default/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="YOUR_GIT_USR_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="YOUR_GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java index 713e045bd71..916ad909680 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java index 2e435896b55..f87f88e4f8e 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java index 32b13ca33f0..69686ad2545 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java index 1664197f590..9d5225846de 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index f38204cff84..f6d6ae1b212 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -16,7 +16,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class PetApi { private ApiClient apiClient; @@ -294,7 +294,7 @@ public class PetApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "petstore_auth", "api_key" }; + String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; GenericType localVarReturnType = new GenericType() {}; @@ -342,7 +342,7 @@ public class PetApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "petstore_auth", "api_key" }; + String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; GenericType localVarReturnType = new GenericType() {}; @@ -390,7 +390,7 @@ public class PetApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "petstore_auth", "api_key" }; + String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; GenericType localVarReturnType = new GenericType() {}; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java index 37eb84d8922..482023831a4 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class StoreApi { private ApiClient apiClient; @@ -247,7 +247,7 @@ public class StoreApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "test_api_key_query", "test_api_key_header" }; + String[] localVarAuthNames = new String[] { "test_api_key_header", "test_api_key_query" }; GenericType localVarReturnType = new GenericType() {}; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java index 032250576f5..45f8deaae8c 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class UserApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index 3f6b03243d1..24864e6e904 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index d7223a76daa..97bd3c96e78 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -9,7 +9,7 @@ import java.util.List; import java.io.UnsupportedEncodingException; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java index 49804fcbb84..701eaa35059 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java index 7ff991f3647..3bb895461e8 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class Category { private Long id = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java index 02a1bbc0f74..cf2f2e8b4f7 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -13,14 +13,12 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class InlineResponse200 { - private List photoUrls = new ArrayList(); - private String name = null; + private List tags = new ArrayList(); private Long id = null; private Object category = null; - private List tags = new ArrayList(); public enum StatusEnum { @@ -42,39 +40,24 @@ public class InlineResponse200 { } private StatusEnum status = null; + private String name = null; + private List photoUrls = new ArrayList(); /** **/ - public InlineResponse200 photoUrls(List photoUrls) { - this.photoUrls = photoUrls; + public InlineResponse200 tags(List tags) { + this.tags = tags; return this; } @ApiModelProperty(example = "null", value = "") - @JsonProperty("photoUrls") - public List getPhotoUrls() { - return photoUrls; + @JsonProperty("tags") + public List getTags() { + return tags; } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - /** - **/ - public InlineResponse200 name(String name) { - this.name = name; - return this; - } - - @ApiModelProperty(example = "doggie", value = "") - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; + public void setTags(List tags) { + this.tags = tags; } @@ -112,23 +95,6 @@ public class InlineResponse200 { } - /** - **/ - public InlineResponse200 tags(List tags) { - this.tags = tags; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("tags") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - /** * pet status in the store **/ @@ -147,6 +113,40 @@ public class InlineResponse200 { } + /** + **/ + public InlineResponse200 name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(example = "doggie", value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + public InlineResponse200 photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("photoUrls") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + @Override public boolean equals(java.lang.Object o) { @@ -157,17 +157,17 @@ public class InlineResponse200 { return false; } InlineResponse200 inlineResponse200 = (InlineResponse200) o; - return Objects.equals(this.photoUrls, inlineResponse200.photoUrls) && - Objects.equals(this.name, inlineResponse200.name) && + return Objects.equals(this.tags, inlineResponse200.tags) && Objects.equals(this.id, inlineResponse200.id) && Objects.equals(this.category, inlineResponse200.category) && - Objects.equals(this.tags, inlineResponse200.tags) && - Objects.equals(this.status, inlineResponse200.status); + Objects.equals(this.status, inlineResponse200.status) && + Objects.equals(this.name, inlineResponse200.name) && + Objects.equals(this.photoUrls, inlineResponse200.photoUrls); } @Override public int hashCode() { - return Objects.hash(photoUrls, name, id, category, tags, status); + return Objects.hash(tags, id, category, status, name, photoUrls); } @Override @@ -175,12 +175,12 @@ public class InlineResponse200 { StringBuilder sb = new StringBuilder(); sb.append("class InlineResponse200 {\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ModelReturn.java index 1436abdfef6..a5376d98f45 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ModelReturn.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class ModelReturn { private Integer _return = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java index 827fdc5e43d..92e6263c62a 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class Name { private Integer name = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java index 9cd77ff064c..7c6d7ea7486 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class Order { private Long id = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java index 4660068b0f3..6149cfca76a 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java @@ -14,7 +14,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/SpecialModelName.java index 816f1f21d81..7d63da4c2f1 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class SpecialModelName { private Long specialPropertyName = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java index 86264e6cdfd..d870b658ca5 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java index 3a3e7aace66..fb441d1ebb8 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-10T11:48:21.307-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-12T17:08:42.639+08:00") public class User { private Long id = null; diff --git a/samples/client/petstore/javascript/git_push.sh b/samples/client/petstore/javascript/git_push.sh new file mode 100644 index 00000000000..1a36388db02 --- /dev/null +++ b/samples/client/petstore/javascript/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="YOUR_GIT_USR_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="YOUR_GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index ec15c154cac..dcc2442232d 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -22,12 +22,12 @@ this.basePath = 'http://petstore.swagger.io/v2'.replace(/\/+$/, ''); this.authentications = { - 'petstore_auth': {type: 'oauth2'}, - 'test_api_client_id': {type: 'apiKey', in: 'header', name: 'x-test_api_client_id'}, - 'test_api_client_secret': {type: 'apiKey', in: 'header', name: 'x-test_api_client_secret'}, + 'test_api_key_header': {type: 'apiKey', in: 'header', name: 'test_api_key_header'}, 'api_key': {type: 'apiKey', in: 'header', name: 'api_key'}, + 'test_api_client_secret': {type: 'apiKey', in: 'header', name: 'x-test_api_client_secret'}, + 'test_api_client_id': {type: 'apiKey', in: 'header', name: 'x-test_api_client_id'}, 'test_api_key_query': {type: 'apiKey', in: 'query', name: 'test_api_key_query'}, - 'test_api_key_header': {type: 'apiKey', in: 'header', name: 'test_api_key_header'} + 'petstore_auth': {type: 'oauth2'} }; /** diff --git a/samples/client/petstore/javascript/src/api/PetApi.js b/samples/client/petstore/javascript/src/api/PetApi.js index 5602b383da8..03893624c62 100644 --- a/samples/client/petstore/javascript/src/api/PetApi.js +++ b/samples/client/petstore/javascript/src/api/PetApi.js @@ -21,39 +21,6 @@ var self = this; - /** - * Update an existing pet - * - * @param {Pet} opts['body'] Pet object that needs to be added to the store - * @param {function} callback the callback function, accepting three arguments: error, data, response - */ - self.updatePet = function(opts, callback) { - opts = opts || {}; - var postBody = opts['body']; - - - var pathParams = { - }; - var queryParams = { - }; - var headerParams = { - }; - var formParams = { - }; - - var authNames = ['petstore_auth']; - var contentTypes = ['application/json', 'application/xml']; - var accepts = ['application/json', 'application/xml']; - var returnType = null; - - return this.apiClient.callApi( - '/pet', 'PUT', - pathParams, queryParams, headerParams, formParams, postBody, - authNames, contentTypes, accepts, returnType, callback - ); - - } - /** * Add a new pet to the store * @@ -87,6 +54,80 @@ } + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param {String} opts['body'] Pet object in the form of byte array + * @param {function} callback the callback function, accepting three arguments: error, data, response + */ + self.addPetUsingByteArray = function(opts, callback) { + opts = opts || {}; + var postBody = opts['body']; + + + var pathParams = { + }; + var queryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = ['petstore_auth']; + var contentTypes = ['application/json', 'application/xml']; + var accepts = ['application/json', 'application/xml']; + var returnType = null; + + return this.apiClient.callApi( + '/pet?testing_byte_array=true', 'POST', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + + } + + /** + * Deletes a pet + * + * @param {Integer} petId Pet id to delete + * @param {String} opts['apiKey'] + * @param {function} callback the callback function, accepting three arguments: error, data, response + */ + self.deletePet = function(petId, opts, callback) { + opts = opts || {}; + var postBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw "Missing the required parameter 'petId' when calling deletePet"; + } + + + var pathParams = { + 'petId': petId + }; + var queryParams = { + }; + var headerParams = { + 'api_key': opts['apiKey'] + }; + var formParams = { + }; + + var authNames = ['petstore_auth']; + var contentTypes = []; + var accepts = ['application/json', 'application/xml']; + var returnType = null; + + return this.apiClient.callApi( + '/pet/{petId}', 'DELETE', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + + } + /** * Finds Pets by status * Multiple status values can be provided with comma separated strings @@ -183,7 +224,7 @@ var formParams = { }; - var authNames = ['petstore_auth', 'api_key']; + var authNames = ['api_key', 'petstore_auth']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = Pet; @@ -196,6 +237,117 @@ } + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param {Integer} petId ID of pet that needs to be fetched + * @param {function} callback the callback function, accepting three arguments: error, data, response + * data is of type: InlineResponse200 + */ + self.getPetByIdInObject = function(petId, callback) { + var postBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw "Missing the required parameter 'petId' when calling getPetByIdInObject"; + } + + + var pathParams = { + 'petId': petId + }; + var queryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = ['api_key', 'petstore_auth']; + var contentTypes = []; + var accepts = ['application/json', 'application/xml']; + var returnType = InlineResponse200; + + return this.apiClient.callApi( + '/pet/{petId}?response=inline_arbitrary_object', 'GET', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + + } + + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param {Integer} petId ID of pet that needs to be fetched + * @param {function} callback the callback function, accepting three arguments: error, data, response + * data is of type: 'String' + */ + self.petPetIdtestingByteArraytrueGet = function(petId, callback) { + var postBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw "Missing the required parameter 'petId' when calling petPetIdtestingByteArraytrueGet"; + } + + + var pathParams = { + 'petId': petId + }; + var queryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = ['api_key', 'petstore_auth']; + var contentTypes = []; + var accepts = ['application/json', 'application/xml']; + var returnType = 'String'; + + return this.apiClient.callApi( + '/pet/{petId}?testing_byte_array=true', 'GET', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + + } + + /** + * Update an existing pet + * + * @param {Pet} opts['body'] Pet object that needs to be added to the store + * @param {function} callback the callback function, accepting three arguments: error, data, response + */ + self.updatePet = function(opts, callback) { + opts = opts || {}; + var postBody = opts['body']; + + + var pathParams = { + }; + var queryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = ['petstore_auth']; + var contentTypes = ['application/json', 'application/xml']; + var accepts = ['application/json', 'application/xml']; + var returnType = null; + + return this.apiClient.callApi( + '/pet', 'PUT', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + + } + /** * Updates a pet in the store with form data * @@ -239,47 +391,6 @@ } - /** - * Deletes a pet - * - * @param {Integer} petId Pet id to delete - * @param {String} opts['apiKey'] - * @param {function} callback the callback function, accepting three arguments: error, data, response - */ - self.deletePet = function(petId, opts, callback) { - opts = opts || {}; - var postBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { - throw "Missing the required parameter 'petId' when calling deletePet"; - } - - - var pathParams = { - 'petId': petId - }; - var queryParams = { - }; - var headerParams = { - 'api_key': opts['apiKey'] - }; - var formParams = { - }; - - var authNames = ['petstore_auth']; - var contentTypes = []; - var accepts = ['application/json', 'application/xml']; - var returnType = null; - - return this.apiClient.callApi( - '/pet/{petId}', 'DELETE', - pathParams, queryParams, headerParams, formParams, postBody, - authNames, contentTypes, accepts, returnType, callback - ); - - } - /** * uploads an image * @@ -323,117 +434,6 @@ } - /** - * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param {Integer} petId ID of pet that needs to be fetched - * @param {function} callback the callback function, accepting three arguments: error, data, response - * data is of type: InlineResponse200 - */ - self.getPetByIdInObject = function(petId, callback) { - var postBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { - throw "Missing the required parameter 'petId' when calling getPetByIdInObject"; - } - - - var pathParams = { - 'petId': petId - }; - var queryParams = { - }; - var headerParams = { - }; - var formParams = { - }; - - var authNames = ['petstore_auth', 'api_key']; - var contentTypes = []; - var accepts = ['application/json', 'application/xml']; - var returnType = InlineResponse200; - - return this.apiClient.callApi( - '/pet/{petId}?response=inline_arbitrary_object', 'GET', - pathParams, queryParams, headerParams, formParams, postBody, - authNames, contentTypes, accepts, returnType, callback - ); - - } - - /** - * Fake endpoint to test byte array return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param {Integer} petId ID of pet that needs to be fetched - * @param {function} callback the callback function, accepting three arguments: error, data, response - * data is of type: 'String' - */ - self.petPetIdtestingByteArraytrueGet = function(petId, callback) { - var postBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { - throw "Missing the required parameter 'petId' when calling petPetIdtestingByteArraytrueGet"; - } - - - var pathParams = { - 'petId': petId - }; - var queryParams = { - }; - var headerParams = { - }; - var formParams = { - }; - - var authNames = ['petstore_auth', 'api_key']; - var contentTypes = []; - var accepts = ['application/json', 'application/xml']; - var returnType = 'String'; - - return this.apiClient.callApi( - '/pet/{petId}?testing_byte_array=true', 'GET', - pathParams, queryParams, headerParams, formParams, postBody, - authNames, contentTypes, accepts, returnType, callback - ); - - } - - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store - * - * @param {String} opts['body'] Pet object in the form of byte array - * @param {function} callback the callback function, accepting three arguments: error, data, response - */ - self.addPetUsingByteArray = function(opts, callback) { - opts = opts || {}; - var postBody = opts['body']; - - - var pathParams = { - }; - var queryParams = { - }; - var headerParams = { - }; - var formParams = { - }; - - var authNames = ['petstore_auth']; - var contentTypes = ['application/json', 'application/xml']; - var accepts = ['application/json', 'application/xml']; - var returnType = null; - - return this.apiClient.callApi( - '/pet?testing_byte_array=true', 'POST', - pathParams, queryParams, headerParams, formParams, postBody, - authNames, contentTypes, accepts, returnType, callback - ); - - } - }; diff --git a/samples/client/petstore/javascript/src/api/StoreApi.js b/samples/client/petstore/javascript/src/api/StoreApi.js index a1e99293f8d..373ae6f076f 100644 --- a/samples/client/petstore/javascript/src/api/StoreApi.js +++ b/samples/client/petstore/javascript/src/api/StoreApi.js @@ -21,6 +21,44 @@ var self = this; + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param {String} orderId ID of the order that needs to be deleted + * @param {function} callback the callback function, accepting three arguments: error, data, response + */ + self.deleteOrder = function(orderId, callback) { + var postBody = null; + + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw "Missing the required parameter 'orderId' when calling deleteOrder"; + } + + + var pathParams = { + 'orderId': orderId + }; + var queryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = []; + var contentTypes = []; + var accepts = ['application/json', 'application/xml']; + var returnType = null; + + return this.apiClient.callApi( + '/store/order/{orderId}', 'DELETE', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + + } + /** * Finds orders by status * A single status value can be provided as a string @@ -120,6 +158,45 @@ } + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param {String} orderId ID of pet that needs to be fetched + * @param {function} callback the callback function, accepting three arguments: error, data, response + * data is of type: Order + */ + self.getOrderById = function(orderId, callback) { + var postBody = null; + + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw "Missing the required parameter 'orderId' when calling getOrderById"; + } + + + var pathParams = { + 'orderId': orderId + }; + var queryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = ['test_api_key_header', 'test_api_key_query']; + var contentTypes = []; + var accepts = ['application/json', 'application/xml']; + var returnType = Order; + + return this.apiClient.callApi( + '/store/order/{orderId}', 'GET', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + + } + /** * Place an order for a pet * @@ -154,83 +231,6 @@ } - /** - * Find purchase order by ID - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @param {String} orderId ID of pet that needs to be fetched - * @param {function} callback the callback function, accepting three arguments: error, data, response - * data is of type: Order - */ - self.getOrderById = function(orderId, callback) { - var postBody = null; - - // verify the required parameter 'orderId' is set - if (orderId == null) { - throw "Missing the required parameter 'orderId' when calling getOrderById"; - } - - - var pathParams = { - 'orderId': orderId - }; - var queryParams = { - }; - var headerParams = { - }; - var formParams = { - }; - - var authNames = ['test_api_key_query', 'test_api_key_header']; - var contentTypes = []; - var accepts = ['application/json', 'application/xml']; - var returnType = Order; - - return this.apiClient.callApi( - '/store/order/{orderId}', 'GET', - pathParams, queryParams, headerParams, formParams, postBody, - authNames, contentTypes, accepts, returnType, callback - ); - - } - - /** - * Delete purchase order by ID - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @param {String} orderId ID of the order that needs to be deleted - * @param {function} callback the callback function, accepting three arguments: error, data, response - */ - self.deleteOrder = function(orderId, callback) { - var postBody = null; - - // verify the required parameter 'orderId' is set - if (orderId == null) { - throw "Missing the required parameter 'orderId' when calling deleteOrder"; - } - - - var pathParams = { - 'orderId': orderId - }; - var queryParams = { - }; - var headerParams = { - }; - var formParams = { - }; - - var authNames = []; - var contentTypes = []; - var accepts = ['application/json', 'application/xml']; - var returnType = null; - - return this.apiClient.callApi( - '/store/order/{orderId}', 'DELETE', - pathParams, queryParams, headerParams, formParams, postBody, - authNames, contentTypes, accepts, returnType, callback - ); - - } - }; diff --git a/samples/client/petstore/javascript/src/api/UserApi.js b/samples/client/petstore/javascript/src/api/UserApi.js index 4886330d3d6..0a185ab71ae 100644 --- a/samples/client/petstore/javascript/src/api/UserApi.js +++ b/samples/client/petstore/javascript/src/api/UserApi.js @@ -120,6 +120,83 @@ } + /** + * Delete user + * This can only be done by the logged in user. + * @param {String} username The name that needs to be deleted + * @param {function} callback the callback function, accepting three arguments: error, data, response + */ + self.deleteUser = function(username, callback) { + var postBody = null; + + // verify the required parameter 'username' is set + if (username == null) { + throw "Missing the required parameter 'username' when calling deleteUser"; + } + + + var pathParams = { + 'username': username + }; + var queryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = []; + var contentTypes = []; + var accepts = ['application/json', 'application/xml']; + var returnType = null; + + return this.apiClient.callApi( + '/user/{username}', 'DELETE', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + + } + + /** + * Get user by user name + * + * @param {String} username The name that needs to be fetched. Use user1 for testing. + * @param {function} callback the callback function, accepting three arguments: error, data, response + * data is of type: User + */ + self.getUserByName = function(username, callback) { + var postBody = null; + + // verify the required parameter 'username' is set + if (username == null) { + throw "Missing the required parameter 'username' when calling getUserByName"; + } + + + var pathParams = { + 'username': username + }; + var queryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = []; + var contentTypes = []; + var accepts = ['application/json', 'application/xml']; + var returnType = User; + + return this.apiClient.callApi( + '/user/{username}', 'GET', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + + } + /** * Logs user into the system * @@ -188,45 +265,6 @@ } - /** - * Get user by user name - * - * @param {String} username The name that needs to be fetched. Use user1 for testing. - * @param {function} callback the callback function, accepting three arguments: error, data, response - * data is of type: User - */ - self.getUserByName = function(username, callback) { - var postBody = null; - - // verify the required parameter 'username' is set - if (username == null) { - throw "Missing the required parameter 'username' when calling getUserByName"; - } - - - var pathParams = { - 'username': username - }; - var queryParams = { - }; - var headerParams = { - }; - var formParams = { - }; - - var authNames = []; - var contentTypes = []; - var accepts = ['application/json', 'application/xml']; - var returnType = User; - - return this.apiClient.callApi( - '/user/{username}', 'GET', - pathParams, queryParams, headerParams, formParams, postBody, - authNames, contentTypes, accepts, returnType, callback - ); - - } - /** * Updated user * This can only be done by the logged in user. @@ -267,44 +305,6 @@ } - /** - * Delete user - * This can only be done by the logged in user. - * @param {String} username The name that needs to be deleted - * @param {function} callback the callback function, accepting three arguments: error, data, response - */ - self.deleteUser = function(username, callback) { - var postBody = null; - - // verify the required parameter 'username' is set - if (username == null) { - throw "Missing the required parameter 'username' when calling deleteUser"; - } - - - var pathParams = { - 'username': username - }; - var queryParams = { - }; - var headerParams = { - }; - var formParams = { - }; - - var authNames = []; - var contentTypes = []; - var accepts = ['application/json', 'application/xml']; - var returnType = null; - - return this.apiClient.callApi( - '/user/{username}', 'DELETE', - pathParams, queryParams, headerParams, formParams, postBody, - authNames, contentTypes, accepts, returnType, callback - ); - - } - }; diff --git a/samples/client/petstore/javascript/src/index.js b/samples/client/petstore/javascript/src/index.js index 6c57bd53ded..35f454d85e4 100644 --- a/samples/client/petstore/javascript/src/index.js +++ b/samples/client/petstore/javascript/src/index.js @@ -1,26 +1,27 @@ (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['./ApiClient', './model/Order', './model/SpecialModelName', './model/User', './model/Category', './model/ObjectReturn', './model/InlineResponse200', './model/Tag', './model/Pet', './api/UserApi', './api/StoreApi', './api/PetApi'], factory); + define(['./ApiClient', './model/Category', './model/InlineResponse200', './model/ModelReturn', './model/Name', './model/Order', './model/Pet', './model/SpecialModelName', './model/Tag', './model/User', './api/PetApi', './api/StoreApi', './api/UserApi'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('./ApiClient'), require('./model/Order'), require('./model/SpecialModelName'), require('./model/User'), require('./model/Category'), require('./model/ObjectReturn'), require('./model/InlineResponse200'), require('./model/Tag'), require('./model/Pet'), require('./api/UserApi'), require('./api/StoreApi'), require('./api/PetApi')); + module.exports = factory(require('./ApiClient'), require('./model/Category'), require('./model/InlineResponse200'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); } -}(function(ApiClient, Order, SpecialModelName, User, Category, ObjectReturn, InlineResponse200, Tag, Pet, UserApi, StoreApi, PetApi) { +}(function(ApiClient, Category, InlineResponse200, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, PetApi, StoreApi, UserApi) { 'use strict'; return { ApiClient: ApiClient, - Order: Order, - SpecialModelName: SpecialModelName, - User: User, Category: Category, - ObjectReturn: ObjectReturn, InlineResponse200: InlineResponse200, - Tag: Tag, + ModelReturn: ModelReturn, + Name: Name, + Order: Order, Pet: Pet, - UserApi: UserApi, + SpecialModelName: SpecialModelName, + Tag: Tag, + User: User, + PetApi: PetApi, StoreApi: StoreApi, - PetApi: PetApi + UserApi: UserApi }; })); diff --git a/samples/client/petstore/javascript/src/model/InlineResponse200.js b/samples/client/petstore/javascript/src/model/InlineResponse200.js index 2afc6996266..99bb688ebef 100644 --- a/samples/client/petstore/javascript/src/model/InlineResponse200.js +++ b/samples/client/petstore/javascript/src/model/InlineResponse200.js @@ -31,12 +31,8 @@ } var _this = new InlineResponse200(); - if (data['photoUrls']) { - _this['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']); - } - - if (data['name']) { - _this['name'] = ApiClient.convertToType(data['name'], 'String'); + if (data['tags']) { + _this['tags'] = ApiClient.convertToType(data['tags'], [Tag]); } if (data['id']) { @@ -47,45 +43,35 @@ _this['category'] = ApiClient.convertToType(data['category'], Object); } - if (data['tags']) { - _this['tags'] = ApiClient.convertToType(data['tags'], [Tag]); - } - if (data['status']) { _this['status'] = ApiClient.convertToType(data['status'], 'String'); } + if (data['name']) { + _this['name'] = ApiClient.convertToType(data['name'], 'String'); + } + + if (data['photoUrls']) { + _this['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']); + } + return _this; } /** - * @return {[String]} + * @return {[Tag]} **/ - InlineResponse200.prototype.getPhotoUrls = function() { - return this['photoUrls']; + InlineResponse200.prototype.getTags = function() { + return this['tags']; } /** - * @param {[String]} photoUrls + * @param {[Tag]} tags **/ - InlineResponse200.prototype.setPhotoUrls = function(photoUrls) { - this['photoUrls'] = photoUrls; - } - - /** - * @return {String} - **/ - InlineResponse200.prototype.getName = function() { - return this['name']; - } - - /** - * @param {String} name - **/ - InlineResponse200.prototype.setName = function(name) { - this['name'] = name; + InlineResponse200.prototype.setTags = function(tags) { + this['tags'] = tags; } /** @@ -116,20 +102,6 @@ this['category'] = category; } - /** - * @return {[Tag]} - **/ - InlineResponse200.prototype.getTags = function() { - return this['tags']; - } - - /** - * @param {[Tag]} tags - **/ - InlineResponse200.prototype.setTags = function(tags) { - this['tags'] = tags; - } - /** * get pet status in the store * @return {StatusEnum} @@ -146,6 +118,34 @@ this['status'] = status; } + /** + * @return {String} + **/ + InlineResponse200.prototype.getName = function() { + return this['name']; + } + + /** + * @param {String} name + **/ + InlineResponse200.prototype.setName = function(name) { + this['name'] = name; + } + + /** + * @return {[String]} + **/ + InlineResponse200.prototype.getPhotoUrls = function() { + return this['photoUrls']; + } + + /** + * @param {[String]} photoUrls + **/ + InlineResponse200.prototype.setPhotoUrls = function(photoUrls) { + this['photoUrls'] = photoUrls; + } + var StatusEnum = { diff --git a/samples/client/petstore/javascript/src/model/ModelReturn.js b/samples/client/petstore/javascript/src/model/ModelReturn.js new file mode 100644 index 00000000000..e93e4de28f6 --- /dev/null +++ b/samples/client/petstore/javascript/src/model/ModelReturn.js @@ -0,0 +1,59 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['../ApiClient'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.ModelReturn = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + var ModelReturn = function ModelReturn() { + + }; + + ModelReturn.constructFromObject = function(data) { + if (!data) { + return null; + } + var _this = new ModelReturn(); + + if (data['return']) { + _this['return'] = ApiClient.convertToType(data['return'], 'Integer'); + } + + return _this; + } + + + + /** + * @return {Integer} + **/ + ModelReturn.prototype.getReturn = function() { + return this['return']; + } + + /** + * @param {Integer} _return + **/ + ModelReturn.prototype.setReturn = function(_return) { + this['return'] = _return; + } + + + + + + return ModelReturn; + + +})); diff --git a/samples/client/petstore/javascript/src/model/Name.js b/samples/client/petstore/javascript/src/model/Name.js new file mode 100644 index 00000000000..8367c1b1e62 --- /dev/null +++ b/samples/client/petstore/javascript/src/model/Name.js @@ -0,0 +1,59 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['../ApiClient'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.Name = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + var Name = function Name() { + + }; + + Name.constructFromObject = function(data) { + if (!data) { + return null; + } + var _this = new Name(); + + if (data['name']) { + _this['name'] = ApiClient.convertToType(data['name'], 'Integer'); + } + + return _this; + } + + + + /** + * @return {Integer} + **/ + Name.prototype.getName = function() { + return this['name']; + } + + /** + * @param {Integer} name + **/ + Name.prototype.setName = function(name) { + this['name'] = name; + } + + + + + + return Name; + + +})); diff --git a/samples/client/petstore/objc/.gitignore b/samples/client/petstore/objc/.gitignore new file mode 100644 index 00000000000..79d9331b6d4 --- /dev/null +++ b/samples/client/petstore/objc/.gitignore @@ -0,0 +1,53 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md + +fastlane/report.xml +fastlane/screenshots diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h index f4009bbc408..8a98d52c1a9 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h @@ -12,14 +12,15 @@ * Do not edit the class manually. */ -#import "SWGUser.h" #import "SWGCategory.h" -#import "SWGPet.h" -#import "SWGTag.h" -#import "SWGReturn.h" -#import "SWGOrder.h" -#import "SWGSpecialModelName_.h" #import "SWGInlineResponse200.h" +#import "SWGName.h" +#import "SWGOrder.h" +#import "SWGPet.h" +#import "SWGReturn.h" +#import "SWGSpecialModelName_.h" +#import "SWGTag.h" +#import "SWGUser.h" @class SWGConfiguration; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h index 74860956be9..aeb69eafa69 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h @@ -7,6 +7,7 @@ * Do not edit the class manually. */ +#import "SWGTag.h" @protocol SWGInlineResponse200 @@ -15,10 +16,17 @@ @interface SWGInlineResponse200 : SWGObject +@property(nonatomic) NSArray* tags; + @property(nonatomic) NSNumber* _id; @property(nonatomic) NSObject* category; +/* pet status in the store [optional] + */ +@property(nonatomic) NSString* status; @property(nonatomic) NSString* name; +@property(nonatomic) NSArray* /* NSString */ photoUrls; + @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m index 9f332e31a15..5ac2e7b4057 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m @@ -20,7 +20,7 @@ */ + (JSONKeyMapper *)keyMapper { - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"category": @"category", @"name": @"name" }]; + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"tags": @"tags", @"id": @"_id", @"category": @"category", @"status": @"status", @"name": @"name", @"photoUrls": @"photoUrls" }]; } /** @@ -30,7 +30,7 @@ */ + (BOOL)propertyIsOptional:(NSString *)propertyName { - NSArray *optionalProperties = @[@"category", @"name"]; + NSArray *optionalProperties = @[@"tags", @"category", @"status", @"name", @"photoUrls"]; if ([optionalProperties containsObject:propertyName]) { return YES; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGName.h b/samples/client/petstore/objc/SwaggerClient/SWGName.h new file mode 100644 index 00000000000..5d390761827 --- /dev/null +++ b/samples/client/petstore/objc/SwaggerClient/SWGName.h @@ -0,0 +1,20 @@ +#import +#import "SWGObject.h" + +/** + * 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. + */ + + + +@protocol SWGName +@end + +@interface SWGName : SWGObject + + +@property(nonatomic) NSNumber* name; + +@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGName.m b/samples/client/petstore/objc/SwaggerClient/SWGName.m new file mode 100644 index 00000000000..849e7f0d3f4 --- /dev/null +++ b/samples/client/petstore/objc/SwaggerClient/SWGName.m @@ -0,0 +1,51 @@ +#import "SWGName.h" + +@implementation SWGName + +- (instancetype)init { + self = [super init]; + + if (self) { + // initalise property's default value, if any + + } + + return self; +} + + +/** + * Maps json key to property name. + * This method is used by `JSONModel`. + */ ++ (JSONKeyMapper *)keyMapper +{ + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"name": @"name" }]; +} + +/** + * Indicates whether the property with the given name is optional. + * If `propertyName` is optional, then return `YES`, otherwise return `NO`. + * This method is used by `JSONModel`. + */ ++ (BOOL)propertyIsOptional:(NSString *)propertyName +{ + NSArray *optionalProperties = @[@"name"]; + + if ([optionalProperties containsObject:propertyName]) { + return YES; + } + else { + return NO; + } +} + +/** + * Gets the string presentation of the object. + * This method will be called when logging model object using `NSLog`. + */ +- (NSString *)description { + return [[self toDictionary] description]; +} + +@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h index 76bcd3524d9..1142ff5311f 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h @@ -20,19 +20,6 @@ -(unsigned long) requestQueueSize; +(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; +(SWGPetApi*) sharedAPI; -/// -/// -/// Update an existing pet -/// -/// -/// @param body Pet object that needs to be added to the store -/// -/// -/// @return --(NSNumber*) updatePetWithBody: (SWGPet*) body - completionHandler: (void (^)(NSError* error)) handler; - - /// /// /// Add a new pet to the store @@ -46,6 +33,34 @@ completionHandler: (void (^)(NSError* error)) handler; +/// +/// +/// Fake endpoint to test byte array in body parameter for adding a new pet to the store +/// +/// +/// @param body Pet object in the form of byte array +/// +/// +/// @return +-(NSNumber*) addPetUsingByteArrayWithBody: (NSString*) body + completionHandler: (void (^)(NSError* error)) handler; + + +/// +/// +/// Deletes a pet +/// +/// +/// @param petId Pet id to delete +/// @param apiKey +/// +/// +/// @return +-(NSNumber*) deletePetWithPetId: (NSNumber*) petId + apiKey: (NSString*) apiKey + completionHandler: (void (^)(NSError* error)) handler; + + /// /// /// Finds Pets by status @@ -85,55 +100,6 @@ completionHandler: (void (^)(SWGPet* output, NSError* error)) handler; -/// -/// -/// Updates a pet in the store with form data -/// -/// -/// @param petId ID of pet that needs to be updated -/// @param name Updated name of the pet -/// @param status Updated status of the pet -/// -/// -/// @return --(NSNumber*) updatePetWithFormWithPetId: (NSString*) petId - name: (NSString*) name - status: (NSString*) status - completionHandler: (void (^)(NSError* error)) handler; - - -/// -/// -/// Deletes a pet -/// -/// -/// @param petId Pet id to delete -/// @param apiKey -/// -/// -/// @return --(NSNumber*) deletePetWithPetId: (NSNumber*) petId - apiKey: (NSString*) apiKey - completionHandler: (void (^)(NSError* error)) handler; - - -/// -/// -/// uploads an image -/// -/// -/// @param petId ID of pet to update -/// @param additionalMetadata Additional data to pass to server -/// @param file file to upload -/// -/// -/// @return --(NSNumber*) uploadFileWithPetId: (NSNumber*) petId - additionalMetadata: (NSString*) additionalMetadata - file: (NSURL*) file - completionHandler: (void (^)(NSError* error)) handler; - - /// /// /// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' @@ -162,14 +128,48 @@ /// /// -/// Fake endpoint to test byte array in body parameter for adding a new pet to the store +/// Update an existing pet /// /// -/// @param body Pet object in the form of byte array +/// @param body Pet object that needs to be added to the store /// /// /// @return --(NSNumber*) addPetUsingByteArrayWithBody: (NSString*) body +-(NSNumber*) updatePetWithBody: (SWGPet*) body + completionHandler: (void (^)(NSError* error)) handler; + + +/// +/// +/// Updates a pet in the store with form data +/// +/// +/// @param petId ID of pet that needs to be updated +/// @param name Updated name of the pet +/// @param status Updated status of the pet +/// +/// +/// @return +-(NSNumber*) updatePetWithFormWithPetId: (NSString*) petId + name: (NSString*) name + status: (NSString*) status + completionHandler: (void (^)(NSError* error)) handler; + + +/// +/// +/// uploads an image +/// +/// +/// @param petId ID of pet to update +/// @param additionalMetadata Additional data to pass to server +/// @param file file to upload +/// +/// +/// @return +-(NSNumber*) uploadFileWithPetId: (NSNumber*) petId + additionalMetadata: (NSString*) additionalMetadata + file: (NSURL*) file completionHandler: (void (^)(NSError* error)) handler; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m index 717ca6b7b22..41c54dc2973 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m @@ -70,81 +70,6 @@ static SWGPetApi* singletonAPI = nil; #pragma mark - Api Methods -/// -/// Update an existing pet -/// -/// @param body Pet object that needs to be added to the store -/// -/// @returns void -/// --(NSNumber*) updatePetWithBody: (SWGPet*) body - completionHandler: (void (^)(NSError* error)) handler { - - - - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; - - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - bodyParam = body; - - - - return [self.apiClient requestWithPath: resourcePath - method: @"PUT" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: nil - completionBlock: ^(id data, NSError *error) { - handler(error); - } - ]; -} - /// /// Add a new pet to the store /// @@ -220,6 +145,170 @@ static SWGPetApi* singletonAPI = nil; ]; } +/// +/// Fake endpoint to test byte array in body parameter for adding a new pet to the store +/// +/// @param body Pet object in the form of byte array +/// +/// @returns void +/// +-(NSNumber*) addPetUsingByteArrayWithBody: (NSString*) body + completionHandler: (void (^)(NSError* error)) handler { + + + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet?testing_byte_array=true"]; + + // remove format in URL if needed + if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { + [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; + } + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { + [headerParams removeObjectForKey:@"Accept"]; + } + + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { + responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; + } + else { + responseContentType = @""; + } + + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; + + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + + bodyParam = body; + + + + return [self.apiClient requestWithPath: resourcePath + method: @"POST" + pathParams: pathParams + queryParams: queryParams + formParams: formParams + files: localVarFiles + body: bodyParam + headerParams: headerParams + authSettings: authSettings + requestContentType: requestContentType + responseContentType: responseContentType + responseType: nil + completionBlock: ^(id data, NSError *error) { + handler(error); + } + ]; +} + +/// +/// Deletes a pet +/// +/// @param petId Pet id to delete +/// +/// @param apiKey +/// +/// @returns void +/// +-(NSNumber*) deletePetWithPetId: (NSNumber*) petId + apiKey: (NSString*) apiKey + completionHandler: (void (^)(NSError* error)) handler { + + + // verify the required parameter 'petId' is set + if (petId == nil) { + [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `deletePet`"]; + } + + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}"]; + + // remove format in URL if needed + if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { + [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; + } + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } + + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + + if (apiKey != nil) { + headerParams[@"api_key"] = apiKey; + } + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { + [headerParams removeObjectForKey:@"Accept"]; + } + + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { + responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; + } + else { + responseContentType = @""; + } + + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + + + + + + return [self.apiClient requestWithPath: resourcePath + method: @"DELETE" + pathParams: pathParams + queryParams: queryParams + formParams: formParams + files: localVarFiles + body: bodyParam + headerParams: headerParams + authSettings: authSettings + requestContentType: requestContentType + responseContentType: responseContentType + responseType: nil + completionBlock: ^(id data, NSError *error) { + handler(error); + } + ]; +} + /// /// Finds Pets by status /// Multiple status values can be provided with comma separated strings @@ -465,295 +554,6 @@ static SWGPetApi* singletonAPI = nil; ]; } -/// -/// Updates a pet in the store with form data -/// -/// @param petId ID of pet that needs to be updated -/// -/// @param name Updated name of the pet -/// -/// @param status Updated status of the pet -/// -/// @returns void -/// --(NSNumber*) updatePetWithFormWithPetId: (NSString*) petId - name: (NSString*) name - status: (NSString*) status - completionHandler: (void (^)(NSError* error)) handler { - - - // verify the required parameter 'petId' is set - if (petId == nil) { - [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `updatePetWithForm`"]; - } - - - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - if (petId != nil) { - pathParams[@"petId"] = petId; - } - - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/x-www-form-urlencoded"]]; - - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - - - if (name) { - formParams[@"name"] = name; - } - - - - if (status) { - formParams[@"status"] = status; - } - - - - - - return [self.apiClient requestWithPath: resourcePath - method: @"POST" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: nil - completionBlock: ^(id data, NSError *error) { - handler(error); - } - ]; -} - -/// -/// Deletes a pet -/// -/// @param petId Pet id to delete -/// -/// @param apiKey -/// -/// @returns void -/// --(NSNumber*) deletePetWithPetId: (NSNumber*) petId - apiKey: (NSString*) apiKey - completionHandler: (void (^)(NSError* error)) handler { - - - // verify the required parameter 'petId' is set - if (petId == nil) { - [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `deletePet`"]; - } - - - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - if (petId != nil) { - pathParams[@"petId"] = petId; - } - - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - if (apiKey != nil) { - headerParams[@"api_key"] = apiKey; - } - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - - - - - return [self.apiClient requestWithPath: resourcePath - method: @"DELETE" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: nil - completionBlock: ^(id data, NSError *error) { - handler(error); - } - ]; -} - -/// -/// uploads an image -/// -/// @param petId ID of pet to update -/// -/// @param additionalMetadata Additional data to pass to server -/// -/// @param file file to upload -/// -/// @returns void -/// --(NSNumber*) uploadFileWithPetId: (NSNumber*) petId - additionalMetadata: (NSString*) additionalMetadata - file: (NSURL*) file - completionHandler: (void (^)(NSError* error)) handler { - - - // verify the required parameter 'petId' is set - if (petId == nil) { - [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `uploadFile`"]; - } - - - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}/uploadImage"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - if (petId != nil) { - pathParams[@"petId"] = petId; - } - - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"multipart/form-data"]]; - - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - - - if (additionalMetadata) { - formParams[@"additionalMetadata"] = additionalMetadata; - } - - - - localVarFiles[@"file"] = file; - - - - - - return [self.apiClient requestWithPath: resourcePath - method: @"POST" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: nil - completionBlock: ^(id data, NSError *error) { - handler(error); - } - ]; -} - /// /// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions @@ -921,18 +721,18 @@ static SWGPetApi* singletonAPI = nil; } /// -/// Fake endpoint to test byte array in body parameter for adding a new pet to the store +/// Update an existing pet /// -/// @param body Pet object in the form of byte array +/// @param body Pet object that needs to be added to the store /// /// @returns void /// --(NSNumber*) addPetUsingByteArrayWithBody: (NSString*) body +-(NSNumber*) updatePetWithBody: (SWGPet*) body completionHandler: (void (^)(NSError* error)) handler { - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet?testing_byte_array=true"]; + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet"]; // remove format in URL if needed if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { @@ -977,6 +777,206 @@ static SWGPetApi* singletonAPI = nil; + return [self.apiClient requestWithPath: resourcePath + method: @"PUT" + pathParams: pathParams + queryParams: queryParams + formParams: formParams + files: localVarFiles + body: bodyParam + headerParams: headerParams + authSettings: authSettings + requestContentType: requestContentType + responseContentType: responseContentType + responseType: nil + completionBlock: ^(id data, NSError *error) { + handler(error); + } + ]; +} + +/// +/// Updates a pet in the store with form data +/// +/// @param petId ID of pet that needs to be updated +/// +/// @param name Updated name of the pet +/// +/// @param status Updated status of the pet +/// +/// @returns void +/// +-(NSNumber*) updatePetWithFormWithPetId: (NSString*) petId + name: (NSString*) name + status: (NSString*) status + completionHandler: (void (^)(NSError* error)) handler { + + + // verify the required parameter 'petId' is set + if (petId == nil) { + [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `updatePetWithForm`"]; + } + + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}"]; + + // remove format in URL if needed + if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { + [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; + } + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } + + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { + [headerParams removeObjectForKey:@"Accept"]; + } + + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { + responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; + } + else { + responseContentType = @""; + } + + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/x-www-form-urlencoded"]]; + + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + + + + if (name) { + formParams[@"name"] = name; + } + + + + if (status) { + formParams[@"status"] = status; + } + + + + + + return [self.apiClient requestWithPath: resourcePath + method: @"POST" + pathParams: pathParams + queryParams: queryParams + formParams: formParams + files: localVarFiles + body: bodyParam + headerParams: headerParams + authSettings: authSettings + requestContentType: requestContentType + responseContentType: responseContentType + responseType: nil + completionBlock: ^(id data, NSError *error) { + handler(error); + } + ]; +} + +/// +/// uploads an image +/// +/// @param petId ID of pet to update +/// +/// @param additionalMetadata Additional data to pass to server +/// +/// @param file file to upload +/// +/// @returns void +/// +-(NSNumber*) uploadFileWithPetId: (NSNumber*) petId + additionalMetadata: (NSString*) additionalMetadata + file: (NSURL*) file + completionHandler: (void (^)(NSError* error)) handler { + + + // verify the required parameter 'petId' is set + if (petId == nil) { + [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `uploadFile`"]; + } + + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}/uploadImage"]; + + // remove format in URL if needed + if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { + [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; + } + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } + + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { + [headerParams removeObjectForKey:@"Accept"]; + } + + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { + responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; + } + else { + responseContentType = @""; + } + + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"multipart/form-data"]]; + + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + + + + if (additionalMetadata) { + formParams[@"additionalMetadata"] = additionalMetadata; + } + + + + localVarFiles[@"file"] = file; + + + + + return [self.apiClient requestWithPath: resourcePath method: @"POST" pathParams: pathParams diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h index f8f058462a0..d565a01e15b 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h @@ -19,6 +19,19 @@ -(unsigned long) requestQueueSize; +(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; +(SWGStoreApi*) sharedAPI; +/// +/// +/// Delete purchase order by ID +/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors +/// +/// @param orderId ID of the order that needs to be deleted +/// +/// +/// @return +-(NSNumber*) deleteOrderWithOrderId: (NSString*) orderId + completionHandler: (void (^)(NSError* error)) handler; + + /// /// /// Finds orders by status @@ -56,19 +69,6 @@ (void (^)(NSObject* output, NSError* error)) handler; -/// -/// -/// Place an order for a pet -/// -/// -/// @param body order placed for purchasing the pet -/// -/// -/// @return SWGOrder* --(NSNumber*) placeOrderWithBody: (SWGOrder*) body - completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler; - - /// /// /// Find purchase order by ID @@ -84,15 +84,15 @@ /// /// -/// Delete purchase order by ID -/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors -/// -/// @param orderId ID of the order that needs to be deleted +/// Place an order for a pet /// /// -/// @return --(NSNumber*) deleteOrderWithOrderId: (NSString*) orderId - completionHandler: (void (^)(NSError* error)) handler; +/// @param body order placed for purchasing the pet +/// +/// +/// @return SWGOrder* +-(NSNumber*) placeOrderWithBody: (SWGOrder*) body + completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m index dbe4564177c..6be6cb8da22 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m @@ -69,6 +69,89 @@ static SWGStoreApi* singletonAPI = nil; #pragma mark - Api Methods +/// +/// Delete purchase order by ID +/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors +/// @param orderId ID of the order that needs to be deleted +/// +/// @returns void +/// +-(NSNumber*) deleteOrderWithOrderId: (NSString*) orderId + completionHandler: (void (^)(NSError* error)) handler { + + + // verify the required parameter 'orderId' is set + if (orderId == nil) { + [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `orderId` when calling `deleteOrder`"]; + } + + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/order/{orderId}"]; + + // remove format in URL if needed + if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { + [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; + } + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (orderId != nil) { + pathParams[@"orderId"] = orderId; + } + + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { + [headerParams removeObjectForKey:@"Accept"]; + } + + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { + responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; + } + else { + responseContentType = @""; + } + + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + + + + + + return [self.apiClient requestWithPath: resourcePath + method: @"DELETE" + pathParams: pathParams + queryParams: queryParams + formParams: formParams + files: localVarFiles + body: bodyParam + headerParams: headerParams + authSettings: authSettings + requestContentType: requestContentType + responseContentType: responseContentType + responseType: nil + completionBlock: ^(id data, NSError *error) { + handler(error); + } + ]; +} + /// /// Finds orders by status /// A single status value can be provided as a string @@ -294,81 +377,6 @@ static SWGStoreApi* singletonAPI = nil; ]; } -/// -/// Place an order for a pet -/// -/// @param body order placed for purchasing the pet -/// -/// @returns SWGOrder* -/// --(NSNumber*) placeOrderWithBody: (SWGOrder*) body - completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler { - - - - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/order"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[@"test_api_client_id", @"test_api_client_secret"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - bodyParam = body; - - - - return [self.apiClient requestWithPath: resourcePath - method: @"POST" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: @"SWGOrder*" - completionBlock: ^(id data, NSError *error) { - handler((SWGOrder*)data, error); - } - ]; -} - /// /// Find purchase order by ID /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -453,23 +461,18 @@ static SWGStoreApi* singletonAPI = nil; } /// -/// Delete purchase order by ID -/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors -/// @param orderId ID of the order that needs to be deleted +/// Place an order for a pet +/// +/// @param body order placed for purchasing the pet /// -/// @returns void +/// @returns SWGOrder* /// --(NSNumber*) deleteOrderWithOrderId: (NSString*) orderId - completionHandler: (void (^)(NSError* error)) handler { +-(NSNumber*) placeOrderWithBody: (SWGOrder*) body + completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler { - // verify the required parameter 'orderId' is set - if (orderId == nil) { - [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `orderId` when calling `deleteOrder`"]; - } - - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/order/{orderId}"]; + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/order"]; // remove format in URL if needed if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { @@ -477,9 +480,6 @@ static SWGStoreApi* singletonAPI = nil; } NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - if (orderId != nil) { - pathParams[@"orderId"] = orderId; - } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -507,18 +507,18 @@ static SWGStoreApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[]; + NSArray *authSettings = @[@"test_api_client_id", @"test_api_client_secret"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - + bodyParam = body; return [self.apiClient requestWithPath: resourcePath - method: @"DELETE" + method: @"POST" pathParams: pathParams queryParams: queryParams formParams: formParams @@ -528,9 +528,9 @@ static SWGStoreApi* singletonAPI = nil; authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType - responseType: nil + responseType: @"SWGOrder*" completionBlock: ^(id data, NSError *error) { - handler(error); + handler((SWGOrder*)data, error); } ]; } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h index 96c0b71da60..209e0c4a1d6 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h @@ -58,6 +58,32 @@ completionHandler: (void (^)(NSError* error)) handler; +/// +/// +/// Delete user +/// This can only be done by the logged in user. +/// +/// @param username The name that needs to be deleted +/// +/// +/// @return +-(NSNumber*) deleteUserWithUsername: (NSString*) username + completionHandler: (void (^)(NSError* error)) handler; + + +/// +/// +/// Get user by user name +/// +/// +/// @param username The name that needs to be fetched. Use user1 for testing. +/// +/// +/// @return SWGUser* +-(NSNumber*) getUserByNameWithUsername: (NSString*) username + completionHandler: (void (^)(SWGUser* output, NSError* error)) handler; + + /// /// /// Logs user into the system @@ -85,19 +111,6 @@ (void (^)(NSError* error)) handler; -/// -/// -/// Get user by user name -/// -/// -/// @param username The name that needs to be fetched. Use user1 for testing. -/// -/// -/// @return SWGUser* --(NSNumber*) getUserByNameWithUsername: (NSString*) username - completionHandler: (void (^)(SWGUser* output, NSError* error)) handler; - - /// /// /// Updated user @@ -113,18 +126,5 @@ completionHandler: (void (^)(NSError* error)) handler; -/// -/// -/// Delete user -/// This can only be done by the logged in user. -/// -/// @param username The name that needs to be deleted -/// -/// -/// @return --(NSNumber*) deleteUserWithUsername: (NSString*) username - completionHandler: (void (^)(NSError* error)) handler; - - @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m index 46cda001e52..70b6f41eb75 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m @@ -294,6 +294,172 @@ static SWGUserApi* singletonAPI = nil; ]; } +/// +/// Delete user +/// This can only be done by the logged in user. +/// @param username The name that needs to be deleted +/// +/// @returns void +/// +-(NSNumber*) deleteUserWithUsername: (NSString*) username + completionHandler: (void (^)(NSError* error)) handler { + + + // verify the required parameter 'username' is set + if (username == nil) { + [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `username` when calling `deleteUser`"]; + } + + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/user/{username}"]; + + // remove format in URL if needed + if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { + [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; + } + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (username != nil) { + pathParams[@"username"] = username; + } + + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { + [headerParams removeObjectForKey:@"Accept"]; + } + + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { + responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; + } + else { + responseContentType = @""; + } + + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + + + + + + return [self.apiClient requestWithPath: resourcePath + method: @"DELETE" + pathParams: pathParams + queryParams: queryParams + formParams: formParams + files: localVarFiles + body: bodyParam + headerParams: headerParams + authSettings: authSettings + requestContentType: requestContentType + responseContentType: responseContentType + responseType: nil + completionBlock: ^(id data, NSError *error) { + handler(error); + } + ]; +} + +/// +/// Get user by user name +/// +/// @param username The name that needs to be fetched. Use user1 for testing. +/// +/// @returns SWGUser* +/// +-(NSNumber*) getUserByNameWithUsername: (NSString*) username + completionHandler: (void (^)(SWGUser* output, NSError* error)) handler { + + + // verify the required parameter 'username' is set + if (username == nil) { + [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `username` when calling `getUserByName`"]; + } + + + NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/user/{username}"]; + + // remove format in URL if needed + if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { + [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; + } + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (username != nil) { + pathParams[@"username"] = username; + } + + + NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; + + + + // HTTP header `Accept` + headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; + if ([headerParams[@"Accept"] length] == 0) { + [headerParams removeObjectForKey:@"Accept"]; + } + + // response content type + NSString *responseContentType; + if ([headerParams objectForKey:@"Accept"]) { + responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; + } + else { + responseContentType = @""; + } + + // request content type + NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + + // Authentication setting + NSArray *authSettings = @[]; + + id bodyParam = nil; + NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; + + + + + + return [self.apiClient requestWithPath: resourcePath + method: @"GET" + pathParams: pathParams + queryParams: queryParams + formParams: formParams + files: localVarFiles + body: bodyParam + headerParams: headerParams + authSettings: authSettings + requestContentType: requestContentType + responseContentType: responseContentType + responseType: @"SWGUser*" + completionBlock: ^(id data, NSError *error) { + handler((SWGUser*)data, error); + } + ]; +} + /// /// Logs user into the system /// @@ -453,89 +619,6 @@ static SWGUserApi* singletonAPI = nil; ]; } -/// -/// Get user by user name -/// -/// @param username The name that needs to be fetched. Use user1 for testing. -/// -/// @returns SWGUser* -/// --(NSNumber*) getUserByNameWithUsername: (NSString*) username - completionHandler: (void (^)(SWGUser* output, NSError* error)) handler { - - - // verify the required parameter 'username' is set - if (username == nil) { - [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `username` when calling `getUserByName`"]; - } - - - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/user/{username}"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - if (username != nil) { - pathParams[@"username"] = username; - } - - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - - - - - return [self.apiClient requestWithPath: resourcePath - method: @"GET" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: @"SWGUser*" - completionBlock: ^(id data, NSError *error) { - handler((SWGUser*)data, error); - } - ]; -} - /// /// Updated user /// This can only be done by the logged in user. @@ -622,89 +705,6 @@ static SWGUserApi* singletonAPI = nil; ]; } -/// -/// Delete user -/// This can only be done by the logged in user. -/// @param username The name that needs to be deleted -/// -/// @returns void -/// --(NSNumber*) deleteUserWithUsername: (NSString*) username - completionHandler: (void (^)(NSError* error)) handler { - - - // verify the required parameter 'username' is set - if (username == nil) { - [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `username` when calling `deleteUser`"]; - } - - - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/user/{username}"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - if (username != nil) { - pathParams[@"username"] = username; - } - - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - - - - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - - - - - return [self.apiClient requestWithPath: resourcePath - method: @"DELETE" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: nil - completionBlock: ^(id data, NSError *error) { - handler(error); - } - ]; -} - @end diff --git a/samples/client/petstore/objc/git_push.sh b/samples/client/petstore/objc/git_push.sh new file mode 100644 index 00000000000..1a36388db02 --- /dev/null +++ b/samples/client/petstore/objc/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="YOUR_GIT_USR_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="YOUR_GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index 9e6d5fdde28..9abd60d84fd 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore Automatically generated by the Perl Swagger Codegen project: -- Build date: 2016-03-11T16:15:14.769+08:00 +- Build date: 2016-03-12T17:06:52.449+08:00 - Build package: class io.swagger.codegen.languages.PerlClientCodegen - Codegen version: diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm index c0613c25f8e..2147903053c 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm @@ -37,7 +37,7 @@ has version_info => ( is => 'ro', default => sub { { app_name => 'Swagger Petstore', app_version => '1.0.0', - generated_date => '2016-03-11T16:15:14.769+08:00', + generated_date => '2016-03-12T17:06:52.449+08:00', generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen', } }, documentation => 'Information about the application version and the codegen codebase version' @@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project: =over 4 -=item Build date: 2016-03-11T16:15:14.769+08:00 +=item Build date: 2016-03-12T17:06:52.449+08:00 =item Build package: class io.swagger.codegen.languages.PerlClientCodegen diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index f17476385cb..b3bf40d11e0 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -91,90 +91,6 @@ class PetApi } - /** - * updatePet - * - * Update an existing pet - * - * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional) - * @return void - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function updatePet($body = null) - { - list($response, $statusCode, $httpHeader) = $this->updatePetWithHttpInfo ($body); - return $response; - } - - - /** - * updatePetWithHttpInfo - * - * Update an existing pet - * - * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional) - * @return Array of null, HTTP status code, HTTP response headers (array of strings) - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function updatePetWithHttpInfo($body = null) - { - - - // parse inputs - $resourcePath = "/pet"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json','application/xml')); - - - - - // default format to json - $resourcePath = str_replace("{format}", "json", $resourcePath); - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - $httpBody = $formParams; // for HTTP post (form) - } - - // this endpoint requires OAuth (access token) - if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); - } - - // make the API Call - try { - list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( - $resourcePath, 'PUT', - $queryParams, $httpBody, - $headerParams - ); - - return array(null, $statusCode, $httpHeader); - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - - throw $e; - } - } - /** * addPet * @@ -259,6 +175,188 @@ class PetApi } } + /** + * addPetUsingByteArray + * + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param string $body Pet object in the form of byte array (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function addPetUsingByteArray($body = null) + { + list($response, $statusCode, $httpHeader) = $this->addPetUsingByteArrayWithHttpInfo ($body); + return $response; + } + + + /** + * addPetUsingByteArrayWithHttpInfo + * + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param string $body Pet object in the form of byte array (optional) + * @return Array of null, HTTP status code, HTTP response headers (array of strings) + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function addPetUsingByteArrayWithHttpInfo($body = null) + { + + + // parse inputs + $resourcePath = "/pet?testing_byte_array=true"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json','application/xml')); + + + + + // default format to json + $resourcePath = str_replace("{format}", "json", $resourcePath); + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + + // this endpoint requires OAuth (access token) + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } + + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, 'POST', + $queryParams, $httpBody, + $headerParams + ); + + return array(null, $statusCode, $httpHeader); + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + + throw $e; + } + } + + /** + * deletePet + * + * Deletes a pet + * + * @param int $pet_id Pet id to delete (required) + * @param string $api_key (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function deletePet($pet_id, $api_key = null) + { + list($response, $statusCode, $httpHeader) = $this->deletePetWithHttpInfo ($pet_id, $api_key); + return $response; + } + + + /** + * deletePetWithHttpInfo + * + * Deletes a pet + * + * @param int $pet_id Pet id to delete (required) + * @param string $api_key (optional) + * @return Array of null, HTTP status code, HTTP response headers (array of strings) + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function deletePetWithHttpInfo($pet_id, $api_key = null) + { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { + throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling deletePet'); + } + + // parse inputs + $resourcePath = "/pet/{petId}"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + + + // header params + + if ($api_key !== null) { + $headerParams['api_key'] = $this->apiClient->getSerializer()->toHeaderValue($api_key); + } + // path params + + if ($pet_id !== null) { + $resourcePath = str_replace( + "{" . "petId" . "}", + $this->apiClient->getSerializer()->toPathValue($pet_id), + $resourcePath + ); + } + // default format to json + $resourcePath = str_replace("{format}", "json", $resourcePath); + + + + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + + // this endpoint requires OAuth (access token) + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } + + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, 'DELETE', + $queryParams, $httpBody, + $headerParams + ); + + return array(null, $statusCode, $httpHeader); + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + + throw $e; + } + } + /** * findPetsByStatus * @@ -558,326 +656,6 @@ class PetApi } } - /** - * updatePetWithForm - * - * Updates a pet in the store with form data - * - * @param string $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) - * @return void - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function updatePetWithForm($pet_id, $name = null, $status = null) - { - list($response, $statusCode, $httpHeader) = $this->updatePetWithFormWithHttpInfo ($pet_id, $name, $status); - return $response; - } - - - /** - * updatePetWithFormWithHttpInfo - * - * Updates a pet in the store with form data - * - * @param string $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) - * @return Array of null, HTTP status code, HTTP response headers (array of strings) - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = null) - { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling updatePetWithForm'); - } - - // parse inputs - $resourcePath = "/pet/{petId}"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded')); - - - - // path params - - if ($pet_id !== null) { - $resourcePath = str_replace( - "{" . "petId" . "}", - $this->apiClient->getSerializer()->toPathValue($pet_id), - $resourcePath - ); - } - // default format to json - $resourcePath = str_replace("{format}", "json", $resourcePath); - - // form params - if ($name !== null) { - - - $formParams['name'] = $this->apiClient->getSerializer()->toFormValue($name); - - }// form params - if ($status !== null) { - - - $formParams['status'] = $this->apiClient->getSerializer()->toFormValue($status); - - } - - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - $httpBody = $formParams; // for HTTP post (form) - } - - // this endpoint requires OAuth (access token) - if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); - } - - // make the API Call - try { - list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( - $resourcePath, 'POST', - $queryParams, $httpBody, - $headerParams - ); - - return array(null, $statusCode, $httpHeader); - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - - throw $e; - } - } - - /** - * deletePet - * - * Deletes a pet - * - * @param int $pet_id Pet id to delete (required) - * @param string $api_key (optional) - * @return void - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function deletePet($pet_id, $api_key = null) - { - list($response, $statusCode, $httpHeader) = $this->deletePetWithHttpInfo ($pet_id, $api_key); - return $response; - } - - - /** - * deletePetWithHttpInfo - * - * Deletes a pet - * - * @param int $pet_id Pet id to delete (required) - * @param string $api_key (optional) - * @return Array of null, HTTP status code, HTTP response headers (array of strings) - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function deletePetWithHttpInfo($pet_id, $api_key = null) - { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling deletePet'); - } - - // parse inputs - $resourcePath = "/pet/{petId}"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); - - - // header params - - if ($api_key !== null) { - $headerParams['api_key'] = $this->apiClient->getSerializer()->toHeaderValue($api_key); - } - // path params - - if ($pet_id !== null) { - $resourcePath = str_replace( - "{" . "petId" . "}", - $this->apiClient->getSerializer()->toPathValue($pet_id), - $resourcePath - ); - } - // default format to json - $resourcePath = str_replace("{format}", "json", $resourcePath); - - - - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - $httpBody = $formParams; // for HTTP post (form) - } - - // this endpoint requires OAuth (access token) - if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); - } - - // make the API Call - try { - list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( - $resourcePath, 'DELETE', - $queryParams, $httpBody, - $headerParams - ); - - return array(null, $statusCode, $httpHeader); - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - - throw $e; - } - } - - /** - * uploadFile - * - * uploads an image - * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param \SplFileObject $file file to upload (optional) - * @return void - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function uploadFile($pet_id, $additional_metadata = null, $file = null) - { - list($response, $statusCode, $httpHeader) = $this->uploadFileWithHttpInfo ($pet_id, $additional_metadata, $file); - return $response; - } - - - /** - * uploadFileWithHttpInfo - * - * uploads an image - * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param \SplFileObject $file file to upload (optional) - * @return Array of null, HTTP status code, HTTP response headers (array of strings) - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $file = null) - { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling uploadFile'); - } - - // parse inputs - $resourcePath = "/pet/{petId}/uploadImage"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('multipart/form-data')); - - - - // path params - - if ($pet_id !== null) { - $resourcePath = str_replace( - "{" . "petId" . "}", - $this->apiClient->getSerializer()->toPathValue($pet_id), - $resourcePath - ); - } - // default format to json - $resourcePath = str_replace("{format}", "json", $resourcePath); - - // form params - if ($additional_metadata !== null) { - - - $formParams['additionalMetadata'] = $this->apiClient->getSerializer()->toFormValue($additional_metadata); - - }// form params - if ($file !== null) { - - // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax - // See: https://wiki.php.net/rfc/curl-file-upload - if (function_exists('curl_file_create')) { - $formParams['file'] = curl_file_create($this->apiClient->getSerializer()->toFormValue($file)); - } else { - $formParams['file'] = '@' . $this->apiClient->getSerializer()->toFormValue($file); - } - - - } - - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - $httpBody = $formParams; // for HTTP post (form) - } - - // this endpoint requires OAuth (access token) - if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); - } - - // make the API Call - try { - list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( - $resourcePath, 'POST', - $queryParams, $httpBody, - $headerParams - ); - - return array(null, $statusCode, $httpHeader); - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - - throw $e; - } - } - /** * getPetByIdInObject * @@ -1093,36 +871,36 @@ class PetApi } /** - * addPetUsingByteArray + * updatePet * - * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * Update an existing pet * - * @param string $body Pet object in the form of byte array (optional) + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional) * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function addPetUsingByteArray($body = null) + public function updatePet($body = null) { - list($response, $statusCode, $httpHeader) = $this->addPetUsingByteArrayWithHttpInfo ($body); + list($response, $statusCode, $httpHeader) = $this->updatePetWithHttpInfo ($body); return $response; } /** - * addPetUsingByteArrayWithHttpInfo + * updatePetWithHttpInfo * - * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * Update an existing pet * - * @param string $body Pet object in the form of byte array (optional) + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional) * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function addPetUsingByteArrayWithHttpInfo($body = null) + public function updatePetWithHttpInfo($body = null) { // parse inputs - $resourcePath = "/pet?testing_byte_array=true"; + $resourcePath = "/pet"; $httpBody = ''; $queryParams = array(); $headerParams = array(); @@ -1146,6 +924,228 @@ class PetApi $_tempBody = $body; } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + + // this endpoint requires OAuth (access token) + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } + + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, 'PUT', + $queryParams, $httpBody, + $headerParams + ); + + return array(null, $statusCode, $httpHeader); + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + + throw $e; + } + } + + /** + * updatePetWithForm + * + * Updates a pet in the store with form data + * + * @param string $pet_id ID of pet that needs to be updated (required) + * @param string $name Updated name of the pet (optional) + * @param string $status Updated status of the pet (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function updatePetWithForm($pet_id, $name = null, $status = null) + { + list($response, $statusCode, $httpHeader) = $this->updatePetWithFormWithHttpInfo ($pet_id, $name, $status); + return $response; + } + + + /** + * updatePetWithFormWithHttpInfo + * + * Updates a pet in the store with form data + * + * @param string $pet_id ID of pet that needs to be updated (required) + * @param string $name Updated name of the pet (optional) + * @param string $status Updated status of the pet (optional) + * @return Array of null, HTTP status code, HTTP response headers (array of strings) + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = null) + { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { + throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling updatePetWithForm'); + } + + // parse inputs + $resourcePath = "/pet/{petId}"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded')); + + + + // path params + + if ($pet_id !== null) { + $resourcePath = str_replace( + "{" . "petId" . "}", + $this->apiClient->getSerializer()->toPathValue($pet_id), + $resourcePath + ); + } + // default format to json + $resourcePath = str_replace("{format}", "json", $resourcePath); + + // form params + if ($name !== null) { + + + $formParams['name'] = $this->apiClient->getSerializer()->toFormValue($name); + + }// form params + if ($status !== null) { + + + $formParams['status'] = $this->apiClient->getSerializer()->toFormValue($status); + + } + + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + + // this endpoint requires OAuth (access token) + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } + + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, 'POST', + $queryParams, $httpBody, + $headerParams + ); + + return array(null, $statusCode, $httpHeader); + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + + throw $e; + } + } + + /** + * uploadFile + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * @param \SplFileObject $file file to upload (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function uploadFile($pet_id, $additional_metadata = null, $file = null) + { + list($response, $statusCode, $httpHeader) = $this->uploadFileWithHttpInfo ($pet_id, $additional_metadata, $file); + return $response; + } + + + /** + * uploadFileWithHttpInfo + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * @param \SplFileObject $file file to upload (optional) + * @return Array of null, HTTP status code, HTTP response headers (array of strings) + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $file = null) + { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { + throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling uploadFile'); + } + + // parse inputs + $resourcePath = "/pet/{petId}/uploadImage"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('multipart/form-data')); + + + + // path params + + if ($pet_id !== null) { + $resourcePath = str_replace( + "{" . "petId" . "}", + $this->apiClient->getSerializer()->toPathValue($pet_id), + $resourcePath + ); + } + // default format to json + $resourcePath = str_replace("{format}", "json", $resourcePath); + + // form params + if ($additional_metadata !== null) { + + + $formParams['additionalMetadata'] = $this->apiClient->getSerializer()->toFormValue($additional_metadata); + + }// form params + if ($file !== null) { + + // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax + // See: https://wiki.php.net/rfc/curl-file-upload + if (function_exists('curl_file_create')) { + $formParams['file'] = curl_file_create($this->apiClient->getSerializer()->toFormValue($file)); + } else { + $formParams['file'] = '@' . $this->apiClient->getSerializer()->toFormValue($file); + } + + + } + + // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index 5e9705df3e3..91dc0cde444 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -91,6 +91,93 @@ class StoreApi } + /** + * deleteOrder + * + * Delete purchase order by ID + * + * @param string $order_id ID of the order that needs to be deleted (required) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function deleteOrder($order_id) + { + list($response, $statusCode, $httpHeader) = $this->deleteOrderWithHttpInfo ($order_id); + return $response; + } + + + /** + * deleteOrderWithHttpInfo + * + * Delete purchase order by ID + * + * @param string $order_id ID of the order that needs to be deleted (required) + * @return Array of null, HTTP status code, HTTP response headers (array of strings) + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function deleteOrderWithHttpInfo($order_id) + { + + // verify the required parameter 'order_id' is set + if ($order_id === null) { + throw new \InvalidArgumentException('Missing the required parameter $order_id when calling deleteOrder'); + } + + // parse inputs + $resourcePath = "/store/order/{orderId}"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + + + + // path params + + if ($order_id !== null) { + $resourcePath = str_replace( + "{" . "orderId" . "}", + $this->apiClient->getSerializer()->toPathValue($order_id), + $resourcePath + ); + } + // default format to json + $resourcePath = str_replace("{format}", "json", $resourcePath); + + + + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, 'DELETE', + $queryParams, $httpBody, + $headerParams + ); + + return array(null, $statusCode, $httpHeader); + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + + throw $e; + } + } + /** * findOrdersByStatus * @@ -368,107 +455,6 @@ class StoreApi } } - /** - * placeOrder - * - * Place an order for a pet - * - * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (optional) - * @return \Swagger\Client\Model\Order - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function placeOrder($body = null) - { - list($response, $statusCode, $httpHeader) = $this->placeOrderWithHttpInfo ($body); - return $response; - } - - - /** - * placeOrderWithHttpInfo - * - * Place an order for a pet - * - * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (optional) - * @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function placeOrderWithHttpInfo($body = null) - { - - - // parse inputs - $resourcePath = "/store/order"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); - - - - - // default format to json - $resourcePath = str_replace("{format}", "json", $resourcePath); - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - $httpBody = $formParams; // for HTTP post (form) - } - - // this endpoint requires API key authentication - $apiKey = $this->apiClient->getApiKeyWithPrefix('x-test_api_client_id'); - if (strlen($apiKey) !== 0) { - $headerParams['x-test_api_client_id'] = $apiKey; - } - - - // this endpoint requires API key authentication - $apiKey = $this->apiClient->getApiKeyWithPrefix('x-test_api_client_secret'); - if (strlen($apiKey) !== 0) { - $headerParams['x-test_api_client_secret'] = $apiKey; - } - - - // make the API Call - try { - list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( - $resourcePath, 'POST', - $queryParams, $httpBody, - $headerParams, '\Swagger\Client\Model\Order' - ); - - if (!$response) { - return array(null, $statusCode, $httpHeader); - } - - return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - - throw $e; - } - } - /** * getOrderById * @@ -579,40 +565,36 @@ class StoreApi } /** - * deleteOrder + * placeOrder * - * Delete purchase order by ID + * Place an order for a pet * - * @param string $order_id ID of the order that needs to be deleted (required) - * @return void + * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (optional) + * @return \Swagger\Client\Model\Order * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deleteOrder($order_id) + public function placeOrder($body = null) { - list($response, $statusCode, $httpHeader) = $this->deleteOrderWithHttpInfo ($order_id); + list($response, $statusCode, $httpHeader) = $this->placeOrderWithHttpInfo ($body); return $response; } /** - * deleteOrderWithHttpInfo + * placeOrderWithHttpInfo * - * Delete purchase order by ID + * Place an order for a pet * - * @param string $order_id ID of the order that needs to be deleted (required) - * @return Array of null, HTTP status code, HTTP response headers (array of strings) + * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (optional) + * @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deleteOrderWithHttpInfo($order_id) + public function placeOrderWithHttpInfo($body = null) { - // verify the required parameter 'order_id' is set - if ($order_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $order_id when calling deleteOrder'); - } // parse inputs - $resourcePath = "/store/order/{orderId}"; + $resourcePath = "/store/order"; $httpBody = ''; $queryParams = array(); $headerParams = array(); @@ -625,20 +607,16 @@ class StoreApi - // path params - if ($order_id !== null) { - $resourcePath = str_replace( - "{" . "orderId" . "}", - $this->apiClient->getSerializer()->toPathValue($order_id), - $resourcePath - ); - } // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } // for model (json/xml) if (isset($_tempBody)) { @@ -647,18 +625,40 @@ class StoreApi $httpBody = $formParams; // for HTTP post (form) } + // this endpoint requires API key authentication + $apiKey = $this->apiClient->getApiKeyWithPrefix('x-test_api_client_id'); + if (strlen($apiKey) !== 0) { + $headerParams['x-test_api_client_id'] = $apiKey; + } + + + // this endpoint requires API key authentication + $apiKey = $this->apiClient->getApiKeyWithPrefix('x-test_api_client_secret'); + if (strlen($apiKey) !== 0) { + $headerParams['x-test_api_client_secret'] = $apiKey; + } + + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( - $resourcePath, 'DELETE', + $resourcePath, 'POST', $queryParams, $httpBody, - $headerParams + $headerParams, '\Swagger\Client\Model\Order' ); - return array(null, $statusCode, $httpHeader); + if (!$response) { + return array(null, $statusCode, $httpHeader); + } + + return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { + case 200: + $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; } throw $e; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php index 595d82fffc1..298cc1bba50 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -328,6 +328,188 @@ class UserApi } } + /** + * deleteUser + * + * Delete user + * + * @param string $username The name that needs to be deleted (required) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function deleteUser($username) + { + list($response, $statusCode, $httpHeader) = $this->deleteUserWithHttpInfo ($username); + return $response; + } + + + /** + * deleteUserWithHttpInfo + * + * Delete user + * + * @param string $username The name that needs to be deleted (required) + * @return Array of null, HTTP status code, HTTP response headers (array of strings) + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function deleteUserWithHttpInfo($username) + { + + // verify the required parameter 'username' is set + if ($username === null) { + throw new \InvalidArgumentException('Missing the required parameter $username when calling deleteUser'); + } + + // parse inputs + $resourcePath = "/user/{username}"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + + + + // path params + + if ($username !== null) { + $resourcePath = str_replace( + "{" . "username" . "}", + $this->apiClient->getSerializer()->toPathValue($username), + $resourcePath + ); + } + // default format to json + $resourcePath = str_replace("{format}", "json", $resourcePath); + + + + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, 'DELETE', + $queryParams, $httpBody, + $headerParams + ); + + return array(null, $statusCode, $httpHeader); + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + + throw $e; + } + } + + /** + * getUserByName + * + * Get user by user name + * + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @return \Swagger\Client\Model\User + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function getUserByName($username) + { + list($response, $statusCode, $httpHeader) = $this->getUserByNameWithHttpInfo ($username); + return $response; + } + + + /** + * getUserByNameWithHttpInfo + * + * Get user by user name + * + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @return Array of \Swagger\Client\Model\User, HTTP status code, HTTP response headers (array of strings) + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function getUserByNameWithHttpInfo($username) + { + + // verify the required parameter 'username' is set + if ($username === null) { + throw new \InvalidArgumentException('Missing the required parameter $username when calling getUserByName'); + } + + // parse inputs + $resourcePath = "/user/{username}"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + + + + // path params + + if ($username !== null) { + $resourcePath = str_replace( + "{" . "username" . "}", + $this->apiClient->getSerializer()->toPathValue($username), + $resourcePath + ); + } + // default format to json + $resourcePath = str_replace("{format}", "json", $resourcePath); + + + + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, 'GET', + $queryParams, $httpBody, + $headerParams, '\Swagger\Client\Model\User' + ); + + if (!$response) { + return array(null, $statusCode, $httpHeader); + } + + return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\User', $httpHeader), $statusCode, $httpHeader); + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\User', $e->getResponseHeaders()); + $e->setResponseObject($data); + break; + } + + throw $e; + } + } + /** * loginUser * @@ -494,101 +676,6 @@ class UserApi } } - /** - * getUserByName - * - * Get user by user name - * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) - * @return \Swagger\Client\Model\User - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function getUserByName($username) - { - list($response, $statusCode, $httpHeader) = $this->getUserByNameWithHttpInfo ($username); - return $response; - } - - - /** - * getUserByNameWithHttpInfo - * - * Get user by user name - * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) - * @return Array of \Swagger\Client\Model\User, HTTP status code, HTTP response headers (array of strings) - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function getUserByNameWithHttpInfo($username) - { - - // verify the required parameter 'username' is set - if ($username === null) { - throw new \InvalidArgumentException('Missing the required parameter $username when calling getUserByName'); - } - - // parse inputs - $resourcePath = "/user/{username}"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); - - - - // path params - - if ($username !== null) { - $resourcePath = str_replace( - "{" . "username" . "}", - $this->apiClient->getSerializer()->toPathValue($username), - $resourcePath - ); - } - // default format to json - $resourcePath = str_replace("{format}", "json", $resourcePath); - - - - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - $httpBody = $formParams; // for HTTP post (form) - } - - // make the API Call - try { - list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( - $resourcePath, 'GET', - $queryParams, $httpBody, - $headerParams, '\Swagger\Client\Model\User' - ); - - if (!$response) { - return array(null, $statusCode, $httpHeader); - } - - return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\User', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\User', $e->getResponseHeaders()); - $e->setResponseObject($data); - break; - } - - throw $e; - } - } - /** * updateUser * @@ -682,91 +769,4 @@ class UserApi } } - /** - * deleteUser - * - * Delete user - * - * @param string $username The name that needs to be deleted (required) - * @return void - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function deleteUser($username) - { - list($response, $statusCode, $httpHeader) = $this->deleteUserWithHttpInfo ($username); - return $response; - } - - - /** - * deleteUserWithHttpInfo - * - * Delete user - * - * @param string $username The name that needs to be deleted (required) - * @return Array of null, HTTP status code, HTTP response headers (array of strings) - * @throws \Swagger\Client\ApiException on non-2xx response - */ - public function deleteUserWithHttpInfo($username) - { - - // verify the required parameter 'username' is set - if ($username === null) { - throw new \InvalidArgumentException('Missing the required parameter $username when calling deleteUser'); - } - - // parse inputs - $resourcePath = "/user/{username}"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); - - - - // path params - - if ($username !== null) { - $resourcePath = str_replace( - "{" . "username" . "}", - $this->apiClient->getSerializer()->toPathValue($username), - $resourcePath - ); - } - // default format to json - $resourcePath = str_replace("{format}", "json", $resourcePath); - - - - - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } elseif (count($formParams) > 0) { - $httpBody = $formParams; // for HTTP post (form) - } - - // make the API Call - try { - list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( - $resourcePath, 'DELETE', - $queryParams, $httpBody, - $headerParams - ); - - return array(null, $statusCode, $httpHeader); - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - - throw $e; - } - } - } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php new file mode 100644 index 00000000000..7c5bcf97f3f --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php @@ -0,0 +1,174 @@ + 'int' + ); + + /** + * Array of attributes where the key is the local name, and the value is the original name + * @var string[] + */ + static $attributeMap = array( + 'return' => 'return' + ); + + /** + * Array of attributes to setter functions (for deserialization of responses) + * @var string[] + */ + static $setters = array( + 'return' => 'setReturn' + ); + + /** + * Array of attributes to getter functions (for serialization of requests) + * @var string[] + */ + static $getters = array( + 'return' => 'getReturn' + ); + + + /** + * $return + * @var int + */ + protected $return; + + + /** + * Constructor + * @param mixed[] $data Associated array of property value initalizing the model + */ + public function __construct(array $data = null) + { + if ($data != null) { + $this->return = $data["return"]; + } + } + + /** + * Gets return + * @return int + */ + public function getReturn() + { + return $this->return; + } + + /** + * Sets return + * @param int $return + * @return $this + */ + public function setReturn($return) + { + + $this->return = $return; + return $this; + } + + /** + * Returns true if offset exists. False otherwise. + * @param integer $offset Offset + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->$offset); + } + + /** + * Gets offset. + * @param integer $offset Offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->$offset; + } + + /** + * Sets value based on offset. + * @param integer $offset Offset + * @param mixed $value Value to be set + * @return void + */ + public function offsetSet($offset, $value) + { + $this->$offset = $value; + } + + /** + * Unsets offset. + * @param integer $offset Offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->$offset); + } + + /** + * Gets the string presentation of the object + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); + } else { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); + } + } +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php new file mode 100644 index 00000000000..025984924c3 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php @@ -0,0 +1,174 @@ + 'int' + ); + + /** + * Array of attributes where the key is the local name, and the value is the original name + * @var string[] + */ + static $attributeMap = array( + 'name' => 'name' + ); + + /** + * Array of attributes to setter functions (for deserialization of responses) + * @var string[] + */ + static $setters = array( + 'name' => 'setName' + ); + + /** + * Array of attributes to getter functions (for serialization of requests) + * @var string[] + */ + static $getters = array( + 'name' => 'getName' + ); + + + /** + * $name + * @var int + */ + protected $name; + + + /** + * Constructor + * @param mixed[] $data Associated array of property value initalizing the model + */ + public function __construct(array $data = null) + { + if ($data != null) { + $this->name = $data["name"]; + } + } + + /** + * Gets name + * @return int + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name + * @param int $name + * @return $this + */ + public function setName($name) + { + + $this->name = $name; + return $this; + } + + /** + * Returns true if offset exists. False otherwise. + * @param integer $offset Offset + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->$offset); + } + + /** + * Gets offset. + * @param integer $offset Offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->$offset; + } + + /** + * Sets value based on offset. + * @param integer $offset Offset + * @param mixed $value Value to be set + * @return void + */ + public function offsetSet($offset, $value) + { + $this->$offset = $value; + } + + /** + * Unsets offset. + * @param integer $offset Offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->$offset); + } + + /** + * Gets the string presentation of the object + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); + } else { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); + } + } +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/ModelReturnTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/ModelReturnTest.php new file mode 100644 index 00000000000..b42efd5ef57 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/ModelReturnTest.php @@ -0,0 +1,70 @@ +&1 | grep -v 'To https' + diff --git a/samples/client/petstore/python/.gitignore b/samples/client/petstore/python/.gitignore new file mode 100644 index 00000000000..1dbc687de01 --- /dev/null +++ b/samples/client/petstore/python/.gitignore @@ -0,0 +1,62 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints diff --git a/samples/client/petstore/python/git_push.sh b/samples/client/petstore/python/git_push.sh new file mode 100644 index 00000000000..1a36388db02 --- /dev/null +++ b/samples/client/petstore/python/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="YOUR_GIT_USR_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="YOUR_GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/python/swagger_client/__init__.py b/samples/client/petstore/python/swagger_client/__init__.py index 8c6fd5bc618..3381f2fda65 100644 --- a/samples/client/petstore/python/swagger_client/__init__.py +++ b/samples/client/petstore/python/swagger_client/__init__.py @@ -1,19 +1,20 @@ from __future__ import absolute_import # import models into sdk package -from .models.user import User from .models.category import Category -from .models.pet import Pet -from .models.tag import Tag -from .models.object_return import ObjectReturn -from .models.order import Order -from .models.special_model_name import SpecialModelName from .models.inline_response_200 import InlineResponse200 +from .models.model_return import ModelReturn +from .models.name import Name +from .models.order import Order +from .models.pet import Pet +from .models.special_model_name import SpecialModelName +from .models.tag import Tag +from .models.user import User # import apis into sdk package -from .apis.user_api import UserApi from .apis.pet_api import PetApi from .apis.store_api import StoreApi +from .apis.user_api import UserApi # import ApiClient from .api_client import ApiClient diff --git a/samples/client/petstore/python/swagger_client/apis/__init__.py b/samples/client/petstore/python/swagger_client/apis/__init__.py index 592a56e282d..a3a12ea9ac1 100644 --- a/samples/client/petstore/python/swagger_client/apis/__init__.py +++ b/samples/client/petstore/python/swagger_client/apis/__init__.py @@ -1,6 +1,6 @@ from __future__ import absolute_import # import apis into api package -from .user_api import UserApi from .pet_api import PetApi from .store_api import StoreApi +from .user_api import UserApi diff --git a/samples/client/petstore/python/swagger_client/apis/pet_api.py b/samples/client/petstore/python/swagger_client/apis/pet_api.py index d4291093b13..8b081e077dc 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -45,80 +45,6 @@ class PetApi(object): config.api_client = ApiClient() self.api_client = config.api_client - def update_pet(self, **kwargs): - """ - Update an existing pet - - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.update_pet(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param Pet body: Pet object that needs to be added to the store - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['body'] - all_params.append('callback') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method update_pet" % key - ) - params[key] = val - del params['kwargs'] - - - resource_path = '/pet'.replace('{format}', 'json') - path_params = {} - - query_params = {} - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json', 'application/xml']) - if not header_params['Accept']: - del header_params['Accept'] - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/json', 'application/xml']) - - # Authentication setting - auth_settings = ['petstore_auth'] - - response = self.api_client.call_api(resource_path, 'PUT', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, - auth_settings=auth_settings, - callback=params.get('callback')) - return response - def add_pet(self, **kwargs): """ Add a new pet to the store @@ -193,6 +119,160 @@ class PetApi(object): callback=params.get('callback')) return response + def add_pet_using_byte_array(self, **kwargs): + """ + Fake endpoint to test byte array in body parameter for adding a new pet to the store + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.add_pet_using_byte_array(callback=callback_function) + + :param callback function: The callback function + for asynchronous request. (optional) + :param str body: Pet object in the form of byte array + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body'] + all_params.append('callback') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method add_pet_using_byte_array" % key + ) + params[key] = val + del params['kwargs'] + + + resource_path = '/pet?testing_byte_array=true'.replace('{format}', 'json') + path_params = {} + + query_params = {} + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + + # HTTP header `Accept` + header_params['Accept'] = self.api_client.\ + select_header_accept(['application/json', 'application/xml']) + if not header_params['Accept']: + del header_params['Accept'] + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type(['application/json', 'application/xml']) + + # Authentication setting + auth_settings = ['petstore_auth'] + + response = self.api_client.call_api(resource_path, 'POST', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, + auth_settings=auth_settings, + callback=params.get('callback')) + return response + + def delete_pet(self, pet_id, **kwargs): + """ + Deletes a pet + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.delete_pet(pet_id, callback=callback_function) + + :param callback function: The callback function + for asynchronous request. (optional) + :param int pet_id: Pet id to delete (required) + :param str api_key: + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['pet_id', 'api_key'] + all_params.append('callback') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_pet" % key + ) + params[key] = val + del params['kwargs'] + + # verify the required parameter 'pet_id' is set + if ('pet_id' not in params) or (params['pet_id'] is None): + raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`") + + resource_path = '/pet/{petId}'.replace('{format}', 'json') + path_params = {} + if 'pet_id' in params: + path_params['petId'] = params['pet_id'] + + query_params = {} + + header_params = {} + if 'api_key' in params: + header_params['api_key'] = params['api_key'] + + form_params = [] + local_var_files = {} + + body_params = None + + # HTTP header `Accept` + header_params['Accept'] = self.api_client.\ + select_header_accept(['application/json', 'application/xml']) + if not header_params['Accept']: + del header_params['Accept'] + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type([]) + + # Authentication setting + auth_settings = ['petstore_auth'] + + response = self.api_client.call_api(resource_path, 'DELETE', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, + auth_settings=auth_settings, + callback=params.get('callback')) + return response + def find_pets_by_status(self, **kwargs): """ Finds Pets by status @@ -418,252 +498,6 @@ class PetApi(object): callback=params.get('callback')) return response - def update_pet_with_form(self, pet_id, **kwargs): - """ - Updates a pet in the store with form data - - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.update_pet_with_form(pet_id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str pet_id: ID of pet that needs to be updated (required) - :param str name: Updated name of the pet - :param str status: Updated status of the pet - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['pet_id', 'name', 'status'] - all_params.append('callback') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method update_pet_with_form" % key - ) - params[key] = val - del params['kwargs'] - - # verify the required parameter 'pet_id' is set - if ('pet_id' not in params) or (params['pet_id'] is None): - raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`") - - resource_path = '/pet/{petId}'.replace('{format}', 'json') - path_params = {} - if 'pet_id' in params: - path_params['petId'] = params['pet_id'] - - query_params = {} - - header_params = {} - - form_params = [] - local_var_files = {} - if 'name' in params: - form_params.append(('name', params['name'])) - if 'status' in params: - form_params.append(('status', params['status'])) - - body_params = None - - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json', 'application/xml']) - if not header_params['Accept']: - del header_params['Accept'] - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['application/x-www-form-urlencoded']) - - # Authentication setting - auth_settings = ['petstore_auth'] - - response = self.api_client.call_api(resource_path, 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, - auth_settings=auth_settings, - callback=params.get('callback')) - return response - - def delete_pet(self, pet_id, **kwargs): - """ - Deletes a pet - - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.delete_pet(pet_id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param int pet_id: Pet id to delete (required) - :param str api_key: - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['pet_id', 'api_key'] - all_params.append('callback') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method delete_pet" % key - ) - params[key] = val - del params['kwargs'] - - # verify the required parameter 'pet_id' is set - if ('pet_id' not in params) or (params['pet_id'] is None): - raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`") - - resource_path = '/pet/{petId}'.replace('{format}', 'json') - path_params = {} - if 'pet_id' in params: - path_params['petId'] = params['pet_id'] - - query_params = {} - - header_params = {} - if 'api_key' in params: - header_params['api_key'] = params['api_key'] - - form_params = [] - local_var_files = {} - - body_params = None - - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json', 'application/xml']) - if not header_params['Accept']: - del header_params['Accept'] - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type([]) - - # Authentication setting - auth_settings = ['petstore_auth'] - - response = self.api_client.call_api(resource_path, 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, - auth_settings=auth_settings, - callback=params.get('callback')) - return response - - def upload_file(self, pet_id, **kwargs): - """ - uploads an image - - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.upload_file(pet_id, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param int pet_id: ID of pet to update (required) - :param str additional_metadata: Additional data to pass to server - :param file file: file to upload - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['pet_id', 'additional_metadata', 'file'] - all_params.append('callback') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method upload_file" % key - ) - params[key] = val - del params['kwargs'] - - # verify the required parameter 'pet_id' is set - if ('pet_id' not in params) or (params['pet_id'] is None): - raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`") - - resource_path = '/pet/{petId}/uploadImage'.replace('{format}', 'json') - path_params = {} - if 'pet_id' in params: - path_params['petId'] = params['pet_id'] - - query_params = {} - - header_params = {} - - form_params = [] - local_var_files = {} - if 'additional_metadata' in params: - form_params.append(('additionalMetadata', params['additional_metadata'])) - if 'file' in params: - local_var_files['file'] = params['file'] - - body_params = None - - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json', 'application/xml']) - if not header_params['Accept']: - del header_params['Accept'] - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type(['multipart/form-data']) - - # Authentication setting - auth_settings = ['petstore_auth'] - - response = self.api_client.call_api(resource_path, 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, - auth_settings=auth_settings, - callback=params.get('callback')) - return response - def get_pet_by_id_in_object(self, pet_id, **kwargs): """ Fake endpoint to test inline arbitrary object return by 'Find pet by ID' @@ -818,9 +652,9 @@ class PetApi(object): callback=params.get('callback')) return response - def add_pet_using_byte_array(self, **kwargs): + def update_pet(self, **kwargs): """ - Fake endpoint to test byte array in body parameter for adding a new pet to the store + Update an existing pet This method makes a synchronous HTTP request by default. To make an @@ -829,11 +663,11 @@ class PetApi(object): >>> def callback_function(response): >>> pprint(response) >>> - >>> thread = api.add_pet_using_byte_array(callback=callback_function) + >>> thread = api.update_pet(callback=callback_function) :param callback function: The callback function for asynchronous request. (optional) - :param str body: Pet object in the form of byte array + :param Pet body: Pet object that needs to be added to the store :return: None If the method is called asynchronously, returns the request thread. @@ -847,13 +681,13 @@ class PetApi(object): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method add_pet_using_byte_array" % key + " to method update_pet" % key ) params[key] = val del params['kwargs'] - resource_path = '/pet?testing_byte_array=true'.replace('{format}', 'json') + resource_path = '/pet'.replace('{format}', 'json') path_params = {} query_params = {} @@ -880,6 +714,172 @@ class PetApi(object): # Authentication setting auth_settings = ['petstore_auth'] + response = self.api_client.call_api(resource_path, 'PUT', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, + auth_settings=auth_settings, + callback=params.get('callback')) + return response + + def update_pet_with_form(self, pet_id, **kwargs): + """ + Updates a pet in the store with form data + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.update_pet_with_form(pet_id, callback=callback_function) + + :param callback function: The callback function + for asynchronous request. (optional) + :param str pet_id: ID of pet that needs to be updated (required) + :param str name: Updated name of the pet + :param str status: Updated status of the pet + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['pet_id', 'name', 'status'] + all_params.append('callback') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method update_pet_with_form" % key + ) + params[key] = val + del params['kwargs'] + + # verify the required parameter 'pet_id' is set + if ('pet_id' not in params) or (params['pet_id'] is None): + raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`") + + resource_path = '/pet/{petId}'.replace('{format}', 'json') + path_params = {} + if 'pet_id' in params: + path_params['petId'] = params['pet_id'] + + query_params = {} + + header_params = {} + + form_params = [] + local_var_files = {} + if 'name' in params: + form_params.append(('name', params['name'])) + if 'status' in params: + form_params.append(('status', params['status'])) + + body_params = None + + # HTTP header `Accept` + header_params['Accept'] = self.api_client.\ + select_header_accept(['application/json', 'application/xml']) + if not header_params['Accept']: + del header_params['Accept'] + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type(['application/x-www-form-urlencoded']) + + # Authentication setting + auth_settings = ['petstore_auth'] + + response = self.api_client.call_api(resource_path, 'POST', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, + auth_settings=auth_settings, + callback=params.get('callback')) + return response + + def upload_file(self, pet_id, **kwargs): + """ + uploads an image + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.upload_file(pet_id, callback=callback_function) + + :param callback function: The callback function + for asynchronous request. (optional) + :param int pet_id: ID of pet to update (required) + :param str additional_metadata: Additional data to pass to server + :param file file: file to upload + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['pet_id', 'additional_metadata', 'file'] + all_params.append('callback') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method upload_file" % key + ) + params[key] = val + del params['kwargs'] + + # verify the required parameter 'pet_id' is set + if ('pet_id' not in params) or (params['pet_id'] is None): + raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`") + + resource_path = '/pet/{petId}/uploadImage'.replace('{format}', 'json') + path_params = {} + if 'pet_id' in params: + path_params['petId'] = params['pet_id'] + + query_params = {} + + header_params = {} + + form_params = [] + local_var_files = {} + if 'additional_metadata' in params: + form_params.append(('additionalMetadata', params['additional_metadata'])) + if 'file' in params: + local_var_files['file'] = params['file'] + + body_params = None + + # HTTP header `Accept` + header_params['Accept'] = self.api_client.\ + select_header_accept(['application/json', 'application/xml']) + if not header_params['Accept']: + del header_params['Accept'] + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type(['multipart/form-data']) + + # Authentication setting + auth_settings = ['petstore_auth'] + response = self.api_client.call_api(resource_path, 'POST', path_params, query_params, diff --git a/samples/client/petstore/python/swagger_client/apis/store_api.py b/samples/client/petstore/python/swagger_client/apis/store_api.py index 220447d7c01..85bb90ed40c 100644 --- a/samples/client/petstore/python/swagger_client/apis/store_api.py +++ b/samples/client/petstore/python/swagger_client/apis/store_api.py @@ -45,6 +45,83 @@ class StoreApi(object): config.api_client = ApiClient() self.api_client = config.api_client + def delete_order(self, order_id, **kwargs): + """ + Delete purchase order by ID + For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.delete_order(order_id, callback=callback_function) + + :param callback function: The callback function + for asynchronous request. (optional) + :param str order_id: ID of the order that needs to be deleted (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['order_id'] + all_params.append('callback') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_order" % key + ) + params[key] = val + del params['kwargs'] + + # verify the required parameter 'order_id' is set + if ('order_id' not in params) or (params['order_id'] is None): + raise ValueError("Missing the required parameter `order_id` when calling `delete_order`") + + resource_path = '/store/order/{orderId}'.replace('{format}', 'json') + path_params = {} + if 'order_id' in params: + path_params['orderId'] = params['order_id'] + + query_params = {} + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + + # HTTP header `Accept` + header_params['Accept'] = self.api_client.\ + select_header_accept(['application/json', 'application/xml']) + if not header_params['Accept']: + del header_params['Accept'] + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type([]) + + # Authentication setting + auth_settings = [] + + response = self.api_client.call_api(resource_path, 'DELETE', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, + auth_settings=auth_settings, + callback=params.get('callback')) + return response + def find_orders_by_status(self, **kwargs): """ Finds orders by status @@ -261,80 +338,6 @@ class StoreApi(object): callback=params.get('callback')) return response - def place_order(self, **kwargs): - """ - Place an order for a pet - - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.place_order(callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param Order body: order placed for purchasing the pet - :return: Order - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['body'] - all_params.append('callback') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method place_order" % key - ) - params[key] = val - del params['kwargs'] - - - resource_path = '/store/order'.replace('{format}', 'json') - path_params = {} - - query_params = {} - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in params: - body_params = params['body'] - - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json', 'application/xml']) - if not header_params['Accept']: - del header_params['Accept'] - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type([]) - - # Authentication setting - auth_settings = ['test_api_client_id', 'test_api_client_secret'] - - response = self.api_client.call_api(resource_path, 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='Order', - auth_settings=auth_settings, - callback=params.get('callback')) - return response - def get_order_by_id(self, order_id, **kwargs): """ Find purchase order by ID @@ -412,10 +415,10 @@ class StoreApi(object): callback=params.get('callback')) return response - def delete_order(self, order_id, **kwargs): + def place_order(self, **kwargs): """ - Delete purchase order by ID - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + Place an order for a pet + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function @@ -423,17 +426,17 @@ class StoreApi(object): >>> def callback_function(response): >>> pprint(response) >>> - >>> thread = api.delete_order(order_id, callback=callback_function) + >>> thread = api.place_order(callback=callback_function) :param callback function: The callback function for asynchronous request. (optional) - :param str order_id: ID of the order that needs to be deleted (required) - :return: None + :param Order body: order placed for purchasing the pet + :return: Order If the method is called asynchronously, returns the request thread. """ - all_params = ['order_id'] + all_params = ['body'] all_params.append('callback') params = locals() @@ -441,19 +444,14 @@ class StoreApi(object): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method delete_order" % key + " to method place_order" % key ) params[key] = val del params['kwargs'] - # verify the required parameter 'order_id' is set - if ('order_id' not in params) or (params['order_id'] is None): - raise ValueError("Missing the required parameter `order_id` when calling `delete_order`") - resource_path = '/store/order/{orderId}'.replace('{format}', 'json') + resource_path = '/store/order'.replace('{format}', 'json') path_params = {} - if 'order_id' in params: - path_params['orderId'] = params['order_id'] query_params = {} @@ -463,6 +461,8 @@ class StoreApi(object): local_var_files = {} body_params = None + if 'body' in params: + body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.\ @@ -475,16 +475,16 @@ class StoreApi(object): select_header_content_type([]) # Authentication setting - auth_settings = [] + auth_settings = ['test_api_client_id', 'test_api_client_secret'] - response = self.api_client.call_api(resource_path, 'DELETE', + response = self.api_client.call_api(resource_path, 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type=None, + response_type='Order', auth_settings=auth_settings, callback=params.get('callback')) return response diff --git a/samples/client/petstore/python/swagger_client/apis/user_api.py b/samples/client/petstore/python/swagger_client/apis/user_api.py index a83243cc245..0d519da1e28 100644 --- a/samples/client/petstore/python/swagger_client/apis/user_api.py +++ b/samples/client/petstore/python/swagger_client/apis/user_api.py @@ -267,6 +267,160 @@ class UserApi(object): callback=params.get('callback')) return response + def delete_user(self, username, **kwargs): + """ + Delete user + This can only be done by the logged in user. + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.delete_user(username, callback=callback_function) + + :param callback function: The callback function + for asynchronous request. (optional) + :param str username: The name that needs to be deleted (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['username'] + all_params.append('callback') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_user" % key + ) + params[key] = val + del params['kwargs'] + + # verify the required parameter 'username' is set + if ('username' not in params) or (params['username'] is None): + raise ValueError("Missing the required parameter `username` when calling `delete_user`") + + resource_path = '/user/{username}'.replace('{format}', 'json') + path_params = {} + if 'username' in params: + path_params['username'] = params['username'] + + query_params = {} + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + + # HTTP header `Accept` + header_params['Accept'] = self.api_client.\ + select_header_accept(['application/json', 'application/xml']) + if not header_params['Accept']: + del header_params['Accept'] + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type([]) + + # Authentication setting + auth_settings = [] + + response = self.api_client.call_api(resource_path, 'DELETE', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, + auth_settings=auth_settings, + callback=params.get('callback')) + return response + + def get_user_by_name(self, username, **kwargs): + """ + Get user by user name + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.get_user_by_name(username, callback=callback_function) + + :param callback function: The callback function + for asynchronous request. (optional) + :param str username: The name that needs to be fetched. Use user1 for testing. (required) + :return: User + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['username'] + all_params.append('callback') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_user_by_name" % key + ) + params[key] = val + del params['kwargs'] + + # verify the required parameter 'username' is set + if ('username' not in params) or (params['username'] is None): + raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`") + + resource_path = '/user/{username}'.replace('{format}', 'json') + path_params = {} + if 'username' in params: + path_params['username'] = params['username'] + + query_params = {} + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + + # HTTP header `Accept` + header_params['Accept'] = self.api_client.\ + select_header_accept(['application/json', 'application/xml']) + if not header_params['Accept']: + del header_params['Accept'] + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type([]) + + # Authentication setting + auth_settings = [] + + response = self.api_client.call_api(resource_path, 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='User', + auth_settings=auth_settings, + callback=params.get('callback')) + return response + def login_user(self, **kwargs): """ Logs user into the system @@ -415,83 +569,6 @@ class UserApi(object): callback=params.get('callback')) return response - def get_user_by_name(self, username, **kwargs): - """ - Get user by user name - - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.get_user_by_name(username, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str username: The name that needs to be fetched. Use user1 for testing. (required) - :return: User - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['username'] - all_params.append('callback') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_user_by_name" % key - ) - params[key] = val - del params['kwargs'] - - # verify the required parameter 'username' is set - if ('username' not in params) or (params['username'] is None): - raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`") - - resource_path = '/user/{username}'.replace('{format}', 'json') - path_params = {} - if 'username' in params: - path_params['username'] = params['username'] - - query_params = {} - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json', 'application/xml']) - if not header_params['Accept']: - del header_params['Accept'] - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type([]) - - # Authentication setting - auth_settings = [] - - response = self.api_client.call_api(resource_path, 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='User', - auth_settings=auth_settings, - callback=params.get('callback')) - return response - def update_user(self, username, **kwargs): """ Updated user @@ -571,80 +648,3 @@ class UserApi(object): auth_settings=auth_settings, callback=params.get('callback')) return response - - def delete_user(self, username, **kwargs): - """ - Delete user - This can only be done by the logged in user. - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.delete_user(username, callback=callback_function) - - :param callback function: The callback function - for asynchronous request. (optional) - :param str username: The name that needs to be deleted (required) - :return: None - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['username'] - all_params.append('callback') - - params = locals() - for key, val in iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method delete_user" % key - ) - params[key] = val - del params['kwargs'] - - # verify the required parameter 'username' is set - if ('username' not in params) or (params['username'] is None): - raise ValueError("Missing the required parameter `username` when calling `delete_user`") - - resource_path = '/user/{username}'.replace('{format}', 'json') - path_params = {} - if 'username' in params: - path_params['username'] = params['username'] - - query_params = {} - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - - # HTTP header `Accept` - header_params['Accept'] = self.api_client.\ - select_header_accept(['application/json', 'application/xml']) - if not header_params['Accept']: - del header_params['Accept'] - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.\ - select_header_content_type([]) - - # Authentication setting - auth_settings = [] - - response = self.api_client.call_api(resource_path, 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, - auth_settings=auth_settings, - callback=params.get('callback')) - return response diff --git a/samples/client/petstore/python/swagger_client/models/__init__.py b/samples/client/petstore/python/swagger_client/models/__init__.py index 399e634fe30..9359039077f 100644 --- a/samples/client/petstore/python/swagger_client/models/__init__.py +++ b/samples/client/petstore/python/swagger_client/models/__init__.py @@ -1,11 +1,12 @@ from __future__ import absolute_import # import models into model package -from .user import User from .category import Category -from .pet import Pet -from .tag import Tag -from .object_return import ObjectReturn -from .order import Order -from .special_model_name import SpecialModelName from .inline_response_200 import InlineResponse200 +from .model_return import ModelReturn +from .name import Name +from .order import Order +from .pet import Pet +from .special_model_name import SpecialModelName +from .tag import Tag +from .user import User diff --git a/samples/client/petstore/python/swagger_client/models/inline_response_200.py b/samples/client/petstore/python/swagger_client/models/inline_response_200.py new file mode 100644 index 00000000000..f55ff5ee4d5 --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/inline_response_200.py @@ -0,0 +1,251 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class InlineResponse200(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + InlineResponse200 - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'tags': 'list[Tag]', + 'id': 'int', + 'category': 'object', + 'status': 'str', + 'name': 'str', + 'photo_urls': 'list[str]' + } + + self.attribute_map = { + 'tags': 'tags', + 'id': 'id', + 'category': 'category', + 'status': 'status', + 'name': 'name', + 'photo_urls': 'photoUrls' + } + + self._tags = None + self._id = None + self._category = None + self._status = None + self._name = None + self._photo_urls = None + + @property + def tags(self): + """ + Gets the tags of this InlineResponse200. + + + :return: The tags of this InlineResponse200. + :rtype: list[Tag] + """ + return self._tags + + @tags.setter + def tags(self, tags): + """ + Sets the tags of this InlineResponse200. + + + :param tags: The tags of this InlineResponse200. + :type: list[Tag] + """ + self._tags = tags + + @property + def id(self): + """ + Gets the id of this InlineResponse200. + + + :return: The id of this InlineResponse200. + :rtype: int + """ + return self._id + + @id.setter + def id(self, id): + """ + Sets the id of this InlineResponse200. + + + :param id: The id of this InlineResponse200. + :type: int + """ + self._id = id + + @property + def category(self): + """ + Gets the category of this InlineResponse200. + + + :return: The category of this InlineResponse200. + :rtype: object + """ + return self._category + + @category.setter + def category(self, category): + """ + Sets the category of this InlineResponse200. + + + :param category: The category of this InlineResponse200. + :type: object + """ + self._category = category + + @property + def status(self): + """ + Gets the status of this InlineResponse200. + pet status in the store + + :return: The status of this InlineResponse200. + :rtype: str + """ + return self._status + + @status.setter + def status(self, status): + """ + Sets the status of this InlineResponse200. + pet status in the store + + :param status: The status of this InlineResponse200. + :type: str + """ + allowed_values = ["available", "pending", "sold"] + if status not in allowed_values: + raise ValueError( + "Invalid value for `status`, must be one of {0}" + .format(allowed_values) + ) + self._status = status + + @property + def name(self): + """ + Gets the name of this InlineResponse200. + + + :return: The name of this InlineResponse200. + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """ + Sets the name of this InlineResponse200. + + + :param name: The name of this InlineResponse200. + :type: str + """ + self._name = name + + @property + def photo_urls(self): + """ + Gets the photo_urls of this InlineResponse200. + + + :return: The photo_urls of this InlineResponse200. + :rtype: list[str] + """ + return self._photo_urls + + @photo_urls.setter + def photo_urls(self, photo_urls): + """ + Sets the photo_urls of this InlineResponse200. + + + :param photo_urls: The photo_urls of this InlineResponse200. + :type: list[str] + """ + self._photo_urls = photo_urls + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other + diff --git a/samples/client/petstore/python/swagger_client/models/model_return.py b/samples/client/petstore/python/swagger_client/models/model_return.py new file mode 100644 index 00000000000..75b46259d6f --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/model_return.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class ModelReturn(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + ModelReturn - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + '_return': 'int' + } + + self.attribute_map = { + '_return': 'return' + } + + self.__return = None + + @property + def _return(self): + """ + Gets the _return of this ModelReturn. + + + :return: The _return of this ModelReturn. + :rtype: int + """ + return self.__return + + @_return.setter + def _return(self, _return): + """ + Sets the _return of this ModelReturn. + + + :param _return: The _return of this ModelReturn. + :type: int + """ + self.__return = _return + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other + diff --git a/samples/client/petstore/python/swagger_client/models/name.py b/samples/client/petstore/python/swagger_client/models/name.py new file mode 100644 index 00000000000..52187bd7bc5 --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/name.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class Name(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + Name - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'name': 'int' + } + + self.attribute_map = { + 'name': 'name' + } + + self._name = None + + @property + def name(self): + """ + Gets the name of this Name. + + + :return: The name of this Name. + :rtype: int + """ + return self._name + + @name.setter + def name(self, name): + """ + Sets the name of this Name. + + + :param name: The name of this Name. + :type: int + """ + self._name = name + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other + diff --git a/samples/client/petstore/python/swagger_client/models/special_model_name.py b/samples/client/petstore/python/swagger_client/models/special_model_name.py new file mode 100644 index 00000000000..191798d7d9a --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/special_model_name.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class SpecialModelName(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + SpecialModelName - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'special_property_name': 'int' + } + + self.attribute_map = { + 'special_property_name': '$special[property.name]' + } + + self._special_property_name = None + + @property + def special_property_name(self): + """ + Gets the special_property_name of this SpecialModelName. + + + :return: The special_property_name of this SpecialModelName. + :rtype: int + """ + return self._special_property_name + + @special_property_name.setter + def special_property_name(self, special_property_name): + """ + Sets the special_property_name of this SpecialModelName. + + + :param special_property_name: The special_property_name of this SpecialModelName. + :type: int + """ + self._special_property_name = special_property_name + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other + diff --git a/samples/client/petstore/ruby/git_push.sh b/samples/client/petstore/ruby/git_push.sh new file mode 100644 index 00000000000..1a36388db02 --- /dev/null +++ b/samples/client/petstore/ruby/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="YOUR_GIT_USR_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="YOUR_GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index d42b7daef8b..52284be90b2 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -24,6 +24,7 @@ require 'petstore/configuration' require 'petstore/models/category' require 'petstore/models/inline_response_200' require 'petstore/models/model_return' +require 'petstore/models/name' require 'petstore/models/order' require 'petstore/models/pet' require 'petstore/models/special_model_name' diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index 4a5d45d766c..29f631a983e 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -360,7 +360,7 @@ module Petstore # http body (model) post_body = nil - auth_names = ['petstore_auth', 'api_key'] + auth_names = ['api_key', 'petstore_auth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -420,7 +420,7 @@ module Petstore # http body (model) post_body = nil - auth_names = ['petstore_auth', 'api_key'] + auth_names = ['api_key', 'petstore_auth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -480,7 +480,7 @@ module Petstore # http body (model) post_body = nil - auth_names = ['petstore_auth', 'api_key'] + auth_names = ['api_key', 'petstore_auth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index 7bdfd013bf6..11bdfaadf62 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -301,7 +301,7 @@ module Petstore # http body (model) post_body = nil - auth_names = ['test_api_key_query', 'test_api_key_header'] + auth_names = ['test_api_key_header', 'test_api_key_query'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/configuration.rb b/samples/client/petstore/ruby/lib/petstore/configuration.rb index 60f689cda6d..e5f39898027 100644 --- a/samples/client/petstore/ruby/lib/petstore/configuration.rb +++ b/samples/client/petstore/ruby/lib/petstore/configuration.rb @@ -157,26 +157,12 @@ module Petstore # Returns Auth Settings hash for api client. def auth_settings { - 'petstore_auth' => - { - type: 'oauth2', - in: 'header', - key: 'Authorization', - value: "Bearer #{access_token}" - }, - 'test_api_client_id' => + 'test_api_key_header' => { type: 'api_key', in: 'header', - key: 'x-test_api_client_id', - value: api_key_with_prefix('x-test_api_client_id') - }, - 'test_api_client_secret' => - { - type: 'api_key', - in: 'header', - key: 'x-test_api_client_secret', - value: api_key_with_prefix('x-test_api_client_secret') + key: 'test_api_key_header', + value: api_key_with_prefix('test_api_key_header') }, 'api_key' => { @@ -185,6 +171,20 @@ module Petstore key: 'api_key', value: api_key_with_prefix('api_key') }, + 'test_api_client_secret' => + { + type: 'api_key', + in: 'header', + key: 'x-test_api_client_secret', + value: api_key_with_prefix('x-test_api_client_secret') + }, + 'test_api_client_id' => + { + type: 'api_key', + in: 'header', + key: 'x-test_api_client_id', + value: api_key_with_prefix('x-test_api_client_id') + }, 'test_api_key_query' => { type: 'api_key', @@ -192,12 +192,12 @@ module Petstore key: 'test_api_key_query', value: api_key_with_prefix('test_api_key_query') }, - 'test_api_key_header' => + 'petstore_auth' => { - type: 'api_key', + type: 'oauth2', in: 'header', - key: 'test_api_key_header', - value: api_key_with_prefix('test_api_key_header') + key: 'Authorization', + value: "Bearer #{access_token}" }, } end diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb b/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb index a793250e45b..190170f18eb 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb @@ -18,34 +18,34 @@ require 'date' module Petstore class InlineResponse200 - attr_accessor :photo_urls - - attr_accessor :name + attr_accessor :tags attr_accessor :id attr_accessor :category - attr_accessor :tags - # pet status in the store attr_accessor :status + attr_accessor :name + + attr_accessor :photo_urls + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'photo_urls' => :'photoUrls', - - :'name' => :'name', + :'tags' => :'tags', :'id' => :'id', :'category' => :'category', - :'tags' => :'tags', + :'status' => :'status', - :'status' => :'status' + :'name' => :'name', + + :'photo_urls' => :'photoUrls' } end @@ -53,12 +53,12 @@ module Petstore # Attribute type mapping. def self.swagger_types { - :'photo_urls' => :'Array', - :'name' => :'String', + :'tags' => :'Array', :'id' => :'Integer', :'category' => :'Object', - :'tags' => :'Array', - :'status' => :'String' + :'status' => :'String', + :'name' => :'String', + :'photo_urls' => :'Array' } end @@ -70,16 +70,12 @@ module Petstore attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} - if attributes[:'photoUrls'] - if (value = attributes[:'photoUrls']).is_a?(Array) - self.photo_urls = value + if attributes[:'tags'] + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value end end - if attributes[:'name'] - self.name = attributes[:'name'] - end - if attributes[:'id'] self.id = attributes[:'id'] end @@ -88,16 +84,20 @@ module Petstore self.category = attributes[:'category'] end - if attributes[:'tags'] - if (value = attributes[:'tags']).is_a?(Array) - self.tags = value - end - end - if attributes[:'status'] self.status = attributes[:'status'] end + if attributes[:'name'] + self.name = attributes[:'name'] + end + + if attributes[:'photoUrls'] + if (value = attributes[:'photoUrls']).is_a?(Array) + self.photo_urls = value + end + end + end # Custom attribute writer method checking allowed values (enum). @@ -113,12 +113,12 @@ module Petstore def ==(o) return true if self.equal?(o) self.class == o.class && - photo_urls == o.photo_urls && - name == o.name && + tags == o.tags && id == o.id && category == o.category && - tags == o.tags && - status == o.status + status == o.status && + name == o.name && + photo_urls == o.photo_urls end # @see the `==` method @@ -128,7 +128,7 @@ module Petstore # Calculate hash code according to all attributes. def hash - [photo_urls, name, id, category, tags, status].hash + [tags, id, category, status, name, photo_urls].hash end # build the object from hash diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb new file mode 100644 index 00000000000..d0b950edaa3 --- /dev/null +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -0,0 +1,165 @@ +=begin +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'date' + +module Petstore + class Name + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + + :'name' => :'name' + + } + end + + # Attribute type mapping. + def self.swagger_types + { + :'name' => :'Integer' + + } + end + + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + + + if attributes[:'name'] + self.name = attributes[:'name'] + end + + end + + # Check equality by comparing each attribute. + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name + end + + # @see the `==` method + def eql?(o) + self == o + end + + # Calculate hash code according to all attributes. + def hash + [name].hash + end + + # build the object from hash + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.swagger_types.each_pair do |key, type| + if type =~ /^Array<(.*)>/i + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) + else + #TODO show warning in debug mode + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + else + # data not found in attributes(hash), not an issue as the data can be optional + end + end + + self + end + + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /^(true|t|yes|y|1)$/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + _model = Petstore.const_get(type).new + _model.build_from_hash(value) + end + end + + def to_s + to_hash.to_s + end + + # to_body is an alias to to_body (backward compatibility)) + def to_body + to_hash + end + + # return the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Method to output non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + def _to_hash(value) + if value.is_a?(Array) + value.compact.map{ |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end +end diff --git a/samples/client/petstore/ruby/spec/models/category_spec.rb b/samples/client/petstore/ruby/spec/models/category_spec.rb index 5c99a87bf86..745974cbabd 100644 --- a/samples/client/petstore/ruby/spec/models/category_spec.rb +++ b/samples/client/petstore/ruby/spec/models/category_spec.rb @@ -18,7 +18,7 @@ require 'spec_helper' require 'json' require 'date' -# Unit tests for Petstore:: +# Unit tests for Petstore::Category # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) # Please update as you see appropriate describe 'Category' do diff --git a/samples/client/petstore/ruby/spec/models/inline_response_200_spec.rb b/samples/client/petstore/ruby/spec/models/inline_response_200_spec.rb index 72394650478..6010167fe8d 100644 --- a/samples/client/petstore/ruby/spec/models/inline_response_200_spec.rb +++ b/samples/client/petstore/ruby/spec/models/inline_response_200_spec.rb @@ -18,7 +18,7 @@ require 'spec_helper' require 'json' require 'date' -# Unit tests for Petstore:: +# Unit tests for Petstore::InlineResponse200 # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) # Please update as you see appropriate describe 'InlineResponse200' do @@ -36,17 +36,8 @@ describe 'InlineResponse200' do @instance.should be_a(Petstore::InlineResponse200) end end - describe 'test attribute "photo_urls"' do - it 'should work' do - # assertion here - # should be_a() - # should be_nil - # should == - # should_not == - end - end - - describe 'test attribute "name"' do + + describe 'test attribute "tags"' do it 'should work' do # assertion here # should be_a() @@ -76,7 +67,7 @@ describe 'InlineResponse200' do end end - describe 'test attribute "tags"' do + describe 'test attribute "status"' do it 'should work' do # assertion here # should be_a() @@ -86,7 +77,17 @@ describe 'InlineResponse200' do end end - describe 'test attribute "status"' do + describe 'test attribute "name"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + + describe 'test attribute "photo_urls"' do it 'should work' do # assertion here # should be_a() diff --git a/samples/client/petstore/ruby/spec/models/name_spec.rb b/samples/client/petstore/ruby/spec/models/name_spec.rb new file mode 100644 index 00000000000..586f2618655 --- /dev/null +++ b/samples/client/petstore/ruby/spec/models/name_spec.rb @@ -0,0 +1,50 @@ +=begin +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Name +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Name' do + before do + # run before each test + @instance = Petstore::Name.new + end + + after do + # run after each test + end + + describe 'test an instance of Name' do + it 'should create an instact of Name' do + @instance.should be_a(Petstore::Name) + end + end + describe 'test attribute "name"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + +end + diff --git a/samples/client/petstore/ruby/spec/models/order_spec.rb b/samples/client/petstore/ruby/spec/models/order_spec.rb index a78677410ef..698f3af9268 100644 --- a/samples/client/petstore/ruby/spec/models/order_spec.rb +++ b/samples/client/petstore/ruby/spec/models/order_spec.rb @@ -18,7 +18,7 @@ require 'spec_helper' require 'json' require 'date' -# Unit tests for Petstore:: +# Unit tests for Petstore::Order # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) # Please update as you see appropriate describe 'Order' do diff --git a/samples/client/petstore/ruby/spec/models/pet_spec.rb b/samples/client/petstore/ruby/spec/models/pet_spec.rb index f78259b5910..cf18e1a5f3a 100644 --- a/samples/client/petstore/ruby/spec/models/pet_spec.rb +++ b/samples/client/petstore/ruby/spec/models/pet_spec.rb @@ -18,7 +18,7 @@ require 'spec_helper' require 'json' require 'date' -# Unit tests for Petstore:: +# Unit tests for Petstore::Pet # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) # Please update as you see appropriate describe 'Pet' do diff --git a/samples/client/petstore/ruby/spec/models/special_model_name_spec.rb b/samples/client/petstore/ruby/spec/models/special_model_name_spec.rb index c42e6229085..e3201cb2e31 100644 --- a/samples/client/petstore/ruby/spec/models/special_model_name_spec.rb +++ b/samples/client/petstore/ruby/spec/models/special_model_name_spec.rb @@ -18,7 +18,7 @@ require 'spec_helper' require 'json' require 'date' -# Unit tests for Petstore:: +# Unit tests for Petstore::SpecialModelName # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) # Please update as you see appropriate describe 'SpecialModelName' do diff --git a/samples/client/petstore/ruby/spec/models/tag_spec.rb b/samples/client/petstore/ruby/spec/models/tag_spec.rb index e13c9169b8f..4b3ff7ac611 100644 --- a/samples/client/petstore/ruby/spec/models/tag_spec.rb +++ b/samples/client/petstore/ruby/spec/models/tag_spec.rb @@ -18,7 +18,7 @@ require 'spec_helper' require 'json' require 'date' -# Unit tests for Petstore:: +# Unit tests for Petstore::Tag # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) # Please update as you see appropriate describe 'Tag' do diff --git a/samples/client/petstore/ruby/spec/models/user_spec.rb b/samples/client/petstore/ruby/spec/models/user_spec.rb index 1d02e14e03a..2c289705417 100644 --- a/samples/client/petstore/ruby/spec/models/user_spec.rb +++ b/samples/client/petstore/ruby/spec/models/user_spec.rb @@ -18,7 +18,7 @@ require 'spec_helper' require 'json' require 'date' -# Unit tests for Petstore:: +# Unit tests for Petstore::User # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) # Please update as you see appropriate describe 'User' do diff --git a/samples/client/petstore/scala/.gitignore b/samples/client/petstore/scala/.gitignore new file mode 100644 index 00000000000..c58d83b3189 --- /dev/null +++ b/samples/client/petstore/scala/.gitignore @@ -0,0 +1,17 @@ +*.class +*.log + +# sbt specific +.cache +.history +.lib/ +dist/* +target/ +lib_managed/ +src_managed/ +project/boot/ +project/plugins/project/ + +# Scala-IDE specific +.scala_dependencies +.worksheet diff --git a/samples/client/petstore/scala/git_push.sh b/samples/client/petstore/scala/git_push.sh new file mode 100644 index 00000000000..1a36388db02 --- /dev/null +++ b/samples/client/petstore/scala/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="YOUR_GIT_USR_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="YOUR_GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala index a11cab9211b..cccc54415db 100644 --- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala +++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala @@ -1,6 +1,7 @@ package io.swagger.client.api import io.swagger.client.model.Pet +import io.swagger.client.model.InlineResponse200 import java.io.File import io.swagger.client.ApiInvoker import io.swagger.client.ApiException @@ -23,53 +24,6 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value - /** - * Update an existing pet - * - * @param body Pet object that needs to be added to the store - * @return void - */ - def updatePet (body: Pet) = { - // create path and map variables - val path = "/pet".replaceAll("\\{format\\}","json") - - val contentTypes = List("application/json", "application/xml", "application/json") - val contentType = contentTypes(0) - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - val formParams = new HashMap[String, String] - - - - - - - - var postBody: AnyRef = body - - if(contentType.startsWith("multipart/form-data")) { - val mp = new FormDataMultiPart() - - postBody = mp - } - else { - - } - - try { - apiInvoker.invokeApi(basePath, path, "PUT", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { - case s: String => - - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } - /** * Add a new pet to the store * @@ -117,10 +71,108 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", } } + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param body Pet object in the form of byte array + * @return void + */ + def addPetUsingByteArray (body: String) = { + // create path and map variables + val path = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json") + + val contentTypes = List("application/json", "application/xml", "application/json") + val contentType = contentTypes(0) + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + val formParams = new HashMap[String, String] + + + + + + + + var postBody: AnyRef = body + + if(contentType.startsWith("multipart/form-data")) { + val mp = new FormDataMultiPart() + + postBody = mp + } + else { + + } + + try { + apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { + case s: String => + + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + * @return void + */ + def deletePet (petId: Long, apiKey: String) = { + // create path and map variables + val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) + + + + val contentTypes = List("application/json") + val contentType = contentTypes(0) + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + val formParams = new HashMap[String, String] + + + + + + headerParams += "api_key" -> apiKey + + + var postBody: AnyRef = null + + if(contentType.startsWith("multipart/form-data")) { + val mp = new FormDataMultiPart() + + postBody = mp + } + else { + + } + + try { + apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { + case s: String => + + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + /** * Finds Pets by status - * Multiple status values can be provided with comma seperated strings - * @param status Status values that need to be considered for filter + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for query * @return List[Pet] */ def findPetsByStatus (status: List[String] /* = available */) : Option[List[Pet]] = { @@ -265,6 +317,153 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", } } + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return InlineResponse200 + */ + def getPetByIdInObject (petId: Long) : Option[InlineResponse200] = { + // create path and map variables + val path = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) + + + + val contentTypes = List("application/json") + val contentType = contentTypes(0) + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + val formParams = new HashMap[String, String] + + + + + + + + var postBody: AnyRef = null + + if(contentType.startsWith("multipart/form-data")) { + val mp = new FormDataMultiPart() + + postBody = mp + } + else { + + } + + try { + apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { + case s: String => + Some(ApiInvoker.deserialize(s, "", classOf[InlineResponse200]).asInstanceOf[InlineResponse200]) + + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return String + */ + def petPetIdtestingByteArraytrueGet (petId: Long) : Option[String] = { + // create path and map variables + val path = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) + + + + val contentTypes = List("application/json") + val contentType = contentTypes(0) + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + val formParams = new HashMap[String, String] + + + + + + + + var postBody: AnyRef = null + + if(contentType.startsWith("multipart/form-data")) { + val mp = new FormDataMultiPart() + + postBody = mp + } + else { + + } + + try { + apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { + case s: String => + Some(ApiInvoker.deserialize(s, "", classOf[String]).asInstanceOf[String]) + + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + * @return void + */ + def updatePet (body: Pet) = { + // create path and map variables + val path = "/pet".replaceAll("\\{format\\}","json") + + val contentTypes = List("application/json", "application/xml", "application/json") + val contentType = contentTypes(0) + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + val formParams = new HashMap[String, String] + + + + + + + + var postBody: AnyRef = body + + if(contentType.startsWith("multipart/form-data")) { + val mp = new FormDataMultiPart() + + postBody = mp + } + else { + + } + + try { + apiInvoker.invokeApi(basePath, path, "PUT", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { + case s: String => + + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + /** * Updates a pet in the store with form data * @@ -322,57 +521,6 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", } } - /** - * Deletes a pet - * - * @param petId Pet id to delete - * @param apiKey - * @return void - */ - def deletePet (petId: Long, apiKey: String) = { - // create path and map variables - val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) - - - - val contentTypes = List("application/json") - val contentType = contentTypes(0) - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - val formParams = new HashMap[String, String] - - - - - - headerParams += "api_key" -> apiKey - - - var postBody: AnyRef = null - - if(contentType.startsWith("multipart/form-data")) { - val mp = new FormDataMultiPart() - - postBody = mp - } - else { - - } - - try { - apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { - case s: String => - - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } - /** * uploads an image * diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/StoreApi.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/StoreApi.scala index 9b3cc91d788..2b0289ae2dc 100644 --- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/StoreApi.scala +++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/StoreApi.scala @@ -22,6 +22,104 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted + * @return void + */ + def deleteOrder (orderId: String) = { + // create path and map variables + val path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}",apiInvoker.escape(orderId)) + + + + val contentTypes = List("application/json") + val contentType = contentTypes(0) + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + val formParams = new HashMap[String, String] + + + + + + + + var postBody: AnyRef = null + + if(contentType.startsWith("multipart/form-data")) { + val mp = new FormDataMultiPart() + + postBody = mp + } + else { + + } + + try { + apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { + case s: String => + + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + + /** + * Finds orders by status + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query + * @return List[Order] + */ + def findOrdersByStatus (status: String /* = placed */) : Option[List[Order]] = { + // create path and map variables + val path = "/store/findByStatus".replaceAll("\\{format\\}","json") + + val contentTypes = List("application/json") + val contentType = contentTypes(0) + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + val formParams = new HashMap[String, String] + + + + if(String.valueOf(status) != "null") queryParams += "status" -> status.toString + + + + + var postBody: AnyRef = null + + if(contentType.startsWith("multipart/form-data")) { + val mp = new FormDataMultiPart() + + postBody = mp + } + else { + + } + + try { + apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { + case s: String => + Some(ApiInvoker.deserialize(s, "array", classOf[Order]).asInstanceOf[List[Order]]) + + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -70,14 +168,13 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", } /** - * Place an order for a pet - * - * @param body order placed for purchasing the pet - * @return Order + * Fake endpoint to test arbitrary object return by 'Get inventory' + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Any */ - def placeOrder (body: Order) : Option[Order] = { + def getInventoryInObject () : Option[Any] = { // create path and map variables - val path = "/store/order".replaceAll("\\{format\\}","json") + val path = "/store/inventory?response=arbitrary_object".replaceAll("\\{format\\}","json") val contentTypes = List("application/json") val contentType = contentTypes(0) @@ -93,7 +190,7 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", - var postBody: AnyRef = body + var postBody: AnyRef = null if(contentType.startsWith("multipart/form-data")) { val mp = new FormDataMultiPart() @@ -105,9 +202,9 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", } try { - apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { + apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { case s: String => - Some(ApiInvoker.deserialize(s, "", classOf[Order]).asInstanceOf[Order]) + Some(ApiInvoker.deserialize(s, "", classOf[Any]).asInstanceOf[Any]) case _ => None } @@ -168,16 +265,14 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", } /** - * Delete purchase order by ID - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @param orderId ID of the order that needs to be deleted - * @return void + * Place an order for a pet + * + * @param body order placed for purchasing the pet + * @return Order */ - def deleteOrder (orderId: String) = { + def placeOrder (body: Order) : Option[Order] = { // create path and map variables - val path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}",apiInvoker.escape(orderId)) - - + val path = "/store/order".replaceAll("\\{format\\}","json") val contentTypes = List("application/json") val contentType = contentTypes(0) @@ -193,7 +288,7 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", - var postBody: AnyRef = null + var postBody: AnyRef = body if(contentType.startsWith("multipart/form-data")) { val mp = new FormDataMultiPart() @@ -205,9 +300,10 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", } try { - apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { + apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { case s: String => - + Some(ApiInvoker.deserialize(s, "", classOf[Order]).asInstanceOf[Order]) + case _ => None } } catch { diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/UserApi.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/UserApi.scala index 802cf01c25b..e728ddfe311 100644 --- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/UserApi.scala +++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/UserApi.scala @@ -163,6 +163,105 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", } } + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + * @return void + */ + def deleteUser (username: String) = { + // create path and map variables + val path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username)) + + + + val contentTypes = List("application/json") + val contentType = contentTypes(0) + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + val formParams = new HashMap[String, String] + + + + + + + + var postBody: AnyRef = null + + if(contentType.startsWith("multipart/form-data")) { + val mp = new FormDataMultiPart() + + postBody = mp + } + else { + + } + + try { + apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { + case s: String => + + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + * @return User + */ + def getUserByName (username: String) : Option[User] = { + // create path and map variables + val path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username)) + + + + val contentTypes = List("application/json") + val contentType = contentTypes(0) + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + val formParams = new HashMap[String, String] + + + + + + + + var postBody: AnyRef = null + + if(contentType.startsWith("multipart/form-data")) { + val mp = new FormDataMultiPart() + + postBody = mp + } + else { + + } + + try { + apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { + case s: String => + Some(ApiInvoker.deserialize(s, "", classOf[User]).asInstanceOf[User]) + + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + /** * Logs user into the system * @@ -260,56 +359,6 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", } } - /** - * Get user by user name - * - * @param username The name that needs to be fetched. Use user1 for testing. - * @return User - */ - def getUserByName (username: String) : Option[User] = { - // create path and map variables - val path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username)) - - - - val contentTypes = List("application/json") - val contentType = contentTypes(0) - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - val formParams = new HashMap[String, String] - - - - - - - - var postBody: AnyRef = null - - if(contentType.startsWith("multipart/form-data")) { - val mp = new FormDataMultiPart() - - postBody = mp - } - else { - - } - - try { - apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { - case s: String => - Some(ApiInvoker.deserialize(s, "", classOf[User]).asInstanceOf[User]) - - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } - /** * Updated user * This can only be done by the logged in user. @@ -360,53 +409,4 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", } } - /** - * Delete user - * This can only be done by the logged in user. - * @param username The name that needs to be deleted - * @return void - */ - def deleteUser (username: String) = { - // create path and map variables - val path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username)) - - - - val contentTypes = List("application/json") - val contentType = contentTypes(0) - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - val formParams = new HashMap[String, String] - - - - - - - - var postBody: AnyRef = null - - if(contentType.startsWith("multipart/form-data")) { - val mp = new FormDataMultiPart() - - postBody = mp - } - else { - - } - - try { - apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { - case s: String => - - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } - } diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/InlineResponse200.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/InlineResponse200.scala new file mode 100644 index 00000000000..e13f63eeefb --- /dev/null +++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/InlineResponse200.scala @@ -0,0 +1,14 @@ +package io.swagger.client.model + + + + +case class InlineResponse200 ( + tags: List[Tag], + id: Long, + category: Any, + /* pet status in the store */ + status: String, + name: String, + photoUrls: List[String]) + diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Name.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Name.scala new file mode 100644 index 00000000000..854a11e6088 --- /dev/null +++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Name.scala @@ -0,0 +1,8 @@ +package io.swagger.client.model + + + + +case class Name ( + name: Integer) + diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/SpecialModelName.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/SpecialModelName.scala new file mode 100644 index 00000000000..2fee09a7f7c --- /dev/null +++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/SpecialModelName.scala @@ -0,0 +1,8 @@ +package io.swagger.client.model + + + + +case class SpecialModelName ( + specialPropertyName: Long) + diff --git a/samples/client/petstore/swift/.gitignore b/samples/client/petstore/swift/.gitignore new file mode 100644 index 00000000000..5e5d5cebcf4 --- /dev/null +++ b/samples/client/petstore/swift/.gitignore @@ -0,0 +1,63 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md + +fastlane/report.xml +fastlane/screenshots diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift index 0b3c5393aa6..3e24fae5153 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift @@ -11,63 +11,6 @@ import PromiseKit public class PetAPI: APIBase { - /** - - Update an existing pet - - - parameter body: (body) Pet object that needs to be added to the store - - parameter completion: completion handler to receive the data and the error objects - */ - public class func updatePet(body body: Pet?, completion: ((error: ErrorType?) -> Void)) { - updatePetWithRequestBuilder(body: body).execute { (response, error) -> Void in - completion(error: error); - } - } - - /** - - Update an existing pet - - - parameter body: (body) Pet object that needs to be added to the store - - returns: Promise - */ - public class func updatePet(body body: Pet?) -> Promise { - let deferred = Promise.pendingPromise() - updatePet(body: body) { error in - if let error = error { - deferred.reject(error) - } else { - deferred.fulfill() - } - } - return deferred.promise - } - - /** - - Update an existing pet - - - PUT /pet - - - - OAuth: - - type: oauth2 - - name: petstore_auth - - - parameter body: (body) Pet object that needs to be added to the store - - - returns: RequestBuilder - */ - public class func updatePetWithRequestBuilder(body body: Pet?) -> RequestBuilder { - let path = "/pet" - let URLString = PetstoreClientAPI.basePath + path - - let parameters = body?.encodeToJSON() as? [String:AnyObject] - - let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - - return requestBuilder.init(method: "PUT", URLString: URLString, parameters: parameters, isBody: true) - } - /** Add a new pet to the store @@ -125,6 +68,122 @@ public class PetAPI: APIBase { return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true) } + /** + + Fake endpoint to test byte array in body parameter for adding a new pet to the store + + - parameter body: (body) Pet object in the form of byte array + - parameter completion: completion handler to receive the data and the error objects + */ + public class func addPetUsingByteArray(body body: String?, completion: ((error: ErrorType?) -> Void)) { + addPetUsingByteArrayWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + + Fake endpoint to test byte array in body parameter for adding a new pet to the store + + - parameter body: (body) Pet object in the form of byte array + - returns: Promise + */ + public class func addPetUsingByteArray(body body: String?) -> Promise { + let deferred = Promise.pendingPromise() + addPetUsingByteArray(body: body) { error in + if let error = error { + deferred.reject(error) + } else { + deferred.fulfill() + } + } + return deferred.promise + } + + /** + + Fake endpoint to test byte array in body parameter for adding a new pet to the store + + - POST /pet?testing_byte_array=true + - + - OAuth: + - type: oauth2 + - name: petstore_auth + + - parameter body: (body) Pet object in the form of byte array + + - returns: RequestBuilder + */ + public class func addPetUsingByteArrayWithRequestBuilder(body body: String?) -> RequestBuilder { + let path = "/pet?testing_byte_array=true" + let URLString = PetstoreClientAPI.basePath + path + + let parameters = body?.encodeToJSON() as? [String:AnyObject] + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true) + } + + /** + + Deletes a pet + + - parameter petId: (path) Pet id to delete + - parameter completion: completion handler to receive the data and the error objects + */ + public class func deletePet(petId petId: Int, completion: ((error: ErrorType?) -> Void)) { + deletePetWithRequestBuilder(petId: petId).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + + Deletes a pet + + - parameter petId: (path) Pet id to delete + - returns: Promise + */ + public class func deletePet(petId petId: Int) -> Promise { + let deferred = Promise.pendingPromise() + deletePet(petId: petId) { error in + if let error = error { + deferred.reject(error) + } else { + deferred.fulfill() + } + } + return deferred.promise + } + + /** + + Deletes a pet + + - DELETE /pet/{petId} + - + - OAuth: + - type: oauth2 + - name: petstore_auth + + - parameter petId: (path) Pet id to delete + + - returns: RequestBuilder + */ + public class func deletePetWithRequestBuilder(petId petId: Int) -> RequestBuilder { + var path = "/pet/{petId}" + path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [:] + let parameters = APIHelper.rejectNil(nillableParameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true) + } + /** Finds Pets by status @@ -445,201 +504,6 @@ public class PetAPI: APIBase { return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true) } - /** - - Updates a pet in the store with form data - - - parameter petId: (path) ID of pet that needs to be updated - - parameter name: (form) Updated name of the pet - - parameter status: (form) Updated status of the pet - - parameter completion: completion handler to receive the data and the error objects - */ - public class func updatePetWithForm(petId petId: String, name: String?, status: String?, completion: ((error: ErrorType?) -> Void)) { - updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in - completion(error: error); - } - } - - /** - - Updates a pet in the store with form data - - - parameter petId: (path) ID of pet that needs to be updated - - parameter name: (form) Updated name of the pet - - parameter status: (form) Updated status of the pet - - returns: Promise - */ - public class func updatePetWithForm(petId petId: String, name: String?, status: String?) -> Promise { - let deferred = Promise.pendingPromise() - updatePetWithForm(petId: petId, name: name, status: status) { error in - if let error = error { - deferred.reject(error) - } else { - deferred.fulfill() - } - } - return deferred.promise - } - - /** - - Updates a pet in the store with form data - - - POST /pet/{petId} - - - - OAuth: - - type: oauth2 - - name: petstore_auth - - - parameter petId: (path) ID of pet that needs to be updated - - parameter name: (form) Updated name of the pet - - parameter status: (form) Updated status of the pet - - - returns: RequestBuilder - */ - public class func updatePetWithFormWithRequestBuilder(petId petId: String, name: String?, status: String?) -> RequestBuilder { - var path = "/pet/{petId}" - path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) - let URLString = PetstoreClientAPI.basePath + path - - let nillableParameters: [String:AnyObject?] = [ - "name": name, - "status": status - ] - let parameters = APIHelper.rejectNil(nillableParameters) - - let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - - return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: false) - } - - /** - - Deletes a pet - - - parameter petId: (path) Pet id to delete - - parameter completion: completion handler to receive the data and the error objects - */ - public class func deletePet(petId petId: Int, completion: ((error: ErrorType?) -> Void)) { - deletePetWithRequestBuilder(petId: petId).execute { (response, error) -> Void in - completion(error: error); - } - } - - /** - - Deletes a pet - - - parameter petId: (path) Pet id to delete - - returns: Promise - */ - public class func deletePet(petId petId: Int) -> Promise { - let deferred = Promise.pendingPromise() - deletePet(petId: petId) { error in - if let error = error { - deferred.reject(error) - } else { - deferred.fulfill() - } - } - return deferred.promise - } - - /** - - Deletes a pet - - - DELETE /pet/{petId} - - - - OAuth: - - type: oauth2 - - name: petstore_auth - - - parameter petId: (path) Pet id to delete - - - returns: RequestBuilder - */ - public class func deletePetWithRequestBuilder(petId petId: Int) -> RequestBuilder { - var path = "/pet/{petId}" - path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) - let URLString = PetstoreClientAPI.basePath + path - - let nillableParameters: [String:AnyObject?] = [:] - let parameters = APIHelper.rejectNil(nillableParameters) - - let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - - return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true) - } - - /** - - uploads an image - - - parameter petId: (path) ID of pet to update - - parameter additionalMetadata: (form) Additional data to pass to server - - parameter _file: (form) file to upload - - parameter completion: completion handler to receive the data and the error objects - */ - public class func uploadFile(petId petId: Int, additionalMetadata: String?, _file: NSURL?, completion: ((error: ErrorType?) -> Void)) { - uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, _file: _file).execute { (response, error) -> Void in - completion(error: error); - } - } - - /** - - uploads an image - - - parameter petId: (path) ID of pet to update - - parameter additionalMetadata: (form) Additional data to pass to server - - parameter _file: (form) file to upload - - returns: Promise - */ - public class func uploadFile(petId petId: Int, additionalMetadata: String?, _file: NSURL?) -> Promise { - let deferred = Promise.pendingPromise() - uploadFile(petId: petId, additionalMetadata: additionalMetadata, _file: _file) { error in - if let error = error { - deferred.reject(error) - } else { - deferred.fulfill() - } - } - return deferred.promise - } - - /** - - uploads an image - - - POST /pet/{petId}/uploadImage - - - - OAuth: - - type: oauth2 - - name: petstore_auth - - - parameter petId: (path) ID of pet to update - - parameter additionalMetadata: (form) Additional data to pass to server - - parameter _file: (form) file to upload - - - returns: RequestBuilder - */ - public class func uploadFileWithRequestBuilder(petId petId: Int, additionalMetadata: String?, _file: NSURL?) -> RequestBuilder { - var path = "/pet/{petId}/uploadImage" - path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) - let URLString = PetstoreClientAPI.basePath + path - - let nillableParameters: [String:AnyObject?] = [ - "additionalMetadata": additionalMetadata, - "file": _file - ] - let parameters = APIHelper.rejectNil(nillableParameters) - - let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - - return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: false) - } - /** Fake endpoint to test inline arbitrary object return by 'Find pet by ID' @@ -686,21 +550,37 @@ public class PetAPI: APIBase { - name: petstore_auth - examples: [{example={ "id" : 123456789, + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], "category" : "{}", - "name" : "doggie" + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] }, contentType=application/json}, {example= 123456 not implemented io.swagger.models.properties.ObjectProperty@37ff6855 + string doggie + string , contentType=application/xml}] - examples: [{example={ "id" : 123456789, + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], "category" : "{}", - "name" : "doggie" + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] }, contentType=application/json}, {example= 123456 not implemented io.swagger.models.properties.ObjectProperty@37ff6855 + string doggie + string , contentType=application/xml}] - parameter petId: (path) ID of pet that needs to be fetched @@ -786,27 +666,27 @@ public class PetAPI: APIBase { /** - Fake endpoint to test byte array in body parameter for adding a new pet to the store + Update an existing pet - - parameter body: (body) Pet object in the form of byte array + - parameter body: (body) Pet object that needs to be added to the store - parameter completion: completion handler to receive the data and the error objects */ - public class func addPetUsingByteArray(body body: String?, completion: ((error: ErrorType?) -> Void)) { - addPetUsingByteArrayWithRequestBuilder(body: body).execute { (response, error) -> Void in + public class func updatePet(body body: Pet?, completion: ((error: ErrorType?) -> Void)) { + updatePetWithRequestBuilder(body: body).execute { (response, error) -> Void in completion(error: error); } } /** - Fake endpoint to test byte array in body parameter for adding a new pet to the store + Update an existing pet - - parameter body: (body) Pet object in the form of byte array + - parameter body: (body) Pet object that needs to be added to the store - returns: Promise */ - public class func addPetUsingByteArray(body body: String?) -> Promise { + public class func updatePet(body body: Pet?) -> Promise { let deferred = Promise.pendingPromise() - addPetUsingByteArray(body: body) { error in + updatePet(body: body) { error in if let error = error { deferred.reject(error) } else { @@ -818,27 +698,163 @@ public class PetAPI: APIBase { /** - Fake endpoint to test byte array in body parameter for adding a new pet to the store + Update an existing pet - - POST /pet?testing_byte_array=true + - PUT /pet - - OAuth: - type: oauth2 - name: petstore_auth - - parameter body: (body) Pet object in the form of byte array + - parameter body: (body) Pet object that needs to be added to the store - returns: RequestBuilder */ - public class func addPetUsingByteArrayWithRequestBuilder(body body: String?) -> RequestBuilder { - let path = "/pet?testing_byte_array=true" + public class func updatePetWithRequestBuilder(body body: Pet?) -> RequestBuilder { + let path = "/pet" let URLString = PetstoreClientAPI.basePath + path let parameters = body?.encodeToJSON() as? [String:AnyObject] let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true) + return requestBuilder.init(method: "PUT", URLString: URLString, parameters: parameters, isBody: true) + } + + /** + + Updates a pet in the store with form data + + - parameter petId: (path) ID of pet that needs to be updated + - parameter name: (form) Updated name of the pet + - parameter status: (form) Updated status of the pet + - parameter completion: completion handler to receive the data and the error objects + */ + public class func updatePetWithForm(petId petId: String, name: String?, status: String?, completion: ((error: ErrorType?) -> Void)) { + updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + + Updates a pet in the store with form data + + - parameter petId: (path) ID of pet that needs to be updated + - parameter name: (form) Updated name of the pet + - parameter status: (form) Updated status of the pet + - returns: Promise + */ + public class func updatePetWithForm(petId petId: String, name: String?, status: String?) -> Promise { + let deferred = Promise.pendingPromise() + updatePetWithForm(petId: petId, name: name, status: status) { error in + if let error = error { + deferred.reject(error) + } else { + deferred.fulfill() + } + } + return deferred.promise + } + + /** + + Updates a pet in the store with form data + + - POST /pet/{petId} + - + - OAuth: + - type: oauth2 + - name: petstore_auth + + - parameter petId: (path) ID of pet that needs to be updated + - parameter name: (form) Updated name of the pet + - parameter status: (form) Updated status of the pet + + - returns: RequestBuilder + */ + public class func updatePetWithFormWithRequestBuilder(petId petId: String, name: String?, status: String?) -> RequestBuilder { + var path = "/pet/{petId}" + path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [ + "name": name, + "status": status + ] + let parameters = APIHelper.rejectNil(nillableParameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: false) + } + + /** + + uploads an image + + - parameter petId: (path) ID of pet to update + - parameter additionalMetadata: (form) Additional data to pass to server + - parameter _file: (form) file to upload + - parameter completion: completion handler to receive the data and the error objects + */ + public class func uploadFile(petId petId: Int, additionalMetadata: String?, _file: NSURL?, completion: ((error: ErrorType?) -> Void)) { + uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, _file: _file).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + + uploads an image + + - parameter petId: (path) ID of pet to update + - parameter additionalMetadata: (form) Additional data to pass to server + - parameter _file: (form) file to upload + - returns: Promise + */ + public class func uploadFile(petId petId: Int, additionalMetadata: String?, _file: NSURL?) -> Promise { + let deferred = Promise.pendingPromise() + uploadFile(petId: petId, additionalMetadata: additionalMetadata, _file: _file) { error in + if let error = error { + deferred.reject(error) + } else { + deferred.fulfill() + } + } + return deferred.promise + } + + /** + + uploads an image + + - POST /pet/{petId}/uploadImage + - + - OAuth: + - type: oauth2 + - name: petstore_auth + + - parameter petId: (path) ID of pet to update + - parameter additionalMetadata: (form) Additional data to pass to server + - parameter _file: (form) file to upload + + - returns: RequestBuilder + */ + public class func uploadFileWithRequestBuilder(petId petId: Int, additionalMetadata: String?, _file: NSURL?) -> RequestBuilder { + var path = "/pet/{petId}/uploadImage" + path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [ + "additionalMetadata": additionalMetadata, + "file": _file + ] + let parameters = APIHelper.rejectNil(nillableParameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: false) } } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift index 2874b7c05ba..b3c08667c21 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift @@ -11,6 +11,62 @@ import PromiseKit public class StoreAPI: APIBase { + /** + + Delete purchase order by ID + + - parameter orderId: (path) ID of the order that needs to be deleted + - parameter completion: completion handler to receive the data and the error objects + */ + public class func deleteOrder(orderId orderId: String, completion: ((error: ErrorType?) -> Void)) { + deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + + Delete purchase order by ID + + - parameter orderId: (path) ID of the order that needs to be deleted + - returns: Promise + */ + public class func deleteOrder(orderId orderId: String) -> Promise { + let deferred = Promise.pendingPromise() + deleteOrder(orderId: orderId) { error in + if let error = error { + deferred.reject(error) + } else { + deferred.fulfill() + } + } + return deferred.promise + } + + /** + + Delete purchase order by ID + + - DELETE /store/order/{orderId} + - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + + - parameter orderId: (path) ID of the order that needs to be deleted + + - returns: RequestBuilder + */ + public class func deleteOrderWithRequestBuilder(orderId orderId: String) -> RequestBuilder { + var path = "/store/order/{orderId}" + path = path.stringByReplacingOccurrencesOfString("{orderId}", withString: "\(orderId)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [:] + let parameters = APIHelper.rejectNil(nillableParameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true) + } + /** Finds orders by status @@ -220,96 +276,6 @@ public class StoreAPI: APIBase { return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true) } - /** - - Place an order for a pet - - - parameter body: (body) order placed for purchasing the pet - - parameter completion: completion handler to receive the data and the error objects - */ - public class func placeOrder(body body: Order?, completion: ((data: Order?, error: ErrorType?) -> Void)) { - placeOrderWithRequestBuilder(body: body).execute { (response, error) -> Void in - completion(data: response?.body, error: error); - } - } - - /** - - Place an order for a pet - - - parameter body: (body) order placed for purchasing the pet - - returns: Promise - */ - public class func placeOrder(body body: Order?) -> Promise { - let deferred = Promise.pendingPromise() - placeOrder(body: body) { data, error in - if let error = error { - deferred.reject(error) - } else { - deferred.fulfill(data!) - } - } - return deferred.promise - } - - /** - - Place an order for a pet - - - POST /store/order - - - - API Key: - - type: apiKey x-test_api_client_id - - name: test_api_client_id - - API Key: - - type: apiKey x-test_api_client_secret - - name: test_api_client_secret - - examples: [{example={ - "id" : 123456789, - "petId" : 123456789, - "complete" : true, - "status" : "aeiou", - "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -}, contentType=application/json}, {example= - 123456 - 123456 - 0 - 2000-01-23T04:56:07.000Z - string - true -, contentType=application/xml}] - - examples: [{example={ - "id" : 123456789, - "petId" : 123456789, - "complete" : true, - "status" : "aeiou", - "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -}, contentType=application/json}, {example= - 123456 - 123456 - 0 - 2000-01-23T04:56:07.000Z - string - true -, contentType=application/xml}] - - - parameter body: (body) order placed for purchasing the pet - - - returns: RequestBuilder - */ - public class func placeOrderWithRequestBuilder(body body: Order?) -> RequestBuilder { - let path = "/store/order" - let URLString = PetstoreClientAPI.basePath + path - - let parameters = body?.encodeToJSON() as? [String:AnyObject] - - let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - - return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true) - } - /** Find purchase order by ID @@ -404,31 +370,31 @@ public class StoreAPI: APIBase { /** - Delete purchase order by ID + Place an order for a pet - - parameter orderId: (path) ID of the order that needs to be deleted + - parameter body: (body) order placed for purchasing the pet - parameter completion: completion handler to receive the data and the error objects */ - public class func deleteOrder(orderId orderId: String, completion: ((error: ErrorType?) -> Void)) { - deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in - completion(error: error); + public class func placeOrder(body body: Order?, completion: ((data: Order?, error: ErrorType?) -> Void)) { + placeOrderWithRequestBuilder(body: body).execute { (response, error) -> Void in + completion(data: response?.body, error: error); } } /** - Delete purchase order by ID + Place an order for a pet - - parameter orderId: (path) ID of the order that needs to be deleted - - returns: Promise + - parameter body: (body) order placed for purchasing the pet + - returns: Promise */ - public class func deleteOrder(orderId orderId: String) -> Promise { - let deferred = Promise.pendingPromise() - deleteOrder(orderId: orderId) { error in + public class func placeOrder(body body: Order?) -> Promise { + let deferred = Promise.pendingPromise() + placeOrder(body: body) { data, error in if let error = error { deferred.reject(error) } else { - deferred.fulfill() + deferred.fulfill(data!) } } return deferred.promise @@ -436,26 +402,60 @@ public class StoreAPI: APIBase { /** - Delete purchase order by ID + Place an order for a pet - - DELETE /store/order/{orderId} - - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + - POST /store/order + - + - API Key: + - type: apiKey x-test_api_client_id + - name: test_api_client_id + - API Key: + - type: apiKey x-test_api_client_secret + - name: test_api_client_secret + - examples: [{example={ + "id" : 123456789, + "petId" : 123456789, + "complete" : true, + "status" : "aeiou", + "quantity" : 123, + "shipDate" : "2000-01-23T04:56:07.000+0000" +}, contentType=application/json}, {example= + 123456 + 123456 + 0 + 2000-01-23T04:56:07.000Z + string + true +, contentType=application/xml}] + - examples: [{example={ + "id" : 123456789, + "petId" : 123456789, + "complete" : true, + "status" : "aeiou", + "quantity" : 123, + "shipDate" : "2000-01-23T04:56:07.000+0000" +}, contentType=application/json}, {example= + 123456 + 123456 + 0 + 2000-01-23T04:56:07.000Z + string + true +, contentType=application/xml}] - - parameter orderId: (path) ID of the order that needs to be deleted + - parameter body: (body) order placed for purchasing the pet - - returns: RequestBuilder + - returns: RequestBuilder */ - public class func deleteOrderWithRequestBuilder(orderId orderId: String) -> RequestBuilder { - var path = "/store/order/{orderId}" - path = path.stringByReplacingOccurrencesOfString("{orderId}", withString: "\(orderId)", options: .LiteralSearch, range: nil) + public class func placeOrderWithRequestBuilder(body body: Order?) -> RequestBuilder { + let path = "/store/order" let URLString = PetstoreClientAPI.basePath + path - let nillableParameters: [String:AnyObject?] = [:] - let parameters = APIHelper.rejectNil(nillableParameters) + let parameters = body?.encodeToJSON() as? [String:AnyObject] - let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true) + return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true) } } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift index 7d304039bb0..7cf1936af55 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift @@ -173,6 +173,128 @@ public class UserAPI: APIBase { return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true) } + /** + + Delete user + + - parameter username: (path) The name that needs to be deleted + - parameter completion: completion handler to receive the data and the error objects + */ + public class func deleteUser(username username: String, completion: ((error: ErrorType?) -> Void)) { + deleteUserWithRequestBuilder(username: username).execute { (response, error) -> Void in + completion(error: error); + } + } + + /** + + Delete user + + - parameter username: (path) The name that needs to be deleted + - returns: Promise + */ + public class func deleteUser(username username: String) -> Promise { + let deferred = Promise.pendingPromise() + deleteUser(username: username) { error in + if let error = error { + deferred.reject(error) + } else { + deferred.fulfill() + } + } + return deferred.promise + } + + /** + + Delete user + + - DELETE /user/{username} + - This can only be done by the logged in user. + + - parameter username: (path) The name that needs to be deleted + + - returns: RequestBuilder + */ + public class func deleteUserWithRequestBuilder(username username: String) -> RequestBuilder { + var path = "/user/{username}" + path = path.stringByReplacingOccurrencesOfString("{username}", withString: "\(username)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [:] + let parameters = APIHelper.rejectNil(nillableParameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true) + } + + /** + + Get user by user name + + - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + - parameter completion: completion handler to receive the data and the error objects + */ + public class func getUserByName(username username: String, completion: ((data: User?, error: ErrorType?) -> Void)) { + getUserByNameWithRequestBuilder(username: username).execute { (response, error) -> Void in + completion(data: response?.body, error: error); + } + } + + /** + + Get user by user name + + - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + - returns: Promise + */ + public class func getUserByName(username username: String) -> Promise { + let deferred = Promise.pendingPromise() + getUserByName(username: username) { data, error in + if let error = error { + deferred.reject(error) + } else { + deferred.fulfill(data!) + } + } + return deferred.promise + } + + /** + + Get user by user name + + - GET /user/{username} + - + - examples: [{example={ + "id" : 1, + "username" : "johnp", + "firstName" : "John", + "lastName" : "Public", + "email" : "johnp@swagger.io", + "password" : "-secret-", + "phone" : "0123456789", + "userStatus" : 0 +}, contentType=application/json}] + + - parameter username: (path) The name that needs to be fetched. Use user1 for testing. + + - returns: RequestBuilder + */ + public class func getUserByNameWithRequestBuilder(username username: String) -> RequestBuilder { + var path = "/user/{username}" + path = path.stringByReplacingOccurrencesOfString("{username}", withString: "\(username)", options: .LiteralSearch, range: nil) + let URLString = PetstoreClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [:] + let parameters = APIHelper.rejectNil(nillableParameters) + + let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true) + } + /** Logs user into the system @@ -287,72 +409,6 @@ public class UserAPI: APIBase { return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true) } - /** - - Get user by user name - - - parameter username: (path) The name that needs to be fetched. Use user1 for testing. - - parameter completion: completion handler to receive the data and the error objects - */ - public class func getUserByName(username username: String, completion: ((data: User?, error: ErrorType?) -> Void)) { - getUserByNameWithRequestBuilder(username: username).execute { (response, error) -> Void in - completion(data: response?.body, error: error); - } - } - - /** - - Get user by user name - - - parameter username: (path) The name that needs to be fetched. Use user1 for testing. - - returns: Promise - */ - public class func getUserByName(username username: String) -> Promise { - let deferred = Promise.pendingPromise() - getUserByName(username: username) { data, error in - if let error = error { - deferred.reject(error) - } else { - deferred.fulfill(data!) - } - } - return deferred.promise - } - - /** - - Get user by user name - - - GET /user/{username} - - - - examples: [{example={ - "id" : 1, - "username" : "johnp", - "firstName" : "John", - "lastName" : "Public", - "email" : "johnp@swagger.io", - "password" : "-secret-", - "phone" : "0123456789", - "userStatus" : 0 -}, contentType=application/json}] - - - parameter username: (path) The name that needs to be fetched. Use user1 for testing. - - - returns: RequestBuilder - */ - public class func getUserByNameWithRequestBuilder(username username: String) -> RequestBuilder { - var path = "/user/{username}" - path = path.stringByReplacingOccurrencesOfString("{username}", withString: "\(username)", options: .LiteralSearch, range: nil) - let URLString = PetstoreClientAPI.basePath + path - - let nillableParameters: [String:AnyObject?] = [:] - let parameters = APIHelper.rejectNil(nillableParameters) - - let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - - return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true) - } - /** Updated user @@ -411,60 +467,4 @@ public class UserAPI: APIBase { return requestBuilder.init(method: "PUT", URLString: URLString, parameters: parameters, isBody: true) } - /** - - Delete user - - - parameter username: (path) The name that needs to be deleted - - parameter completion: completion handler to receive the data and the error objects - */ - public class func deleteUser(username username: String, completion: ((error: ErrorType?) -> Void)) { - deleteUserWithRequestBuilder(username: username).execute { (response, error) -> Void in - completion(error: error); - } - } - - /** - - Delete user - - - parameter username: (path) The name that needs to be deleted - - returns: Promise - */ - public class func deleteUser(username username: String) -> Promise { - let deferred = Promise.pendingPromise() - deleteUser(username: username) { error in - if let error = error { - deferred.reject(error) - } else { - deferred.fulfill() - } - } - return deferred.promise - } - - /** - - Delete user - - - DELETE /user/{username} - - This can only be done by the logged in user. - - - parameter username: (path) The name that needs to be deleted - - - returns: RequestBuilder - */ - public class func deleteUserWithRequestBuilder(username username: String) -> RequestBuilder { - var path = "/user/{username}" - path = path.stringByReplacingOccurrencesOfString("{username}", withString: "\(username)", options: .LiteralSearch, range: nil) - let URLString = PetstoreClientAPI.basePath + path - - let nillableParameters: [String:AnyObject?] = [:] - let parameters = APIHelper.rejectNil(nillableParameters) - - let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - - return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true) - } - } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift index 46ebae1e2ba..a27f02d4ebc 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift @@ -124,26 +124,6 @@ class Decoders { fatalError("formatter failed to parse \(source)") } - // Decoder for [User] - Decoders.addDecoder(clazz: [User].self) { (source: AnyObject) -> [User] in - return Decoders.decode(clazz: [User].self, source: source) - } - // Decoder for User - Decoders.addDecoder(clazz: User.self) { (source: AnyObject) -> User in - let sourceDictionary = source as! [NSObject:AnyObject] - let instance = User() - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) - instance.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"]) - instance.firstName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"]) - instance.lastName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"]) - instance.email = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"]) - instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"]) - instance.phone = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"]) - instance.userStatus = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["userStatus"]) - return instance - } - - // Decoder for [Category] Decoders.addDecoder(clazz: [Category].self) { (source: AnyObject) -> [Category] in return Decoders.decode(clazz: [Category].self, source: source) @@ -158,51 +138,50 @@ class Decoders { } - // Decoder for [Pet] - Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject) -> [Pet] in - return Decoders.decode(clazz: [Pet].self, source: source) + // Decoder for [InlineResponse200] + Decoders.addDecoder(clazz: [InlineResponse200].self) { (source: AnyObject) -> [InlineResponse200] in + return Decoders.decode(clazz: [InlineResponse200].self, source: source) } - // Decoder for Pet - Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject) -> Pet in + // Decoder for InlineResponse200 + Decoders.addDecoder(clazz: InlineResponse200.self) { (source: AnyObject) -> InlineResponse200 in let sourceDictionary = source as! [NSObject:AnyObject] - let instance = Pet() + let instance = InlineResponse200() + instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"]) instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) - instance.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"]) + instance.category = Decoders.decodeOptional(clazz: AnyObject.self, source: sourceDictionary["category"]) + instance.status = InlineResponse200.Status(rawValue: (sourceDictionary["status"] as? String) ?? "") instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"]) - instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"]) - instance.status = Pet.Status(rawValue: (sourceDictionary["status"] as? String) ?? "") return instance } - // Decoder for [Tag] - Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in - return Decoders.decode(clazz: [Tag].self, source: source) + // Decoder for [ModelReturn] + Decoders.addDecoder(clazz: [ModelReturn].self) { (source: AnyObject) -> [ModelReturn] in + return Decoders.decode(clazz: [ModelReturn].self, source: source) } - // Decoder for Tag - Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in + // Decoder for ModelReturn + Decoders.addDecoder(clazz: ModelReturn.self) { (source: AnyObject) -> ModelReturn in let sourceDictionary = source as! [NSObject:AnyObject] - let instance = Tag() - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) - return instance - } - - - // Decoder for [ObjectReturn] - Decoders.addDecoder(clazz: [ObjectReturn].self) { (source: AnyObject) -> [ObjectReturn] in - return Decoders.decode(clazz: [ObjectReturn].self, source: source) - } - // Decoder for ObjectReturn - Decoders.addDecoder(clazz: ObjectReturn.self) { (source: AnyObject) -> ObjectReturn in - let sourceDictionary = source as! [NSObject:AnyObject] - let instance = ObjectReturn() + let instance = ModelReturn() instance._return = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["_return"]) return instance } + // Decoder for [Name] + Decoders.addDecoder(clazz: [Name].self) { (source: AnyObject) -> [Name] in + return Decoders.decode(clazz: [Name].self, source: source) + } + // Decoder for Name + Decoders.addDecoder(clazz: Name.self) { (source: AnyObject) -> Name in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = Name() + instance.name = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["name"]) + return instance + } + + // Decoder for [Order] Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject) -> [Order] in return Decoders.decode(clazz: [Order].self, source: source) @@ -221,6 +200,24 @@ class Decoders { } + // Decoder for [Pet] + Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject) -> [Pet] in + return Decoders.decode(clazz: [Pet].self, source: source) + } + // Decoder for Pet + Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject) -> Pet in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = Pet() + instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) + instance.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"]) + instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) + instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"]) + instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"]) + instance.status = Pet.Status(rawValue: (sourceDictionary["status"] as? String) ?? "") + return instance + } + + // Decoder for [SpecialModelName] Decoders.addDecoder(clazz: [SpecialModelName].self) { (source: AnyObject) -> [SpecialModelName] in return Decoders.decode(clazz: [SpecialModelName].self, source: source) @@ -234,20 +231,39 @@ class Decoders { } - // Decoder for [InlineResponse200] - Decoders.addDecoder(clazz: [InlineResponse200].self) { (source: AnyObject) -> [InlineResponse200] in - return Decoders.decode(clazz: [InlineResponse200].self, source: source) + // Decoder for [Tag] + Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in + return Decoders.decode(clazz: [Tag].self, source: source) } - // Decoder for InlineResponse200 - Decoders.addDecoder(clazz: InlineResponse200.self) { (source: AnyObject) -> InlineResponse200 in + // Decoder for Tag + Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in let sourceDictionary = source as! [NSObject:AnyObject] - let instance = InlineResponse200() + let instance = Tag() instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) - instance.category = Decoders.decodeOptional(clazz: AnyObject.self, source: sourceDictionary["category"]) instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) return instance } + + // Decoder for [User] + Decoders.addDecoder(clazz: [User].self) { (source: AnyObject) -> [User] in + return Decoders.decode(clazz: [User].self, source: source) + } + // Decoder for User + Decoders.addDecoder(clazz: User.self) { (source: AnyObject) -> User in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = User() + instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) + instance.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"]) + instance.firstName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"]) + instance.lastName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"]) + instance.email = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"]) + instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"]) + instance.phone = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"]) + instance.userStatus = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["userStatus"]) + return instance + } + } } } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift index 6ef68d3309d..5835a8d9899 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift @@ -10,9 +10,19 @@ import Foundation public class InlineResponse200: JSONEncodable { + public enum Status: String { + case Available = "available" + case Pending = "pending" + case Sold = "sold" + } + + public var tags: [Tag]? public var id: Int? public var category: AnyObject? + /** pet status in the store */ + public var status: Status? public var name: String? + public var photoUrls: [String]? public init() {} @@ -20,9 +30,12 @@ public class InlineResponse200: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() + nillableDictionary["tags"] = self.tags?.encodeToJSON() nillableDictionary["id"] = self.id nillableDictionary["category"] = self.category + nillableDictionary["status"] = self.status?.rawValue nillableDictionary["name"] = self.name + nillableDictionary["photoUrls"] = self.photoUrls?.encodeToJSON() let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift new file mode 100644 index 00000000000..e996c6458e9 --- /dev/null +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift @@ -0,0 +1,25 @@ +// +// ModelReturn.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class ModelReturn: JSONEncodable { + + public var _return: Int? + + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["_return"] = self._return + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift new file mode 100644 index 00000000000..3a18591deb1 --- /dev/null +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift @@ -0,0 +1,25 @@ +// +// Name.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class Name: JSONEncodable { + + public var name: Int? + + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["name"] = self.name + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/samples/client/petstore/swift/git_push.sh b/samples/client/petstore/swift/git_push.sh new file mode 100644 index 00000000000..1a36388db02 --- /dev/null +++ b/samples/client/petstore/swift/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="YOUR_GIT_USR_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="YOUR_GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' +