diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a40a96f7b38..d7d241c1040 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,15 +28,19 @@ For a list of variables available in the template, please refer to this [page](h ### Style guide Code change should conform to the programming style guide of the respective langauages: +- Android: https://source.android.com/source/code-style.html - C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx +- Haskell: https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md - Java: https://google.github.io/styleguide/javaguide.html - JavaScript: https://github.com/airbnb/javascript/tree/master/es5 +- Groovy: http://groovy-lang.org/style-guide.html - Go: https://github.com/golang/go/wiki/CodeReviewComments - ObjC: https://github.com/NYTimes/objective-c-style-guide - Perl: http://perldoc.perl.org/perlstyle.html - PHP: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md - Python: https://www.python.org/dev/peps/pep-0008/ - Ruby: https://github.com/bbatsov/ruby-style-guide +- Scala: http://docs.scala-lang.org/style/ - Swift: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html - TypeScript: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines diff --git a/README.md b/README.md index ece108666e1..fb1d8501287 100644 --- a/README.md +++ b/README.md @@ -641,155 +641,7 @@ open index.html ### To build a server stub -You can also use the codegen to generate a server for a couple different frameworks. Take a look here: - -### Node.js - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l nodejs-server \ - -o samples/server/petstore/nodejs -``` - -### PHP Slim - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l slim \ - -o samples/server/petstore/slim -``` - -### PHP Silex - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l silex-PHP \ - -o samples/server/petstore/silex -``` - -### Python Flask (Connexion) - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l python-flask \ - -o samples/server/petstore/flaskConnexion -``` - -### Ruby Sinatra - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l sinatra \ - -o samples/server/petstore/sinatra -``` - -### Scala Scalatra -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l scalatra \ - -o samples/server/petstore/scalatra -``` - -### Java JAX-RS (Jersey v1.18) - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l jaxrs \ - -o samples/server/petstore/jaxrs-jersey -``` - -### Java JAX-RS (Apache CXF 2 / 3) - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l jaxrs-cxf \ - -o samples/server/petstore/jaxrs-cxf -``` - -This Codegen only generate a minimalist server stub. You must add the CXF dependency to your classpath (eg: with Maven) -If you are using CXF v2.x, you must provided a custom ```ResourceComparator``` class. This class will help CXF to choose the good resource interface for mapping an incomming request. The default behavior of CXF v2.x is not correct when many resources interface have the same global path. -See: See http://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Customselectionbetweenmultipleresources - -You can found this class here: https://github.com/hiveship/CXF2-resource-comparator/blob/master/src/main/java/CXFInterfaceComparator.java -TODO: This class could be directly generated by the Codegen. - -You must register this class into your JAX-RS configuration file: -```xml - - - -``` - -This is no longer necessary if you are using CXF >=v3.x - -### Java JAX-RS (Resteasy) - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l jaxrs-resteasy \ - -o samples/server/petstore/jaxrs-resteasy -``` - -### Java Spring MVC - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l spring-mvc \ - -o samples/server/petstore/spring-mvc -``` - -### Java SpringBoot - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l springboot \ - -o samples/server/petstore/springboot -``` - -You can also set a Json file with basePackage & configPackage properties : -Example : -``` -{ -"basePackage":"io.swagger", -"configPackage":"io.swagger.config" -} -``` -For use it add option ```-c myOptions.json``` to the generation command - -To Use-it : -in the generated folder try ``` mvn package ``` for build jar. -Start your server ``` java -jar target/swagger-springboot-server-1.0.0.jar ``` -SpringBoot listening on default port 8080 - - -### Haskell Servant - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l haskell-servant \ - -o samples/server/petstore/haskell-servant -``` - -### ASP.NET 5 Web API - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l aspnet5 \ - -o samples/server/petstore/aspnet5 -``` +Please refer to https://github.com/swagger-api/swagger-codegen/wiki/Server-stub-generator-HOWTO for more information. ### To build the codegen library @@ -864,6 +716,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you - [IMS Health](http://www.imshealth.com/en/solution-areas/technology-and-applications) - [Interactive Intelligence](http://developer.mypurecloud.com/) - [LANDR Audio](https://www.landr.com/) +- [Lascaux](http://www.lascaux.it/) - [LiveAgent](https://www.ladesk.com/) - [Kabuku](http://www.kabuku.co.jp/en) - [Kuary](https://kuary.com/) @@ -935,6 +788,7 @@ Swaagger Codegen core team members are contributors who have been making signfic Here is a list of template creators: * API Clients: * Akka-Scala: @cchafer + * C++ REST: @Danielku15 * C# (.NET 2.0): @who * Clojure: @xhh * Dart: @yissachar diff --git a/bin/cpprest-petstore.sh b/bin/cpprest-petstore.sh new file mode 100755 index 00000000000..93f7ad609cc --- /dev/null +++ b/bin/cpprest-petstore.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/cpprest -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l cpprest -o samples/client/petstore/cpprest" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/go-petstore-server.sh b/bin/go-petstore-server.sh new file mode 100755 index 00000000000..a668a1cfbdd --- /dev/null +++ b/bin/go-petstore-server.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l go-server -o samples/server/petstore/go-api-server -DpackageName=petstoreserver " + +java $JAVA_OPTS -Dservice -jar $executable $ags diff --git a/bin/lumen-petstore-server.sh b/bin/lumen-petstore-server.sh index 15acb2fe2bd..a4a5df0f817 100755 --- a/bin/lumen-petstore-server.sh +++ b/bin/lumen-petstore-server.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/lumen -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l lumen -o samples/server/petstore/lumen" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/lumen -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l lumen -o samples/server/petstore/lumen" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/swift-petstore-all.sh b/bin/swift-petstore-all.sh new file mode 100755 index 00000000000..e74eba37704 --- /dev/null +++ b/bin/swift-petstore-all.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l swift -c ./bin/swift-petstore.json -o samples/client/petstore/swift/default" + +echo "#### Petstore Swift API client (default) ####" +java $JAVA_OPTS -jar $executable $ags + +ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l swift -c ./bin/swift-petstore-promisekit.json -o samples/client/petstore/swift/promisekit" +echo "#### Petstore Swift API client (promisekit) ####" +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/windows/cpprest-petstore.bat b/bin/windows/cpprest-petstore.bat new file mode 100755 index 00000000000..43312669840 --- /dev/null +++ b/bin/windows/cpprest-petstore.bat @@ -0,0 +1,10 @@ +set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar + +If Not Exist %executable% ( + mvn clean package +) + +set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties +set ags=generate -t modules\swagger-codegen\src\main\resources\cpprest -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l cpprest -o samples\client\petstore\cpprest + +java %JAVA_OPTS% -jar %executable% %ags% diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java index c11f444437b..3752f69dca5 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java @@ -22,6 +22,7 @@ public class CodegenModel { public String unescapedDescription; public String discriminator; public String defaultValue; + public String arrayModelType; public List vars = new ArrayList(); public List requiredVars = new ArrayList(); // a list of required properties public List optionalVars = new ArrayList(); // a list of optional properties @@ -35,7 +36,7 @@ public class CodegenModel { public Set allMandatory; public Set imports = new TreeSet(); - public Boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired; + public Boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, isArrayModel; public ExternalDocs externalDocs; public Map vendorExtensions; diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 8304849a14c..0bd0c08cccc 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -1198,6 +1198,8 @@ public class DefaultCodegen { ArrayModel am = (ArrayModel) model; ArrayProperty arrayProperty = new ArrayProperty(am.getItems()); m.hasEnums = false; // Otherwise there will be a NullPointerException in JavaClientCodegen.fromModel + m.isArrayModel = true; + m.arrayModelType = fromProperty(name, arrayProperty).complexType; addParentContainer(m, name, arrayProperty); } else if (model instanceof RefModel) { // TODO @@ -1465,7 +1467,9 @@ public class DefaultCodegen { if (p instanceof BinaryProperty) { property.isBinary = true; } - + if (p instanceof UUIDProperty) { + property.isString = true; + } if (p instanceof ByteArrayProperty) { property.isByteArray = true; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java new file mode 100644 index 00000000000..f8299fc60cd --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java @@ -0,0 +1,380 @@ +package io.swagger.codegen.languages; + +import io.swagger.codegen.*; +import io.swagger.codegen.examples.ExampleGenerator; +import io.swagger.models.Model; +import io.swagger.models.Operation; +import io.swagger.models.Response; +import io.swagger.models.Swagger; +import io.swagger.models.properties.*; + +import java.util.*; +import java.io.File; + +public class CppRestClientCodegen extends DefaultCodegen implements CodegenConfig { + + public static final String DECLSPEC = "declspec"; + public static final String DEFAULT_INCLUDE = "defaultInclude"; + + protected String packageVersion = "1.0.0"; + protected String declspec = ""; + protected String defaultInclude = ""; + + /** + * Configures the type of generator. + * + * @return the CodegenType for this generator + * @see io.swagger.codegen.CodegenType + */ + public CodegenType getTag() { + return CodegenType.CLIENT; + } + + /** + * Configures a friendly name for the generator. This will be used by the + * generator to select the library with the -l flag. + * + * @return the friendly name for the generator + */ + public String getName() { + return "cpprest"; + } + + /** + * Returns human-friendly help for the generator. Provide the consumer with + * help tips, parameters here + * + * @return A string value for the help message + */ + public String getHelp() { + return "Generates a C++ API client with C++ REST SDK (https://github.com/Microsoft/cpprestsdk)."; + } + + public CppRestClientCodegen() { + super(); + + apiPackage = "io.swagger.client.api"; + modelPackage = "io.swagger.client.model"; + + modelTemplateFiles.put("model-header.mustache", ".h"); + modelTemplateFiles.put("model-source.mustache", ".cpp"); + + apiTemplateFiles.put("api-header.mustache", ".h"); + apiTemplateFiles.put("api-source.mustache", ".cpp"); + + templateDir = "cpprest"; + + cliOptions.clear(); + + // CLI options + addOption(CodegenConstants.MODEL_PACKAGE, "C++ namespace for models (convention: name.space.model).", + this.modelPackage); + addOption(CodegenConstants.API_PACKAGE, "C++ namespace for apis (convention: name.space.api).", + this.apiPackage); + addOption(CodegenConstants.PACKAGE_VERSION, "C++ package version.", this.packageVersion); + addOption(DECLSPEC, "C++ preprocessor to place before the class name for handling dllexport/dllimport.", + this.declspec); + addOption(DEFAULT_INCLUDE, + "The default include statement that should be placed in all headers for including things like the declspec (convention: #include \"Commons.h\" ", + this.defaultInclude); + + reservedWords = new HashSet(); + + supportingFiles.add(new SupportingFile("modelbase-header.mustache", "", "ModelBase.h")); + supportingFiles.add(new SupportingFile("modelbase-source.mustache", "", "ModelBase.cpp")); + supportingFiles.add(new SupportingFile("apiclient-header.mustache", "", "ApiClient.h")); + supportingFiles.add(new SupportingFile("apiclient-source.mustache", "", "ApiClient.cpp")); + supportingFiles.add(new SupportingFile("apiconfiguration-header.mustache", "", "ApiConfiguration.h")); + supportingFiles.add(new SupportingFile("apiconfiguration-source.mustache", "", "ApiConfiguration.cpp")); + supportingFiles.add(new SupportingFile("apiexception-header.mustache", "", "ApiException.h")); + supportingFiles.add(new SupportingFile("apiexception-source.mustache", "", "ApiException.cpp")); + supportingFiles.add(new SupportingFile("ihttpbody-header.mustache", "", "IHttpBody.h")); + supportingFiles.add(new SupportingFile("jsonbody-header.mustache", "", "JsonBody.h")); + supportingFiles.add(new SupportingFile("jsonbody-source.mustache", "", "JsonBody.cpp")); + supportingFiles.add(new SupportingFile("httpcontent-header.mustache", "", "HttpContent.h")); + supportingFiles.add(new SupportingFile("httpcontent-source.mustache", "", "HttpContent.cpp")); + supportingFiles.add(new SupportingFile("multipart-header.mustache", "", "MultipartFormData.h")); + supportingFiles.add(new SupportingFile("multipart-source.mustache", "", "MultipartFormData.cpp")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + + languageSpecificPrimitives = new HashSet( + Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t")); + + typeMapping = new HashMap(); + typeMapping.put("date", "utility::datetime"); + typeMapping.put("DateTime", "utility::datetime"); + typeMapping.put("string", "utility::string_t"); + typeMapping.put("integer", "int32_t"); + typeMapping.put("long", "int64_t"); + typeMapping.put("boolean", "bool"); + typeMapping.put("array", "std::vector"); + typeMapping.put("map", "std::map"); + typeMapping.put("file", "HttpContent"); + typeMapping.put("object", "Object"); + typeMapping.put("binary", "std::string"); + + super.importMapping = new HashMap(); + importMapping.put("std::vector", "#include "); + importMapping.put("std::map", "#include "); + importMapping.put("std::string", "#include "); + importMapping.put("HttpContent", "#include \"HttpContent.h\""); + importMapping.put("Object", "#include \"Object.h\""); + importMapping.put("utility::string_t", "#include "); + importMapping.put("utility::datetime", "#include "); + } + + protected void addOption(String key, String description, String defaultValue) { + CliOption option = new CliOption(key, description); + if (defaultValue != null) + option.defaultValue(defaultValue); + cliOptions.add(option); + } + + @Override + public void processOpts() { + super.processOpts(); + + if (additionalProperties.containsKey(DECLSPEC)) { + declspec = additionalProperties.get(DECLSPEC).toString(); + } + + if (additionalProperties.containsKey(DEFAULT_INCLUDE)) { + defaultInclude = additionalProperties.get(DEFAULT_INCLUDE).toString(); + } + + additionalProperties.put("modelNamespaceDeclarations", modelPackage.split("\\.")); + additionalProperties.put("modelNamespace", modelPackage.replaceAll("\\.", "::")); + additionalProperties.put("apiNamespaceDeclarations", apiPackage.split("\\.")); + additionalProperties.put("apiNamespace", apiPackage.replaceAll("\\.", "::")); + additionalProperties.put("declspec", declspec); + additionalProperties.put("defaultInclude", defaultInclude); + } + + /** + * Escapes a reserved word as defined in the `reservedWords` array. Handle + * escaping those terms here. This logic is only called if a variable + * matches the reseved words + * + * @return the escaped term + */ + @Override + public String escapeReservedWord(String name) { + return "_" + name; // add an underscore to the name + } + + /** + * Location to write model files. You can use the modelPackage() as defined + * when the class is instantiated + */ + public String modelFileFolder() { + return outputFolder + "/model"; + } + + /** + * Location to write api files. You can use the apiPackage() as defined when + * the class is instantiated + */ + @Override + public String apiFileFolder() { + return outputFolder + "/api"; + } + + @Override + public String toModelImport(String name) { + if (importMapping.containsKey(name)) { + return importMapping.get(name); + } else { + return "#include \"" + name + ".h\""; + } + } + + @Override + public CodegenModel fromModel(String name, Model model, Map allDefinitions) { + CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); + + Set oldImports = codegenModel.imports; + codegenModel.imports = new HashSet(); + for (String imp : oldImports) { + String newImp = toModelImport(imp); + if (!newImp.isEmpty()) { + codegenModel.imports.add(newImp); + } + } + + return codegenModel; + } + + @Override + public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, + Map definitions, Swagger swagger) { + CodegenOperation op = super.fromOperation(path, httpMethod, operation, definitions, swagger); + + if (operation.getResponses() != null && !operation.getResponses().isEmpty()) { + Response methodResponse = findMethodResponse(operation.getResponses()); + + if (methodResponse != null) { + if (methodResponse.getSchema() != null) { + CodegenProperty cm = fromProperty("response", methodResponse.getSchema()); + op.vendorExtensions.put("x-codegen-response", cm); + } + } + } + + return op; + } + + @Override + public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { + if (isFileProperty(property)) { + property.vendorExtensions.put("x-codegen-file", true); + } + } + + protected boolean isFileProperty(CodegenProperty property) { + return property.baseType.equals("HttpContent"); + } + + @Override + public String toModelFilename(String name) { + return initialCaps(name); + } + + @Override + public String toApiFilename(String name) { + return initialCaps(name) + "Api"; + } + + /** + * Optional - type declaration. This is a String which is used by the + * templates to instantiate your types. There is typically special handling + * for different property types + * + * @return a string value used as the `dataType` field for model templates, + * `returnType` for api templates + */ + @Override + public String getTypeDeclaration(Property p) { + String swaggerType = getSwaggerType(p); + + if (p instanceof ArrayProperty) { + ArrayProperty ap = (ArrayProperty) p; + Property inner = ap.getItems(); + return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">"; + } + if (p instanceof MapProperty) { + MapProperty mp = (MapProperty) p; + Property inner = mp.getAdditionalProperties(); + return getSwaggerType(p) + ""; + } + if (p instanceof StringProperty || p instanceof DateProperty || p instanceof DateTimeProperty + || languageSpecificPrimitives.contains(swaggerType)) { + return toModelName(swaggerType); + } + + return "std::shared_ptr<" + swaggerType + ">"; + } + + @Override + public String toDefaultValue(Property p) { + if (p instanceof StringProperty) { + return "U(\"\")"; + } else if (p instanceof BooleanProperty) { + return "false"; + } else if (p instanceof DateProperty) { + return "utility::datetime()"; + } else if (p instanceof DateTimeProperty) { + return "utility::datetime()"; + } else if (p instanceof DoubleProperty) { + return "0.0"; + } else if (p instanceof FloatProperty) { + return "0.0f"; + } else if (p instanceof IntegerProperty) { + return "0"; + } else if (p instanceof LongProperty) { + return "0L"; + } else if (p instanceof DecimalProperty) { + return "0.0"; + } else if (p instanceof MapProperty) { + MapProperty ap = (MapProperty) p; + String inner = getSwaggerType(ap.getAdditionalProperties()); + return "std::map()"; + } else if (p instanceof ArrayProperty) { + ArrayProperty ap = (ArrayProperty) p; + String inner = getSwaggerType(ap.getItems()); + if (!languageSpecificPrimitives.contains(inner)) { + inner = "std::shared_ptr<" + inner + ">"; + } + return "std::vector<" + inner + ">()"; + } else if (p instanceof RefProperty) { + RefProperty rp = (RefProperty) p; + return "new " + toModelName(rp.getSimpleRef()) + "()"; + } + return "nullptr"; + } + + @Override + public void postProcessParameter(CodegenParameter parameter) { + super.postProcessParameter(parameter); + + boolean isPrimitiveType = parameter.isPrimitiveType == Boolean.TRUE; + boolean isListContainer = parameter.isListContainer == Boolean.TRUE; + boolean isString = parameter.isString == Boolean.TRUE; + + if (!isPrimitiveType && !isListContainer && !isString && !parameter.dataType.startsWith("std::shared_ptr")) { + parameter.dataType = "std::shared_ptr<" + parameter.dataType + ">"; + } + } + + /** + * Optional - swagger type conversion. This is used to map swagger types in + * a `Property` into either language specific types via `typeMapping` or + * into complex models if there is not a mapping. + * + * @return a string value of the type or complex model for this property + * @see io.swagger.models.properties.Property + */ + @Override + public String getSwaggerType(Property p) { + String swaggerType = super.getSwaggerType(p); + String type = null; + if (typeMapping.containsKey(swaggerType)) { + type = typeMapping.get(swaggerType); + if (languageSpecificPrimitives.contains(type)) + return toModelName(type); + } else + type = swaggerType; + return toModelName(type); + } + + @Override + public String toModelName(String type) { + if (typeMapping.keySet().contains(type) || typeMapping.values().contains(type) + || importMapping.values().contains(type) || defaultIncludes.contains(type) + || languageSpecificPrimitives.contains(type)) { + return type; + } else { + return Character.toUpperCase(type.charAt(0)) + type.substring(1); + } + } + + @Override + public String toVarName(String name) { + if (typeMapping.keySet().contains(name) || typeMapping.values().contains(name) + || importMapping.values().contains(name) || defaultIncludes.contains(name) + || languageSpecificPrimitives.contains(name)) { + return name; + } + + if (name.length() > 1) { + return Character.toUpperCase(name.charAt(0)) + name.substring(1); + } + + return name; + } + + @Override + public String toApiName(String type) { + return Character.toUpperCase(type.charAt(0)) + type.substring(1) + "Api"; + } +} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoServerCodegen.java new file mode 100644 index 00000000000..43c48cc64f7 --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoServerCodegen.java @@ -0,0 +1,266 @@ +package io.swagger.codegen.languages; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Multimap; +import io.swagger.codegen.*; +import io.swagger.models.*; +import io.swagger.util.Yaml; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.*; +import java.util.Map.Entry; +import org.apache.commons.lang3.StringUtils; + +public class GoServerCodegen extends DefaultCodegen implements CodegenConfig { + + private static final Logger LOGGER = LoggerFactory.getLogger(GoServerCodegen.class); + + protected String apiVersion = "1.0.0"; + protected int serverPort = 8080; + protected String projectName = "swagger-server"; + protected String apiPath = "go"; + + public GoServerCodegen() { + super(); + + // set the output folder here + outputFolder = "generated-code/go"; + + /** + * Models. You can write model files using the modelTemplateFiles map. + * if you want to create one template for file, you can do so here. + * for multiple files for model, just put another entry in the `modelTemplateFiles` with + * a different extension + */ + modelTemplateFiles.clear(); + + /** + * Api classes. You can write classes for each Api file with the apiTemplateFiles map. + * as with models, add multiple entries with different extensions for multiple files per + * class + */ + apiTemplateFiles.put( + "controller.mustache", // the template to use + ".go"); // the extension for each file to write + + /** + * Template Location. This is the location which templates will be read from. The generator + * will use the resource stream to attempt to read the templates. + */ + embeddedTemplateDir = templateDir = "go-server"; + + /** + * Reserved words. Override this with reserved words specific to your language + */ + setReservedWordsLowerCase( + Arrays.asList( + "break", "default", "func", "interface", "select", + "case", "defer", "go", "map", "struct", + "chan", "else", "goto", "package", "switch", + "const", "fallthrough", "if", "range", "type", + "continue", "for", "import", "return", "var", "error", "ApiResponse") + // Added "error" as it's used so frequently that it may as well be a keyword + ); + + defaultIncludes = new HashSet( + Arrays.asList( + "map", + "array") + ); + + languageSpecificPrimitives = new HashSet( + Arrays.asList( + "string", + "bool", + "uint", + "uint32", + "uint64", + "int", + "int32", + "int64", + "float32", + "float64", + "complex64", + "complex128", + "rune", + "byte") + ); + + instantiationTypes.clear(); + /*instantiationTypes.put("array", "GoArray"); + instantiationTypes.put("map", "GoMap");*/ + + typeMapping.clear(); + typeMapping.put("integer", "int32"); + typeMapping.put("long", "int64"); + typeMapping.put("number", "float32"); + typeMapping.put("float", "float32"); + typeMapping.put("double", "float64"); + typeMapping.put("boolean", "bool"); + typeMapping.put("string", "string"); + typeMapping.put("date", "time.Time"); + typeMapping.put("DateTime", "time.Time"); + typeMapping.put("password", "string"); + typeMapping.put("File", "*os.File"); + typeMapping.put("file", "*os.File"); + // map binary to string as a workaround + // the correct solution is to use []byte + typeMapping.put("binary", "string"); + typeMapping.put("ByteArray", "string"); + + importMapping = new HashMap(); + importMapping.put("time.Time", "time"); + importMapping.put("*os.File", "os"); + importMapping.put("os", "io/ioutil"); + + cliOptions.clear(); + cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).") + .defaultValue("swagger")); + /** + * Additional Properties. These values can be passed to the templates and + * are available in models, apis, and supporting files + */ + additionalProperties.put("apiVersion", apiVersion); + additionalProperties.put("serverPort", serverPort); + additionalProperties.put("apiPath", apiPath); + /** + * Supporting Files. You can write single files for the generator with the + * entire object tree available. If the input file has a suffix of `.mustache + * it will be processed by the template engine. Otherwise, it will be copied + */ + supportingFiles.add(new SupportingFile("swagger.mustache", + "api", + "swagger.yaml") + ); + supportingFiles.add(new SupportingFile("main.mustache", "", "main.go")); + supportingFiles.add(new SupportingFile("routers.mustache", apiPath, "routers.go")); + supportingFiles.add(new SupportingFile("logger.mustache", apiPath, "logger.go")); + supportingFiles.add(new SupportingFile("app.mustache", apiPath, "app.yaml")); + writeOptional(outputFolder, new SupportingFile("README.mustache", apiPath, "README.md")); + } + + @Override + public String apiPackage() { + return apiPath; + } + + /** + * Configures the type of generator. + * + * @return the CodegenType for this generator + * @see io.swagger.codegen.CodegenType + */ + @Override + public CodegenType getTag() { + return CodegenType.SERVER; + } + + /** + * Configures a friendly name for the generator. This will be used by the generator + * to select the library with the -l flag. + * + * @return the friendly name for the generator + */ + @Override + public String getName() { + return "go-server"; + } + + /** + * Returns human-friendly help for the generator. Provide the consumer with help + * tips, parameters here + * + * @return A string value for the help message + */ + @Override + public String getHelp() { + return "Generates a Go server library using the swagger-tools project. By default, " + + "it will also generate service classes--which you can disable with the `-Dnoservice` environment variable."; + } + + @Override + public String toApiName(String name) { + if (name.length() == 0) { + return "DefaultController"; + } + return initialCaps(name); + } + + /** + * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping + * those terms here. This logic is only called if a variable matches the reseved words + * + * @return the escaped term + */ + @Override + public String escapeReservedWord(String name) { + return "_" + name; // add an underscore to the name + } + + /** + * Location to write api files. You can use the apiPackage() as defined when the class is + * instantiated + */ + @Override + public String apiFileFolder() { + return outputFolder + File.separator + apiPackage().replace('.', File.separatorChar); + } + + @Override + public String toModelName(String name) { + // camelize the model name + // phone_number => PhoneNumber + return camelize(toModelFilename(name)); + } + + @Override + public String toOperationId(String operationId) { + // method name cannot use reserved keyword, e.g. return + if (isReservedWord(operationId)) { + LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId))); + operationId = "call_" + operationId; + } + + return camelize(operationId); + } + + @Override + public String toModelFilename(String name) { + if (!StringUtils.isEmpty(modelNamePrefix)) { + name = modelNamePrefix + "_" + name; + } + + if (!StringUtils.isEmpty(modelNameSuffix)) { + name = name + "_" + modelNameSuffix; + } + + name = sanitizeName(name); + + // model name cannot use reserved keyword, e.g. return + if (isReservedWord(name)) { + LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name)); + name = "model_" + name; // e.g. return => ModelReturn (after camelize) + } + + return underscore(name); + } + + @Override + public String toApiFilename(String name) { + // replace - with _ e.g. created-at => created_at + name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. + + // e.g. PetApi.go => pet_api.go + return underscore(name); + } +} 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 c80bb0ed23f..ad4750cf8ce 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 @@ -127,6 +127,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use"); Map dateOptions = new HashMap(); dateOptions.put("java8", "Java 8 native"); + dateOptions.put("java8-localdatetime", "Java 8 using LocalDateTime (for legacy app only)"); dateOptions.put("joda", "Joda"); dateOptions.put("legacy", "Legacy java.util.Date"); dateLibrary.setEnum(dateOptions); @@ -262,6 +263,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { writeOptional(outputFolder, new SupportingFile("settings.gradle.mustache", "", "settings.gradle")); writeOptional(outputFolder, new SupportingFile("gradle.properties.mustache", "", "gradle.properties")); writeOptional(outputFolder, new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml")); + supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml")); supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java")); supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java")); @@ -362,7 +364,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } if(additionalProperties.containsKey(DATE_LIBRARY)) { - this.dateLibrary = additionalProperties.get(DATE_LIBRARY).toString(); + setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString()); + additionalProperties.put(dateLibrary, "true"); } if("joda".equals(dateLibrary)) { @@ -372,13 +375,17 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { importMapping.put("LocalDate", "org.joda.time.LocalDate"); importMapping.put("DateTime", "org.joda.time.DateTime"); } - else if ("java8".equals(dateLibrary)) { + else if (dateLibrary.startsWith("java8")) { additionalProperties.put("java8", "true"); - additionalProperties.put("javaVersion", "1.8"); typeMapping.put("date", "LocalDate"); - typeMapping.put("DateTime", "LocalDateTime"); importMapping.put("LocalDate", "java.time.LocalDate"); - importMapping.put("LocalDateTime", "java.time.LocalDateTime"); + if ("java8-localdatetime".equals(dateLibrary)) { + typeMapping.put("DateTime", "LocalDateTime"); + importMapping.put("LocalDateTime", "java.time.LocalDateTime"); + } else { + typeMapping.put("DateTime", "OffsetDateTime"); + importMapping.put("OffsetDateTime", "java.time.OffsetDateTime"); + } } supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); @@ -1031,7 +1038,5 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { this.useRxJava = useRxJava; } - public void setDateLibrary(String library) { - this.dateLibrary = library; - } + public void setDateLibrary(String library) { this.dateLibrary = library; } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java index 72f969403bf..f6c3f861e49 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java @@ -89,16 +89,11 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen { implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER); } - if (additionalProperties.containsKey("dateLibrary")) { - setDateLibrary(additionalProperties.get("dateLibrary").toString()); - additionalProperties.put(dateLibrary, "true"); - } - if ("joda".equals(dateLibrary)) { supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java")); supportingFiles.add(new SupportingFile("JodaLocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaLocalDateProvider.java")); - } else if ( "java8".equals(dateLibrary) ) { - supportingFiles.add(new SupportingFile("LocalDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateTimeProvider.java")); + } else if ( dateLibrary.startsWith("java8") ) { + supportingFiles.add(new SupportingFile("OffsetDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "OffsetDateTimeProvider.java")); supportingFiles.add(new SupportingFile("LocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateProvider.java")); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java index 4c13fd50f0b..33803b087b8 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java @@ -47,14 +47,6 @@ public class JavaResteasyServerCodegen extends JavaClientCodegen implements Code } } - CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use"); - Map dateOptions = new HashMap(); - dateOptions.put("java8", "Java 8 native"); - dateOptions.put("joda", "Joda"); - dateLibrary.setEnum(dateOptions); - - cliOptions.add(dateLibrary); - CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); library.setDefault(DEFAULT_LIBRARY); @@ -117,35 +109,16 @@ public class JavaResteasyServerCodegen extends JavaClientCodegen implements Code supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + invokerPackage).replace(".", "/"), "StringUtil.java")); - if (additionalProperties.containsKey("dateLibrary")) { - setDateLibrary(additionalProperties.get("dateLibrary").toString()); - additionalProperties.put(dateLibrary, "true"); - } - if ("joda".equals(dateLibrary)) { - typeMapping.put("date", "LocalDate"); - typeMapping.put("DateTime", "DateTime"); - - importMapping.put("LocalDate", "org.joda.time.LocalDate"); - importMapping.put("DateTime", "org.joda.time.DateTime"); - supportingFiles.add(new SupportingFile("JacksonConfig.mustache", (sourceFolder + '/' + invokerPackage).replace(".", "/"), "JacksonConfig.java")); - supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java")); supportingFiles.add(new SupportingFile("JodaLocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaLocalDateProvider.java")); - } else if ("java8".equals(dateLibrary)) { - additionalProperties.put("java8", "true"); - additionalProperties.put("javaVersion", "1.8"); - typeMapping.put("date", "LocalDate"); - typeMapping.put("DateTime", "LocalDateTime"); - importMapping.put("LocalDate", "java.time.LocalDate"); - importMapping.put("LocalDateTime", "java.time.LocalDateTime"); - - supportingFiles.add(new SupportingFile("LocalDateTimeProvider.mustache", - (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateTimeProvider.java")); + } else if (dateLibrary.startsWith("java8")) { + supportingFiles.add(new SupportingFile("OffsetDateTimeProvider.mustache", + (sourceFolder + '/' + apiPackage).replace(".", "/"), "OffsetDateTimeProvider.java")); supportingFiles.add(new SupportingFile("LocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateProvider.java")); } 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 d937842a128..6ecf9a89c0e 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 @@ -74,12 +74,16 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo protected boolean emitJSDoc = true; protected String apiDocPath = "docs/"; protected String modelDocPath = "docs/"; + protected String apiTestPath = "api/"; + protected String modelTestPath = "model/"; public JavascriptClientCodegen() { super(); outputFolder = "generated-code/js"; modelTemplateFiles.put("model.mustache", ".js"); + modelTestTemplateFiles.put("model_test.mustache", ".js"); apiTemplateFiles.put("api.mustache", ".js"); + apiTestTemplateFiles.put("api_test.mustache", ".js"); templateDir = "Javascript"; apiPackage = "api"; modelPackage = "model"; @@ -292,6 +296,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo supportingFiles.add(new SupportingFile("ApiClient.mustache", createPath(sourceFolder, invokerPackage), "ApiClient.js")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); + supportingFiles.add(new SupportingFile("mocha.opts", "", "mocha.opts")); + supportingFiles.add(new SupportingFile("travis.yml", "", ".travis.yml")); } @Override @@ -322,6 +328,16 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo return buf.toString(); } + @Override + public String apiTestFileFolder() { + return (outputFolder + "/test/" + apiTestPath).replace('/', File.separatorChar); + } + + @Override + public String modelTestFileFolder() { + return (outputFolder + "/test/" + modelTestPath).replace('/', File.separatorChar); + } + @Override public String apiFileFolder() { return createPath(outputFolder, sourceFolder, invokerPackage, apiPackage()); @@ -400,6 +416,16 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo return toModelName(name); } + @Override + public String toApiTestFilename(String name) { + return toApiName(name) + ".spec"; + } + + @Override + public String toModelTestFilename(String name) { + return toModelName(name) + ".spec"; + } + @Override public String toVarName(String name) { // sanitize name diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LumenServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LumenServerCodegen.java index fbd98c034df..abc747435bf 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LumenServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LumenServerCodegen.java @@ -9,9 +9,20 @@ import java.io.File; public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig { // source folder where to write the files - protected String sourceFolder = "src"; - protected String apiVersion = "1.0.0"; + protected String sourceFolder = ""; + public static final String SRC_BASE_PATH = "srcBasePath"; + public static final String COMPOSER_VENDOR_NAME = "composerVendorName"; + public static final String COMPOSER_PROJECT_NAME = "composerProjectName"; + protected String invokerPackage = "Swagger\\Client"; + protected String composerVendorName = null; + protected String composerProjectName = null; + protected String packagePath = "SwaggerClient-php"; + protected String artifactVersion = null; + protected String srcBasePath = "lib"; + protected String apiVersion = "1.0.0"; + protected String apiDirName = "Api"; + /** * Configures the type of generator. * @@ -46,13 +57,8 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig super(); // set the output folder here - outputFolder = "generated-code/lumen"; - String packagePath = "lumen"; - - // modelPackage = packagePath + "\\lib\\Models"; - // apiPackage = packagePath + "\\lib"; - // // outputFolder = "generated-code" + File.separator + "slim"; - // modelTemplateFiles.put("model.mustache", ".php"); + outputFolder = "lumen"; + String packagePath = ""; /** * Models. You can write model files using the modelTemplateFiles map. @@ -75,7 +81,8 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig // no api files - apiTemplateFiles.clear(); + // apiTemplateFiles.clear(); + apiTemplateFiles.put("api.mustache", ".php"); // embeddedTemplateDir = templateDir = "slim"; @@ -115,43 +122,18 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig * entire object tree available. If the input file has a suffix of `.mustache * it will be processed by the template engine. Otherwise, it will be copied */ - // supportingFiles.add(new SupportingFile("index.mustache", packagePath, "index.php")); - // supportingFiles.add(new SupportingFile("routes.mustache", packagePath, "routes.php")); - - supportingFiles.add(new SupportingFile("composer.json", packagePath, "composer.json")); + supportingFiles.add(new SupportingFile("composer.mustache", packagePath, "composer.json")); supportingFiles.add(new SupportingFile("readme.md", packagePath, "readme.md")); - supportingFiles.add(new SupportingFile("artisan", packagePath, "artisan")); - // supportingFiles.add(new SupportingFile("server.php", packagePath, "server.php")); - - supportingFiles.add(new SupportingFile("bootstrap" + File.separator + "app.php", packagePath + File.separator + "bootstrap", "app.php")); - - supportingFiles.add(new SupportingFile("public" + File.separator + "index.php", packagePath + File.separator + "public", "index.php")); - - supportingFiles.add(new SupportingFile("app" + File.separator + "User.php", packagePath + File.separator + "app", "User.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Console" + File.separator + "Kernel.php", packagePath + File.separator + "app" + File.separator + "Console", "Kernel.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Exceptions" + File.separator + "Handler.php", packagePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Kernel.php", packagePath + File.separator + "app" + File.separator + "Http", "Kernel.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "routes.mustache", packagePath + File.separator + "app" + File.separator + "Http", "routes.php")); + supportingFiles.add(new SupportingFile("app.php", packagePath + File.separator + "bootstrap", "app.php")); + supportingFiles.add(new SupportingFile("index.php", packagePath + File.separator + "public", "index.php")); + supportingFiles.add(new SupportingFile("User.php", packagePath + File.separator + "app", "User.php")); + supportingFiles.add(new SupportingFile("Kernel.php", packagePath + File.separator + "app" + File.separator + "Console", "Kernel.php")); + supportingFiles.add(new SupportingFile("Handler.php", packagePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php")); + supportingFiles.add(new SupportingFile("routes.mustache", packagePath + File.separator + "app" + File.separator + "Http", "routes.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Controller.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "ExampleController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "ExampleController.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator + "AuthController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator, "AuthController.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator + "PasswordController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator, "PasswordController.php")); + supportingFiles.add(new SupportingFile("Controller.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php")); + supportingFiles.add(new SupportingFile("Authenticate.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "Authenticate.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "ExampleMiddleware.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "ExampleMiddleware.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "RedirectIfAuthenticated.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "RedirectIfAuthenticated.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "VerifyCsrfToken.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "VerifyCsrfToken.php")); - - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Requests" + File.separator + "Request.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Requests" + File.separator, "Request.php")); - - supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "AppServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "AppServiceProvider.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "AuthServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "AuthServiceProvider.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "EventServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "EventServiceProvider.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "RouteServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "RouteServiceProvider.php")); - - // supportingFiles.add(new SupportingFile("config" + File.separator + "app.php", packagePath + File.separator + "config" + File.separator, "app.php")); - /** * Language Specific Primitives. These types will not trigger imports by * the client generator @@ -188,7 +170,8 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig */ @Override public String apiFileFolder() { - return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar); + return outputFolder + "/app/Http/controllers"; + // return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar); } /** 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 cc1e77649e5..4344d90c7ae 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 @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.*; +import io.swagger.models.ArrayModel; import io.swagger.models.Model; import io.swagger.models.properties.*; @@ -94,7 +95,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.clear(); typeMapping.put("enum", "NSString"); typeMapping.put("date", "NSDate"); - typeMapping.put("DateTime", "NSDate"); + typeMapping.put("datetime", "NSDate"); typeMapping.put("boolean", "NSNumber"); typeMapping.put("string", "NSString"); typeMapping.put("integer", "NSNumber"); @@ -105,12 +106,15 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("array", "NSArray"); typeMapping.put("map", "NSDictionary"); typeMapping.put("number", "NSNumber"); + typeMapping.put("bigdecimal", "NSNumber"); typeMapping.put("List", "NSArray"); typeMapping.put("object", "NSObject"); typeMapping.put("file", "NSURL"); typeMapping.put("binary", "NSData"); - typeMapping.put("ByteArray", "NSData"); + typeMapping.put("bytearray", "NSData"); typeMapping.put("byte", "NSData"); + typeMapping.put("uuid", "NSString"); + typeMapping.put("password", "NSString"); // ref: http://www.tutorialspoint.com/objective_c/objective_c_basic_syntax.htm setReservedWordsLowerCase( @@ -293,8 +297,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { public String getSwaggerType(Property p) { String swaggerType = super.getSwaggerType(p); String type = null; - if (typeMapping.containsKey(swaggerType)) { - type = typeMapping.get(swaggerType); + if (typeMapping.containsKey(swaggerType.toLowerCase())) { + type = typeMapping.get(swaggerType.toLowerCase()); if (languageSpecificPrimitives.contains(type) && !foundationClasses.contains(type)) { return toModelNameWithoutReservedWordCheck(type); } @@ -304,15 +308,6 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { return toModelNameWithoutReservedWordCheck(type); } - public CodegenProperty coreDatafromProperty(String name, Property p) { - CodegenProperty property = fromProperty(name, p); - if(!generateCoreData) { - return property; - } - property.baseType = getTypeCoreDataDeclaration(p); - return property; - } - @Override public String getTypeDeclaration(Property p) { if (p instanceof ArrayProperty) { @@ -377,73 +372,6 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { } } - - public String getTypeCoreDataDeclaration(Property p) { - if (p instanceof ArrayProperty) { - ArrayProperty ap = (ArrayProperty) p; - Property inner = ap.getItems(); - String innerType = getSwaggerType(inner); - - String innerTypeDeclaration = getTypeDeclaration(inner); - if (innerTypeDeclaration.endsWith("*")) { - innerTypeDeclaration = innerTypeDeclaration.substring(0, innerTypeDeclaration.length() - 1); - } - // In this codition, type of property p is array of primitive, - // return container type with pointer, e.g. `NSArray**' - if (languageSpecificPrimitives.contains(innerTypeDeclaration)) { - return getSwaggerType(p) + "<" + innerTypeDeclaration + "*>*"; - } - // In this codition, type of property p is array of model, - // return container type combine inner type with pointer, e.g. `NSArray*' - else { - for (String sd : advancedMapingTypes) { - if(innerTypeDeclaration.startsWith(sd)) { - return getSwaggerType(p) + "<" + innerTypeDeclaration + "*>*"; - } - } - return getSwaggerType(p) + "<" + innerTypeDeclaration + ">*"; - } - } else if (p instanceof MapProperty) { - MapProperty mp = (MapProperty) p; - Property inner = mp.getAdditionalProperties(); - - String innerTypeDeclaration = getTypeDeclaration(inner); - - if (innerTypeDeclaration.endsWith("*")) { - innerTypeDeclaration = innerTypeDeclaration.substring(0, innerTypeDeclaration.length() - 1); - } - if (languageSpecificPrimitives.contains(innerTypeDeclaration)) { - return getSwaggerType(p) + "*"; - } else { - for (String s : advancedMapingTypes) { - if(innerTypeDeclaration.startsWith(s)) { - return getSwaggerType(p) + "*"; - } - } - return getSwaggerType(p) + "*"; - } - } else { - String swaggerType = getSwaggerType(p); - - // In this codition, type of p is objective-c primitive type, e.g. `NSSNumber', - // return type of p with pointer, e.g. `NSNumber*' - if (languageSpecificPrimitives.contains(swaggerType) && - foundationClasses.contains(swaggerType)) { - return swaggerType + "*"; - } - // In this codition, type of p is c primitive type, e.g. `bool', - // return type of p, e.g. `bool' - else if (languageSpecificPrimitives.contains(swaggerType)) { - return swaggerType; - } - // In this codition, type of p is objective-c object type, e.g. `SWGPet', - // return type of p with pointer, e.g. `SWGPet*' - else { - return swaggerType + "*"; - } - } - } - @Override public boolean isDataTypeBinary(String dataType) { return dataType.toLowerCase().startsWith("nsdata"); 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 51bd143ba8f..ba9dfa2ab60 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 @@ -167,6 +167,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig } supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml")); } private static String dropDots(String str) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java index aa32eb4e510..2b8e3523287 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java @@ -104,8 +104,8 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder, PREFIX + "Helpers.h")); supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder, PREFIX + "Helpers.cpp")); - supportingFiles.add(new SupportingFile("HttpRequest.h", sourceFolder, PREFIX + "HttpRequest.h")); - supportingFiles.add(new SupportingFile("HttpRequest.cpp", sourceFolder, PREFIX + "HttpRequest.cpp")); + supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, PREFIX + "HttpRequest.h")); + supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, PREFIX + "HttpRequest.cpp")); supportingFiles.add(new SupportingFile("modelFactory.mustache", sourceFolder, PREFIX + "ModelFactory.h")); supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h")); @@ -135,6 +135,9 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig { systemIncludes.add("QString"); systemIncludes.add("QList"); + systemIncludes.add("QMap"); + systemIncludes.add("QDate"); + systemIncludes.add("QDateTime"); } /** diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalatraServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalatraServerCodegen.java index d3fb0bf1881..46a3af76324 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalatraServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalatraServerCodegen.java @@ -86,7 +86,7 @@ public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConf supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("build.sbt", "", "build.sbt")); supportingFiles.add(new SupportingFile("web.xml", "/src/main/webapp/WEB-INF", "web.xml")); - supportingFiles.add(new SupportingFile("JettyMain.scala", sourceFolder, "JettyMain.scala")); + supportingFiles.add(new SupportingFile("JettyMain.mustache", sourceFolder, "JettyMain.scala")); supportingFiles.add(new SupportingFile("Bootstrap.mustache", sourceFolder, "ScalatraBootstrap.scala")); supportingFiles.add(new SupportingFile("ServletApp.mustache", sourceFolder, "ServletApp.scala")); supportingFiles.add(new SupportingFile("project/build.properties", "project", "build.properties")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java index dbed6bc98c4..4b30062d799 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringBootServerCodegen.java @@ -12,11 +12,15 @@ public class SpringBootServerCodegen extends JavaClientCodegen implements Codege public static final String BASE_PACKAGE = "basePackage"; public static final String INTERFACE_ONLY = "interfaceOnly"; public static final String SINGLE_CONTENT_TYPES = "singleContentTypes"; + public static final String JAVA_8 = "java8"; + public static final String ASYNC = "async"; protected String title = "Petstore Server"; protected String configPackage = ""; protected String basePackage = ""; protected boolean interfaceOnly = false; protected boolean singleContentTypes = false; + protected boolean java8 = false; + protected boolean async = false; protected String templateFileName = "api.mustache"; public SpringBootServerCodegen() { @@ -45,11 +49,14 @@ public class SpringBootServerCodegen extends JavaClientCodegen implements Codege cliOptions.add(new CliOption(BASE_PACKAGE, "base package for generated code")); cliOptions.add(CliOption.newBoolean(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files.")); cliOptions.add(CliOption.newBoolean(SINGLE_CONTENT_TYPES, "Whether to select only one produces/consumes content-type by operation.")); + cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface")); + cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers")); supportedLibraries.clear(); supportedLibraries.put(DEFAULT_LIBRARY, "Default Spring Boot server stub."); supportedLibraries.put("j8-async", "Use async servlet feature and Java 8's default interface. Generating interface with service " + - "declaration is useful when using Maven plugin. Just provide a implementation with @Controller to instantiate service."); + "declaration is useful when using Maven plugin. Just provide a implementation with @Controller to instantiate service." + + "(DEPRECATED: use -Djava8=true,async=true instead)"); } @Override @@ -92,11 +99,19 @@ public class SpringBootServerCodegen extends JavaClientCodegen implements Codege this.setSingleContentTypes(Boolean.valueOf(additionalProperties.get(SINGLE_CONTENT_TYPES).toString())); } + if (additionalProperties.containsKey(JAVA_8)) { + this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString())); + } + + if (additionalProperties.containsKey(ASYNC)) { + this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString())); + } + supportingFiles.clear(); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); - if(!this.interfaceOnly) { + if (!this.interfaceOnly) { apiTemplateFiles.put("apiController.mustache", "Controller.java"); supportingFiles.add(new SupportingFile("apiException.mustache", (sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiException.java")); @@ -115,6 +130,19 @@ public class SpringBootServerCodegen extends JavaClientCodegen implements Codege supportingFiles.add(new SupportingFile("application.properties", ("src.main.resources").replace(".", java.io.File.separator), "application.properties")); } + + if ("j8-async".equals(getLibrary())) { + setJava8(true); + setAsync(true); + } + + if (this.java8) { + additionalProperties.put("javaVersion", "1.8"); + typeMapping.put("date", "LocalDate"); + typeMapping.put("DateTime", "OffsetDateTime"); + importMapping.put("LocalDate", "java.time.LocalDate"); + importMapping.put("OffsetDateTime", "java.time.OffsetDateTime"); + } } @Override @@ -228,23 +256,6 @@ public class SpringBootServerCodegen extends JavaClientCodegen implements Codege } } } - if("j8-async".equals(getLibrary())) { - apiTemplateFiles.remove(this.templateFileName); - this.templateFileName = "api-j8-async.mustache"; - apiTemplateFiles.put(this.templateFileName, ".java"); - - int originalPomFileIdx = -1; - for (int i = 0; i < supportingFiles.size(); i++) { - if ("pom.xml".equals(supportingFiles.get(i).destinationFilename)) { - originalPomFileIdx = i; - break; - } - } - if (originalPomFileIdx > -1) { - supportingFiles.remove(originalPomFileIdx); - } - supportingFiles.add(new SupportingFile("pom-j8-async.mustache", "", "pom.xml")); - } return objs; } @@ -266,13 +277,15 @@ public class SpringBootServerCodegen extends JavaClientCodegen implements Codege this.basePackage = configPackage; } - public void setInterfaceOnly(boolean interfaceOnly) { - this.interfaceOnly = interfaceOnly; - } + public void setInterfaceOnly(boolean interfaceOnly) { this.interfaceOnly = interfaceOnly; } public void setSingleContentTypes(boolean singleContentTypes) { this.singleContentTypes = singleContentTypes; } + + public void setJava8(boolean java8) { this.java8 = java8; } + + public void setAsync(boolean async) { this.async = async; } @Override public Map postProcessModels(Map objs) { diff --git a/modules/swagger-codegen/src/main/resources/Java/gitignore.mustache b/modules/swagger-codegen/src/main/resources/Java/gitignore.mustache index 7cf39af816c..a530464afa1 100644 --- a/modules/swagger-codegen/src/main/resources/Java/gitignore.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/gitignore.mustache @@ -13,3 +13,9 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* + +# build files +**/target +target +.gradle +build diff --git a/modules/swagger-codegen/src/main/resources/Java/travis.mustache b/modules/swagger-codegen/src/main/resources/Java/travis.mustache new file mode 100644 index 00000000000..33e79472abd --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/travis.mustache @@ -0,0 +1,29 @@ +# +# Generated by: https://github.com/swagger-api/swagger-codegen.git +# +# 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. +# +language: java +jdk: + - oraclejdk8 + - oraclejdk7 +before_install: + # ensure gradlew has proper permission + - chmod a+x ./gradlew +script: + # test using maven + - mvn test + # uncomment below to test using gradle + # - gradle test + # uncomment below to test using sbt + # - sbt test diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache index f17abb0d222..c214ae2ae84 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache @@ -18,6 +18,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{>enumClass}}{{/items}}{{/items.isEnum}} + @XmlElement(name="{{baseName}}") private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}} {{#vars}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey1/LocalDateTimeProvider.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey1/OffsetDateTimeProvider.mustache similarity index 67% rename from modules/swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey1/LocalDateTimeProvider.mustache rename to modules/swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey1/OffsetDateTimeProvider.mustache index 93bb6f19d50..876aeb327be 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey1/LocalDateTimeProvider.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey1/OffsetDateTimeProvider.mustache @@ -11,23 +11,23 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; import javax.ws.rs.ext.Provider; -import java.time.LocalDateTime; +import java.time.OffsetDateTime; import java.util.List; @Provider -public class LocalDateTimeProvider extends PerRequestTypeInjectableProvider { +public class OffsetDateTimeProvider extends PerRequestTypeInjectableProvider { private final UriInfo uriInfo; - public LocalDateTimeProvider(@Context UriInfo uriInfo) { - super(LocalDateTime.class); + public OffsetDateTimeProvider(@Context UriInfo uriInfo) { + super(OffsetDateTime.class); this.uriInfo = uriInfo; } @Override - public Injectable getInjectable(final ComponentContext cc, final QueryParam a) { - return new Injectable() { + public Injectable getInjectable(final ComponentContext cc, final QueryParam a) { + return new Injectable() { @Override - public LocalDateTime getValue() { + public OffsetDateTime getValue() { final List values = uriInfo.getQueryParameters().get(a.value()); if (values == null || values.isEmpty()) @@ -37,7 +37,7 @@ public class LocalDateTimeProvider extends PerRequestTypeInjectableProvider { +public class OffsetDateTimeProvider extends PerRequestTypeInjectableProvider { private final UriInfo uriInfo; - public LocalDateTimeProvider(@Context UriInfo uriInfo) { - super(LocalDateTime.class); + public OffsetDateTimeProvider(@Context UriInfo uriInfo) { + super(OffsetDateTime.class); this.uriInfo = uriInfo; } @Override - public Injectable getInjectable(final ComponentContext cc, final QueryParam a) { - return new Injectable() { + public Injectable getInjectable(final ComponentContext cc, final QueryParam a) { + return new Injectable() { @Override - public LocalDateTime getValue() { + public OffsetDateTime getValue() { final List values = uriInfo.getQueryParameters().get(a.value()); if (values == null || values.isEmpty()) @@ -37,7 +37,7 @@ public class LocalDateTimeProvider extends PerRequestTypeInjectableProvider { - - @Override - public LocalDateTime fromString(String string) { - LocalDateTime localDateTime = LocalDateTime.parse(string); - return localDateTime; - } - - @Override - public String toString(LocalDateTime t) { - return t.toString(); - } - } - - @Override - public ParamConverter getConverter(Class type, Type type1, Annotation[] antns) { - if (LocalDateTime.class.equals(type)) { - return (ParamConverter) new LocalDateTimeConverter(); - } - return null; - } -} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/OffsetDateTimeProvider.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/OffsetDateTimeProvider.mustache new file mode 100644 index 00000000000..f24dabbe283 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/resteasy/OffsetDateTimeProvider.mustache @@ -0,0 +1,34 @@ +package {{apiPackage}}; + +import java.time.OffsetDateTime; +import javax.ws.rs.ext.ParamConverter; +import javax.ws.rs.ext.ParamConverterProvider; +import javax.ws.rs.ext.Provider; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; + +@Provider +public class OffsetDateTimeProvider implements ParamConverterProvider { + + public static class OffsetDateTimeConverter implements ParamConverter { + + @Override + public OffsetDateTime fromString(String string) { + OffsetDateTime OffsetDateTime = OffsetDateTime.parse(string); + return OffsetDateTime; + } + + @Override + public String toString(OffsetDateTime t) { + return t.toString(); + } + } + + @Override + public ParamConverter getConverter(Class type, Type type1, Annotation[] antns) { + if (OffsetDateTime.class.equals(type)) { + return (ParamConverter) new OffsetDateTimeConverter(); + } + return null; + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/api.mustache index bd0d7180529..c3b3bb66908 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/api.mustache @@ -1,12 +1,12 @@ package {{apiPackage}}; -import {{modelPackage}}.*; - {{#imports}}import {{import}}; {{/imports}} import io.swagger.annotations.*; - +{{#java8}} +import org.springframework.http.HttpStatus; +{{/java8}} import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -18,33 +18,37 @@ import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; import java.util.List; +{{#async}} +import java.util.concurrent.Callable; +{{/async}} -import static org.springframework.http.MediaType.*; - -@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API") {{>generatedAnnotation}} +@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API") {{#operations}} public interface {{classname}} { - {{#operation}} +{{#operation}} - @ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { - {{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = { - {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, - {{/hasMore}}{{/scopes}} - }{{/isOAuth}}){{#hasMore}}, - {{/hasMore}}{{/authMethods}} - }{{/hasAuthMethods}}) - @ApiResponses(value = { {{#responses}} - @ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class){{#hasMore}},{{/hasMore}}{{/responses}} }) - @RequestMapping(value = "{{{path}}}",{{#singleContentTypes}} - produces = "{{{vendorExtensions.x-accepts}}}", - consumes = "{{{vendorExtensions.x-contentType}}}",{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} - produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} - consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} - method = RequestMethod.{{httpMethod}}) - ResponseEntity<{{>returnTypes}}> {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, - {{/hasMore}}{{/allParams}}); + @ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { + {{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = { + {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, + {{/hasMore}}{{/scopes}} + }{{/isOAuth}}){{#hasMore}}, + {{/hasMore}}{{/authMethods}} + }{{/hasAuthMethods}}) + @ApiResponses(value = { {{#responses}} + @ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class){{#hasMore}},{{/hasMore}}{{/responses}} }) + @RequestMapping(value = "{{{path}}}",{{#singleContentTypes}} + produces = "{{{vendorExtensions.x-accepts}}}", + consumes = "{{{vendorExtensions.x-contentType}}}",{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} + produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} + consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} + method = RequestMethod.{{httpMethod}}) + {{#java8}}default {{/java8}}{{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, + {{/hasMore}}{{/allParams}}){{^java8}};{{/java8}}{{#java8}} { + // do some magic! + return {{#async}}() -> {{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); + }{{/java8}} - {{/operation}} +{{/operation}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/apiController.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/apiController.mustache index 0cde913d660..f9c03faafc1 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/apiController.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/apiController.mustache @@ -1,7 +1,6 @@ package {{apiPackage}}; -import {{modelPackage}}.*; - +{{^java8}} {{#imports}}import {{import}}; {{/imports}} @@ -9,7 +8,9 @@ import io.swagger.annotations.*; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +{{/java8}} import org.springframework.stereotype.Controller; +{{^java8}} import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -18,18 +19,26 @@ import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; import java.util.List; +{{#async}} +import java.util.concurrent.Callable; +{{/async}}{{/java8}} -@Controller {{>generatedAnnotation}} +@Controller {{#operations}} public class {{classname}}Controller implements {{classname}} { - {{#operation}} - public ResponseEntity<{{>returnTypes}}> {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, - {{/hasMore}}{{/allParams}}) { - // do some magic! - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); - } - - {{/operation}} +{{^java8}}{{#operation}} + public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, + {{/hasMore}}{{/allParams}}) { + // do some magic!{{^async}} + return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK);{{/async}}{{#async}} + return new CallablereturnTypes}}>>() { + @Override + public ResponseEntity<{{>returnTypes}}> call() throws Exception { + return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); + } + };{{/async}} + } +{{/operation}}{{/java8}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/pom.mustache index 53c3652cb45..d3b0cbfd467 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/pom.mustache @@ -1,63 +1,78 @@ - 4.0.0 - {{groupId}} - {{artifactId}} - jar - {{artifactId}} - {{artifactVersion}} - - 2.4.0 - - - org.springframework.boot - spring-boot-starter-parent - 1.3.3.RELEASE - - - src/main/java{{^interfaceOnly}} - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - {{/interfaceOnly}} - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - provided - - - - io.springfox - springfox-swagger2 - ${springfox-version} - - - io.springfox - springfox-swagger-ui - ${springfox-version} - + 4.0.0 + {{groupId}} + {{artifactId}} + jar + {{artifactId}} + {{artifactVersion}} + + 2.4.0 + {{#java8}} + 1.8 + 1.8 + {{/java8}} + + + org.springframework.boot + spring-boot-starter-parent + 1.3.3.RELEASE + + + src/main/java + {{^interfaceOnly}} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + {{/interfaceOnly}} + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + io.springfox + springfox-swagger2 + ${springfox-version} + + + io.springfox + springfox-swagger-ui + ${springfox-version} + + {{#java8}} - - com.fasterxml.jackson.datatype - jackson-datatype-joda - - - joda-time - joda-time - - + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + {{/java8}} + {{^java8}} + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + + + joda-time + joda-time + + {{/java8}} + \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/swaggerDocumentationConfig.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/swaggerDocumentationConfig.mustache index 970739e1b97..fc4af3892c6 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringBoot/swaggerDocumentationConfig.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringBoot/swaggerDocumentationConfig.mustache @@ -30,13 +30,15 @@ public class SwaggerDocumentationConfig { @Bean public Docket customImplementation(){ - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("{{apiPackage}}")) - .build() - .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("{{apiPackage}}")) + .build(){{#java8}} + .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class){{/java8}}{{^java8}} + .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class){{/java8}} + .apiInfo(apiInfo()); } } diff --git a/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache index 25a0e5155aa..3b301e0937c 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/modules/swagger-codegen/src/main/resources/Javascript/api.mustache b/modules/swagger-codegen/src/main/resources/Javascript/api.mustache index 14abda4751c..375acd90ac7 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/api.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} {{=< >=}}(function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/modules/swagger-codegen/src/main/resources/Javascript/api_test.mustache b/modules/swagger-codegen/src/main/resources/Javascript/api_test.mustache new file mode 100644 index 00000000000..181c114ca96 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Javascript/api_test.mustache @@ -0,0 +1,55 @@ +{{>licenseInfo}} +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.{{moduleName}}); + } +}(this, function(expect, {{moduleName}}) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new {{moduleName}}.{{classname}}(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('{{classname}}', function() { +{{#operations}} +{{#operation}} + describe('{{operationId}}', function() { + it('should call {{operationId}} successfully', function(done) { + //uncomment below and update the code to test {{operationId}} + //instance.{{operationId}}(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); +{{/operation}} +{{/operations}} + }); + +})); diff --git a/modules/swagger-codegen/src/main/resources/Javascript/index.mustache b/modules/swagger-codegen/src/main/resources/Javascript/index.mustache index 1561763af0e..d6ca3cff704 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/index.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/index.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/modules/swagger-codegen/src/main/resources/Javascript/licenseInfo.mustache b/modules/swagger-codegen/src/main/resources/Javascript/licenseInfo.mustache new file mode 100644 index 00000000000..861d97234cf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Javascript/licenseInfo.mustache @@ -0,0 +1,23 @@ +/** + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ diff --git a/modules/swagger-codegen/src/main/resources/Javascript/mocha.opts b/modules/swagger-codegen/src/main/resources/Javascript/mocha.opts new file mode 100644 index 00000000000..907011807d6 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Javascript/mocha.opts @@ -0,0 +1 @@ +--timeout 10000 diff --git a/modules/swagger-codegen/src/main/resources/Javascript/model.mustache b/modules/swagger-codegen/src/main/resources/Javascript/model.mustache index db480f05b1d..95f2b2df81d 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/model.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/modules/swagger-codegen/src/main/resources/Javascript/model_test.mustache b/modules/swagger-codegen/src/main/resources/Javascript/model_test.mustache new file mode 100644 index 00000000000..2b43b338812 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Javascript/model_test.mustache @@ -0,0 +1,65 @@ +{{>licenseInfo}} +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.{{moduleName}}); + } +}(this, function(expect, {{moduleName}}) { + 'use strict'; + + var instance; + + beforeEach(function() { +{{#models}} +{{#model}} +{{^isEnum}} + instance = new {{moduleName}}.{{classname}}(); +{{/isEnum}} +{{/model}} +{{/models}} + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('{{classname}}', function() { + it('should create an instance of {{classname}}', function() { + // uncomment below and update the code to test {{classname}} + //var instane = new {{moduleName}}.{{classname}}(); + //expect(instance).to.be.a({{moduleName}}.{{classname}}); + }); + +{{#models}} +{{#model}} +{{#vars}} + it('should have the property {{name}} (base name: "{{baseName}}")', function() { + // uncomment below and update the code to test the property {{name}} + //var instane = new {{moduleName}}.{{classname}}(); + //expect(instance).to.be(); + }); + +{{/vars}} +{{/model}} +{{/models}} + }); + +})); diff --git a/modules/swagger-codegen/src/main/resources/Javascript/travis.yml b/modules/swagger-codegen/src/main/resources/Javascript/travis.yml new file mode 100644 index 00000000000..e49f4692f7c --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Javascript/travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - "6" + - "6.1" + - "5" + - "5.11" + diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index f0d0fde5e57..c75af63df84 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -2,6 +2,7 @@ io.swagger.codegen.languages.AndroidClientCodegen io.swagger.codegen.languages.AspNet5ServerCodegen io.swagger.codegen.languages.AsyncScalaClientCodegen io.swagger.codegen.languages.CSharpClientCodegen +io.swagger.codegen.languages.CppRestClientCodegen io.swagger.codegen.languages.DartClientCodegen io.swagger.codegen.languages.FlashClientCodegen io.swagger.codegen.languages.FlaskConnexionCodegen @@ -46,3 +47,4 @@ io.swagger.codegen.languages.CsharpDotNet2ClientCodegen io.swagger.codegen.languages.ClojureClientCodegen io.swagger.codegen.languages.HaskellServantCodegen io.swagger.codegen.languages.LumenServerCodegen +io.swagger.codegen.languages.GoServerCodegen \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/_common/.swagger-codegen-ignore b/modules/swagger-codegen/src/main/resources/_common/.swagger-codegen-ignore index 19d3377182e..c5fa491b4c5 100644 --- a/modules/swagger-codegen/src/main/resources/_common/.swagger-codegen-ignore +++ b/modules/swagger-codegen/src/main/resources/_common/.swagger-codegen-ignore @@ -14,7 +14,7 @@ # You can recursively match patterns against a directory, file or extension with a double asterisk (**): #foo/**/qux -# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux # You can also negate patterns with an exclamation (!). # For example, you can ignore all files in a docs folder with the file extension .md: diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache index 6b0600e77b9..b5def5f589f 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache @@ -34,11 +34,17 @@ public class DeleteRequest extends Request { @Override public String getBodyContentType() { + if(entity == null) { + return null; + } return entity.getContentType().getValue(); } @Override public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { entity.writeTo(bos); diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache index 188fc5edb41..3607a03eeab 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache @@ -34,11 +34,17 @@ public class PatchRequest extends Request { @Override public String getBodyContentType() { + if(entity == null) { + return null; + } return entity.getContentType().getValue(); } @Override public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { entity.writeTo(bos); diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache index 02c7fdfb119..7d0d1fe1c14 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache @@ -34,11 +34,17 @@ public class PostRequest extends Request { @Override public String getBodyContentType() { + if(entity == null) { + return null; + } return entity.getContentType().getValue(); } @Override public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { entity.writeTo(bos); diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache index 571a921e56a..a9dd14b0a7b 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache @@ -34,11 +34,17 @@ public class PutRequest extends Request { @Override public String getBodyContentType() { + if(entity == null) { + return null; + } return entity.getContentType().getValue(); } @Override public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { entity.writeTo(bos); diff --git a/modules/swagger-codegen/src/main/resources/cpprest/api-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/api-header.mustache new file mode 100644 index 00000000000..a93709b1fd5 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/api-header.mustache @@ -0,0 +1,48 @@ +{{#operations}}/* + * {{classname}}.h + * + * {{description}} + */ + +#ifndef {{classname}}_H_ +#define {{classname}}_H_ + +{{{defaultInclude}}} +#include "ApiClient.h" + +{{#imports}}{{{import}}} +{{/imports}} + +{{#apiNamespaceDeclarations}} +namespace {{this}} { +{{/apiNamespaceDeclarations}} + +using namespace {{modelNamespace}}; + +class {{declspec}} {{classname}} +{ +public: + {{classname}}( std::shared_ptr apiClient ); + virtual ~{{classname}}(); + {{#operation}} + /// + /// {{summary}} + /// + /// + /// {{notes}} + /// + {{#allParams}}/// {{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{/allParams}} + pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + {{/operation}} + +protected: + std::shared_ptr m_ApiClient; +}; + +{{#apiNamespaceDeclarations}} +} +{{/apiNamespaceDeclarations}} + +#endif /* {{classname}}_H_ */ + +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache new file mode 100644 index 00000000000..6ecbdb1a0f5 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache @@ -0,0 +1,269 @@ +{{#operations}} + +#include "{{classname}}.h" +#include "IHttpBody.h" +#include "JsonBody.h" +#include "MultipartFormData.h" + +#include + +#include + +{{#apiNamespaceDeclarations}} +namespace {{this}} { +{{/apiNamespaceDeclarations}} + +using namespace {{modelNamespace}}; + +{{classname}}::{{classname}}( std::shared_ptr apiClient ) + : m_ApiClient(apiClient) +{ +} + +{{classname}}::~{{classname}}() +{ +} + +{{#operation}} +pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{classname}}::{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) +{ + {{#allParams}}{{#required}}{{^isPrimitiveType}}{{^isContainer}} + // verify the required parameter '{{paramName}}' is set + if ({{paramName}} == nullptr) + { + throw ApiException(400, U("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")); + } + {{/isContainer}}{{/isPrimitiveType}}{{/required}}{{/allParams}} + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("{{path}}"); + {{#pathParams}}boost::replace_all(path, U("{") U("{{baseName}}") U("}"), ApiClient::parameterToString({{{paramName}}})); + {{/pathParams}} + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + {{#produces}}responseHttpContentTypes.insert( U("{{mediaType}}") ); + {{/produces}} + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("{{classname}}->{{operationId}} does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + {{#consumes}}consumeHttpContentTypes.insert( U("{{mediaType}}") ); + {{/consumes}} + + {{#allParams}}{{^isBodyParam}}{{^isPrimitiveType}}{{^isContainer}}if ({{paramName}} != nullptr){{/isContainer}}{{/isPrimitiveType}} + { + {{#isContainer}}{{#isQueryParam}}queryParams[U("{{baseName}}")] = ApiClient::parameterToArrayString<{{items.datatype}}>({{paramName}}); + {{/isQueryParam}}{{#isHeaderParam}}headerParams[U("{{baseName}}")] = ApiClient::parameterToArrayString<{{items.datatype}}>({{paramName}}); + {{/isHeaderParam}}{{#isFormParam}}{{^isFile}}formParams[ U("{{baseName}}") ] = ApiClient::parameterToArrayString<{{items.datatype}}>({{paramName}}); + {{/isFile}}{{/isFormParam}}{{/isContainer}}{{^isContainer}}{{#isQueryParam}}queryParams[U("{{baseName}}")] = ApiClient::parameterToString({{paramName}}); + {{/isQueryParam}}{{#isHeaderParam}}headerParams[U("{{baseName}}")] = ApiClient::parameterToString({{paramName}}); + {{/isHeaderParam}}{{#isFormParam}}{{#isFile}}fileParams[ U("{{baseName}}") ] = {{paramName}}; + {{/isFile}}{{^isFile}}formParams[ U("{{baseName}}") ] = ApiClient::parameterToString({{paramName}}); + {{/isFile}}{{/isFormParam}}{{/isContainer}} + } + {{/isBodyParam}}{{/allParams}} + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + {{#bodyParam}} + web::json::value json; + + {{#isPrimitiveType}} json = ModelBase::toJson({{paramName}}); + {{/isPrimitiveType}}{{^isPrimitiveType}}{{#isListContainer}} + { + std::vector jsonArray; + for( auto& item : {{paramName}} ) + { + {{#items.isPrimitiveType}}jsonArray.push_back(ModelBase::toJson(item)); + {{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}jsonArray.push_back(ModelBase::toJson(item)); + {{/items.isString}}{{^items.isString}}{{#items.isDateTime}}jsonArray.push_back(ModelBase::toJson(item)); + {{/items.isDateTime}}{{^items.isDateTime}}jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() ); + {{/items.isDateTime}}{{/items.isString}}{{/items.isPrimitiveType}} + } + json = web::json::value::array(jsonArray); + } + {{/isListContainer}}{{^isListContainer}}json = ModelBase::toJson({{paramName}}); + {{/isListContainer}}{{/isPrimitiveType}} + + httpBody = std::shared_ptr( new JsonBody( json ) ); + + {{/bodyParam}} + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + {{#bodyParam}} + std::shared_ptr multipart(new MultipartFormData); + {{#isPrimitiveType}} multipart->add(ModelBase::toHttpContent("{{paramName}}", {{paramName}})); + {{/isPrimitiveType}}{{^isPrimitiveType}}{{#isListContainer}} + { + std::vector jsonArray; + for( auto& item : {{paramName}} ) + { + {{#items.isPrimitiveType}}jsonArray.push_back(ModelBase::toJson(item)); + {{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}jsonArray.push_back(ModelBase::toJson(item)); + {{/items.isString}}{{^items.isString}}{{#items.isDateTime}}jsonArray.push_back(ModelBase::toJson(item)); + {{/items.isDateTime}}{{^items.isDateTime}}jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() ); + {{/items.isDateTime}}{{/items.isString}}{{/items.isPrimitiveType}} + } + multipart->add(ModelBase::toHttpContent(U("{{paramName}}"), web::json::value::array(jsonArray), U("application/json"))); + } + {{/isListContainer}}{{^isListContainer}}{{#isString}}multipart->add(ModelBase::toHttpContent(U("{{paramName}}"), {{paramName}})); + {{/isString}}{{^isString}} + if({{paramName}}.get()) + { + {{paramName}}->toMultipart(multipart, U("{{paramName}}")); + } + {{/isString}}{{/isListContainer}}{{/isPrimitiveType}} + + httpBody = multipart; + requestHttpContentType += U("; boundary=") + multipart->getBoundary(); + {{/bodyParam}} + } + else + { + throw ApiException(415, U("{{classname}}->{{operationId}} does not consume any supported media type")); + } + + {{#authMethods}} + // authentication ({{name}}) required + {{#isApiKey}} + {{#isKeyInHeader}} + { + utility::string_t apiKey = apiConfiguration->getApiKey(U("{{keyParamName}}")); + if ( apiKey.size() > 0 ) + { + headerParams[U("{{keyParamName}}")] = apiKey; + } + } + {{/isKeyInHeader}} + {{#isKeyInQuery}} + { + utility::string_t apiKey = apiConfiguration->getApiKey(U("{{keyParamName}}")); + if ( apiKey.size() > 0 ) + { + queryParams[U("{{keyParamName}}")] = apiKey; + } + } + {{/isKeyInQuery}} + {{/isApiKey}} + {{#isBasic}} + // Basic authentication is added automatically as part of the http_client_config + {{/isBasic}} + {{#isOAuth}} + // oauth2 authentication is added automatically as part of the http_client_config + {{/isOAuth}} + {{/authMethods}} + + return m_ApiClient->callApi(path, U("{{httpMethod}}"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling {{operationId}}: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling {{operationId}}: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + {{^returnType}}return void(); + {{/returnType}}{{#returnType}}{{#returnContainer}}{{{returnType}}} result; + {{/returnContainer}}{{^returnContainer}}{{{returnType}}} result({{{defaultResponse}}});{{/returnContainer}} + + if(responseHttpContentType == U("application/json")) + { + web::json::value json = web::json::value::parse(response); + + {{#isListContainer}}for( auto& item : json.as_array() ) + { + {{#vendorExtensions.x-codegen-response.items.isPrimitiveType}}result.push_back(ModelBase::{{vendorExtensions.x-codegen-response.items.datatype}}FromJson(item)); + {{/vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{^vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.items.isString}}result.push_back(ModelBase::stringFromJson(item)); + {{/vendorExtensions.x-codegen-response.items.isString}}{{^vendorExtensions.x-codegen-response.items.isString}}{{{vendorExtensions.x-codegen-response.items.datatype}}} itemObj({{{vendorExtensions.x-codegen-response.items.defaultValue}}}); + itemObj->fromJson(item); + result.push_back(itemObj); + {{/vendorExtensions.x-codegen-response.items.isString}}{{/vendorExtensions.x-codegen-response.items.isPrimitiveType}} + } + {{/isListContainer}}{{^isListContainer}}{{#isMapContainer}}for( auto& item : json.as_object() ) + { + {{#vendorExtensions.x-codegen-response.items.isPrimitiveType}}result[item.first] = ModelBase::{{vendorExtensions.x-codegen-response.items.datatype}}FromJson(item.second); + {{/vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{^vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.items.isString}}result[item.first] = ModelBase::stringFromJson(item.second); + {{/vendorExtensions.x-codegen-response.items.isString}}{{^vendorExtensions.x-codegen-response.items.isString}}{{{vendorExtensions.x-codegen-response.items.datatype}}} itemObj({{{vendorExtensions.x-codegen-response.items.defaultValue}}}); + itemObj->fromJson(item); + result[item.first] = itemObj; + {{/vendorExtensions.x-codegen-response.items.isString}}{{/vendorExtensions.x-codegen-response.items.isPrimitiveType}} + } + {{/isMapContainer}}{{^isMapContainer}}{{#vendorExtensions.x-codegen-response.isPrimitiveType}}result = ModelBase::{{vendorExtensions.x-codegen-response.items.datatype}}FromJson(json); + {{/vendorExtensions.x-codegen-response.isPrimitiveType}}{{^vendorExtensions.x-codegen-response.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.isString}}result = ModelBase::stringFromJson(json); + {{/vendorExtensions.x-codegen-response.isString}}{{^vendorExtensions.x-codegen-response.isString}}result->fromJson(json);{{/vendorExtensions.x-codegen-response.isString}}{{/vendorExtensions.x-codegen-response.isPrimitiveType}}{{/isMapContainer}}{{/isListContainer}} + } + // else if(responseHttpContentType == U("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , U("error calling findPetsByStatus: unsupported response type")); + } + + return result; + {{/returnType}} + }); +} +{{/operation}} + +{{#apiNamespaceDeclarations}} +} +{{/apiNamespaceDeclarations}} + +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/cpprest/apiclient-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/apiclient-header.mustache new file mode 100644 index 00000000000..97bd2f823e1 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/apiclient-header.mustache @@ -0,0 +1,75 @@ +/* + * ApiClient.h + * + * This is an API client responsible for stating the HTTP calls + */ + +#ifndef ApiClient_H_ +#define ApiClient_H_ + +{{{defaultInclude}}} +#include "ApiConfiguration.h" +#include "ApiException.h" +#include "IHttpBody.h" +#include "HttpContent.h" + +#include +#include + +#include +#include + +{{#apiNamespaceDeclarations}} +namespace {{this}} { +{{/apiNamespaceDeclarations}} + +using namespace {{modelNamespace}}; + +class {{declspec}} ApiClient +{ +public: + ApiClient( std::shared_ptr configuration = nullptr ); + virtual ~ApiClient(); + + std::shared_ptr getConfiguration() const; + void setConfiguration(std::shared_ptr configuration); + + static utility::string_t parameterToString(utility::string_t value); + static utility::string_t parameterToString(int32_t value); + static utility::string_t parameterToString(int64_t value); + + template + static utility::string_t parameterToArrayString(std::vector value) + { + utility::stringstream_t ss; + + for( size_t i = 0; i < value.size(); i++) + { + if( i > 0) ss << U(", "); + ss << ApiClient::parameterToString(value[i]); + } + + return ss.str(); + } + + pplx::task callApi( + const utility::string_t& path, + const utility::string_t& method, + const std::map& queryParams, + const std::shared_ptr postBody, + const std::map& headerParams, + const std::map& formParams, + const std::map>& fileParams, + const utility::string_t& contentType + ) const; + +protected: + + std::shared_ptr m_Configuration; +}; + +{{#apiNamespaceDeclarations}} +} +{{/apiNamespaceDeclarations}} + +#endif /* ApiClient_H_ */ \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/apiclient-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/apiclient-source.mustache new file mode 100644 index 00000000000..cdb62a507b4 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/apiclient-source.mustache @@ -0,0 +1,131 @@ +#include "ApiClient.h" +#include "MultipartFormData.h" +#include "ModelBase.h" + +{{#apiNamespaceDeclarations}} +namespace {{this}} { +{{/apiNamespaceDeclarations}} + +using namespace {{modelNamespace}}; + +ApiClient::ApiClient(std::shared_ptr configuration ) + : m_Configuration(configuration) +{ +} +ApiClient::~ApiClient() +{ +} + +std::shared_ptr ApiClient::getConfiguration() const +{ + return m_Configuration; +} +void ApiClient::setConfiguration(std::shared_ptr configuration) +{ + m_Configuration = configuration; +} + + +utility::string_t ApiClient::parameterToString(utility::string_t value) +{ + return value; +} +utility::string_t ApiClient::parameterToString(int64_t value) +{ + return std::to_wstring(value); +} +utility::string_t ApiClient::parameterToString(int32_t value) +{ + return std::to_wstring(value); +} + +pplx::task ApiClient::callApi( + const utility::string_t& path, + const utility::string_t& method, + const std::map& queryParams, + const std::shared_ptr postBody, + const std::map& headerParams, + const std::map& formParams, + const std::map>& fileParams, + const utility::string_t& contentType +) const +{ + if (postBody != nullptr && formParams.size() != 0) + { + throw ApiException(400, U("Cannot have body and form params")); + } + + if (postBody != nullptr && fileParams.size() != 0) + { + throw ApiException(400, U("Cannot have body and file params")); + } + + if (fileParams.size() > 0 && contentType != U("multipart/form-data")) + { + throw ApiException(400, U("Operations with file parameters must be called with multipart/form-data")); + } + + web::http::client::http_client client(m_Configuration->getBaseUrl(), m_Configuration->getHttpConfig()); + + web::http::http_request request; + for ( auto& kvp : headerParams ) + { + request.headers().add(kvp.first, kvp.second); + } + + if (fileParams.size() > 0) + { + MultipartFormData uploadData; + for (auto& kvp : formParams) + { + uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); + } + for (auto& kvp : fileParams) + { + uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); + } + std::stringstream data; + postBody->writeTo(data); + auto bodyString = data.str(); + auto length = bodyString.size(); + request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, contentType); + } + else + { + if (postBody != nullptr) + { + std::stringstream data; + postBody->writeTo(data); + auto bodyString = data.str(); + auto length = bodyString.size(); + request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, contentType); + } + else + { + web::http::uri_builder formData; + for (auto& kvp : formParams) + { + formData.append_query(kvp.first, kvp.second); + } + request.set_body(formData.query(), U("application/x-www-form-urlencoded")); + } + } + + web::http::uri_builder builder(path); + for (auto& kvp : queryParams) + { + builder.append_query(kvp.first, kvp.second); + } + request.set_request_uri(builder.to_uri()); + request.set_method(method); + if ( !request.headers().has( web::http::header_names::user_agent ) ) + { + request.headers().add( web::http::header_names::user_agent, m_Configuration->getUserAgent() ); + } + + return client.request(request); +} + +{{#apiNamespaceDeclarations}} +} +{{/apiNamespaceDeclarations}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/apiconfiguration-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/apiconfiguration-header.mustache new file mode 100644 index 00000000000..0463650572b --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/apiconfiguration-header.mustache @@ -0,0 +1,51 @@ +/* + * ApiConfiguration.h + * + * This class represents a single item of a multipart-formdata request. + */ + +#ifndef ApiConfiguration_H_ +#define ApiConfiguration_H_ + +{{{defaultInclude}}} + +#include + +#include +#include +{{#apiNamespaceDeclarations}} +namespace {{this}} { +{{/apiNamespaceDeclarations}} + +class {{declspec}} ApiConfiguration +{ +public: + ApiConfiguration(); + virtual ~ApiConfiguration(); + + web::http::client::http_client_config& getHttpConfig(); + void setHttpConfig( web::http::client::http_client_config& value ); + + utility::string_t getBaseUrl() const; + void setBaseUrl( const utility::string_t value ); + + utility::string_t getUserAgent() const; + void setUserAgent( const utility::string_t value ); + + std::map& getDefaultHeaders(); + + utility::string_t getApiKey( const utility::string_t& prefix) const; + void setApiKey( const utility::string_t& prefix, const utility::string_t& apiKey ); + +protected: + utility::string_t m_BaseUrl; + std::map m_DefaultHeaders; + std::map m_ApiKeys; + web::http::client::http_client_config m_HttpConfig; + utility::string_t m_UserAgent; +}; + +{{#apiNamespaceDeclarations}} +} +{{/apiNamespaceDeclarations}} +#endif /* ApiConfiguration_H_ */ \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/apiconfiguration-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/apiconfiguration-source.mustache new file mode 100644 index 00000000000..7585bc10924 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/apiconfiguration-source.mustache @@ -0,0 +1,67 @@ +#include "ApiConfiguration.h" + +{{#apiNamespaceDeclarations}} +namespace {{this}} { +{{/apiNamespaceDeclarations}} + +ApiConfiguration::ApiConfiguration() +{ +} + +ApiConfiguration::~ApiConfiguration() +{ +} + +web::http::client::http_client_config& ApiConfiguration::getHttpConfig() +{ + return m_HttpConfig; +} + +void ApiConfiguration::setHttpConfig( web::http::client::http_client_config& value ) +{ + m_HttpConfig = value; +} + +utility::string_t ApiConfiguration::getBaseUrl() const +{ + return m_BaseUrl; +} + +void ApiConfiguration::setBaseUrl( const utility::string_t value ) +{ + m_BaseUrl = value; +} + +utility::string_t ApiConfiguration::getUserAgent() const +{ + return m_UserAgent; +} + +void ApiConfiguration::setUserAgent( const utility::string_t value ) +{ + m_UserAgent = value; +} + +std::map& ApiConfiguration::getDefaultHeaders() +{ + return m_DefaultHeaders; +} + +utility::string_t ApiConfiguration::getApiKey( const utility::string_t& prefix) const +{ + auto result = m_ApiKeys.find(prefix); + if( result != m_ApiKeys.end() ) + { + return result->second; + } + return U(""); +} + +void ApiConfiguration::setApiKey( const utility::string_t& prefix, const utility::string_t& apiKey ) +{ + m_ApiKeys[prefix] = apiKey; +} + +{{#apiNamespaceDeclarations}} +} +{{/apiNamespaceDeclarations}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/apiexception-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/apiexception-header.mustache new file mode 100644 index 00000000000..94a46402858 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/apiexception-header.mustache @@ -0,0 +1,48 @@ +/* + * ApiException.h + * + * This is the exception being thrown in case the api call was not successful + */ + +#ifndef ApiException_H_ +#define ApiException_H_ + +{{{defaultInclude}}} + +#include +#include + +#include +#include + + +{{#apiNamespaceDeclarations}} +namespace {{this}} { +{{/apiNamespaceDeclarations}} + +class {{declspec}} ApiException + : public web::http::http_exception +{ +public: + ApiException( int errorCode + , const utility::string_t& message + , std::shared_ptr content = nullptr ); + ApiException( int errorCode + , const utility::string_t& message + , std::map& headers + , std::shared_ptr content = nullptr ); + virtual ~ApiException(); + + std::map& getHeaders(); + std::shared_ptr getContent() const; + +protected: + std::shared_ptr m_Content; + std::map m_Headers; +}; + +{{#apiNamespaceDeclarations}} +} +{{/apiNamespaceDeclarations}} + +#endif /* ApiBase_H_ */ \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/apiexception-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/apiexception-source.mustache new file mode 100644 index 00000000000..c6276211b61 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/apiexception-source.mustache @@ -0,0 +1,40 @@ +#include "ApiException.h" + +{{#apiNamespaceDeclarations}} +namespace {{this}} { +{{/apiNamespaceDeclarations}} + +ApiException::ApiException( int errorCode + , const utility::string_t& message + , std::shared_ptr content /*= nullptr*/ ) + : web::http::http_exception( errorCode, message ) + , m_Content(content) +{ +} +ApiException::ApiException( int errorCode + , const utility::string_t& message + , std::map& headers + , std::shared_ptr content /*= nullptr*/ ) + : web::http::http_exception( errorCode, message ) + , m_Content(content) + , m_Headers(headers) +{ +} + +ApiException::~ApiException() +{ +} + +std::shared_ptr ApiException::getContent() const +{ + return m_Content; +} + +std::map& ApiException::getHeaders() +{ + return m_Headers; +} + +{{#apiNamespaceDeclarations}} +} +{{/apiNamespaceDeclarations}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/cpprest/git_push.sh.mustache new file mode 100644 index 00000000000..2619d82f14d --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/git_push.sh.mustache @@ -0,0 +1,51 @@ +#!/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-cpprest "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/cpprest/gitignore.mustache b/modules/swagger-codegen/src/main/resources/cpprest/gitignore.mustache new file mode 100644 index 00000000000..4581ef2eeef --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/gitignore.mustache @@ -0,0 +1,29 @@ +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app diff --git a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache new file mode 100644 index 00000000000..93130031118 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache @@ -0,0 +1,56 @@ +/* + * HttpContent.h + * + * This class represents a single item of a multipart-formdata request. + */ + +#ifndef HttpContent_H_ +#define HttpContent_H_ + +{{{defaultInclude}}} + +#include + +#include + +{{#modelNamespaceDeclarations}} +namespace {{this}} { +{{/modelNamespaceDeclarations}} + +class {{declspec}} HttpContent +{ +public: + HttpContent(); + virtual ~HttpContent(); + + virtual utility::string_t getContentDisposition(); + virtual void setContentDisposition( const utility::string_t& value ); + + virtual utility::string_t getName(); + virtual void setName( const utility::string_t& value ); + + virtual utility::string_t getFileName(); + virtual void setFileName( const utility::string_t& value ); + + virtual utility::string_t getContentType(); + virtual void setContentType( const utility::string_t& value ); + + virtual std::shared_ptr getData(); + virtual void setData( std::shared_ptr value ); + + virtual void writeTo( std::ostream& stream ); + +protected: + // NOTE: no utility::string_t here because those strings can only contain ascii + utility::string_t m_ContentDisposition; + utility::string_t m_Name; + utility::string_t m_FileName; + utility::string_t m_ContentType; + std::shared_ptr m_Data; +}; + +{{#modelNamespaceDeclarations}} +} +{{/modelNamespaceDeclarations}} + +#endif /* HttpContent_H_ */ \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache new file mode 100644 index 00000000000..c6d9c6da608 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache @@ -0,0 +1,73 @@ +#include "HttpContent.h" + +{{#modelNamespaceDeclarations}} +namespace {{this}} { +{{/modelNamespaceDeclarations}} + +HttpContent::HttpContent() +{ +} + +HttpContent::~HttpContent() +{ +} + +utility::string_t HttpContent::getContentDisposition() +{ + return m_ContentDisposition; +} + +void HttpContent::setContentDisposition( const utility::string_t & value ) +{ + m_ContentDisposition = value; +} + +utility::string_t HttpContent::getName() +{ + return m_Name; +} + +void HttpContent::setName( const utility::string_t & value ) +{ + m_Name = value; +} + +utility::string_t HttpContent::getFileName() +{ + return m_FileName; +} + +void HttpContent::setFileName( const utility::string_t & value ) +{ + m_FileName = value; +} + +utility::string_t HttpContent::getContentType() +{ + return m_ContentType; +} + +void HttpContent::setContentType( const utility::string_t & value ) +{ + m_ContentType = value; +} + +std::shared_ptr HttpContent::getData() +{ + return m_Data; +} + +void HttpContent::setData( std::shared_ptr value ) +{ + m_Data = value; +} + +void HttpContent::writeTo( std::ostream& stream ) +{ + m_Data->seekg( 0, m_Data->beg ); + stream << m_Data->rdbuf(); +} + +{{#modelNamespaceDeclarations}} +} +{{/modelNamespaceDeclarations}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/ihttpbody-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/ihttpbody-header.mustache new file mode 100644 index 00000000000..50ccf4a4d63 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/ihttpbody-header.mustache @@ -0,0 +1,29 @@ +/* + * IHttpBody.h + * + * This is the interface for contents that can be sent to a remote HTTP server. + */ + +#ifndef IHttpBody_H_ +#define IHttpBody_H_ + +{{{defaultInclude}}} +#include + +{{#modelNamespaceDeclarations}} +namespace {{this}} { +{{/modelNamespaceDeclarations}} + +class {{declspec}} IHttpBody +{ +public: + virtual ~IHttpBody() { } + + virtual void writeTo( std::ostream& stream ) = 0; +}; + +{{#modelNamespaceDeclarations}} +} +{{/modelNamespaceDeclarations}} + +#endif /* IHttpBody_H_ */ \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/jsonbody-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/jsonbody-header.mustache new file mode 100644 index 00000000000..3dfcba1458e --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/jsonbody-header.mustache @@ -0,0 +1,36 @@ +/* + * JsonBody.h + * + * This is a JSON http body which can be submitted via http + */ + +#ifndef JsonBody_H_ +#define JsonBody_H_ + +{{{defaultInclude}}} +#include "IHttpBody.h" + +#include + +{{#modelNamespaceDeclarations}} +namespace {{this}} { +{{/modelNamespaceDeclarations}} + +class {{declspec}} JsonBody + : public IHttpBody +{ +public: + JsonBody( const web::json::value& value ); + virtual ~JsonBody(); + + void writeTo( std::ostream& target ) override; + +protected: + web::json::value m_Json; +}; + +{{#modelNamespaceDeclarations}} +} +{{/modelNamespaceDeclarations}} + +#endif /* JsonBody_H_ */ \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/jsonbody-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/jsonbody-source.mustache new file mode 100644 index 00000000000..c787471e5d4 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/jsonbody-source.mustache @@ -0,0 +1,23 @@ +#include "JsonBody.h" + +{{#modelNamespaceDeclarations}} +namespace {{this}} { +{{/modelNamespaceDeclarations}} + +JsonBody::JsonBody( const web::json::value& json) + : m_Json(json) +{ +} + +JsonBody::~JsonBody() +{ +} + +void JsonBody::writeTo( std::ostream& target ) +{ + m_Json.serialize(target); +} + +{{#modelNamespaceDeclarations}} +} +{{/modelNamespaceDeclarations}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/model-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/model-header.mustache new file mode 100644 index 00000000000..615a00f57e2 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/model-header.mustache @@ -0,0 +1,69 @@ +{{#models}}{{#model}}/* + * {{classname}}.h + * + * {{description}} + */ + +#ifndef {{classname}}_H_ +#define {{classname}}_H_ + +{{{defaultInclude}}} +#include "ModelBase.h" + +{{#imports}}{{{this}}} +{{/imports}} + +{{#modelNamespaceDeclarations}} +namespace {{this}} { +{{/modelNamespaceDeclarations}} + +/// +/// {{description}} +/// +class {{declspec}} {{classname}} + : public ModelBase +{ +public: + {{classname}}(); + virtual ~{{classname}}(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + void fromJson(web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// {{classname}} members + + {{#vars}} + /// + /// {{description}} + /// + {{^isNotContainer}}{{{datatype}}}& {{getter}}(); + {{/isNotContainer}}{{#isNotContainer}}{{{datatype}}} {{getter}}() const; + void {{setter}}({{{datatype}}} value); + {{/isNotContainer}}{{^required}}bool {{baseName}}IsSet() const; + void unset{{name}}(); + {{/required}} + {{/vars}} + +protected: + {{#vars}}{{{datatype}}} m_{{name}}; + {{^required}}bool m_{{name}}IsSet; + {{/required}} + {{/vars}} +}; + +{{#modelNamespaceDeclarations}} +} +{{/modelNamespaceDeclarations}} + +#endif /* {{classname}}_H_ */ +{{/model}} +{{/models}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/model-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/model-source.mustache new file mode 100644 index 00000000000..c784bb4eb47 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/model-source.mustache @@ -0,0 +1,254 @@ +{{#models}}{{#model}} + +#include "{{classname}}.h" + +{{#modelNamespaceDeclarations}} +namespace {{this}} { +{{/modelNamespaceDeclarations}} + +{{classname}}::{{classname}}() +{ + {{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}m_{{name}} = {{{defaultValue}}}; + {{/isPrimitiveType}}{{^isPrimitiveType}}{{#isString}}m_{{name}} = {{{defaultValue}}}; + {{/isString}}{{#isDateTime}}m_{{name}} = {{{defaultValue}}}; + {{/isDateTime}}{{/isPrimitiveType}}{{/isNotContainer}}{{^required}}m_{{name}}IsSet = false; + {{/required}}{{/vars}} +} + +{{classname}}::~{{classname}}() +{ +} + +void {{classname}}::validate() +{ + // TODO: implement validation +} + +web::json::value {{classname}}::toJson() const +{ + web::json::value val = web::json::value::object(); + + {{#vars}}{{#isPrimitiveType}}{{^required}}if(m_{{name}}IsSet) + { + val[U("{{baseName}}")] = ModelBase::toJson(m_{{name}}); + } + {{/required}}{{#required}}val[U("{{baseName}}")] = ModelBase::toJson(m_{{name}}); + {{/required}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isListContainer}}{ + std::vector jsonArray; + for( auto& item : m_{{name}} ) + { + jsonArray.push_back(ModelBase::toJson(item)); + } + {{#required}}val[U("{{baseName}}")] = web::json::value::array(jsonArray); + {{/required}}{{^required}} + if(jsonArray.size() > 0) + { + val[U("{{baseName}}")] = web::json::value::array(jsonArray); + } + {{/required}} + } + {{/isListContainer}}{{^isListContainer}}{{^required}}if(m_{{name}}IsSet) + { + val[U("{{baseName}}")] = ModelBase::toJson(m_{{name}}); + } + {{/required}}{{#required}}val[U("{{baseName}}")] = ModelBase::toJson(m_{{name}}); + {{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{/vars}} + + return val; +} + +void {{classname}}::fromJson(web::json::value& val) +{ + {{#vars}}{{#isPrimitiveType}}{{^required}}if(val.has_field(U("{{baseName}}"))) + { + {{setter}}(ModelBase::{{baseType}}FromJson(val[U("{{baseName}}")])); + } + {{/required}}{{#required}}{{setter}}(ModelBase::{{baseType}}FromJson(val[U("{{baseName}}")])); + {{/required}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isListContainer}}{ + m_{{name}}.clear(); + std::vector jsonArray; + {{^required}}if(val.has_field(U("{{baseName}}"))) + { + {{/required}} + for( auto& item : val[U("{{baseName}}")].as_array() ) + { + {{#items.isPrimitiveType}}m_{{name}}.push_back(ModelBase::{{baseType}}FromJson(item)); + {{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}m_{{name}}.push_back(ModelBase::stringFromJson(item)); + {{/items.isString}}{{^items.isString}}{{#items.isDateTime}}m_{{name}}.push_back(ModelBase::dateFromJson(item)); + {{/items.isDateTime}}{{^items.isDateTime}} + if(item.is_null()) + { + m_{{name}}.push_back( {{{items.datatype}}}(nullptr) ); + } + else + { + {{{items.datatype}}} newItem({{{items.defaultValue}}}); + newItem->fromJson(item); + m_{{name}}.push_back( newItem ); + } + {{/items.isDateTime}}{{/items.isString}}{{/items.isPrimitiveType}} + } + {{^required}} + } + {{/required}} + } + {{/isListContainer}}{{^isListContainer}}{{^required}}if(val.has_field(U("{{baseName}}"))) + { + {{#isString}}{{setter}}(ModelBase::stringFromJson(val[U("{{baseName}}")])); + {{/isString}}{{^isString}}{{#isDateTime}}{{setter}}(ModelBase::dateFromJson(val[U("{{baseName}}")])); + {{/isDateTime}}{{^isDateTime}}if(!val[U("{{baseName}}")].is_null()) + { + {{{datatype}}} newItem({{{defaultValue}}}); + newItem->fromJson(val[U("{{baseName}}")]); + {{setter}}( newItem ); + } + {{/isDateTime}}{{/isString}} + } + {{/required}}{{#required}}{{#isString}}{{setter}}(ModelBase::stringFromJson(val[U("{{baseName}}")])); + {{/isString}}{{^isString}}{{#isDateTime}}{{setter}}(ModelBase::dateFromJson(val[U("{{baseName}}")])); + {{/isDateTime}}{{^isDateTime}}{{#vendorExtensions.x-codegen-file}}{{setter}}(ModelBase::fileFromJson(val[U("{{baseName}}")])); + {{/vendorExtensions.x-codegen-file}}{{^vendorExtensions.x-codegen-file}}{{{datatype}}} new{{name}}({{{defaultValue}}}); + new{{name}}->fromJson(val[U("{{baseName}}")]); + {{setter}}( newItem ); + {{/vendorExtensions.x-codegen-file}}{{/isDateTime}}{{/isString}}{{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{/vars}} +} + +void {{classname}}::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + {{#vars}}{{#isPrimitiveType}}{{^required}}if(m_{{name}}IsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); + } + {{/required}}{{#required}}multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); + {{/required}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isListContainer}}{ + std::vector jsonArray; + for( auto& item : m_{{name}} ) + { + jsonArray.push_back(ModelBase::toJson(item)); + } + {{#required}}multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), web::json::value::array(jsonArray), U("application/json"))); + {{/required}}{{^required}} + if(jsonArray.size() > 0) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), web::json::value::array(jsonArray), U("application/json"))); + } + {{/required}} + } + {{/isListContainer}}{{^isListContainer}}{{^required}}if(m_{{name}}IsSet) + { + {{#isString}}multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); + {{/isString}}{{^isString}}{{#isDateTime}}multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); + {{/isDateTime}}{{^isDateTime}}if (m_{{name}}.get()) + { + m_{{name}}->toMultipart(multipart, U("{{baseName}}.")); + } + {{/isDateTime}}{{/isString}} + } + {{/required}}{{#required}}{{#isString}}multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); + {{/isString}}{{^isString}}{{#isDateTime}}multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); + {{/isDateTime}}{{^isDateTime}}{{#vendorExtensions.x-codegen-file}}multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); + {{/vendorExtensions.x-codegen-file}}{{^vendorExtensions.x-codegen-file}}m_{{name}}->toMultipart(multipart, U("{{baseName}}.")); + {{/vendorExtensions.x-codegen-file}}{{/isDateTime}}{{/isString}}{{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{/vars}} +} + +void {{classname}}::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + {{#vars}}{{#isPrimitiveType}}{{^required}}if(multipart->hasContent(U("{{baseName}}"))) + { + {{setter}}(ModelBase::{{baseType}}FromHttpContent(multipart->getContent(U("{{baseName}}")))); + } + {{/required}}{{#required}}{{setter}}(ModelBase::{{baseType}}FromHttpContent(multipart->getContent(U("{{baseName}}")))); + {{/required}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isListContainer}}{ + m_{{name}}.clear(); + {{^required}}if(multipart->hasContent(U("{{baseName}}"))) + { + {{/required}} + + web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(U("{{baseName}}")))); + for( auto& item : jsonArray.as_array() ) + { + {{#items.isPrimitiveType}}m_{{name}}.push_back(ModelBase::{{baseType}}FromJson(item)); + {{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}m_{{name}}.push_back(ModelBase::stringFromJson(item)); + {{/items.isString}}{{^items.isString}}{{#items.isDateTime}}m_{{name}}.push_back(ModelBase::dateFromJson(item)); + {{/items.isDateTime}}{{^items.isDateTime}} + if(item.is_null()) + { + m_{{name}}.push_back( {{{items.datatype}}}(nullptr) ); + } + else + { + {{{items.datatype}}} newItem({{{items.defaultValue}}}); + newItem->fromJson(item); + m_{{name}}.push_back( newItem ); + } + {{/items.isDateTime}}{{/items.isString}}{{/items.isPrimitiveType}} + } + {{^required}} + } + {{/required}} + } + {{/isListContainer}}{{^isListContainer}}{{^required}}if(multipart->hasContent(U("{{baseName}}"))) + { + {{#isString}}{{setter}}(ModelBase::stringFromHttpContent(multipart->getContent(U("{{baseName}}")))); + {{/isString}}{{^isString}}{{#isDateTime}}{{setter}}(ModelBase::dateFromHttpContent(multipart->getContent(U("{{baseName}}")))); + {{/isDateTime}}{{^isDateTime}}if(multipart->hasContent(U("{{baseName}}"))) + { + {{{datatype}}} newItem({{{defaultValue}}}); + newItem->fromMultiPart(multipart, U("{{baseName}}.")); + {{setter}}( newItem ); + } + {{/isDateTime}}{{/isString}} + } + {{/required}}{{#required}}{{#isString}}{{setter}}(ModelBase::stringFromHttpContent(multipart->getContent(U("{{baseName}}")))); + {{/isString}}{{^isString}}{{#isDateTime}}{{setter}}(ModelBase::dateFromHttpContent(multipart->getContent(U("{{baseName}}")))); + {{/isDateTime}}{{^isDateTime}}{{#vendorExtensions.x-codegen-file}}{{setter}}(multipart->getContent(U("{{baseName}}"))); + {{/vendorExtensions.x-codegen-file}}{{^vendorExtensions.x-codegen-file}}{{{datatype}}} new{{name}}({{{defaultValue}}}); + new{{name}}->fromMultiPart(multipart, U("{{baseName}}.")); + {{setter}}( new{{name}} ); + {{/vendorExtensions.x-codegen-file}}{{/isDateTime}}{{/isString}}{{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{/vars}} +} + + +{{#vars}}{{^isNotContainer}}{{{datatype}}}& {{classname}}::{{getter}}() +{ + return m_{{name}}; +} +{{/isNotContainer}}{{#isNotContainer}}{{{datatype}}} {{classname}}::{{getter}}() const +{ + return m_{{name}}; +} +void {{classname}}::{{setter}}({{{datatype}}} value) +{ + m_{{name}} = value; + {{^required}}m_{{name}}IsSet = true;{{/required}} +} +{{/isNotContainer}} +{{^required}}bool {{classname}}::{{baseName}}IsSet() const +{ + return m_{{name}}IsSet; +} +void {{classname}}::unset{{name}}() +{ + m_{{name}}IsSet = false; +} +{{/required}} +{{/vars}} + +{{#modelNamespaceDeclarations}} +} +{{/modelNamespaceDeclarations}} + +{{/model}} +{{/models}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache new file mode 100644 index 00000000000..9505286ec97 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache @@ -0,0 +1,76 @@ +/* + * ModelBase.h + * + * This is the base class for all model classes + */ + +#ifndef ModelBase_H_ +#define ModelBase_H_ + +{{{defaultInclude}}} +#include "HttpContent.h" +#include "MultipartFormData.h" + +#include +#include + +{{#modelNamespaceDeclarations}} +namespace {{this}} { +{{/modelNamespaceDeclarations}} + +class {{declspec}} ModelBase +{ +public: + ModelBase(); + virtual ~ModelBase(); + + virtual void validate() = 0; + + virtual web::json::value toJson() const = 0; + virtual void fromJson(web::json::value& json) = 0; + + virtual void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const = 0; + virtual void fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) = 0; + + static web::json::value toJson( const utility::string_t& value ); + static web::json::value toJson( const utility::datetime& value ); + static web::json::value toJson( std::shared_ptr value ); + static web::json::value toJson( std::shared_ptr value ); + static web::json::value toJson( int32_t value ); + static web::json::value toJson( int64_t value ); + static web::json::value toJson( double value ); + + static int64_t int64_tFromJson(web::json::value& val); + static int32_t int32_tFromJson(web::json::value& val); + static utility::string_t stringFromJson(web::json::value& val); + static utility::datetime dateFromJson(web::json::value& val); + static double doubleFromJson(web::json::value& val); + static bool boolFromJson(web::json::value& val); + static std::shared_ptr fileFromJson(web::json::value& val); + + static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = U("")); + static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = U("")); + static std::shared_ptr toHttpContent( const utility::string_t& name, std::shared_ptr value ); + static std::shared_ptr toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType = U("application/json") ); + static std::shared_ptr toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType = U("") ); + static std::shared_ptr toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType = U("") ); + static std::shared_ptr toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType = U("") ); + + static int64_t int64_tFromHttpContent(std::shared_ptr val); + static int32_t int32_tFromHttpContent(std::shared_ptr val); + static utility::string_t stringFromHttpContent(std::shared_ptr val); + static utility::datetime dateFromHttpContent(std::shared_ptr val); + static bool boolFromHttpContent(std::shared_ptr val); + static double doubleFromHttpContent(std::shared_ptr val); + + + static utility::string_t toBase64( utility::string_t value ); + static utility::string_t toBase64( std::shared_ptr value ); + static std::shared_ptr fromBase64( const utility::string_t& encoded ); +}; + +{{#modelNamespaceDeclarations}} +} +{{/modelNamespaceDeclarations}} + +#endif /* ModelBase_H_ */ \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache new file mode 100644 index 00000000000..dce2c3eb3b4 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache @@ -0,0 +1,337 @@ +#include "ModelBase.h" + +{{#modelNamespaceDeclarations}} +namespace {{this}} { +{{/modelNamespaceDeclarations}} + +ModelBase::ModelBase() +{ +} +ModelBase::~ModelBase() +{ +} + +web::json::value ModelBase::toJson( const utility::string_t& value ) +{ + return web::json::value::string(value); +} +web::json::value ModelBase::toJson( const utility::datetime& value ) +{ + return web::json::value::string(value.to_string(utility::datetime::ISO_8601)); +} +web::json::value ModelBase::toJson( int32_t value ) +{ + return web::json::value::number(value); +} +web::json::value ModelBase::toJson( int64_t value ) +{ + return web::json::value::number(value); +} +web::json::value ModelBase::toJson( double value ) +{ + return web::json::value::number(value); +} + +web::json::value ModelBase::toJson( std::shared_ptr content ) +{ + web::json::value value; + value[U("ContentDisposition")] = ModelBase::toJson(content->getContentDisposition()); + value[U("ContentType")] = ModelBase::toJson(content->getContentType()); + value[U("FileName")] = ModelBase::toJson(content->getFileName()); + value[U("InputStream")] = web::json::value::string( ModelBase::toBase64(content->getData()) ); + return value; +} + +std::shared_ptr ModelBase::fileFromJson(web::json::value& val) +{ + std::shared_ptr content(new HttpContent); + + if(val.has_field(U("ContentDisposition"))) + { + content->setContentDisposition( ModelBase::stringFromJson(val[U("ContentDisposition")]) ); + } + if(val.has_field(U("ContentType"))) + { + content->setContentType( ModelBase::stringFromJson(val[U("ContentType")]) ); + } + if(val.has_field(U("FileName"))) + { + content->setFileName( ModelBase::stringFromJson(val[U("FileName")]) ); + } + if(val.has_field(U("InputStream"))) + { + content->setData( ModelBase::fromBase64( ModelBase::stringFromJson(val[U("InputStream")]) ) ); + } + + return content; +} + +web::json::value ModelBase::toJson( std::shared_ptr content ) +{ + return content.get() ? content->toJson() : web::json::value::null(); +} + +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType) +{ + std::shared_ptr content(new HttpContent); + content->setName( name ); + content->setContentDisposition( U("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(value) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( U("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(value.to_string(utility::datetime::ISO_8601) ) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, std::shared_ptr value ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( value->getContentDisposition() ); + content->setContentType( value->getContentType() ); + content->setData( value->getData() ); + content->setFileName( value->getFileName() ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( U("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(value.serialize()) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( U("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( std::to_string( value ) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( U("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( std::to_string( value ) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( U("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( std::to_string( value ) ) ) ); + return content; +} + +// base64 encoding/decoding based on : https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#C.2B.2B +const static char Base64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +const static char Base64PadChar = '='; +utility::string_t ModelBase::toBase64( utility::string_t value ) +{ + std::shared_ptr source( new std::stringstream( utility::conversions::to_utf8string(value) ) ); + return ModelBase::toBase64(source); +} +utility::string_t ModelBase::toBase64( std::shared_ptr value ) +{ + value->seekg( 0, value->end ); + size_t length = value->tellg(); + value->seekg( 0, value->beg ); + utility::string_t base64; + base64.reserve( ((length / 3) + (length % 3 > 0)) * 4 ); + char read[3] = { 0 }; + uint32_t temp; + for ( size_t idx = 0; idx < length / 3; idx++ ) + { + value->read( read, 3 ); + temp = (read[0]) << 16; + temp += (read[1]) << 8; + temp += (read[2]); + base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); + base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); + base64.append( 1, Base64Chars[(temp & 0x00000FC0) >> 6] ); + base64.append( 1, Base64Chars[(temp & 0x0000003F)] ); + } + switch ( length % 3 ) + { + case 1: + value->read( read, 1 ); + temp = read[0] << 16; + base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); + base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); + base64.append( 2, Base64PadChar ); + break; + case 2: + value->read( read, 2 ); + temp = read[0] << 16; + temp += read[1] << 8; + base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); + base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); + base64.append( 1, Base64Chars[(temp & 0x00000FC0) >> 6] ); + base64.append( 1, Base64PadChar ); + break; + } + return base64; +} + + +std::shared_ptr ModelBase::fromBase64( const utility::string_t& encoded ) +{ + std::shared_ptr result(new std::stringstream); + + char outBuf[3] = { 0 }; + uint32_t temp = 0; + + utility::string_t::const_iterator cursor = encoded.begin(); + while ( cursor < encoded.end() ) + { + for ( size_t quantumPosition = 0; quantumPosition < 4; quantumPosition++ ) + { + temp <<= 6; + if ( *cursor >= 0x41 && *cursor <= 0x5A ) + { + temp |= *cursor - 0x41; + } + else if ( *cursor >= 0x61 && *cursor <= 0x7A ) + { + temp |= *cursor - 0x47; + } + else if ( *cursor >= 0x30 && *cursor <= 0x39 ) + { + temp |= *cursor + 0x04; + } + else if ( *cursor == 0x2B ) + { + temp |= 0x3E; //change to 0x2D for URL alphabet + } + else if ( *cursor == 0x2F ) + { + temp |= 0x3F; //change to 0x5F for URL alphabet + } + else if ( *cursor == Base64PadChar ) //pad + { + switch ( encoded.end() - cursor ) + { + case 1: //One pad character + outBuf[0] = (temp >> 16) & 0x000000FF; + outBuf[1] = (temp >> 8) & 0x000000FF; + result->write( outBuf, 2 ); + return result; + case 2: //Two pad characters + outBuf[0] = (temp >> 10) & 0x000000FF; + result->write( outBuf, 1 ); + return result; + default: + throw web::json::json_exception( U( "Invalid Padding in Base 64!" ) ); + } + } + else + { + throw web::json::json_exception( U( "Non-Valid Character in Base 64!" ) ); + } + ++cursor; + } + + outBuf[0] = (temp >> 16) & 0x000000FF; + outBuf[1] = (temp >> 8) & 0x000000FF; + outBuf[2] = (temp) & 0x000000FF; + result->write( outBuf, 3 ); + } + + return result; +} + +int64_t ModelBase::int64_tFromJson(web::json::value& val) +{ + return val.as_number().to_int64(); +} +int32_t ModelBase::int32_tFromJson(web::json::value& val) +{ + return val.as_integer(); +} +utility::string_t ModelBase::stringFromJson(web::json::value& val) +{ + return val.is_string() ? val.as_string() : U(""); +} + +utility::datetime ModelBase::dateFromJson(web::json::value& val) +{ + return utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601); +} +bool ModelBase::boolFromJson(web::json::value& val) +{ + return val.as_bool(); +} +double ModelBase::doubleFromJson(web::json::value& val) +{ + return val.as_double(); +} + +int64_t ModelBase::int64_tFromHttpContent(std::shared_ptr val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); + + utility::stringstream_t ss(str); + int64_t result = 0; + ss >> result; + return result; +} +int32_t ModelBase::int32_tFromHttpContent(std::shared_ptr val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); + + utility::stringstream_t ss(str); + int32_t result = 0; + ss >> result; + return result; +} +utility::string_t ModelBase::stringFromHttpContent(std::shared_ptr val) +{ + std::shared_ptr data = val->getData(); + data->seekg( 0, data->beg ); + + std::string str((std::istreambuf_iterator(*data.get())), + std::istreambuf_iterator()); + + return utility::conversions::to_utf16string(str); +} +utility::datetime ModelBase::dateFromHttpContent(std::shared_ptr val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); + return utility::datetime::from_string(str, utility::datetime::ISO_8601); +} + +bool ModelBase::boolFromHttpContent(std::shared_ptr val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); + + utility::stringstream_t ss(str); + bool result = false; + ss >> result; + return result; +} +double ModelBase::doubleFromHttpContent(std::shared_ptr val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); + + utility::stringstream_t ss(str); + double result = 0.0; + ss >> result; + return result; +} + +{{#modelNamespaceDeclarations}} +} +{{/modelNamespaceDeclarations}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/multipart-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/multipart-header.mustache new file mode 100644 index 00000000000..f6e1b774379 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/multipart-header.mustache @@ -0,0 +1,49 @@ +/* + * MultipartFormData.h + * + * This class represents a container for building a application/x-multipart-formdata requests. + */ + +#ifndef MultipartFormData_H_ +#define MultipartFormData_H_ + +{{{defaultInclude}}} +#include "IHttpBody.h" +#include "HttpContent.h" + +#include +#include +#include + +#include + + +{{#modelNamespaceDeclarations}} +namespace {{this}} { +{{/modelNamespaceDeclarations}} + +class {{declspec}} MultipartFormData + : public IHttpBody +{ +public: + MultipartFormData(); + MultipartFormData(const utility::string_t& boundary); + virtual ~MultipartFormData(); + + virtual void add( std::shared_ptr content ); + virtual utility::string_t getBoundary(); + virtual std::shared_ptr getContent(const utility::string_t& name) const; + virtual bool hasContent(const utility::string_t& name) const; + virtual void writeTo( std::ostream& target ); + +protected: + std::vector> m_Contents; + utility::string_t m_Boundary; + std::map> m_ContentLookup; +}; + +{{#modelNamespaceDeclarations}} +} +{{/modelNamespaceDeclarations}} + +#endif /* MultipartFormData_H_ */ \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/cpprest/multipart-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/multipart-source.mustache new file mode 100644 index 00000000000..64b59113050 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/cpprest/multipart-source.mustache @@ -0,0 +1,99 @@ +#include "MultipartFormData.h" +#include "ModelBase.h" + +#include +#include + +{{#modelNamespaceDeclarations}} +namespace {{this}} { +{{/modelNamespaceDeclarations}} + +MultipartFormData::MultipartFormData() +{ + utility::stringstream_t uuidString; + uuidString << boost::uuids::random_generator()(); + m_Boundary = uuidString.str(); +} + +MultipartFormData::MultipartFormData(const utility::string_t& boundary) + : m_Boundary(boundary) +{ + +} + +MultipartFormData::~MultipartFormData() +{ +} + +utility::string_t MultipartFormData::getBoundary() +{ + return m_Boundary; +} + +void MultipartFormData::add( std::shared_ptr content ) +{ + m_Contents.push_back( content ); + m_ContentLookup[content->getName()] = content; +} + +bool MultipartFormData::hasContent(const utility::string_t& name) const +{ + return m_ContentLookup.find(name) != m_ContentLookup.end(); +} + +std::shared_ptr MultipartFormData::getContent(const utility::string_t& name) const +{ + auto result = m_ContentLookup.find(name); + if(result == m_ContentLookup.end()) + { + return std::shared_ptr(nullptr); + } + return result->second; +} + +void MultipartFormData::writeTo( std::ostream& target ) +{ + for ( size_t i = 0; i < m_Contents.size(); i++ ) + { + std::shared_ptr content = m_Contents[i]; + + // boundary + target << "\r\n" << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n"; + + // headers + target << "Content-Disposition: " << utility::conversions::to_utf8string( content->getContentDisposition() ); + if ( content->getName().size() > 0 ) + { + target << "; name=\"" << utility::conversions::to_utf8string( content->getName() ) << "\""; + } + if ( content->getFileName().size() > 0 ) + { + target << "; filename=\"" << utility::conversions::to_utf8string( content->getFileName() ) << "\""; + } + target << "\r\n"; + + if ( content->getContentType().size() > 0 ) + { + target << "Content-Type: " << utility::conversions::to_utf8string( content->getContentType() ) << "\r\n"; + } + + target << "\r\n"; + + // body + std::shared_ptr data = content->getData(); + + data->seekg( 0, data->end ); + std::vector dataBytes( data->tellg() ); + + data->seekg( 0, data->beg ); + data->read( &dataBytes[0], dataBytes.size() ); + + std::copy( dataBytes.begin(), dataBytes.end(), std::ostreambuf_iterator( target ) ); + } + + target << "\r\n--" << utility::conversions::to_utf8string( m_Boundary ) << "--\r\n"; +} + +{{#modelNamespaceDeclarations}} +} +{{/modelNamespaceDeclarations}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/go-server/README.mustache b/modules/swagger-codegen/src/main/resources/go-server/README.mustache new file mode 100644 index 00000000000..8b66fe30f46 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go-server/README.mustache @@ -0,0 +1,30 @@ +# Go API Server for {{packageName}} + +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +## Overview +This server was generated by the [swagger-codegen] +(https://github.com/swagger-api/swagger-codegen) project. +By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub. +- + +To see how to make this your own, look here: + +[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md) + +- API version: {{appVersion}} +- Build date: {{generatedDate}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + + +### Running the server +To run the server, follow these simple steps: + +``` +go run main.go +``` + diff --git a/modules/swagger-codegen/src/main/resources/go-server/app.mustache b/modules/swagger-codegen/src/main/resources/go-server/app.mustache new file mode 100644 index 00000000000..18774a8cd31 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go-server/app.mustache @@ -0,0 +1 @@ +application: {{packageName}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/go-server/controller.mustache b/modules/swagger-codegen/src/main/resources/go-server/controller.mustache new file mode 100644 index 00000000000..b8efd5f50e7 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go-server/controller.mustache @@ -0,0 +1,19 @@ +package {{packageName}} + +{{#operations}} +import ( + "net/http" +) + +type {{classname}} struct { + +} + +{{#operation}} +func {{nickname}}(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +{{/operation}} +{{/operations}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/go-server/logger.mustache b/modules/swagger-codegen/src/main/resources/go-server/logger.mustache new file mode 100644 index 00000000000..6ccb2dafe81 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go-server/logger.mustache @@ -0,0 +1,23 @@ +package {{packageName}} + +import ( + "log" + "net/http" + "time" +) + +func Logger(inner http.Handler, name string) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() + + inner.ServeHTTP(w, r) + + log.Printf( + "%s %s %s %s", + r.Method, + r.RequestURI, + name, + time.Since(start), + ) + }) +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/go-server/main.mustache b/modules/swagger-codegen/src/main/resources/go-server/main.mustache new file mode 100644 index 00000000000..17b6072ebfb --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go-server/main.mustache @@ -0,0 +1,22 @@ +package main + +import ( + // WARNING! + // Change this to a fully-qualified import path + // once you place this file into your project. + // For example, + // + // sw "github.com/myname/myrepo/{{apiPath}}" + // + sw "./{{apiPath}}" + "log" + "net/http" +) + +func main() { + log.Printf("Server started") + + router := sw.NewRouter() + + log.Fatal(http.ListenAndServe(":{{serverPort}}", router)) +} diff --git a/modules/swagger-codegen/src/main/resources/go-server/routers.mustache b/modules/swagger-codegen/src/main/resources/go-server/routers.mustache new file mode 100644 index 00000000000..5999268a528 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go-server/routers.mustache @@ -0,0 +1,54 @@ +package {{packageName}} + +import ( + "net/http" + "fmt" + "github.com/gorilla/mux" +) + +type Route struct { + Name string + Method string + Pattern string + HandlerFunc http.HandlerFunc +} + +type Routes []Route + +func NewRouter() *mux.Router { + router := mux.NewRouter().StrictSlash(true) + for _, route := range routes { + var handler http.Handler + handler = route.HandlerFunc + handler = Logger(handler, route.Name) + + router. + Methods(route.Method). + Path(route.Pattern). + Name(route.Name). + Handler(handler) + } + + return router +} + +func Index(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Hello World!") +} + +var routes = Routes{ + Route{ + "Index", + "GET", + "/", + Index, + }, +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}} + Route{ + "{{operationId}}", + "{{httpMethod}}", + "{{path}}", + {{operationId}}, + }, +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/go-server/swagger.mustache b/modules/swagger-codegen/src/main/resources/go-server/swagger.mustache new file mode 100644 index 00000000000..51560926bba --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go-server/swagger.mustache @@ -0,0 +1 @@ +{{{swagger-yaml}}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Http/Middleware/Authenticate.php b/modules/swagger-codegen/src/main/resources/lumen/Authenticate.php similarity index 55% rename from modules/swagger-codegen/src/main/resources/lumen/app/Http/Middleware/Authenticate.php rename to modules/swagger-codegen/src/main/resources/lumen/Authenticate.php index 361a11eecd0..cbf5998f412 100644 --- a/modules/swagger-codegen/src/main/resources/lumen/app/Http/Middleware/Authenticate.php +++ b/modules/swagger-codegen/src/main/resources/lumen/Authenticate.php @@ -1,5 +1,23 @@ licenseInfo}} + +namespace App\Http\Controllers; + +use Illuminate\Support\Facades\Request; + +{{#operations}}class {{classname}} extends Controller +{ + /** + * Constructor + */ + public function __construct() + { + } + + {{#operation}} + /** + * Operation {{{operationId}}} + * + * {{{summary}}}. + * + {{#pathParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + {{/pathParams}} * + * @return Http response + */ + public function {{operationId}}({{#pathParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/pathParams}}) + { + $input = Request::all(); + + //path params validation + {{#pathParams}} + {{#hasValidation}} + {{#maxLength}} + if (strlen(${{paramName}}]) > {{maxLength}}) { + throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.'); + } + {{/maxLength}} + {{#minLength}} + if (strlen(${{paramName}}]) < {{minLength}}) { + throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.'); + } + {{/minLength}} + {{#maximum}} + if (${{paramName}}] > {{maximum}}) { + throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maximum}}.'); + } + {{/maximum}} + {{#minimum}} + if (${{paramName}}] < {{minimum}}) { + throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minimum}}.'); + } + {{/minimum}} + {{#pattern}} + if (!preg_match("{{pattern}}", ${{paramName}}])) { + throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{pattern}}.'); + } + {{/pattern}} + {{/hasValidation}} + {{/pathParams}} + + + //not path params validation + {{#allParams}} + {{^pathParams}} + {{#required}} + if (!isset($input['{{paramName}}'])) { + throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{operationId}}'); + } + {{/required}} + {{#hasValidation}} + {{#maxLength}} + if (strlen($input['{{paramName}}']) > {{maxLength}}) { + throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.'); + } + {{/maxLength}} + {{#minLength}} + if (strlen($input['{{paramName}}']) < {{minLength}}) { + throw new \InvalidArgumentException('invalid length for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.'); + } + {{/minLength}} + {{#maximum}} + if ($input['{{paramName}}'] > {{maximum}}) { + throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maximum}}.'); + } + {{/maximum}} + {{#minimum}} + if ($input['{{paramName}}'] < {{minimum}}) { + throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minimum}}.'); + } + {{/minimum}} + {{#pattern}} + if (!preg_match("{{pattern}}", $input['{{paramName}}'])) { + throw new \InvalidArgumentException('invalid value for ${{paramName}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{pattern}}.'); + } + {{/pattern}} + {{/hasValidation}} + ${{paramName}} = $input['{{paramName}}']; + + {{/pathParams}} + {{/allParams}} + + return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); + } + {{/operation}} +} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/lumen/bootstrap/app.php b/modules/swagger-codegen/src/main/resources/lumen/app.php similarity index 79% rename from modules/swagger-codegen/src/main/resources/lumen/bootstrap/app.php rename to modules/swagger-codegen/src/main/resources/lumen/app.php index 9bc334dd886..2811ed03ef9 100644 --- a/modules/swagger-codegen/src/main/resources/lumen/bootstrap/app.php +++ b/modules/swagger-codegen/src/main/resources/lumen/app.php @@ -1,5 +1,23 @@ withFacades(); +$app->withFacades(); // $app->withEloquent(); @@ -48,8 +66,6 @@ $app->singleton( App\Console\Kernel::class ); -class_alias('Illuminate\Support\Facades\Request', 'Request'); //to use the Reqesut facade - /* |-------------------------------------------------------------------------- | Register Middleware diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Console/Kernel.php b/modules/swagger-codegen/src/main/resources/lumen/app/Console/Kernel.php deleted file mode 100644 index ad6e311cdd0..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/app/Console/Kernel.php +++ /dev/null @@ -1,29 +0,0 @@ -get('/', function () use ($app) { - return $app->version(); -}); - -{{#apis}}{{#operations}}{{#operation}} -/** - * {{httpMethod}} {{nickname}} - * Summary: {{summary}} - * Notes: {{notes}} -{{#hasProduces}} * Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}} - */ -$app->{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}}, {{/pathParams}}$null = null) use ($app) { - {{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}} - {{#hasQueryParams}}{{#queryParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} - {{/queryParams}}{{/hasQueryParams}} - {{#hasFormParams}}{{#formParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} {{/formParams}}{{/hasFormParams}} - - return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); - }); - -{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} - diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Providers/AppServiceProvider.php b/modules/swagger-codegen/src/main/resources/lumen/app/Providers/AppServiceProvider.php deleted file mode 100644 index ddec04694c3..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/app/Providers/AppServiceProvider.php +++ /dev/null @@ -1,18 +0,0 @@ -input('api_token')) { - return User::where('api_token', $request->input('api_token'))->first(); - } - }); - } -} diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Providers/EventServiceProvider.php b/modules/swagger-codegen/src/main/resources/lumen/app/Providers/EventServiceProvider.php deleted file mode 100644 index 0b8f3934fb3..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/app/Providers/EventServiceProvider.php +++ /dev/null @@ -1,19 +0,0 @@ - [ - 'App\Listeners\EventListener', - ], - ]; -} diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/User.php b/modules/swagger-codegen/src/main/resources/lumen/app/User.php deleted file mode 100644 index fd4de31172c..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/app/User.php +++ /dev/null @@ -1,34 +0,0 @@ -=5.5.9", - "laravel/lumen-framework": "5.2.*", - "vlucas/phpdotenv": "~2.2" - }, - "autoload": { - "psr-4": { - "App\\": "app/" - } - } -} diff --git a/modules/swagger-codegen/src/main/resources/lumen/composer.mustache b/modules/swagger-codegen/src/main/resources/lumen/composer.mustache new file mode 100644 index 00000000000..c3ae9fddfbf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/composer.mustache @@ -0,0 +1,31 @@ +{ + "name": "{{#composerVendorName}}{{.}}{{/composerVendorName}}{{^composerVendorName}}{{gitUserId}}{{/composerVendorName}}/{{#composerProjectName}}{{.}}{{/composerProjectName}}{{^composerProjectName}}{{gitRepoId}}{{/composerProjectName}}", + {{#artifactVersion}} + "version": "{{artifactVersion}}", + {{/artifactVersion}} + "description": "{{description}}", + "keywords": [ + "swagger", + "php", + "sdk", + "api" + ], + "homepage": "http://swagger.io", + "license": "Apache v2", + "authors": [ + { + "name": "Swagger and contributors", + "homepage": "https://github.com/swagger-api/swagger-codegen" + } + ], + "require": { + "php": ">=5.5.9", + "laravel/lumen-framework": "5.2.*", + "vlucas/phpdotenv": "~2.2" + }, + "autoload": { + "psr-4": { + "App\\": "app/" + } + } +} diff --git a/samples/server/petstore/lumen/lumen/public/index.php b/modules/swagger-codegen/src/main/resources/lumen/index.php similarity index 55% rename from samples/server/petstore/lumen/lumen/public/index.php rename to modules/swagger-codegen/src/main/resources/lumen/index.php index 04aa08688e0..3fc94132231 100644 --- a/samples/server/petstore/lumen/lumen/public/index.php +++ b/modules/swagger-codegen/src/main/resources/lumen/index.php @@ -1,5 +1,23 @@ - - Options -MultiViews - - - RewriteEngine On - - # Redirect Trailing Slashes If Not A Folder... - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule ^(.*)/$ /$1 [L,R=301] - - # Handle Front Controller... - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^ index.php [L] - diff --git a/modules/swagger-codegen/src/main/resources/lumen/readme.md b/modules/swagger-codegen/src/main/resources/lumen/readme.md index 9605e5f3f45..c146781b7ae 100644 --- a/modules/swagger-codegen/src/main/resources/lumen/readme.md +++ b/modules/swagger-codegen/src/main/resources/lumen/readme.md @@ -1,21 +1,16 @@ -## Lumen PHP Framework +# Swagger generated server -[![Build Status](https://travis-ci.org/laravel/lumen-framework.svg)](https://travis-ci.org/laravel/lumen-framework) -[![Total Downloads](https://poser.pugx.org/laravel/lumen-framework/d/total.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![Latest Stable Version](https://poser.pugx.org/laravel/lumen-framework/v/stable.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![Latest Unstable Version](https://poser.pugx.org/laravel/lumen-framework/v/unstable.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![License](https://poser.pugx.org/laravel/lumen-framework/license.svg)](https://packagist.org/packages/laravel/lumen-framework) +## Overview +This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the +[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This +is an example of building a PHP server. -Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching. +This example uses the [Lumen Framework](http://lumen.laravel.com/). To see how to make this your own, please take a look at the template here: -## Official Documentation +[TEMPLATES](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/slim/) -Documentation for the framework can be found on the [Lumen website](http://lumen.laravel.com/docs). +## Installation & Usage +### Composer -## Security Vulnerabilities +Using `composer install` to install the framework and dependencies via [Composer](http://getcomposer.org/). -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. - -### License - -The Lumen framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) diff --git a/modules/swagger-codegen/src/main/resources/lumen/routes.mustache b/modules/swagger-codegen/src/main/resources/lumen/routes.mustache index 3d91b32c8e4..c5f3bdf858a 100644 --- a/modules/swagger-codegen/src/main/resources/lumen/routes.mustache +++ b/modules/swagger-codegen/src/main/resources/lumen/routes.mustache @@ -1,4 +1,6 @@ licenseInfo}} {{#apiInfo}}/** * {{appName}} * @version {{appVersion}} @@ -8,21 +10,18 @@ $app->get('/', function () use ($app) { return $app->version(); }); -{{#apis}}{{#operations}}{{#operation}} +{{#apis}} +{{#operations}} +{{#operation}} /** * {{httpMethod}} {{nickname}} * Summary: {{summary}} * Notes: {{notes}} {{#hasProduces}} * Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}} */ -Route::{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}}, {{/pathParams}}null) use ($app) { - {{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}} - {{#hasQueryParams}}{{#queryParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} - {{/queryParams}}{{/hasQueryParams}} - {{#hasFormParams}}{{#formParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} {{/formParams}}{{/hasFormParams}} - - return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); - }); - -{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} +$app->{{httpMethod}}('{{path}}', '{{classname}}@{{operationId}}'); +{{/operation}} +{{/operations}} +{{/apis}} +{{/apiInfo}} diff --git a/modules/swagger-codegen/src/main/resources/lumen/storage/app/.gitignore b/modules/swagger-codegen/src/main/resources/lumen/storage/app/.gitignore deleted file mode 100644 index d6b7ef32c84..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/storage/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/modules/swagger-codegen/src/main/resources/lumen/storage/framework/views/.gitignore b/modules/swagger-codegen/src/main/resources/lumen/storage/framework/views/.gitignore deleted file mode 100644 index d6b7ef32c84..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/storage/framework/views/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/modules/swagger-codegen/src/main/resources/lumen/storage/logs/.gitignore b/modules/swagger-codegen/src/main/resources/lumen/storage/logs/.gitignore deleted file mode 100644 index d6b7ef32c84..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/storage/logs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/modules/swagger-codegen/src/main/resources/lumen/tests/ExampleTest.php b/modules/swagger-codegen/src/main/resources/lumen/tests/ExampleTest.php deleted file mode 100644 index 2b206c66173..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/tests/ExampleTest.php +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $this->assertEquals( - $this->response->getContent(), $this->app->version() - ); - } -} diff --git a/modules/swagger-codegen/src/main/resources/lumen/tests/TestCase.php b/modules/swagger-codegen/src/main/resources/lumen/tests/TestCase.php deleted file mode 100644 index 651d9cbd67f..00000000000 --- a/modules/swagger-codegen/src/main/resources/lumen/tests/TestCase.php +++ /dev/null @@ -1,14 +0,0 @@ - {{#models}}{{#model}} -{{#vars}}{{#complexType}} {{/complexType}}{{^complexType}} {{/complexType}} +{{#isArrayModel}} +{{/isArrayModel}}{{^isArrayModel}}{{#vars}}{{#complexType}} {{/complexType}}{{^complexType}} {{/complexType}}{{#vendorExtensions.x-is-unique}} + {{/vendorExtensions.x-is-unique}} {{/vars}} +{{/isArrayModel}} {{/model}}{{/models}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/objc/NSManagedObject-body.mustache b/modules/swagger-codegen/src/main/resources/objc/NSManagedObject-body.mustache index c8e563e75e8..205a692af5e 100644 --- a/modules/swagger-codegen/src/main/resources/objc/NSManagedObject-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/NSManagedObject-body.mustache @@ -8,11 +8,13 @@ * Do not edit the class manually. */ @implementation {{classname}}ManagedObject +{{#isArrayModel}} -{{#vars}} -@dynamic {{name}}; -{{/vars}} +@dynamic entries; +{{/isArrayModel}}{{^isArrayModel}}{{#vars}} +@dynamic {{name}};{{/vars}} +{{/isArrayModel}} {{/model}} @end {{/models}} diff --git a/modules/swagger-codegen/src/main/resources/objc/NSManagedObject-header.mustache b/modules/swagger-codegen/src/main/resources/objc/NSManagedObject-header.mustache index e25dad5795c..53bc9172472 100644 --- a/modules/swagger-codegen/src/main/resources/objc/NSManagedObject-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/NSManagedObject-header.mustache @@ -10,26 +10,40 @@ {{#model}} NS_ASSUME_NONNULL_BEGIN +{{#isArrayModel}} -@interface {{classname}}ManagedObject : {{#parent}}{{{parent}}}{{/parent}}{{^parent}}NSManagedObject{{/parent}} +@interface {{classname}}ManagedObject : NSManagedObject + +@property (nullable, nonatomic, retain) NSSet<{{{arrayModelType}}}ManagedObject*>* entries; + +{{/isArrayModel}}{{^isArrayModel}} +@interface {{classname}}ManagedObject : {{#parent}}{{{parent}}}ManagedObject{{/parent}}{{^parent}}NSManagedObject{{/parent}} {{#vars}} {{#description}}/* {{{description}}} {{^required}}[optional]{{/required}} */{{/description}} -@property (nullable, nonatomic, retain) {{^complexType}}{{{ datatype }}}{{/complexType}}{{#complexType}}{{#isListContainer}}NSSet<{{{complexType}}}ManagedObject*>*{{/isListContainer}}{{^isListContainer}}{{{complexType}}}ManagedObject*{{/isListContainer}}{{/complexType}} {{name}}; +@property (nullable, nonatomic, retain) {{^complexType}}{{{ datatype }}}{{/complexType}}{{#complexType}}{{#isListContainer}}NSSet<{{{complexType}}}ManagedObject*>*{{/isListContainer}}{{^isListContainer}}{{#isMapContainer}}{{{ datatype }}}{{/isMapContainer}}{{^isMapContainer}}{{{complexType}}}ManagedObject*{{/isMapContainer}}{{/isListContainer}}{{/complexType}} {{name}}; {{/vars}} - +{{/isArrayModel}} @end @interface {{classname}}ManagedObject (GeneratedAccessors) - +{{#isArrayModel}} +- (void)addEntriesObject:({{arrayModelType}}ManagedObject *)value; +- (void)removeEntriesObject:({{arrayModelType}}ManagedObject *)value; +- (void)addEntries:(NSSet<{{{arrayModelType}}}ManagedObject*> *)values; +- (void)removeEntries:(NSSet<{{{arrayModelType}}}ManagedObject*> *)values; +{{/isArrayModel}} +{{^isArrayModel}} {{#vars}}{{#isListContainer}}{{#complexType}}- (void)add{{vendorExtensions.x-uppercaseName}}Object:({{complexType}}ManagedObject *)value; - (void)remove{{vendorExtensions.x-uppercaseName}}Object:({{complexType}}ManagedObject *)value; - (void)add{{vendorExtensions.x-uppercaseName}}:(NSSet<{{{complexType}}}ManagedObject*> *)values; - (void)remove{{vendorExtensions.x-uppercaseName}}:(NSSet<{{{complexType}}}ManagedObject*> *)values; {{/complexType}}{{/isListContainer}}{{/vars}} +{{/isArrayModel}} @end -{{/model}} -{{/models}} + NS_ASSUME_NONNULL_END +{{/model}} +{{/models}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/objc/NSManagedObjectBuilder-body.mustache b/modules/swagger-codegen/src/main/resources/objc/NSManagedObjectBuilder-body.mustache index 70f97418eed..b6b69135286 100644 --- a/modules/swagger-codegen/src/main/resources/objc/NSManagedObjectBuilder-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/NSManagedObjectBuilder-body.mustache @@ -13,8 +13,9 @@ -(instancetype)init { self = [super init]; if (self != nil) { -{{#vars}}{{#complexType}} _{{name}}Builder = [[{{complexType}}ManagedObjectBuilder alloc] init]; -{{/complexType}}{{/vars}} } +{{#isArrayModel}} _entriesBuilder = [[{{arrayModelType}}ManagedObjectBuilder alloc] init]; +{{/isArrayModel}}{{#vars}}{{#complexType}}{{^isMapContainer}} _{{name}}Builder = [[{{complexType}}ManagedObjectBuilder alloc] init]; +{{/isMapContainer}}{{/complexType}}{{/vars}} } return self; } @@ -23,9 +24,9 @@ return managedObject; } --({{classname}}ManagedObject*){{classname}}ManagedObjectFrom{{classname}}:({{classname}}*){{name}} context:(NSManagedObjectContext*)context { +-({{classname}}ManagedObject*){{classname}}ManagedObjectFrom{{classname}}:({{classname}}*)object context:(NSManagedObjectContext*)context { {{classname}}ManagedObject* new{{classname}} = [self createNew{{{classname}}}ManagedObjectInContext:context]; - [self update{{classname}}ManagedObject:new{{classname}} with{{classname}}:{{name}}]; + [self update{{classname}}ManagedObject:new{{classname}} with{{classname}}:object]; return new{{classname}}; } @@ -40,13 +41,18 @@ [convertedObjs addObject:convertedObj]; } managedObject.{{name}} = convertedObjs; - }{{/isListContainer}}{{^isListContainer}} + }{{/isListContainer}}{{^isListContainer}}{{^isMapContainer}} if(!managedObject.{{name}}) { managedObject.{{name}} = [self.{{name}}Builder {{complexType}}ManagedObjectFrom{{complexType}}:object.{{name}} context:managedObject.managedObjectContext]; } else { [self.{{name}}Builder update{{complexType}}ManagedObject:managedObject.{{name}} with{{complexType}}:object.{{name}}]; - }{{/isListContainer}}{{/complexType}} - {{/vars}} + }{{/isMapContainer}}{{#isMapContainer}}managedObject.{{name}} = [object.{{name}} copy];{{/isMapContainer}}{{/isListContainer}}{{/complexType}} +{{/vars}}{{#isArrayModel}} NSMutableSet * convertedObjs = [NSMutableSet set]; + for (id innerObject in object) { + id convertedObj = [self.entriesBuilder {{arrayModelType}}ManagedObjectFrom{{arrayModelType}}:innerObject context:managedObject.managedObjectContext]; + [convertedObjs addObject:convertedObj]; + } + managedObject.entries = convertedObjs;{{/isArrayModel}} } -({{classname}}*){{classname}}From{{classname}}ManagedObject:({{classname}}ManagedObject*)obj { @@ -59,7 +65,14 @@ } -(void)update{{classname}}:({{classname}}*)new{{classname}} with{{classname}}ManagedObject:({{classname}}ManagedObject*)obj { -{{#vars}}{{^complexType}} new{{classname}}.{{name}} = [obj.{{name}} copy];{{/complexType}}{{#complexType}}{{#isListContainer}} if(obj.{{name}} != nil) { +{{#isArrayModel}} [new{{classname}} removeAllObjects]; + NSMutableArray* convertedObjs = [NSMutableArray array]; + for (id innerObject in obj.entries) { + id convertedObj = [self.entriesBuilder {{arrayModelType}}From{{arrayModelType}}ManagedObject:innerObject]; + [convertedObjs addObject:convertedObj]; + } + [new{{classname}} addObjectsFromArray:convertedObjs]; +{{/isArrayModel}}{{#vars}}{{^complexType}} new{{classname}}.{{name}} = [obj.{{name}} copy];{{/complexType}}{{#complexType}}{{#isListContainer}} if(obj.{{name}} != nil) { NSMutableArray* convertedObjs = [NSMutableArray array]; for (id innerObject in obj.{{name}}) { id convertedObj = [self.{{name}}Builder {{complexType}}From{{complexType}}ManagedObject:innerObject]; diff --git a/modules/swagger-codegen/src/main/resources/objc/NSManagedObjectBuilder-header.mustache b/modules/swagger-codegen/src/main/resources/objc/NSManagedObjectBuilder-header.mustache index f462a1f0950..15778de3217 100644 --- a/modules/swagger-codegen/src/main/resources/objc/NSManagedObjectBuilder-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/NSManagedObjectBuilder-header.mustache @@ -6,25 +6,25 @@ {{#models}} {{#model}} -#import "{{classPrefix}}{{name}}ManagedObject.h" -#import "{{classPrefix}}{{name}}.h" +#import "{{classname}}ManagedObject.h" +#import "{{classname}}.h" {{>licenceInfo}} @interface {{classname}}ManagedObjectBuilder : NSObject -{{#vars}}{{#complexType}}@property (nonatomic, strong) {{complexType}}ManagedObjectBuilder * {{name}}Builder; +{{#isArrayModel}}@property (nonatomic, strong) {{arrayModelType}}ManagedObjectBuilder * entriesBuilder;{{/isArrayModel}}{{#vars}}{{#complexType}}@property (nonatomic, strong) {{complexType}}ManagedObjectBuilder * {{name}}Builder; {{/complexType}}{{/vars}} -({{classname}}ManagedObject*)createNew{{classname}}ManagedObjectInContext:(NSManagedObjectContext*)context; --({{classname}}ManagedObject*){{classname}}ManagedObjectFrom{{classname}}:({{classname}}*){{name}} context:(NSManagedObjectContext*)context; +-({{classname}}ManagedObject*){{classname}}ManagedObjectFrom{{classname}}:({{classname}}*)object context:(NSManagedObjectContext*)context; --(void)update{{classname}}ManagedObject:({{classname}}ManagedObject*){{name}} with{{classname}}:({{classname}}*){{name}}2; +-(void)update{{classname}}ManagedObject:({{classname}}ManagedObject*)object with{{classname}}:({{classname}}*)object2; -({{classname}}*){{classname}}From{{classname}}ManagedObject:({{classname}}ManagedObject*)obj; --(void)update{{classname}}:({{classname}}*){{name}} with{{classname}}ManagedObject:({{classname}}ManagedObject*){{name}}2; +-(void)update{{classname}}:({{classname}}*)object with{{classname}}ManagedObject:({{classname}}ManagedObject*)object2; @end {{/model}} diff --git a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache index ae4e66fba69..2a4a548458e 100644 --- a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache @@ -13,7 +13,11 @@ } return self; } - +{{#vars}}{{^vendorExtensions.x-unique-id-key}}{{/vendorExtensions.x-unique-id-key}}{{#vendorExtensions.x-unique-id-key}} +-(NSString*)indexPropertyName { + return @"{{name}}"; +} +{{/vendorExtensions.x-unique-id-key}}{{/vars}} {{#discriminator}} /** * Maps "discriminator" value to the sub-class name, so that inheritance is supported. diff --git a/modules/swagger-codegen/src/main/resources/perl/partial_license.mustache b/modules/swagger-codegen/src/main/resources/perl/partial_license.mustache new file mode 100644 index 00000000000..8dcedd38585 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/perl/partial_license.mustache @@ -0,0 +1,29 @@ +=begin comment + +{{#appName}} +{{{appName}}} + +{{/appName}} +{{#appDescription}} +{{{appDescription}}} + +{{/appDescription}} +{{#version}}OpenAPI spec version: {{version}}{{/version}} +{{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} +Generated by: https://github.com/swagger-api/swagger-codegen.git + +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. + +=end comment + +=cut diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index 26f79cd6139..5fe25f05b5e 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -244,11 +244,8 @@ use \{{invokerPackage}}\ObjectSerializer; $headerParams{{#returnType}}, '{{returnType}}'{{/returnType}} ); - {{#returnType}} - if (!$response) { - return array(null, $statusCode, $httpHeader); - } + {{#returnType}} return array($this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader{{#discriminator}}, '{{discriminator}}'{{/discriminator}}), $statusCode, $httpHeader); {{/returnType}} {{^returnType}} diff --git a/modules/swagger-codegen/src/main/resources/python/travis.mustache b/modules/swagger-codegen/src/main/resources/python/travis.mustache new file mode 100644 index 00000000000..86211e2d4a2 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/python/travis.mustache @@ -0,0 +1,14 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" + #- "3.5-dev" # 3.5 development branch + #- "nightly" # points to the latest development branch e.g. 3.6-dev +# command to install dependencies +install: "pip install -r requirements.txt" +# command to run tests +script: nosetests diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.cpp b/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.cpp.mustache similarity index 99% rename from modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.cpp rename to modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.cpp.mustache index f1e79c4d197..f4701f860d2 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.cpp +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.cpp.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} #include "SWGHttpRequest.h" #include #include diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.h b/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.h.mustache similarity index 98% rename from modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.h rename to modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.h.mustache index a2e91a0765e..d03e671e251 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.h +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.h.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} /** * Based on http://www.creativepulse.gr/en/blog/2014/restful-api-requests-using-qt-cpp-for-linux-mac-osx-ms-windows * By Alex Stylianos diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/api-body.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/api-body.mustache index fc69cfa4404..578eecc9c62 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/api-body.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/api-body.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} #include "{{classname}}.h" #include "{{prefix}}Helpers.h" #include "{{prefix}}ModelFactory.h" @@ -87,7 +88,7 @@ void HttpRequestInput input(fullPath, "{{httpMethod}}"); {{#formParams}}if ({{paramName}} != NULL) { - {{^isFile}}input.add_var("{{paramName}}", *{{paramName}});{{/isFile}}{{#isFile}}input.add_file("{{paramName}}", *{{paramName}}.local_filename, *{{paramName}}.request_filename, *{{paramName}}.mime_type);{{/isFile}} + {{^isFile}}input.add_var("{{paramName}}", *{{paramName}});{{/isFile}}{{#isFile}}input.add_file("{{paramName}}", (*{{paramName}}).local_filename, (*{{paramName}}).request_filename, (*{{paramName}}).mime_type);{{/isFile}} } {{/formParams}} diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/api-header.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/api-header.mustache index 4260ba6ff86..53b7271c8d5 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/api-header.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/api-header.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} #ifndef _SWG_{{classname}}_H_ #define _SWG_{{classname}}_H_ @@ -31,4 +32,4 @@ signals: {{/operation}}{{/operations}} }; } -#endif \ No newline at end of file +#endif diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache index 6b439996724..fc5af8e0ae3 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} #include "SWGHelpers.h" #include "SWGModelFactory.h" #include "SWGObject.h" @@ -53,6 +54,46 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) { qDebug() << "Can't set value because the target pointer is NULL"; } } + else if (QStringLiteral("QDateTime").compare(type) == 0) { + QDateTime **val = static_cast(value); + + if(val != NULL) { + if(!obj.isNull()) { + // create a new value and return + delete *val; + *val = new QDateTime(QDateTime::fromString(obj.toString(), Qt::ISODate)); + return; + } + else { + // set target to NULL + delete *val; + *val = NULL; + } + } + else { + qDebug() << "Can't set value because the target pointer is NULL"; + } + } + else if (QStringLiteral("QDate").compare(type) == 0) { + QDate **val = static_cast(value); + + if(val != NULL) { + if(!obj.isNull()) { + // create a new value and return + delete *val; + *val = new QDate(QDate::fromString(obj.toString(), Qt::ISODate)); + return; + } + else { + // set target to NULL + delete *val; + *val = NULL; + } + } + else { + qDebug() << "Can't set value because the target pointer is NULL"; + } + } else if(type.startsWith("SWG") && obj.isObject()) { // complex type QJsonObject jsonObj = obj.toObject(); @@ -104,6 +145,21 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) { setValue(&val, jval, QStringLiteral("double"), QStringLiteral("")); output->append((void*)&val); } + else if(QStringLiteral("QString").compare(complexType) == 0) { + QString val; + setValue(&val, jval, QStringLiteral("QString"), QStringLiteral("")); + output->append((void*)&val); + } + else if(QStringLiteral("QDate").compare(complexType) == 0) { + QDate val; + setValue(&val, jval, QStringLiteral("QDate"), QStringLiteral("")); + output->append((void*)&val); + } + else if(QStringLiteral("QDateTime").compare(complexType) == 0) { + QDateTime val; + setValue(&val, jval, QStringLiteral("QDateTime"), QStringLiteral("")); + output->append((void*)&val); + } } } QList **val = static_cast**>(value); @@ -139,23 +195,31 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) { } else if(QStringLiteral("qint32").compare(type) == 0) { qint32* str = static_cast(value); - output->insert(name, QJsonValue(*str)); + output->insert(name, QJsonValue(*str)); } else if(QStringLiteral("qint64").compare(type) == 0) { qint64* str = static_cast(value); - output->insert(name, QJsonValue(*str)); + output->insert(name, QJsonValue(*str)); } else if(QStringLiteral("bool").compare(type) == 0) { bool* str = static_cast(value); - output->insert(name, QJsonValue(*str)); + output->insert(name, QJsonValue(*str)); } else if(QStringLiteral("float").compare(type) == 0) { float* str = static_cast(value); - output->insert(name, QJsonValue((double)*str)); + output->insert(name, QJsonValue((double)*str)); } else if(QStringLiteral("double").compare(type) == 0) { double* str = static_cast(value); - output->insert(name, QJsonValue(*str)); + output->insert(name, QJsonValue(*str)); + } + else if(QStringLiteral("QDate").compare(type) == 0) { + QDate* date = static_cast(value); + output->insert(name, QJsonValue(date->toString(Qt::ISODate))); + } + else if(QStringLiteral("QDateTime").compare(type) == 0) { + QDateTime* datetime = static_cast(value); + output->insert(name, QJsonValue(datetime->toString(Qt::ISODate))); } } diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-header.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-header.mustache index 3a02c0952d5..c61f4554f74 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-header.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-header.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} #ifndef SWGHELPERS_H #define SWGHELPERS_H diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/licenseInfo.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/licenseInfo.mustache new file mode 100644 index 00000000000..861d97234cf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/licenseInfo.mustache @@ -0,0 +1,23 @@ +/** + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache index 705cb852108..a7a8bf0afbd 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} {{#models}}{{#model}} #include "{{classname}}.h" diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/model-header.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/model-header.mustache index 7b0b6cdcc1b..48e07bcbdad 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/model-header.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/model-header.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} {{#models}}{{#model}}/* * {{classname}}.h * diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/model.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/model.mustache index 1a2a831f5ac..64cb203e4c6 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/model.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/model.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} {{#models}}{{#model}}/* * {{classname}}.h * diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/modelFactory.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/modelFactory.mustache index 4ec9e6f7411..349ccaf3b98 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/modelFactory.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/modelFactory.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} #ifndef ModelFactory_H_ #define ModelFactory_H_ diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/object.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/object.mustache index 62914cb5162..14a23716357 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/object.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/object.mustache @@ -1,3 +1,4 @@ +{{>licenseInfo}} #ifndef _{{prefix}}_OBJECT_H_ #define _{{prefix}}_OBJECT_H_ diff --git a/modules/swagger-codegen/src/main/resources/scalatra/Bootstrap.mustache b/modules/swagger-codegen/src/main/resources/scalatra/Bootstrap.mustache index 5121079424f..afb0dd162d1 100644 --- a/modules/swagger-codegen/src/main/resources/scalatra/Bootstrap.mustache +++ b/modules/swagger-codegen/src/main/resources/scalatra/Bootstrap.mustache @@ -1,3 +1,5 @@ +{{>licenseInfo}} + import {{apiPackage}}._ import akka.actor.ActorSystem import io.swagger.app.{ResourcesApp, SwaggerApp} diff --git a/modules/swagger-codegen/src/main/resources/scalatra/JettyMain.scala b/modules/swagger-codegen/src/main/resources/scalatra/JettyMain.mustache similarity index 98% rename from modules/swagger-codegen/src/main/resources/scalatra/JettyMain.scala rename to modules/swagger-codegen/src/main/resources/scalatra/JettyMain.mustache index e25f16ba392..1eedae148b3 100644 --- a/modules/swagger-codegen/src/main/resources/scalatra/JettyMain.scala +++ b/modules/swagger-codegen/src/main/resources/scalatra/JettyMain.mustache @@ -1,3 +1,5 @@ +{{>licenseInfo}} + import org.eclipse.jetty.server._ import org.eclipse.jetty.webapp.WebAppContext import org.scalatra.servlet.ScalatraListener diff --git a/modules/swagger-codegen/src/main/resources/scalatra/ServletApp.mustache b/modules/swagger-codegen/src/main/resources/scalatra/ServletApp.mustache index 423b8644712..faeeb5fcb7a 100644 --- a/modules/swagger-codegen/src/main/resources/scalatra/ServletApp.mustache +++ b/modules/swagger-codegen/src/main/resources/scalatra/ServletApp.mustache @@ -1,3 +1,5 @@ +{{>licenseInfo}} + package io.swagger.app import _root_.akka.actor.ActorSystem diff --git a/modules/swagger-codegen/src/main/resources/scalatra/api.mustache b/modules/swagger-codegen/src/main/resources/scalatra/api.mustache index b6749641e54..bd3b40b8fac 100644 --- a/modules/swagger-codegen/src/main/resources/scalatra/api.mustache +++ b/modules/swagger-codegen/src/main/resources/scalatra/api.mustache @@ -1,3 +1,5 @@ +{{>licenseInfo}} + package {{package}} {{#imports}}import {{import}} diff --git a/modules/swagger-codegen/src/main/resources/scalatra/licenseInfo.mustache b/modules/swagger-codegen/src/main/resources/scalatra/licenseInfo.mustache new file mode 100644 index 00000000000..2ed71d3a875 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/scalatra/licenseInfo.mustache @@ -0,0 +1,23 @@ +/** + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/scalatra/model.mustache b/modules/swagger-codegen/src/main/resources/scalatra/model.mustache index e9dac65dd79..c1a2f2585de 100644 --- a/modules/swagger-codegen/src/main/resources/scalatra/model.mustache +++ b/modules/swagger-codegen/src/main/resources/scalatra/model.mustache @@ -1,3 +1,5 @@ +{{>licenseInfo}} + package {{package}} {{#imports}}import {{import}} diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache index 817afd33f34..48c9ebcea45 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache @@ -80,7 +80,13 @@ export class {{classname}} { {{/hasFormParams}} return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } {{/operation}} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJava8ModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJava8ModelTest.java index 34c91e28335..ad26ecc9ae5 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJava8ModelTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxrsJava8ModelTest.java @@ -34,6 +34,6 @@ public class JaxrsJava8ModelTest { Json.prettyPrint(cm); assertEquals(cm.vars.get(0).datatype, "Long"); assertEquals(cm.vars.get(1).datatype, "LocalDate"); - assertEquals(cm.vars.get(2).datatype, "LocalDateTime"); + assertEquals(cm.vars.get(2).datatype, "OffsetDateTime"); } } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcModelTest.java index f3948b00781..76e5ced012f 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcModelTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/objc/ObjcModelTest.java @@ -267,6 +267,43 @@ public class ObjcModelTest { Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("SWGChildren")).size(), 1); } + @Test(description = "test udid") + public void udidAndPasswordDataModelTest() { + final Swagger model = new SwaggerParser().read("src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml"); + final DefaultCodegen codegen = new ObjcClientCodegen(); + final Model definition = model.getDefinitions().get("format_test"); + + Property property = definition.getProperties().get("uuid"); + CodegenProperty prope = codegen.fromProperty("uuid", property); + Assert.assertEquals(prope.baseType, "NSString"); + + prope = codegen.fromProperty("password", property); + Assert.assertEquals(prope.baseType, "NSString"); + } + + @Test(description = "test mixedProperties") + public void mixedPropertiesDataModelTest() { + final Swagger model = new SwaggerParser().read("src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml"); + final DefaultCodegen codegen = new ObjcClientCodegen(); + final Model definition = model.getDefinitions().get("MixedPropertiesAndAdditionalPropertiesClass"); + + Property property = definition.getProperties().get("map"); + CodegenProperty prope = codegen.fromProperty("map", property); + Assert.assertEquals(prope.baseType, "NSDictionary"); + } + + @Test(description = "test isArrayModel") + public void isArrayModelModelTest() { + final Swagger model = new SwaggerParser().read("src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml"); + final DefaultCodegen codegen = new ObjcClientCodegen(); + final Model definition = model.getDefinitions().get("AnimalFarm"); + final CodegenModel codegenModel = codegen.fromModel("AnimalFarm",definition); + + Assert.assertEquals(codegenModel.isArrayModel,Boolean.TRUE); + Assert.assertEquals(codegenModel.arrayModelType,"SWGAnimal"); + } + + @Test(description = "test binary data") public void binaryDataModelTest() { final Swagger model = new SwaggerParser().read("src/test/resources/2_0/binaryDataTest.json"); diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/GoServerOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/GoServerOptionsProvider.java new file mode 100644 index 00000000000..71e47537f45 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/GoServerOptionsProvider.java @@ -0,0 +1,30 @@ +package io.swagger.codegen.options; + +import io.swagger.codegen.CodegenConstants; + +import com.google.common.collect.ImmutableMap; + +import java.util.Map; + +public class GoServerOptionsProvider implements OptionsProvider { + public static final String SORT_PARAMS_VALUE = "false"; + public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true"; + + @Override + public String getLanguage() { + return "go-server"; + } + + @Override + public Map createOptions() { + ImmutableMap.Builder builder = new ImmutableMap.Builder(); + return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE) + .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) + .build(); + } + + @Override + public boolean isServer() { + return true; + } +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringBootServerOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringBootServerOptionsProvider.java index c4b1281c1dc..a4b703d4d07 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringBootServerOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/SpringBootServerOptionsProvider.java @@ -12,6 +12,8 @@ public class SpringBootServerOptionsProvider extends JavaOptionsProvider { public static final String LIBRARY_VALUE = "j8-async"; //FIXME hidding value from super class public static final String INTERFACE_ONLY = "true"; public static final String SINGLE_CONTENT_TYPES = "true"; + public static final String JAVA_8 = "true"; + public static final String ASYNC = "true"; @Override public String getLanguage() { @@ -26,6 +28,8 @@ public class SpringBootServerOptionsProvider extends JavaOptionsProvider { options.put(CodegenConstants.LIBRARY, LIBRARY_VALUE); options.put(SpringBootServerCodegen.INTERFACE_ONLY, INTERFACE_ONLY); options.put(SpringBootServerCodegen.SINGLE_CONTENT_TYPES, SINGLE_CONTENT_TYPES); + options.put(SpringBootServerCodegen.JAVA_8, JAVA_8); + options.put(SpringBootServerCodegen.ASYNC, ASYNC); return options; } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/springboot/SpringBootServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/springboot/SpringBootServerOptionsTest.java index c60ac3a582d..376a44a60b8 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/springboot/SpringBootServerOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/springboot/SpringBootServerOptionsTest.java @@ -58,6 +58,10 @@ public class SpringBootServerOptionsTest extends JavaClientOptionsTest { times = 1; clientCodegen.setSingleContentTypes(Boolean.valueOf(SpringBootServerOptionsProvider.SINGLE_CONTENT_TYPES)); times = 1; + clientCodegen.setJava8(Boolean.valueOf(SpringBootServerOptionsProvider.JAVA_8)); + times = 1; + clientCodegen.setAsync(Boolean.valueOf(SpringBootServerOptionsProvider.ASYNC)); + times = 1; }}; } diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml index ee4c0bfbcc9..109feba388e 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -717,6 +717,7 @@ definitions: id: type: integer format: int64 + x-is-unique: true username: type: string firstName: @@ -754,6 +755,7 @@ definitions: id: type: integer format: int64 + x-is-unique: true category: $ref: '#/definitions/Category' name: diff --git a/samples/client/petstore/android/volley/.swagger-codegen-ignore b/samples/client/petstore/android/volley/.swagger-codegen-ignore new file mode 100644 index 00000000000..19d3377182e --- /dev/null +++ b/samples/client/petstore/android/volley/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/android/volley/LICENSE b/samples/client/petstore/android/volley/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/samples/client/petstore/android/volley/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. diff --git a/samples/client/petstore/android/volley/README.md b/samples/client/petstore/android/volley/README.md index 65931066a32..6f0a2c65f92 100644 --- a/samples/client/petstore/android/volley/README.md +++ b/samples/client/petstore/android/volley/README.md @@ -1,4 +1,4 @@ -# swagger-android-client +# swagger-petstore-android-volley ## Requirements @@ -27,7 +27,7 @@ Add this dependency to your project's POM: ```xml io.swagger - swagger-android-client + swagger-petstore-android-volley 1.0.0 compile @@ -38,7 +38,7 @@ Add this dependency to your project's POM: Add this dependency to your project's build file: ```groovy -compile "io.swagger:swagger-android-client:1.0.0" +compile "io.swagger:swagger-petstore-android-volley:1.0.0" ``` ### Others @@ -49,7 +49,7 @@ At first generate the JAR by executing: Then manually install the following JARs: -* target/swagger-android-client-1.0.0.jar +* target/swagger-petstore-android-volley-1.0.0.jar * target/lib/*.jar ## Getting Started @@ -116,12 +116,6 @@ Class | Method | HTTP request | Description ## Documentation for Authorization Authentication schemes defined for the API: -### api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - ### petstore_auth - **Type**: OAuth @@ -131,6 +125,12 @@ Authentication schemes defined for the API: - write:pets: modify pets in your account - read:pets: read your pets +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + ## Recommendation diff --git a/samples/client/petstore/android/volley/git_push.sh b/samples/client/petstore/android/volley/git_push.sh index f711c4b3130..4d72f2fc955 100644 --- a/samples/client/petstore/android/volley/git_push.sh +++ b/samples/client/petstore/android/volley/git_push.sh @@ -28,7 +28,7 @@ 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. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote @@ -48,4 +48,4 @@ 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' \ No newline at end of file +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/android/volley/pom.xml b/samples/client/petstore/android/volley/pom.xml index 04369688c3b..d3ce92aeb96 100644 --- a/samples/client/petstore/android/volley/pom.xml +++ b/samples/client/petstore/android/volley/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 io.swagger - swagger-android-client + swagger-petstore-android-volley 1.0.0 diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/DeleteRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/DeleteRequest.java index 36b0c6ad07d..141fa5a1060 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/DeleteRequest.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/DeleteRequest.java @@ -34,11 +34,17 @@ public class DeleteRequest extends Request { @Override public String getBodyContentType() { + if(entity == null) { + return null; + } return entity.getContentType().getValue(); } @Override public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { entity.writeTo(bos); diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PatchRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PatchRequest.java index 206a745e5b2..252141eb976 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PatchRequest.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PatchRequest.java @@ -34,11 +34,17 @@ public class PatchRequest extends Request { @Override public String getBodyContentType() { + if(entity == null) { + return null; + } return entity.getContentType().getValue(); } @Override public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { entity.writeTo(bos); diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PostRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PostRequest.java index 97d0eb16b1a..7cbe01b701e 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PostRequest.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PostRequest.java @@ -34,11 +34,17 @@ public class PostRequest extends Request { @Override public String getBodyContentType() { + if(entity == null) { + return null; + } return entity.getContentType().getValue(); } @Override public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { entity.writeTo(bos); diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PutRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PutRequest.java index 0a7b40e510e..f3b9c648324 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PutRequest.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PutRequest.java @@ -34,11 +34,17 @@ public class PutRequest extends Request { @Override public String getBodyContentType() { + if(entity == null) { + return null; + } return entity.getContentType().getValue(); } @Override public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { entity.writeTo(bos); diff --git a/samples/client/petstore/cpprest/.gitignore b/samples/client/petstore/cpprest/.gitignore new file mode 100644 index 00000000000..4581ef2eeef --- /dev/null +++ b/samples/client/petstore/cpprest/.gitignore @@ -0,0 +1,29 @@ +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app diff --git a/samples/client/petstore/cpprest/.swagger-codegen-ignore b/samples/client/petstore/cpprest/.swagger-codegen-ignore new file mode 100644 index 00000000000..19d3377182e --- /dev/null +++ b/samples/client/petstore/cpprest/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/cpprest/ApiClient.cpp b/samples/client/petstore/cpprest/ApiClient.cpp new file mode 100644 index 00000000000..b04707e54c9 --- /dev/null +++ b/samples/client/petstore/cpprest/ApiClient.cpp @@ -0,0 +1,133 @@ +#include "ApiClient.h" +#include "MultipartFormData.h" +#include "ModelBase.h" + +namespace io { +namespace swagger { +namespace client { +namespace api { + +using namespace io::swagger::client::model; + +ApiClient::ApiClient(std::shared_ptr configuration ) + : m_Configuration(configuration) +{ +} +ApiClient::~ApiClient() +{ +} + +std::shared_ptr ApiClient::getConfiguration() const +{ + return m_Configuration; +} +void ApiClient::setConfiguration(std::shared_ptr configuration) +{ + m_Configuration = configuration; +} + + +utility::string_t ApiClient::parameterToString(utility::string_t value) +{ + return value; +} +utility::string_t ApiClient::parameterToString(int64_t value) +{ + return std::to_wstring(value); +} +utility::string_t ApiClient::parameterToString(int32_t value) +{ + return std::to_wstring(value); +} + +pplx::task ApiClient::callApi( + const utility::string_t& path, + const utility::string_t& method, + const std::map& queryParams, + const std::shared_ptr postBody, + const std::map& headerParams, + const std::map& formParams, + const std::map>& fileParams, + const utility::string_t& contentType +) const +{ + if (postBody != nullptr && formParams.size() != 0) + { + throw ApiException(400, U("Cannot have body and form params")); + } + + if (postBody != nullptr && fileParams.size() != 0) + { + throw ApiException(400, U("Cannot have body and file params")); + } + + if (fileParams.size() > 0 && contentType != U("multipart/form-data")) + { + throw ApiException(400, U("Operations with file parameters must be called with multipart/form-data")); + } + + web::http::client::http_client client(m_Configuration->getBaseUrl(), m_Configuration->getHttpConfig()); + + web::http::http_request request; + for ( auto& kvp : headerParams ) + { + request.headers().add(kvp.first, kvp.second); + } + + if (fileParams.size() > 0) + { + MultipartFormData uploadData; + for (auto& kvp : formParams) + { + uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); + } + for (auto& kvp : fileParams) + { + uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); + } + std::stringstream data; + postBody->writeTo(data); + auto bodyString = data.str(); + auto length = bodyString.size(); + request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, contentType); + } + else + { + if (postBody != nullptr) + { + std::stringstream data; + postBody->writeTo(data); + auto bodyString = data.str(); + auto length = bodyString.size(); + request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, contentType); + } + else + { + web::http::uri_builder formData; + for (auto& kvp : formParams) + { + formData.append_query(kvp.first, kvp.second); + } + request.set_body(formData.query(), U("application/x-www-form-urlencoded")); + } + } + + web::http::uri_builder builder(path); + for (auto& kvp : queryParams) + { + builder.append_query(kvp.first, kvp.second); + } + request.set_request_uri(builder.to_uri()); + request.set_method(method); + if ( !request.headers().has( web::http::header_names::user_agent ) ) + { + request.headers().add( web::http::header_names::user_agent, m_Configuration->getUserAgent() ); + } + + return client.request(request); +} + +} +} +} +} diff --git a/samples/client/petstore/cpprest/ApiClient.h b/samples/client/petstore/cpprest/ApiClient.h new file mode 100644 index 00000000000..cbbb91ce7db --- /dev/null +++ b/samples/client/petstore/cpprest/ApiClient.h @@ -0,0 +1,77 @@ +/* + * ApiClient.h + * + * This is an API client responsible for stating the HTTP calls + */ + +#ifndef ApiClient_H_ +#define ApiClient_H_ + + +#include "ApiConfiguration.h" +#include "ApiException.h" +#include "IHttpBody.h" +#include "HttpContent.h" + +#include +#include + +#include +#include + +namespace io { +namespace swagger { +namespace client { +namespace api { + +using namespace io::swagger::client::model; + +class ApiClient +{ +public: + ApiClient( std::shared_ptr configuration = nullptr ); + virtual ~ApiClient(); + + std::shared_ptr getConfiguration() const; + void setConfiguration(std::shared_ptr configuration); + + static utility::string_t parameterToString(utility::string_t value); + static utility::string_t parameterToString(int32_t value); + static utility::string_t parameterToString(int64_t value); + + template + static utility::string_t parameterToArrayString(std::vector value) + { + utility::stringstream_t ss; + + for( size_t i = 0; i < value.size(); i++) + { + if( i > 0) ss << U(", "); + ss << ApiClient::parameterToString(value[i]); + } + + return ss.str(); + } + + pplx::task callApi( + const utility::string_t& path, + const utility::string_t& method, + const std::map& queryParams, + const std::shared_ptr postBody, + const std::map& headerParams, + const std::map& formParams, + const std::map>& fileParams, + const utility::string_t& contentType + ) const; + +protected: + + std::shared_ptr m_Configuration; +}; + +} +} +} +} + +#endif /* ApiClient_H_ */ \ No newline at end of file diff --git a/samples/client/petstore/cpprest/ApiConfiguration.cpp b/samples/client/petstore/cpprest/ApiConfiguration.cpp new file mode 100644 index 00000000000..e66ce50a209 --- /dev/null +++ b/samples/client/petstore/cpprest/ApiConfiguration.cpp @@ -0,0 +1,69 @@ +#include "ApiConfiguration.h" + +namespace io { +namespace swagger { +namespace client { +namespace api { + +ApiConfiguration::ApiConfiguration() +{ +} + +ApiConfiguration::~ApiConfiguration() +{ +} + +web::http::client::http_client_config& ApiConfiguration::getHttpConfig() +{ + return m_HttpConfig; +} + +void ApiConfiguration::setHttpConfig( web::http::client::http_client_config& value ) +{ + m_HttpConfig = value; +} + +utility::string_t ApiConfiguration::getBaseUrl() const +{ + return m_BaseUrl; +} + +void ApiConfiguration::setBaseUrl( const utility::string_t value ) +{ + m_BaseUrl = value; +} + +utility::string_t ApiConfiguration::getUserAgent() const +{ + return m_UserAgent; +} + +void ApiConfiguration::setUserAgent( const utility::string_t value ) +{ + m_UserAgent = value; +} + +std::map& ApiConfiguration::getDefaultHeaders() +{ + return m_DefaultHeaders; +} + +utility::string_t ApiConfiguration::getApiKey( const utility::string_t& prefix) const +{ + auto result = m_ApiKeys.find(prefix); + if( result != m_ApiKeys.end() ) + { + return result->second; + } + return U(""); +} + +void ApiConfiguration::setApiKey( const utility::string_t& prefix, const utility::string_t& apiKey ) +{ + m_ApiKeys[prefix] = apiKey; +} + +} +} +} +} diff --git a/samples/client/petstore/cpprest/ApiConfiguration.h b/samples/client/petstore/cpprest/ApiConfiguration.h new file mode 100644 index 00000000000..d0011a82c9e --- /dev/null +++ b/samples/client/petstore/cpprest/ApiConfiguration.h @@ -0,0 +1,53 @@ +/* + * ApiConfiguration.h + * + * This class represents a single item of a multipart-formdata request. + */ + +#ifndef ApiConfiguration_H_ +#define ApiConfiguration_H_ + + + +#include + +#include +#include +namespace io { +namespace swagger { +namespace client { +namespace api { + +class ApiConfiguration +{ +public: + ApiConfiguration(); + virtual ~ApiConfiguration(); + + web::http::client::http_client_config& getHttpConfig(); + void setHttpConfig( web::http::client::http_client_config& value ); + + utility::string_t getBaseUrl() const; + void setBaseUrl( const utility::string_t value ); + + utility::string_t getUserAgent() const; + void setUserAgent( const utility::string_t value ); + + std::map& getDefaultHeaders(); + + utility::string_t getApiKey( const utility::string_t& prefix) const; + void setApiKey( const utility::string_t& prefix, const utility::string_t& apiKey ); + +protected: + utility::string_t m_BaseUrl; + std::map m_DefaultHeaders; + std::map m_ApiKeys; + web::http::client::http_client_config m_HttpConfig; + utility::string_t m_UserAgent; +}; + +} +} +} +} +#endif /* ApiConfiguration_H_ */ \ No newline at end of file diff --git a/samples/client/petstore/cpprest/ApiException.cpp b/samples/client/petstore/cpprest/ApiException.cpp new file mode 100644 index 00000000000..a2d5ba18da2 --- /dev/null +++ b/samples/client/petstore/cpprest/ApiException.cpp @@ -0,0 +1,42 @@ +#include "ApiException.h" + +namespace io { +namespace swagger { +namespace client { +namespace api { + +ApiException::ApiException( int errorCode + , const utility::string_t& message + , std::shared_ptr content /*= nullptr*/ ) + : web::http::http_exception( errorCode, message ) + , m_Content(content) +{ +} +ApiException::ApiException( int errorCode + , const utility::string_t& message + , std::map& headers + , std::shared_ptr content /*= nullptr*/ ) + : web::http::http_exception( errorCode, message ) + , m_Content(content) + , m_Headers(headers) +{ +} + +ApiException::~ApiException() +{ +} + +std::shared_ptr ApiException::getContent() const +{ + return m_Content; +} + +std::map& ApiException::getHeaders() +{ + return m_Headers; +} + +} +} +} +} diff --git a/samples/client/petstore/cpprest/ApiException.h b/samples/client/petstore/cpprest/ApiException.h new file mode 100644 index 00000000000..1c16a5c2d3b --- /dev/null +++ b/samples/client/petstore/cpprest/ApiException.h @@ -0,0 +1,50 @@ +/* + * ApiException.h + * + * This is the exception being thrown in case the api call was not successful + */ + +#ifndef ApiException_H_ +#define ApiException_H_ + + + +#include +#include + +#include +#include + + +namespace io { +namespace swagger { +namespace client { +namespace api { + +class ApiException + : public web::http::http_exception +{ +public: + ApiException( int errorCode + , const utility::string_t& message + , std::shared_ptr content = nullptr ); + ApiException( int errorCode + , const utility::string_t& message + , std::map& headers + , std::shared_ptr content = nullptr ); + virtual ~ApiException(); + + std::map& getHeaders(); + std::shared_ptr getContent() const; + +protected: + std::shared_ptr m_Content; + std::map m_Headers; +}; + +} +} +} +} + +#endif /* ApiBase_H_ */ \ No newline at end of file diff --git a/samples/client/petstore/cpprest/HttpContent.cpp b/samples/client/petstore/cpprest/HttpContent.cpp new file mode 100644 index 00000000000..c6697f6e0d2 --- /dev/null +++ b/samples/client/petstore/cpprest/HttpContent.cpp @@ -0,0 +1,75 @@ +#include "HttpContent.h" + +namespace io { +namespace swagger { +namespace client { +namespace model { + +HttpContent::HttpContent() +{ +} + +HttpContent::~HttpContent() +{ +} + +utility::string_t HttpContent::getContentDisposition() +{ + return m_ContentDisposition; +} + +void HttpContent::setContentDisposition( const utility::string_t & value ) +{ + m_ContentDisposition = value; +} + +utility::string_t HttpContent::getName() +{ + return m_Name; +} + +void HttpContent::setName( const utility::string_t & value ) +{ + m_Name = value; +} + +utility::string_t HttpContent::getFileName() +{ + return m_FileName; +} + +void HttpContent::setFileName( const utility::string_t & value ) +{ + m_FileName = value; +} + +utility::string_t HttpContent::getContentType() +{ + return m_ContentType; +} + +void HttpContent::setContentType( const utility::string_t & value ) +{ + m_ContentType = value; +} + +std::shared_ptr HttpContent::getData() +{ + return m_Data; +} + +void HttpContent::setData( std::shared_ptr value ) +{ + m_Data = value; +} + +void HttpContent::writeTo( std::ostream& stream ) +{ + m_Data->seekg( 0, m_Data->beg ); + stream << m_Data->rdbuf(); +} + +} +} +} +} diff --git a/samples/client/petstore/cpprest/HttpContent.h b/samples/client/petstore/cpprest/HttpContent.h new file mode 100644 index 00000000000..d8ec4ba51db --- /dev/null +++ b/samples/client/petstore/cpprest/HttpContent.h @@ -0,0 +1,58 @@ +/* + * HttpContent.h + * + * This class represents a single item of a multipart-formdata request. + */ + +#ifndef HttpContent_H_ +#define HttpContent_H_ + + + +#include + +#include + +namespace io { +namespace swagger { +namespace client { +namespace model { + +class HttpContent +{ +public: + HttpContent(); + virtual ~HttpContent(); + + virtual utility::string_t getContentDisposition(); + virtual void setContentDisposition( const utility::string_t& value ); + + virtual utility::string_t getName(); + virtual void setName( const utility::string_t& value ); + + virtual utility::string_t getFileName(); + virtual void setFileName( const utility::string_t& value ); + + virtual utility::string_t getContentType(); + virtual void setContentType( const utility::string_t& value ); + + virtual std::shared_ptr getData(); + virtual void setData( std::shared_ptr value ); + + virtual void writeTo( std::ostream& stream ); + +protected: + // NOTE: no utility::string_t here because those strings can only contain ascii + utility::string_t m_ContentDisposition; + utility::string_t m_Name; + utility::string_t m_FileName; + utility::string_t m_ContentType; + std::shared_ptr m_Data; +}; + +} +} +} +} + +#endif /* HttpContent_H_ */ \ No newline at end of file diff --git a/samples/client/petstore/cpprest/IHttpBody.h b/samples/client/petstore/cpprest/IHttpBody.h new file mode 100644 index 00000000000..a4e34b6e76a --- /dev/null +++ b/samples/client/petstore/cpprest/IHttpBody.h @@ -0,0 +1,31 @@ +/* + * IHttpBody.h + * + * This is the interface for contents that can be sent to a remote HTTP server. + */ + +#ifndef IHttpBody_H_ +#define IHttpBody_H_ + + +#include + +namespace io { +namespace swagger { +namespace client { +namespace model { + +class IHttpBody +{ +public: + virtual ~IHttpBody() { } + + virtual void writeTo( std::ostream& stream ) = 0; +}; + +} +} +} +} + +#endif /* IHttpBody_H_ */ \ No newline at end of file diff --git a/samples/client/petstore/cpprest/JsonBody.cpp b/samples/client/petstore/cpprest/JsonBody.cpp new file mode 100644 index 00000000000..43970e03f25 --- /dev/null +++ b/samples/client/petstore/cpprest/JsonBody.cpp @@ -0,0 +1,25 @@ +#include "JsonBody.h" + +namespace io { +namespace swagger { +namespace client { +namespace model { + +JsonBody::JsonBody( const web::json::value& json) + : m_Json(json) +{ +} + +JsonBody::~JsonBody() +{ +} + +void JsonBody::writeTo( std::ostream& target ) +{ + m_Json.serialize(target); +} + +} +} +} +} diff --git a/samples/client/petstore/cpprest/JsonBody.h b/samples/client/petstore/cpprest/JsonBody.h new file mode 100644 index 00000000000..a86d9a5177a --- /dev/null +++ b/samples/client/petstore/cpprest/JsonBody.h @@ -0,0 +1,38 @@ +/* + * JsonBody.h + * + * This is a JSON http body which can be submitted via http + */ + +#ifndef JsonBody_H_ +#define JsonBody_H_ + + +#include "IHttpBody.h" + +#include + +namespace io { +namespace swagger { +namespace client { +namespace model { + +class JsonBody + : public IHttpBody +{ +public: + JsonBody( const web::json::value& value ); + virtual ~JsonBody(); + + void writeTo( std::ostream& target ) override; + +protected: + web::json::value m_Json; +}; + +} +} +} +} + +#endif /* JsonBody_H_ */ \ No newline at end of file diff --git a/samples/client/petstore/cpprest/LICENSE b/samples/client/petstore/cpprest/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/samples/client/petstore/cpprest/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. diff --git a/samples/client/petstore/cpprest/ModelBase.cpp b/samples/client/petstore/cpprest/ModelBase.cpp new file mode 100644 index 00000000000..d8abe304fa5 --- /dev/null +++ b/samples/client/petstore/cpprest/ModelBase.cpp @@ -0,0 +1,339 @@ +#include "ModelBase.h" + +namespace io { +namespace swagger { +namespace client { +namespace model { + +ModelBase::ModelBase() +{ +} +ModelBase::~ModelBase() +{ +} + +web::json::value ModelBase::toJson( const utility::string_t& value ) +{ + return web::json::value::string(value); +} +web::json::value ModelBase::toJson( const utility::datetime& value ) +{ + return web::json::value::string(value.to_string(utility::datetime::ISO_8601)); +} +web::json::value ModelBase::toJson( int32_t value ) +{ + return web::json::value::number(value); +} +web::json::value ModelBase::toJson( int64_t value ) +{ + return web::json::value::number(value); +} +web::json::value ModelBase::toJson( double value ) +{ + return web::json::value::number(value); +} + +web::json::value ModelBase::toJson( std::shared_ptr content ) +{ + web::json::value value; + value[U("ContentDisposition")] = ModelBase::toJson(content->getContentDisposition()); + value[U("ContentType")] = ModelBase::toJson(content->getContentType()); + value[U("FileName")] = ModelBase::toJson(content->getFileName()); + value[U("InputStream")] = web::json::value::string( ModelBase::toBase64(content->getData()) ); + return value; +} + +std::shared_ptr ModelBase::fileFromJson(web::json::value& val) +{ + std::shared_ptr content(new HttpContent); + + if(val.has_field(U("ContentDisposition"))) + { + content->setContentDisposition( ModelBase::stringFromJson(val[U("ContentDisposition")]) ); + } + if(val.has_field(U("ContentType"))) + { + content->setContentType( ModelBase::stringFromJson(val[U("ContentType")]) ); + } + if(val.has_field(U("FileName"))) + { + content->setFileName( ModelBase::stringFromJson(val[U("FileName")]) ); + } + if(val.has_field(U("InputStream"))) + { + content->setData( ModelBase::fromBase64( ModelBase::stringFromJson(val[U("InputStream")]) ) ); + } + + return content; +} + +web::json::value ModelBase::toJson( std::shared_ptr content ) +{ + return content.get() ? content->toJson() : web::json::value::null(); +} + +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType) +{ + std::shared_ptr content(new HttpContent); + content->setName( name ); + content->setContentDisposition( U("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(value) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( U("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(value.to_string(utility::datetime::ISO_8601) ) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, std::shared_ptr value ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( value->getContentDisposition() ); + content->setContentType( value->getContentType() ); + content->setData( value->getData() ); + content->setFileName( value->getFileName() ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( U("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(value.serialize()) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( U("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( std::to_string( value ) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( U("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( std::to_string( value ) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( U("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( std::to_string( value ) ) ) ); + return content; +} + +// base64 encoding/decoding based on : https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#C.2B.2B +const static char Base64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +const static char Base64PadChar = '='; +utility::string_t ModelBase::toBase64( utility::string_t value ) +{ + std::shared_ptr source( new std::stringstream( utility::conversions::to_utf8string(value) ) ); + return ModelBase::toBase64(source); +} +utility::string_t ModelBase::toBase64( std::shared_ptr value ) +{ + value->seekg( 0, value->end ); + size_t length = value->tellg(); + value->seekg( 0, value->beg ); + utility::string_t base64; + base64.reserve( ((length / 3) + (length % 3 > 0)) * 4 ); + char read[3] = { 0 }; + uint32_t temp; + for ( size_t idx = 0; idx < length / 3; idx++ ) + { + value->read( read, 3 ); + temp = (read[0]) << 16; + temp += (read[1]) << 8; + temp += (read[2]); + base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); + base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); + base64.append( 1, Base64Chars[(temp & 0x00000FC0) >> 6] ); + base64.append( 1, Base64Chars[(temp & 0x0000003F)] ); + } + switch ( length % 3 ) + { + case 1: + value->read( read, 1 ); + temp = read[0] << 16; + base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); + base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); + base64.append( 2, Base64PadChar ); + break; + case 2: + value->read( read, 2 ); + temp = read[0] << 16; + temp += read[1] << 8; + base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); + base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); + base64.append( 1, Base64Chars[(temp & 0x00000FC0) >> 6] ); + base64.append( 1, Base64PadChar ); + break; + } + return base64; +} + + +std::shared_ptr ModelBase::fromBase64( const utility::string_t& encoded ) +{ + std::shared_ptr result(new std::stringstream); + + char outBuf[3] = { 0 }; + uint32_t temp = 0; + + utility::string_t::const_iterator cursor = encoded.begin(); + while ( cursor < encoded.end() ) + { + for ( size_t quantumPosition = 0; quantumPosition < 4; quantumPosition++ ) + { + temp <<= 6; + if ( *cursor >= 0x41 && *cursor <= 0x5A ) + { + temp |= *cursor - 0x41; + } + else if ( *cursor >= 0x61 && *cursor <= 0x7A ) + { + temp |= *cursor - 0x47; + } + else if ( *cursor >= 0x30 && *cursor <= 0x39 ) + { + temp |= *cursor + 0x04; + } + else if ( *cursor == 0x2B ) + { + temp |= 0x3E; //change to 0x2D for URL alphabet + } + else if ( *cursor == 0x2F ) + { + temp |= 0x3F; //change to 0x5F for URL alphabet + } + else if ( *cursor == Base64PadChar ) //pad + { + switch ( encoded.end() - cursor ) + { + case 1: //One pad character + outBuf[0] = (temp >> 16) & 0x000000FF; + outBuf[1] = (temp >> 8) & 0x000000FF; + result->write( outBuf, 2 ); + return result; + case 2: //Two pad characters + outBuf[0] = (temp >> 10) & 0x000000FF; + result->write( outBuf, 1 ); + return result; + default: + throw web::json::json_exception( U( "Invalid Padding in Base 64!" ) ); + } + } + else + { + throw web::json::json_exception( U( "Non-Valid Character in Base 64!" ) ); + } + ++cursor; + } + + outBuf[0] = (temp >> 16) & 0x000000FF; + outBuf[1] = (temp >> 8) & 0x000000FF; + outBuf[2] = (temp) & 0x000000FF; + result->write( outBuf, 3 ); + } + + return result; +} + +int64_t ModelBase::int64_tFromJson(web::json::value& val) +{ + return val.as_number().to_int64(); +} +int32_t ModelBase::int32_tFromJson(web::json::value& val) +{ + return val.as_integer(); +} +utility::string_t ModelBase::stringFromJson(web::json::value& val) +{ + return val.is_string() ? val.as_string() : U(""); +} + +utility::datetime ModelBase::dateFromJson(web::json::value& val) +{ + return utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601); +} +bool ModelBase::boolFromJson(web::json::value& val) +{ + return val.as_bool(); +} +double ModelBase::doubleFromJson(web::json::value& val) +{ + return val.as_double(); +} + +int64_t ModelBase::int64_tFromHttpContent(std::shared_ptr val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); + + utility::stringstream_t ss(str); + int64_t result = 0; + ss >> result; + return result; +} +int32_t ModelBase::int32_tFromHttpContent(std::shared_ptr val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); + + utility::stringstream_t ss(str); + int32_t result = 0; + ss >> result; + return result; +} +utility::string_t ModelBase::stringFromHttpContent(std::shared_ptr val) +{ + std::shared_ptr data = val->getData(); + data->seekg( 0, data->beg ); + + std::string str((std::istreambuf_iterator(*data.get())), + std::istreambuf_iterator()); + + return utility::conversions::to_utf16string(str); +} +utility::datetime ModelBase::dateFromHttpContent(std::shared_ptr val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); + return utility::datetime::from_string(str, utility::datetime::ISO_8601); +} + +bool ModelBase::boolFromHttpContent(std::shared_ptr val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); + + utility::stringstream_t ss(str); + bool result = false; + ss >> result; + return result; +} +double ModelBase::doubleFromHttpContent(std::shared_ptr val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); + + utility::stringstream_t ss(str); + double result = 0.0; + ss >> result; + return result; +} + +} +} +} +} diff --git a/samples/client/petstore/cpprest/ModelBase.h b/samples/client/petstore/cpprest/ModelBase.h new file mode 100644 index 00000000000..a3dccce65da --- /dev/null +++ b/samples/client/petstore/cpprest/ModelBase.h @@ -0,0 +1,78 @@ +/* + * ModelBase.h + * + * This is the base class for all model classes + */ + +#ifndef ModelBase_H_ +#define ModelBase_H_ + + +#include "HttpContent.h" +#include "MultipartFormData.h" + +#include +#include + +namespace io { +namespace swagger { +namespace client { +namespace model { + +class ModelBase +{ +public: + ModelBase(); + virtual ~ModelBase(); + + virtual void validate() = 0; + + virtual web::json::value toJson() const = 0; + virtual void fromJson(web::json::value& json) = 0; + + virtual void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const = 0; + virtual void fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) = 0; + + static web::json::value toJson( const utility::string_t& value ); + static web::json::value toJson( const utility::datetime& value ); + static web::json::value toJson( std::shared_ptr value ); + static web::json::value toJson( std::shared_ptr value ); + static web::json::value toJson( int32_t value ); + static web::json::value toJson( int64_t value ); + static web::json::value toJson( double value ); + + static int64_t int64_tFromJson(web::json::value& val); + static int32_t int32_tFromJson(web::json::value& val); + static utility::string_t stringFromJson(web::json::value& val); + static utility::datetime dateFromJson(web::json::value& val); + static double doubleFromJson(web::json::value& val); + static bool boolFromJson(web::json::value& val); + static std::shared_ptr fileFromJson(web::json::value& val); + + static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = U("")); + static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = U("")); + static std::shared_ptr toHttpContent( const utility::string_t& name, std::shared_ptr value ); + static std::shared_ptr toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType = U("application/json") ); + static std::shared_ptr toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType = U("") ); + static std::shared_ptr toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType = U("") ); + static std::shared_ptr toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType = U("") ); + + static int64_t int64_tFromHttpContent(std::shared_ptr val); + static int32_t int32_tFromHttpContent(std::shared_ptr val); + static utility::string_t stringFromHttpContent(std::shared_ptr val); + static utility::datetime dateFromHttpContent(std::shared_ptr val); + static bool boolFromHttpContent(std::shared_ptr val); + static double doubleFromHttpContent(std::shared_ptr val); + + + static utility::string_t toBase64( utility::string_t value ); + static utility::string_t toBase64( std::shared_ptr value ); + static std::shared_ptr fromBase64( const utility::string_t& encoded ); +}; + +} +} +} +} + +#endif /* ModelBase_H_ */ \ No newline at end of file diff --git a/samples/client/petstore/cpprest/MultipartFormData.cpp b/samples/client/petstore/cpprest/MultipartFormData.cpp new file mode 100644 index 00000000000..2637af6ed2e --- /dev/null +++ b/samples/client/petstore/cpprest/MultipartFormData.cpp @@ -0,0 +1,101 @@ +#include "MultipartFormData.h" +#include "ModelBase.h" + +#include +#include + +namespace io { +namespace swagger { +namespace client { +namespace model { + +MultipartFormData::MultipartFormData() +{ + utility::stringstream_t uuidString; + uuidString << boost::uuids::random_generator()(); + m_Boundary = uuidString.str(); +} + +MultipartFormData::MultipartFormData(const utility::string_t& boundary) + : m_Boundary(boundary) +{ + +} + +MultipartFormData::~MultipartFormData() +{ +} + +utility::string_t MultipartFormData::getBoundary() +{ + return m_Boundary; +} + +void MultipartFormData::add( std::shared_ptr content ) +{ + m_Contents.push_back( content ); + m_ContentLookup[content->getName()] = content; +} + +bool MultipartFormData::hasContent(const utility::string_t& name) const +{ + return m_ContentLookup.find(name) != m_ContentLookup.end(); +} + +std::shared_ptr MultipartFormData::getContent(const utility::string_t& name) const +{ + auto result = m_ContentLookup.find(name); + if(result == m_ContentLookup.end()) + { + return std::shared_ptr(nullptr); + } + return result->second; +} + +void MultipartFormData::writeTo( std::ostream& target ) +{ + for ( size_t i = 0; i < m_Contents.size(); i++ ) + { + std::shared_ptr content = m_Contents[i]; + + // boundary + target << "\r\n" << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n"; + + // headers + target << "Content-Disposition: " << utility::conversions::to_utf8string( content->getContentDisposition() ); + if ( content->getName().size() > 0 ) + { + target << "; name=\"" << utility::conversions::to_utf8string( content->getName() ) << "\""; + } + if ( content->getFileName().size() > 0 ) + { + target << "; filename=\"" << utility::conversions::to_utf8string( content->getFileName() ) << "\""; + } + target << "\r\n"; + + if ( content->getContentType().size() > 0 ) + { + target << "Content-Type: " << utility::conversions::to_utf8string( content->getContentType() ) << "\r\n"; + } + + target << "\r\n"; + + // body + std::shared_ptr data = content->getData(); + + data->seekg( 0, data->end ); + std::vector dataBytes( data->tellg() ); + + data->seekg( 0, data->beg ); + data->read( &dataBytes[0], dataBytes.size() ); + + std::copy( dataBytes.begin(), dataBytes.end(), std::ostreambuf_iterator( target ) ); + } + + target << "\r\n--" << utility::conversions::to_utf8string( m_Boundary ) << "--\r\n"; +} + +} +} +} +} diff --git a/samples/client/petstore/cpprest/MultipartFormData.h b/samples/client/petstore/cpprest/MultipartFormData.h new file mode 100644 index 00000000000..aab22d7467f --- /dev/null +++ b/samples/client/petstore/cpprest/MultipartFormData.h @@ -0,0 +1,51 @@ +/* + * MultipartFormData.h + * + * This class represents a container for building a application/x-multipart-formdata requests. + */ + +#ifndef MultipartFormData_H_ +#define MultipartFormData_H_ + + +#include "IHttpBody.h" +#include "HttpContent.h" + +#include +#include +#include + +#include + + +namespace io { +namespace swagger { +namespace client { +namespace model { + +class MultipartFormData + : public IHttpBody +{ +public: + MultipartFormData(); + MultipartFormData(const utility::string_t& boundary); + virtual ~MultipartFormData(); + + virtual void add( std::shared_ptr content ); + virtual utility::string_t getBoundary(); + virtual std::shared_ptr getContent(const utility::string_t& name) const; + virtual bool hasContent(const utility::string_t& name) const; + virtual void writeTo( std::ostream& target ); + +protected: + std::vector> m_Contents; + utility::string_t m_Boundary; + std::map> m_ContentLookup; +}; + +} +} +} +} + +#endif /* MultipartFormData_H_ */ \ No newline at end of file diff --git a/samples/client/petstore/cpprest/api/PetApi.cpp b/samples/client/petstore/cpprest/api/PetApi.cpp new file mode 100644 index 00000000000..fe197a14b10 --- /dev/null +++ b/samples/client/petstore/cpprest/api/PetApi.cpp @@ -0,0 +1,1000 @@ + +#include "PetApi.h" +#include "IHttpBody.h" +#include "JsonBody.h" +#include "MultipartFormData.h" + +#include + +#include + +namespace io { +namespace swagger { +namespace client { +namespace api { + +using namespace io::swagger::client::model; + +PetApi::PetApi( std::shared_ptr apiClient ) + : m_ApiClient(apiClient) +{ +} + +PetApi::~PetApi() +{ +} + +pplx::task PetApi::addPet(std::shared_ptr body) +{ + + // verify the required parameter 'body' is set + if (body == nullptr) + { + throw ApiException(400, U("Missing required parameter 'body' when calling PetApi->addPet")); + } + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/pet"); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("PetApi->addPet does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + consumeHttpContentTypes.insert( U("application/json") ); +consumeHttpContentTypes.insert( U("application/xml") ); + + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + web::json::value json; + + json = ModelBase::toJson(body); + + + httpBody = std::shared_ptr( new JsonBody( json ) ); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + std::shared_ptr multipart(new MultipartFormData); + + if(body.get()) + { + body->toMultipart(multipart, U("body")); + } + + + httpBody = multipart; + requestHttpContentType += U("; boundary=") + multipart->getBoundary(); + } + else + { + throw ApiException(415, U("PetApi->addPet does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling addPet: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling addPet: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + return void(); + }); +} +pplx::task PetApi::deletePet(int64_t petId, utility::string_t apiKey) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/pet/{petId}"); + boost::replace_all(path, U("{") U("petId") U("}"), ApiClient::parameterToString(petId)); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("PetApi->deletePet does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + { + + } + + { + headerParams[U("api_key")] = ApiClient::parameterToString(apiKey); + + } + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("PetApi->deletePet does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(path, U("DELETE"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling deletePet: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling deletePet: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + return void(); + }); +} +pplx::task>> PetApi::findPetsByStatus(std::vector status) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/pet/findByStatus"); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("PetApi->findPetsByStatus does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + { + queryParams[U("status")] = ApiClient::parameterToArrayString(status); + + } + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("PetApi->findPetsByStatus does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling findPetsByStatus: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling findPetsByStatus: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + std::vector> result; + + + if(responseHttpContentType == U("application/json")) + { + web::json::value json = web::json::value::parse(response); + + for( auto& item : json.as_array() ) + { + std::shared_ptr itemObj(new Pet()); + itemObj->fromJson(item); + result.push_back(itemObj); + + } + + } + // else if(responseHttpContentType == U("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , U("error calling findPetsByStatus: unsupported response type")); + } + + return result; + }); +} +pplx::task>> PetApi::findPetsByTags(std::vector tags) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/pet/findByTags"); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("PetApi->findPetsByTags does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + { + queryParams[U("tags")] = ApiClient::parameterToArrayString<>(tags); + + } + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("PetApi->findPetsByTags does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling findPetsByTags: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling findPetsByTags: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + std::vector> result; + + + if(responseHttpContentType == U("application/json")) + { + web::json::value json = web::json::value::parse(response); + + for( auto& item : json.as_array() ) + { + std::shared_ptr itemObj(new Pet()); + itemObj->fromJson(item); + result.push_back(itemObj); + + } + + } + // else if(responseHttpContentType == U("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , U("error calling findPetsByStatus: unsupported response type")); + } + + return result; + }); +} +pplx::task> PetApi::getPetById(int64_t petId) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/pet/{petId}"); + boost::replace_all(path, U("{") U("petId") U("}"), ApiClient::parameterToString(petId)); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("PetApi->getPetById does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + { + + } + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("PetApi->getPetById does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t apiKey = apiConfiguration->getApiKey(U("api_key")); + if ( apiKey.size() > 0 ) + { + headerParams[U("api_key")] = apiKey; + } + } + + return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling getPetById: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling getPetById: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + std::shared_ptr result(new Pet()); + + if(responseHttpContentType == U("application/json")) + { + web::json::value json = web::json::value::parse(response); + + result->fromJson(json); + } + // else if(responseHttpContentType == U("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , U("error calling findPetsByStatus: unsupported response type")); + } + + return result; + }); +} +pplx::task PetApi::updatePet(std::shared_ptr body) +{ + + // verify the required parameter 'body' is set + if (body == nullptr) + { + throw ApiException(400, U("Missing required parameter 'body' when calling PetApi->updatePet")); + } + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/pet"); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("PetApi->updatePet does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + consumeHttpContentTypes.insert( U("application/json") ); +consumeHttpContentTypes.insert( U("application/xml") ); + + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + web::json::value json; + + json = ModelBase::toJson(body); + + + httpBody = std::shared_ptr( new JsonBody( json ) ); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + std::shared_ptr multipart(new MultipartFormData); + + if(body.get()) + { + body->toMultipart(multipart, U("body")); + } + + + httpBody = multipart; + requestHttpContentType += U("; boundary=") + multipart->getBoundary(); + } + else + { + throw ApiException(415, U("PetApi->updatePet does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(path, U("PUT"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling updatePet: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling updatePet: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + return void(); + }); +} +pplx::task PetApi::updatePetWithForm(int64_t petId, utility::string_t name, utility::string_t status) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/pet/{petId}"); + boost::replace_all(path, U("{") U("petId") U("}"), ApiClient::parameterToString(petId)); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("PetApi->updatePetWithForm does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + consumeHttpContentTypes.insert( U("application/x-www-form-urlencoded") ); + + + { + + } + + { + formParams[ U("name") ] = ApiClient::parameterToString(name); + + } + + { + formParams[ U("status") ] = ApiClient::parameterToString(status); + + } + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("PetApi->updatePetWithForm does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling updatePetWithForm: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling updatePetWithForm: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + return void(); + }); +} +pplx::task> PetApi::uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/pet/{petId}/uploadImage"); + boost::replace_all(path, U("{") U("petId") U("}"), ApiClient::parameterToString(petId)); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("PetApi->uploadFile does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + consumeHttpContentTypes.insert( U("multipart/form-data") ); + + + { + + } + + { + formParams[ U("additionalMetadata") ] = ApiClient::parameterToString(additionalMetadata); + + } + if (file != nullptr) + { + fileParams[ U("file") ] = file; + + } + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("PetApi->uploadFile does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling uploadFile: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling uploadFile: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + std::shared_ptr result(new ApiResponse()); + + if(responseHttpContentType == U("application/json")) + { + web::json::value json = web::json::value::parse(response); + + result->fromJson(json); + } + // else if(responseHttpContentType == U("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , U("error calling findPetsByStatus: unsupported response type")); + } + + return result; + }); +} + +} +} +} +} + diff --git a/samples/client/petstore/cpprest/api/PetApi.h b/samples/client/petstore/cpprest/api/PetApi.h new file mode 100644 index 00000000000..7aa37d09701 --- /dev/null +++ b/samples/client/petstore/cpprest/api/PetApi.h @@ -0,0 +1,105 @@ +/* + * PetApi.h + * + * + */ + +#ifndef PetApi_H_ +#define PetApi_H_ + + +#include "ApiClient.h" + +#include "Pet.h" +#include +#include "ApiResponse.h" +#include "HttpContent.h" + +namespace io { +namespace swagger { +namespace client { +namespace api { + +using namespace io::swagger::client::model; + +class PetApi +{ +public: + PetApi( std::shared_ptr apiClient ); + virtual ~PetApi(); + /// + /// Add a new pet to the store + /// + /// + /// + /// + /// Pet object that needs to be added to the store + pplx::task addPet(std::shared_ptr body); + /// + /// Deletes a pet + /// + /// + /// + /// + /// Pet id to delete/// (optional) + pplx::task deletePet(int64_t petId, utility::string_t apiKey); + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma separated strings + /// + /// Status values that need to be considered for filter + pplx::task>> findPetsByStatus(std::vector status); + /// + /// Finds Pets by tags + /// + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + pplx::task>> findPetsByTags(std::vector tags); + /// + /// Find pet by ID + /// + /// + /// Returns a single pet + /// + /// ID of pet to return + pplx::task> getPetById(int64_t petId); + /// + /// Update an existing pet + /// + /// + /// + /// + /// Pet object that needs to be added to the store + pplx::task updatePet(std::shared_ptr body); + /// + /// Updates a pet in the store with form data + /// + /// + /// + /// + /// ID of pet that needs to be updated/// Updated name of the pet (optional)/// Updated status of the pet (optional) + pplx::task updatePetWithForm(int64_t petId, utility::string_t name, utility::string_t status); + /// + /// uploads an image + /// + /// + /// + /// + /// ID of pet to update/// Additional data to pass to server (optional)/// file to upload (optional) + pplx::task> uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file); + +protected: + std::shared_ptr m_ApiClient; +}; + +} +} +} +} + +#endif /* PetApi_H_ */ + diff --git a/samples/client/petstore/cpprest/api/StoreApi.cpp b/samples/client/petstore/cpprest/api/StoreApi.cpp new file mode 100644 index 00000000000..ddb7e5b0067 --- /dev/null +++ b/samples/client/petstore/cpprest/api/StoreApi.cpp @@ -0,0 +1,508 @@ + +#include "StoreApi.h" +#include "IHttpBody.h" +#include "JsonBody.h" +#include "MultipartFormData.h" + +#include + +#include + +namespace io { +namespace swagger { +namespace client { +namespace api { + +using namespace io::swagger::client::model; + +StoreApi::StoreApi( std::shared_ptr apiClient ) + : m_ApiClient(apiClient) +{ +} + +StoreApi::~StoreApi() +{ +} + +pplx::task StoreApi::deleteOrder(utility::string_t orderId) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/store/order/{orderId}"); + boost::replace_all(path, U("{") U("orderId") U("}"), ApiClient::parameterToString(orderId)); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("StoreApi->deleteOrder does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + { + + } + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("StoreApi->deleteOrder does not consume any supported media type")); + } + + + return m_ApiClient->callApi(path, U("DELETE"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling deleteOrder: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling deleteOrder: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + return void(); + }); +} +pplx::task> StoreApi::getInventory() +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/store/inventory"); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("StoreApi->getInventory does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("StoreApi->getInventory does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t apiKey = apiConfiguration->getApiKey(U("api_key")); + if ( apiKey.size() > 0 ) + { + headerParams[U("api_key")] = apiKey; + } + } + + return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling getInventory: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling getInventory: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + std::map result; + + + if(responseHttpContentType == U("application/json")) + { + web::json::value json = web::json::value::parse(response); + + for( auto& item : json.as_object() ) + { + result[item.first] = ModelBase::int32_tFromJson(item.second); + + } + + } + // else if(responseHttpContentType == U("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , U("error calling findPetsByStatus: unsupported response type")); + } + + return result; + }); +} +pplx::task> StoreApi::getOrderById(int64_t orderId) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/store/order/{orderId}"); + boost::replace_all(path, U("{") U("orderId") U("}"), ApiClient::parameterToString(orderId)); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("StoreApi->getOrderById does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + { + + } + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("StoreApi->getOrderById does not consume any supported media type")); + } + + + return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling getOrderById: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling getOrderById: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + std::shared_ptr result(new Order()); + + if(responseHttpContentType == U("application/json")) + { + web::json::value json = web::json::value::parse(response); + + result->fromJson(json); + } + // else if(responseHttpContentType == U("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , U("error calling findPetsByStatus: unsupported response type")); + } + + return result; + }); +} +pplx::task> StoreApi::placeOrder(std::shared_ptr body) +{ + + // verify the required parameter 'body' is set + if (body == nullptr) + { + throw ApiException(400, U("Missing required parameter 'body' when calling StoreApi->placeOrder")); + } + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/store/order"); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("StoreApi->placeOrder does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + web::json::value json; + + json = ModelBase::toJson(body); + + + httpBody = std::shared_ptr( new JsonBody( json ) ); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + std::shared_ptr multipart(new MultipartFormData); + + if(body.get()) + { + body->toMultipart(multipart, U("body")); + } + + + httpBody = multipart; + requestHttpContentType += U("; boundary=") + multipart->getBoundary(); + } + else + { + throw ApiException(415, U("StoreApi->placeOrder does not consume any supported media type")); + } + + + return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling placeOrder: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling placeOrder: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + std::shared_ptr result(new Order()); + + if(responseHttpContentType == U("application/json")) + { + web::json::value json = web::json::value::parse(response); + + result->fromJson(json); + } + // else if(responseHttpContentType == U("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , U("error calling findPetsByStatus: unsupported response type")); + } + + return result; + }); +} + +} +} +} +} + diff --git a/samples/client/petstore/cpprest/api/StoreApi.h b/samples/client/petstore/cpprest/api/StoreApi.h new file mode 100644 index 00000000000..c076a255359 --- /dev/null +++ b/samples/client/petstore/cpprest/api/StoreApi.h @@ -0,0 +1,72 @@ +/* + * StoreApi.h + * + * + */ + +#ifndef StoreApi_H_ +#define StoreApi_H_ + + +#include "ApiClient.h" + +#include +#include +#include "Order.h" + +namespace io { +namespace swagger { +namespace client { +namespace api { + +using namespace io::swagger::client::model; + +class StoreApi +{ +public: + StoreApi( std::shared_ptr apiClient ); + virtual ~StoreApi(); + /// + /// Delete purchase order by ID + /// + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + pplx::task deleteOrder(utility::string_t orderId); + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + + pplx::task> getInventory(); + /// + /// Find purchase order by ID + /// + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// ID of pet that needs to be fetched + pplx::task> getOrderById(int64_t orderId); + /// + /// Place an order for a pet + /// + /// + /// + /// + /// order placed for purchasing the pet + pplx::task> placeOrder(std::shared_ptr body); + +protected: + std::shared_ptr m_ApiClient; +}; + +} +} +} +} + +#endif /* StoreApi_H_ */ + diff --git a/samples/client/petstore/cpprest/api/UserApi.cpp b/samples/client/petstore/cpprest/api/UserApi.cpp new file mode 100644 index 00000000000..e17a1acf42b --- /dev/null +++ b/samples/client/petstore/cpprest/api/UserApi.cpp @@ -0,0 +1,954 @@ + +#include "UserApi.h" +#include "IHttpBody.h" +#include "JsonBody.h" +#include "MultipartFormData.h" + +#include + +#include + +namespace io { +namespace swagger { +namespace client { +namespace api { + +using namespace io::swagger::client::model; + +UserApi::UserApi( std::shared_ptr apiClient ) + : m_ApiClient(apiClient) +{ +} + +UserApi::~UserApi() +{ +} + +pplx::task UserApi::createUser(std::shared_ptr body) +{ + + // verify the required parameter 'body' is set + if (body == nullptr) + { + throw ApiException(400, U("Missing required parameter 'body' when calling UserApi->createUser")); + } + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/user"); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("UserApi->createUser does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + web::json::value json; + + json = ModelBase::toJson(body); + + + httpBody = std::shared_ptr( new JsonBody( json ) ); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + std::shared_ptr multipart(new MultipartFormData); + + if(body.get()) + { + body->toMultipart(multipart, U("body")); + } + + + httpBody = multipart; + requestHttpContentType += U("; boundary=") + multipart->getBoundary(); + } + else + { + throw ApiException(415, U("UserApi->createUser does not consume any supported media type")); + } + + + return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling createUser: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling createUser: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + return void(); + }); +} +pplx::task UserApi::createUsersWithArrayInput(std::vector> body) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/user/createWithArray"); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("UserApi->createUsersWithArrayInput does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + web::json::value json; + + + { + std::vector jsonArray; + for( auto& item : body ) + { + jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() ); + + } + json = web::json::value::array(jsonArray); + } + + + httpBody = std::shared_ptr( new JsonBody( json ) ); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + std::shared_ptr multipart(new MultipartFormData); + + { + std::vector jsonArray; + for( auto& item : body ) + { + jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() ); + + } + multipart->add(ModelBase::toHttpContent(U("body"), web::json::value::array(jsonArray), U("application/json"))); + } + + + httpBody = multipart; + requestHttpContentType += U("; boundary=") + multipart->getBoundary(); + } + else + { + throw ApiException(415, U("UserApi->createUsersWithArrayInput does not consume any supported media type")); + } + + + return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling createUsersWithArrayInput: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling createUsersWithArrayInput: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + return void(); + }); +} +pplx::task UserApi::createUsersWithListInput(std::vector> body) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/user/createWithList"); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("UserApi->createUsersWithListInput does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + web::json::value json; + + + { + std::vector jsonArray; + for( auto& item : body ) + { + jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() ); + + } + json = web::json::value::array(jsonArray); + } + + + httpBody = std::shared_ptr( new JsonBody( json ) ); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + std::shared_ptr multipart(new MultipartFormData); + + { + std::vector jsonArray; + for( auto& item : body ) + { + jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() ); + + } + multipart->add(ModelBase::toHttpContent(U("body"), web::json::value::array(jsonArray), U("application/json"))); + } + + + httpBody = multipart; + requestHttpContentType += U("; boundary=") + multipart->getBoundary(); + } + else + { + throw ApiException(415, U("UserApi->createUsersWithListInput does not consume any supported media type")); + } + + + return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling createUsersWithListInput: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling createUsersWithListInput: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + return void(); + }); +} +pplx::task UserApi::deleteUser(utility::string_t username) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/user/{username}"); + boost::replace_all(path, U("{") U("username") U("}"), ApiClient::parameterToString(username)); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("UserApi->deleteUser does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + { + + } + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("UserApi->deleteUser does not consume any supported media type")); + } + + + return m_ApiClient->callApi(path, U("DELETE"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling deleteUser: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling deleteUser: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + return void(); + }); +} +pplx::task> UserApi::getUserByName(utility::string_t username) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/user/{username}"); + boost::replace_all(path, U("{") U("username") U("}"), ApiClient::parameterToString(username)); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("UserApi->getUserByName does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + { + + } + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("UserApi->getUserByName does not consume any supported media type")); + } + + + return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling getUserByName: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling getUserByName: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + std::shared_ptr result(new User()); + + if(responseHttpContentType == U("application/json")) + { + web::json::value json = web::json::value::parse(response); + + result->fromJson(json); + } + // else if(responseHttpContentType == U("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , U("error calling findPetsByStatus: unsupported response type")); + } + + return result; + }); +} +pplx::task UserApi::loginUser(utility::string_t username, utility::string_t password) +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/user/login"); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("UserApi->loginUser does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + { + queryParams[U("username")] = ApiClient::parameterToString(username); + + } + + { + queryParams[U("password")] = ApiClient::parameterToString(password); + + } + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("UserApi->loginUser does not consume any supported media type")); + } + + + return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling loginUser: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling loginUser: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + utility::string_t result(U("")); + + if(responseHttpContentType == U("application/json")) + { + web::json::value json = web::json::value::parse(response); + + result = ModelBase::stringFromJson(json); + + } + // else if(responseHttpContentType == U("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , U("error calling findPetsByStatus: unsupported response type")); + } + + return result; + }); +} +pplx::task UserApi::logoutUser() +{ + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/user/logout"); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("UserApi->logoutUser does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + } + else + { + throw ApiException(415, U("UserApi->logoutUser does not consume any supported media type")); + } + + + return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling logoutUser: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling logoutUser: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + return void(); + }); +} +pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr body) +{ + + // verify the required parameter 'body' is set + if (body == nullptr) + { + throw ApiException(400, U("Missing required parameter 'body' when calling UserApi->updateUser")); + } + + + std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t path = U("/user/{username}"); + boost::replace_all(path, U("{") U("username") U("}"), ApiClient::parameterToString(username)); + + std::map queryParams; + std::map headerParams( apiConfiguration->getDefaultHeaders() ); + std::map formParams; + std::map> fileParams; + + std::unordered_set responseHttpContentTypes; + responseHttpContentTypes.insert( U("application/xml") ); +responseHttpContentTypes.insert( U("application/json") ); + + utility::string_t responseHttpContentType; + + // use JSON if possible + if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("application/json"); + } + // multipart formdata + else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() ) + { + responseHttpContentType = U("multipart/form-data"); + } + else + { + throw ApiException(400, U("UserApi->updateUser does not produce any supported media type")); + } + + headerParams[U("Accept")] = responseHttpContentType; + + std::unordered_set consumeHttpContentTypes; + + + { + + } + + + std::shared_ptr httpBody; + utility::string_t requestHttpContentType; + + // use JSON if possible + if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("application/json"); + + web::json::value json; + + json = ModelBase::toJson(body); + + + httpBody = std::shared_ptr( new JsonBody( json ) ); + + } + // multipart formdata + else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() ) + { + requestHttpContentType = U("multipart/form-data"); + + std::shared_ptr multipart(new MultipartFormData); + + if(body.get()) + { + body->toMultipart(multipart, U("body")); + } + + + httpBody = multipart; + requestHttpContentType += U("; boundary=") + multipart->getBoundary(); + } + else + { + throw ApiException(415, U("UserApi->updateUser does not consume any supported media type")); + } + + + return m_ApiClient->callApi(path, U("PUT"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) + .then([=](web::http::http_response response) + { + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling updateUser: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } + + // check response content type + if(response.headers().has(U("Content-Type"))) + { + utility::string_t contentType = response.headers()[U("Content-Type")]; + if( contentType.find(responseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , U("error calling updateUser: unexpected response type: ") + contentType + , std::make_shared(response.extract_utf8string(true).get())); + } + } + + return response.extract_string(); + }) + .then([=](utility::string_t response) + { + return void(); + }); +} + +} +} +} +} + diff --git a/samples/client/petstore/cpprest/api/UserApi.h b/samples/client/petstore/cpprest/api/UserApi.h new file mode 100644 index 00000000000..217ad44a12e --- /dev/null +++ b/samples/client/petstore/cpprest/api/UserApi.h @@ -0,0 +1,104 @@ +/* + * UserApi.h + * + * + */ + +#ifndef UserApi_H_ +#define UserApi_H_ + + +#include "ApiClient.h" + +#include "User.h" +#include +#include + +namespace io { +namespace swagger { +namespace client { +namespace api { + +using namespace io::swagger::client::model; + +class UserApi +{ +public: + UserApi( std::shared_ptr apiClient ); + virtual ~UserApi(); + /// + /// Create user + /// + /// + /// This can only be done by the logged in user. + /// + /// Created user object + pplx::task createUser(std::shared_ptr body); + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + pplx::task createUsersWithArrayInput(std::vector> body); + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + pplx::task createUsersWithListInput(std::vector> body); + /// + /// Delete user + /// + /// + /// This can only be done by the logged in user. + /// + /// The name that needs to be deleted + pplx::task deleteUser(utility::string_t username); + /// + /// Get user by user name + /// + /// + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + pplx::task> getUserByName(utility::string_t username); + /// + /// Logs user into the system + /// + /// + /// + /// + /// The user name for login/// The password for login in clear text + pplx::task loginUser(utility::string_t username, utility::string_t password); + /// + /// Logs out current logged in user session + /// + /// + /// + /// + + pplx::task logoutUser(); + /// + /// Updated user + /// + /// + /// This can only be done by the logged in user. + /// + /// name that need to be deleted/// Updated user object + pplx::task updateUser(utility::string_t username, std::shared_ptr body); + +protected: + std::shared_ptr m_ApiClient; +}; + +} +} +} +} + +#endif /* UserApi_H_ */ + diff --git a/samples/client/petstore/cpprest/git_push.sh b/samples/client/petstore/cpprest/git_push.sh new file mode 100644 index 00000000000..970522bca1f --- /dev/null +++ b/samples/client/petstore/cpprest/git_push.sh @@ -0,0 +1,51 @@ +#!/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-cpprest "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_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="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/cpprest/model/ApiResponse.cpp b/samples/client/petstore/cpprest/model/ApiResponse.cpp new file mode 100644 index 00000000000..66ee88ef464 --- /dev/null +++ b/samples/client/petstore/cpprest/model/ApiResponse.cpp @@ -0,0 +1,177 @@ + + +#include "ApiResponse.h" + +namespace io { +namespace swagger { +namespace client { +namespace model { + +ApiResponse::ApiResponse() +{ + m_Code = 0; + m_CodeIsSet = false; + m_Type = U(""); + m_TypeIsSet = false; + m_Message = U(""); + m_MessageIsSet = false; + +} + +ApiResponse::~ApiResponse() +{ +} + +void ApiResponse::validate() +{ + // TODO: implement validation +} + +web::json::value ApiResponse::toJson() const +{ + web::json::value val = web::json::value::object(); + + if(m_CodeIsSet) + { + val[U("code")] = ModelBase::toJson(m_Code); + } + if(m_TypeIsSet) + { + val[U("type")] = ModelBase::toJson(m_Type); + } + if(m_MessageIsSet) + { + val[U("message")] = ModelBase::toJson(m_Message); + } + + + return val; +} + +void ApiResponse::fromJson(web::json::value& val) +{ + if(val.has_field(U("code"))) + { + setCode(ModelBase::int32_tFromJson(val[U("code")])); + } + if(val.has_field(U("type"))) + { + setType(ModelBase::stringFromJson(val[U("type")])); + + } + if(val.has_field(U("message"))) + { + setMessage(ModelBase::stringFromJson(val[U("message")])); + + } + +} + +void ApiResponse::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + if(m_CodeIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("code"), m_Code)); + } + if(m_TypeIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("type"), m_Type)); + + } + if(m_MessageIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("message"), m_Message)); + + } + +} + +void ApiResponse::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + if(multipart->hasContent(U("code"))) + { + setCode(ModelBase::int32_tFromHttpContent(multipart->getContent(U("code")))); + } + if(multipart->hasContent(U("type"))) + { + setType(ModelBase::stringFromHttpContent(multipart->getContent(U("type")))); + + } + if(multipart->hasContent(U("message"))) + { + setMessage(ModelBase::stringFromHttpContent(multipart->getContent(U("message")))); + + } + +} + + +int32_t ApiResponse::getCode() const +{ + return m_Code; +} +void ApiResponse::setCode(int32_t value) +{ + m_Code = value; + m_CodeIsSet = true; +} +bool ApiResponse::codeIsSet() const +{ + return m_CodeIsSet; +} +void ApiResponse::unsetCode() +{ + m_CodeIsSet = false; +} +utility::string_t ApiResponse::getType() const +{ + return m_Type; +} +void ApiResponse::setType(utility::string_t value) +{ + m_Type = value; + m_TypeIsSet = true; +} +bool ApiResponse::typeIsSet() const +{ + return m_TypeIsSet; +} +void ApiResponse::unsetType() +{ + m_TypeIsSet = false; +} +utility::string_t ApiResponse::getMessage() const +{ + return m_Message; +} +void ApiResponse::setMessage(utility::string_t value) +{ + m_Message = value; + m_MessageIsSet = true; +} +bool ApiResponse::messageIsSet() const +{ + return m_MessageIsSet; +} +void ApiResponse::unsetMessage() +{ + m_MessageIsSet = false; +} + +} +} +} +} + diff --git a/samples/client/petstore/cpprest/model/ApiResponse.h b/samples/client/petstore/cpprest/model/ApiResponse.h new file mode 100644 index 00000000000..ca9e137b6b2 --- /dev/null +++ b/samples/client/petstore/cpprest/model/ApiResponse.h @@ -0,0 +1,80 @@ +/* + * ApiResponse.h + * + * + */ + +#ifndef ApiResponse_H_ +#define ApiResponse_H_ + + +#include "ModelBase.h" + +#include + +namespace io { +namespace swagger { +namespace client { +namespace model { + +/// +/// +/// +class ApiResponse + : public ModelBase +{ +public: + ApiResponse(); + virtual ~ApiResponse(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + void fromJson(web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// ApiResponse members + + /// + /// + /// + int32_t getCode() const; + void setCode(int32_t value); + bool codeIsSet() const; + void unsetCode(); + /// + /// + /// + utility::string_t getType() const; + void setType(utility::string_t value); + bool typeIsSet() const; + void unsetType(); + /// + /// + /// + utility::string_t getMessage() const; + void setMessage(utility::string_t value); + bool messageIsSet() const; + void unsetMessage(); + +protected: + int32_t m_Code; + bool m_CodeIsSet; +utility::string_t m_Type; + bool m_TypeIsSet; +utility::string_t m_Message; + bool m_MessageIsSet; +}; + +} +} +} +} + +#endif /* ApiResponse_H_ */ diff --git a/samples/client/petstore/cpprest/model/Category.cpp b/samples/client/petstore/cpprest/model/Category.cpp new file mode 100644 index 00000000000..3420df3392c --- /dev/null +++ b/samples/client/petstore/cpprest/model/Category.cpp @@ -0,0 +1,139 @@ + + +#include "Category.h" + +namespace io { +namespace swagger { +namespace client { +namespace model { + +Category::Category() +{ + m_Id = 0L; + m_IdIsSet = false; + m_Name = U(""); + m_NameIsSet = false; + +} + +Category::~Category() +{ +} + +void Category::validate() +{ + // TODO: implement validation +} + +web::json::value Category::toJson() const +{ + web::json::value val = web::json::value::object(); + + if(m_IdIsSet) + { + val[U("id")] = ModelBase::toJson(m_Id); + } + if(m_NameIsSet) + { + val[U("name")] = ModelBase::toJson(m_Name); + } + + + return val; +} + +void Category::fromJson(web::json::value& val) +{ + if(val.has_field(U("id"))) + { + setId(ModelBase::int64_tFromJson(val[U("id")])); + } + if(val.has_field(U("name"))) + { + setName(ModelBase::stringFromJson(val[U("name")])); + + } + +} + +void Category::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("id"), m_Id)); + } + if(m_NameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("name"), m_Name)); + + } + +} + +void Category::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + if(multipart->hasContent(U("id"))) + { + setId(ModelBase::int64_tFromHttpContent(multipart->getContent(U("id")))); + } + if(multipart->hasContent(U("name"))) + { + setName(ModelBase::stringFromHttpContent(multipart->getContent(U("name")))); + + } + +} + + +int64_t Category::getId() const +{ + return m_Id; +} +void Category::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} +bool Category::idIsSet() const +{ + return m_IdIsSet; +} +void Category::unsetId() +{ + m_IdIsSet = false; +} +utility::string_t Category::getName() const +{ + return m_Name; +} +void Category::setName(utility::string_t value) +{ + m_Name = value; + m_NameIsSet = true; +} +bool Category::nameIsSet() const +{ + return m_NameIsSet; +} +void Category::unsetName() +{ + m_NameIsSet = false; +} + +} +} +} +} + diff --git a/samples/client/petstore/cpprest/model/Category.h b/samples/client/petstore/cpprest/model/Category.h new file mode 100644 index 00000000000..d472fb13927 --- /dev/null +++ b/samples/client/petstore/cpprest/model/Category.h @@ -0,0 +1,71 @@ +/* + * Category.h + * + * + */ + +#ifndef Category_H_ +#define Category_H_ + + +#include "ModelBase.h" + +#include + +namespace io { +namespace swagger { +namespace client { +namespace model { + +/// +/// +/// +class Category + : public ModelBase +{ +public: + Category(); + virtual ~Category(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + void fromJson(web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Category members + + /// + /// + /// + int64_t getId() const; + void setId(int64_t value); + bool idIsSet() const; + void unsetId(); + /// + /// + /// + utility::string_t getName() const; + void setName(utility::string_t value); + bool nameIsSet() const; + void unsetName(); + +protected: + int64_t m_Id; + bool m_IdIsSet; +utility::string_t m_Name; + bool m_NameIsSet; +}; + +} +} +} +} + +#endif /* Category_H_ */ diff --git a/samples/client/petstore/cpprest/model/Order.cpp b/samples/client/petstore/cpprest/model/Order.cpp new file mode 100644 index 00000000000..ca0ecf8f93b --- /dev/null +++ b/samples/client/petstore/cpprest/model/Order.cpp @@ -0,0 +1,282 @@ + + +#include "Order.h" + +namespace io { +namespace swagger { +namespace client { +namespace model { + +Order::Order() +{ + m_Id = 0L; + m_IdIsSet = false; + m_PetId = 0L; + m_PetIdIsSet = false; + m_Quantity = 0; + m_QuantityIsSet = false; + m_ShipDate = utility::datetime(); + m_ShipDateIsSet = false; + m_Status = U(""); + m_StatusIsSet = false; + m_Complete = false; + m_CompleteIsSet = false; + +} + +Order::~Order() +{ +} + +void Order::validate() +{ + // TODO: implement validation +} + +web::json::value Order::toJson() const +{ + web::json::value val = web::json::value::object(); + + if(m_IdIsSet) + { + val[U("id")] = ModelBase::toJson(m_Id); + } + if(m_PetIdIsSet) + { + val[U("petId")] = ModelBase::toJson(m_PetId); + } + if(m_QuantityIsSet) + { + val[U("quantity")] = ModelBase::toJson(m_Quantity); + } + if(m_ShipDateIsSet) + { + val[U("shipDate")] = ModelBase::toJson(m_ShipDate); + } + if(m_StatusIsSet) + { + val[U("status")] = ModelBase::toJson(m_Status); + } + if(m_CompleteIsSet) + { + val[U("complete")] = ModelBase::toJson(m_Complete); + } + + + return val; +} + +void Order::fromJson(web::json::value& val) +{ + if(val.has_field(U("id"))) + { + setId(ModelBase::int64_tFromJson(val[U("id")])); + } + if(val.has_field(U("petId"))) + { + setPetId(ModelBase::int64_tFromJson(val[U("petId")])); + } + if(val.has_field(U("quantity"))) + { + setQuantity(ModelBase::int32_tFromJson(val[U("quantity")])); + } + if(val.has_field(U("shipDate"))) + { + setShipDate(ModelBase::dateFromJson(val[U("shipDate")])); + + } + if(val.has_field(U("status"))) + { + setStatus(ModelBase::stringFromJson(val[U("status")])); + + } + if(val.has_field(U("complete"))) + { + setComplete(ModelBase::boolFromJson(val[U("complete")])); + } + +} + +void Order::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("id"), m_Id)); + } + if(m_PetIdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("petId"), m_PetId)); + } + if(m_QuantityIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("quantity"), m_Quantity)); + } + if(m_ShipDateIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("shipDate"), m_ShipDate)); + + } + if(m_StatusIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("status"), m_Status)); + + } + if(m_CompleteIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("complete"), m_Complete)); + } + +} + +void Order::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + if(multipart->hasContent(U("id"))) + { + setId(ModelBase::int64_tFromHttpContent(multipart->getContent(U("id")))); + } + if(multipart->hasContent(U("petId"))) + { + setPetId(ModelBase::int64_tFromHttpContent(multipart->getContent(U("petId")))); + } + if(multipart->hasContent(U("quantity"))) + { + setQuantity(ModelBase::int32_tFromHttpContent(multipart->getContent(U("quantity")))); + } + if(multipart->hasContent(U("shipDate"))) + { + setShipDate(ModelBase::dateFromHttpContent(multipart->getContent(U("shipDate")))); + + } + if(multipart->hasContent(U("status"))) + { + setStatus(ModelBase::stringFromHttpContent(multipart->getContent(U("status")))); + + } + if(multipart->hasContent(U("complete"))) + { + setComplete(ModelBase::boolFromHttpContent(multipart->getContent(U("complete")))); + } + +} + + +int64_t Order::getId() const +{ + return m_Id; +} +void Order::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} +bool Order::idIsSet() const +{ + return m_IdIsSet; +} +void Order::unsetId() +{ + m_IdIsSet = false; +} +int64_t Order::getPetId() const +{ + return m_PetId; +} +void Order::setPetId(int64_t value) +{ + m_PetId = value; + m_PetIdIsSet = true; +} +bool Order::petIdIsSet() const +{ + return m_PetIdIsSet; +} +void Order::unsetPetId() +{ + m_PetIdIsSet = false; +} +int32_t Order::getQuantity() const +{ + return m_Quantity; +} +void Order::setQuantity(int32_t value) +{ + m_Quantity = value; + m_QuantityIsSet = true; +} +bool Order::quantityIsSet() const +{ + return m_QuantityIsSet; +} +void Order::unsetQuantity() +{ + m_QuantityIsSet = false; +} +utility::datetime Order::getShipDate() const +{ + return m_ShipDate; +} +void Order::setShipDate(utility::datetime value) +{ + m_ShipDate = value; + m_ShipDateIsSet = true; +} +bool Order::shipDateIsSet() const +{ + return m_ShipDateIsSet; +} +void Order::unsetShipDate() +{ + m_ShipDateIsSet = false; +} +utility::string_t Order::getStatus() const +{ + return m_Status; +} +void Order::setStatus(utility::string_t value) +{ + m_Status = value; + m_StatusIsSet = true; +} +bool Order::statusIsSet() const +{ + return m_StatusIsSet; +} +void Order::unsetStatus() +{ + m_StatusIsSet = false; +} +bool Order::getComplete() const +{ + return m_Complete; +} +void Order::setComplete(bool value) +{ + m_Complete = value; + m_CompleteIsSet = true; +} +bool Order::completeIsSet() const +{ + return m_CompleteIsSet; +} +void Order::unsetComplete() +{ + m_CompleteIsSet = false; +} + +} +} +} +} + diff --git a/samples/client/petstore/cpprest/model/Order.h b/samples/client/petstore/cpprest/model/Order.h new file mode 100644 index 00000000000..8fe54141d10 --- /dev/null +++ b/samples/client/petstore/cpprest/model/Order.h @@ -0,0 +1,107 @@ +/* + * Order.h + * + * + */ + +#ifndef Order_H_ +#define Order_H_ + + +#include "ModelBase.h" + +#include + +namespace io { +namespace swagger { +namespace client { +namespace model { + +/// +/// +/// +class Order + : public ModelBase +{ +public: + Order(); + virtual ~Order(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + void fromJson(web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Order members + + /// + /// + /// + int64_t getId() const; + void setId(int64_t value); + bool idIsSet() const; + void unsetId(); + /// + /// + /// + int64_t getPetId() const; + void setPetId(int64_t value); + bool petIdIsSet() const; + void unsetPetId(); + /// + /// + /// + int32_t getQuantity() const; + void setQuantity(int32_t value); + bool quantityIsSet() const; + void unsetQuantity(); + /// + /// + /// + utility::datetime getShipDate() const; + void setShipDate(utility::datetime value); + bool shipDateIsSet() const; + void unsetShipDate(); + /// + /// Order Status + /// + utility::string_t getStatus() const; + void setStatus(utility::string_t value); + bool statusIsSet() const; + void unsetStatus(); + /// + /// + /// + bool getComplete() const; + void setComplete(bool value); + bool completeIsSet() const; + void unsetComplete(); + +protected: + int64_t m_Id; + bool m_IdIsSet; +int64_t m_PetId; + bool m_PetIdIsSet; +int32_t m_Quantity; + bool m_QuantityIsSet; +utility::datetime m_ShipDate; + bool m_ShipDateIsSet; +utility::string_t m_Status; + bool m_StatusIsSet; +bool m_Complete; + bool m_CompleteIsSet; +}; + +} +} +} +} + +#endif /* Order_H_ */ diff --git a/samples/client/petstore/cpprest/model/Pet.cpp b/samples/client/petstore/cpprest/model/Pet.cpp new file mode 100644 index 00000000000..4589b73d871 --- /dev/null +++ b/samples/client/petstore/cpprest/model/Pet.cpp @@ -0,0 +1,324 @@ + + +#include "Pet.h" + +namespace io { +namespace swagger { +namespace client { +namespace model { + +Pet::Pet() +{ + m_Id = 0L; + m_IdIsSet = false; + m_CategoryIsSet = false; + m_Name = U(""); + m_TagsIsSet = false; + m_Status = U(""); + m_StatusIsSet = false; + +} + +Pet::~Pet() +{ +} + +void Pet::validate() +{ + // TODO: implement validation +} + +web::json::value Pet::toJson() const +{ + web::json::value val = web::json::value::object(); + + if(m_IdIsSet) + { + val[U("id")] = ModelBase::toJson(m_Id); + } + if(m_CategoryIsSet) + { + val[U("category")] = ModelBase::toJson(m_Category); + } + val[U("name")] = ModelBase::toJson(m_Name); + { + std::vector jsonArray; + for( auto& item : m_PhotoUrls ) + { + jsonArray.push_back(ModelBase::toJson(item)); + } + val[U("photoUrls")] = web::json::value::array(jsonArray); + } + { + std::vector jsonArray; + for( auto& item : m_Tags ) + { + jsonArray.push_back(ModelBase::toJson(item)); + } + + if(jsonArray.size() > 0) + { + val[U("tags")] = web::json::value::array(jsonArray); + } + } + if(m_StatusIsSet) + { + val[U("status")] = ModelBase::toJson(m_Status); + } + + + return val; +} + +void Pet::fromJson(web::json::value& val) +{ + if(val.has_field(U("id"))) + { + setId(ModelBase::int64_tFromJson(val[U("id")])); + } + if(val.has_field(U("category"))) + { + if(!val[U("category")].is_null()) + { + std::shared_ptr newItem(new Category()); + newItem->fromJson(val[U("category")]); + setCategory( newItem ); + } + + } + setName(ModelBase::stringFromJson(val[U("name")])); + { + m_PhotoUrls.clear(); + std::vector jsonArray; + for( auto& item : val[U("photoUrls")].as_array() ) + { + m_PhotoUrls.push_back(ModelBase::stringFromJson(item)); + + } + } + { + m_Tags.clear(); + std::vector jsonArray; + if(val.has_field(U("tags"))) + { + for( auto& item : val[U("tags")].as_array() ) + { + + if(item.is_null()) + { + m_Tags.push_back( std::shared_ptr(nullptr) ); + } + else + { + std::shared_ptr newItem(new Tag()); + newItem->fromJson(item); + m_Tags.push_back( newItem ); + } + + } + } + } + if(val.has_field(U("status"))) + { + setStatus(ModelBase::stringFromJson(val[U("status")])); + + } + +} + +void Pet::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("id"), m_Id)); + } + if(m_CategoryIsSet) + { + if (m_Category.get()) + { + m_Category->toMultipart(multipart, U("category.")); + } + + } + multipart->add(ModelBase::toHttpContent(namePrefix + U("name"), m_Name)); + { + std::vector jsonArray; + for( auto& item : m_PhotoUrls ) + { + jsonArray.push_back(ModelBase::toJson(item)); + } + multipart->add(ModelBase::toHttpContent(namePrefix + U("photoUrls"), web::json::value::array(jsonArray), U("application/json"))); + } + { + std::vector jsonArray; + for( auto& item : m_Tags ) + { + jsonArray.push_back(ModelBase::toJson(item)); + } + + if(jsonArray.size() > 0) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("tags"), web::json::value::array(jsonArray), U("application/json"))); + } + } + if(m_StatusIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("status"), m_Status)); + + } + +} + +void Pet::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + if(multipart->hasContent(U("id"))) + { + setId(ModelBase::int64_tFromHttpContent(multipart->getContent(U("id")))); + } + if(multipart->hasContent(U("category"))) + { + if(multipart->hasContent(U("category"))) + { + std::shared_ptr newItem(new Category()); + newItem->fromMultiPart(multipart, U("category.")); + setCategory( newItem ); + } + + } + setName(ModelBase::stringFromHttpContent(multipart->getContent(U("name")))); + { + m_PhotoUrls.clear(); + + web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(U("photoUrls")))); + for( auto& item : jsonArray.as_array() ) + { + m_PhotoUrls.push_back(ModelBase::stringFromJson(item)); + + } + } + { + m_Tags.clear(); + if(multipart->hasContent(U("tags"))) + { + + web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(U("tags")))); + for( auto& item : jsonArray.as_array() ) + { + + if(item.is_null()) + { + m_Tags.push_back( std::shared_ptr(nullptr) ); + } + else + { + std::shared_ptr newItem(new Tag()); + newItem->fromJson(item); + m_Tags.push_back( newItem ); + } + + } + } + } + if(multipart->hasContent(U("status"))) + { + setStatus(ModelBase::stringFromHttpContent(multipart->getContent(U("status")))); + + } + +} + + +int64_t Pet::getId() const +{ + return m_Id; +} +void Pet::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} +bool Pet::idIsSet() const +{ + return m_IdIsSet; +} +void Pet::unsetId() +{ + m_IdIsSet = false; +} +std::shared_ptr Pet::getCategory() const +{ + return m_Category; +} +void Pet::setCategory(std::shared_ptr value) +{ + m_Category = value; + m_CategoryIsSet = true; +} +bool Pet::categoryIsSet() const +{ + return m_CategoryIsSet; +} +void Pet::unsetCategory() +{ + m_CategoryIsSet = false; +} +utility::string_t Pet::getName() const +{ + return m_Name; +} +void Pet::setName(utility::string_t value) +{ + m_Name = value; + +} +std::vector& Pet::getPhotoUrls() +{ + return m_PhotoUrls; +} +std::vector>& Pet::getTags() +{ + return m_Tags; +} +bool Pet::tagsIsSet() const +{ + return m_TagsIsSet; +} +void Pet::unsetTags() +{ + m_TagsIsSet = false; +} +utility::string_t Pet::getStatus() const +{ + return m_Status; +} +void Pet::setStatus(utility::string_t value) +{ + m_Status = value; + m_StatusIsSet = true; +} +bool Pet::statusIsSet() const +{ + return m_StatusIsSet; +} +void Pet::unsetStatus() +{ + m_StatusIsSet = false; +} + +} +} +} +} + diff --git a/samples/client/petstore/cpprest/model/Pet.h b/samples/client/petstore/cpprest/model/Pet.h new file mode 100644 index 00000000000..3152cd580f7 --- /dev/null +++ b/samples/client/petstore/cpprest/model/Pet.h @@ -0,0 +1,102 @@ +/* + * Pet.h + * + * + */ + +#ifndef Pet_H_ +#define Pet_H_ + + +#include "ModelBase.h" + +#include "Category.h" +#include +#include +#include "Tag.h" + +namespace io { +namespace swagger { +namespace client { +namespace model { + +/// +/// +/// +class Pet + : public ModelBase +{ +public: + Pet(); + virtual ~Pet(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + void fromJson(web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Pet members + + /// + /// + /// + int64_t getId() const; + void setId(int64_t value); + bool idIsSet() const; + void unsetId(); + /// + /// + /// + std::shared_ptr getCategory() const; + void setCategory(std::shared_ptr value); + bool categoryIsSet() const; + void unsetCategory(); + /// + /// + /// + utility::string_t getName() const; + void setName(utility::string_t value); + /// + /// + /// + std::vector& getPhotoUrls(); + /// + /// + /// + std::vector>& getTags(); + bool tagsIsSet() const; + void unsetTags(); + /// + /// pet status in the store + /// + utility::string_t getStatus() const; + void setStatus(utility::string_t value); + bool statusIsSet() const; + void unsetStatus(); + +protected: + int64_t m_Id; + bool m_IdIsSet; +std::shared_ptr m_Category; + bool m_CategoryIsSet; +utility::string_t m_Name; + std::vector m_PhotoUrls; + std::vector> m_Tags; + bool m_TagsIsSet; +utility::string_t m_Status; + bool m_StatusIsSet; +}; + +} +} +} +} + +#endif /* Pet_H_ */ diff --git a/samples/client/petstore/cpprest/model/Tag.cpp b/samples/client/petstore/cpprest/model/Tag.cpp new file mode 100644 index 00000000000..115cc6bb899 --- /dev/null +++ b/samples/client/petstore/cpprest/model/Tag.cpp @@ -0,0 +1,139 @@ + + +#include "Tag.h" + +namespace io { +namespace swagger { +namespace client { +namespace model { + +Tag::Tag() +{ + m_Id = 0L; + m_IdIsSet = false; + m_Name = U(""); + m_NameIsSet = false; + +} + +Tag::~Tag() +{ +} + +void Tag::validate() +{ + // TODO: implement validation +} + +web::json::value Tag::toJson() const +{ + web::json::value val = web::json::value::object(); + + if(m_IdIsSet) + { + val[U("id")] = ModelBase::toJson(m_Id); + } + if(m_NameIsSet) + { + val[U("name")] = ModelBase::toJson(m_Name); + } + + + return val; +} + +void Tag::fromJson(web::json::value& val) +{ + if(val.has_field(U("id"))) + { + setId(ModelBase::int64_tFromJson(val[U("id")])); + } + if(val.has_field(U("name"))) + { + setName(ModelBase::stringFromJson(val[U("name")])); + + } + +} + +void Tag::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("id"), m_Id)); + } + if(m_NameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("name"), m_Name)); + + } + +} + +void Tag::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + if(multipart->hasContent(U("id"))) + { + setId(ModelBase::int64_tFromHttpContent(multipart->getContent(U("id")))); + } + if(multipart->hasContent(U("name"))) + { + setName(ModelBase::stringFromHttpContent(multipart->getContent(U("name")))); + + } + +} + + +int64_t Tag::getId() const +{ + return m_Id; +} +void Tag::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} +bool Tag::idIsSet() const +{ + return m_IdIsSet; +} +void Tag::unsetId() +{ + m_IdIsSet = false; +} +utility::string_t Tag::getName() const +{ + return m_Name; +} +void Tag::setName(utility::string_t value) +{ + m_Name = value; + m_NameIsSet = true; +} +bool Tag::nameIsSet() const +{ + return m_NameIsSet; +} +void Tag::unsetName() +{ + m_NameIsSet = false; +} + +} +} +} +} + diff --git a/samples/client/petstore/cpprest/model/Tag.h b/samples/client/petstore/cpprest/model/Tag.h new file mode 100644 index 00000000000..e657692ea35 --- /dev/null +++ b/samples/client/petstore/cpprest/model/Tag.h @@ -0,0 +1,71 @@ +/* + * Tag.h + * + * + */ + +#ifndef Tag_H_ +#define Tag_H_ + + +#include "ModelBase.h" + +#include + +namespace io { +namespace swagger { +namespace client { +namespace model { + +/// +/// +/// +class Tag + : public ModelBase +{ +public: + Tag(); + virtual ~Tag(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + void fromJson(web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Tag members + + /// + /// + /// + int64_t getId() const; + void setId(int64_t value); + bool idIsSet() const; + void unsetId(); + /// + /// + /// + utility::string_t getName() const; + void setName(utility::string_t value); + bool nameIsSet() const; + void unsetName(); + +protected: + int64_t m_Id; + bool m_IdIsSet; +utility::string_t m_Name; + bool m_NameIsSet; +}; + +} +} +} +} + +#endif /* Tag_H_ */ diff --git a/samples/client/petstore/cpprest/model/User.cpp b/samples/client/petstore/cpprest/model/User.cpp new file mode 100644 index 00000000000..39c17dfd964 --- /dev/null +++ b/samples/client/petstore/cpprest/model/User.cpp @@ -0,0 +1,364 @@ + + +#include "User.h" + +namespace io { +namespace swagger { +namespace client { +namespace model { + +User::User() +{ + m_Id = 0L; + m_IdIsSet = false; + m_Username = U(""); + m_UsernameIsSet = false; + m_FirstName = U(""); + m_FirstNameIsSet = false; + m_LastName = U(""); + m_LastNameIsSet = false; + m_Email = U(""); + m_EmailIsSet = false; + m_Password = U(""); + m_PasswordIsSet = false; + m_Phone = U(""); + m_PhoneIsSet = false; + m_UserStatus = 0; + m_UserStatusIsSet = false; + +} + +User::~User() +{ +} + +void User::validate() +{ + // TODO: implement validation +} + +web::json::value User::toJson() const +{ + web::json::value val = web::json::value::object(); + + if(m_IdIsSet) + { + val[U("id")] = ModelBase::toJson(m_Id); + } + if(m_UsernameIsSet) + { + val[U("username")] = ModelBase::toJson(m_Username); + } + if(m_FirstNameIsSet) + { + val[U("firstName")] = ModelBase::toJson(m_FirstName); + } + if(m_LastNameIsSet) + { + val[U("lastName")] = ModelBase::toJson(m_LastName); + } + if(m_EmailIsSet) + { + val[U("email")] = ModelBase::toJson(m_Email); + } + if(m_PasswordIsSet) + { + val[U("password")] = ModelBase::toJson(m_Password); + } + if(m_PhoneIsSet) + { + val[U("phone")] = ModelBase::toJson(m_Phone); + } + if(m_UserStatusIsSet) + { + val[U("userStatus")] = ModelBase::toJson(m_UserStatus); + } + + + return val; +} + +void User::fromJson(web::json::value& val) +{ + if(val.has_field(U("id"))) + { + setId(ModelBase::int64_tFromJson(val[U("id")])); + } + if(val.has_field(U("username"))) + { + setUsername(ModelBase::stringFromJson(val[U("username")])); + + } + if(val.has_field(U("firstName"))) + { + setFirstName(ModelBase::stringFromJson(val[U("firstName")])); + + } + if(val.has_field(U("lastName"))) + { + setLastName(ModelBase::stringFromJson(val[U("lastName")])); + + } + if(val.has_field(U("email"))) + { + setEmail(ModelBase::stringFromJson(val[U("email")])); + + } + if(val.has_field(U("password"))) + { + setPassword(ModelBase::stringFromJson(val[U("password")])); + + } + if(val.has_field(U("phone"))) + { + setPhone(ModelBase::stringFromJson(val[U("phone")])); + + } + if(val.has_field(U("userStatus"))) + { + setUserStatus(ModelBase::int32_tFromJson(val[U("userStatus")])); + } + +} + +void User::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("id"), m_Id)); + } + if(m_UsernameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("username"), m_Username)); + + } + if(m_FirstNameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("firstName"), m_FirstName)); + + } + if(m_LastNameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("lastName"), m_LastName)); + + } + if(m_EmailIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("email"), m_Email)); + + } + if(m_PasswordIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("password"), m_Password)); + + } + if(m_PhoneIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("phone"), m_Phone)); + + } + if(m_UserStatusIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + U("userStatus"), m_UserStatus)); + } + +} + +void User::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } + + if(multipart->hasContent(U("id"))) + { + setId(ModelBase::int64_tFromHttpContent(multipart->getContent(U("id")))); + } + if(multipart->hasContent(U("username"))) + { + setUsername(ModelBase::stringFromHttpContent(multipart->getContent(U("username")))); + + } + if(multipart->hasContent(U("firstName"))) + { + setFirstName(ModelBase::stringFromHttpContent(multipart->getContent(U("firstName")))); + + } + if(multipart->hasContent(U("lastName"))) + { + setLastName(ModelBase::stringFromHttpContent(multipart->getContent(U("lastName")))); + + } + if(multipart->hasContent(U("email"))) + { + setEmail(ModelBase::stringFromHttpContent(multipart->getContent(U("email")))); + + } + if(multipart->hasContent(U("password"))) + { + setPassword(ModelBase::stringFromHttpContent(multipart->getContent(U("password")))); + + } + if(multipart->hasContent(U("phone"))) + { + setPhone(ModelBase::stringFromHttpContent(multipart->getContent(U("phone")))); + + } + if(multipart->hasContent(U("userStatus"))) + { + setUserStatus(ModelBase::int32_tFromHttpContent(multipart->getContent(U("userStatus")))); + } + +} + + +int64_t User::getId() const +{ + return m_Id; +} +void User::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} +bool User::idIsSet() const +{ + return m_IdIsSet; +} +void User::unsetId() +{ + m_IdIsSet = false; +} +utility::string_t User::getUsername() const +{ + return m_Username; +} +void User::setUsername(utility::string_t value) +{ + m_Username = value; + m_UsernameIsSet = true; +} +bool User::usernameIsSet() const +{ + return m_UsernameIsSet; +} +void User::unsetUsername() +{ + m_UsernameIsSet = false; +} +utility::string_t User::getFirstName() const +{ + return m_FirstName; +} +void User::setFirstName(utility::string_t value) +{ + m_FirstName = value; + m_FirstNameIsSet = true; +} +bool User::firstNameIsSet() const +{ + return m_FirstNameIsSet; +} +void User::unsetFirstName() +{ + m_FirstNameIsSet = false; +} +utility::string_t User::getLastName() const +{ + return m_LastName; +} +void User::setLastName(utility::string_t value) +{ + m_LastName = value; + m_LastNameIsSet = true; +} +bool User::lastNameIsSet() const +{ + return m_LastNameIsSet; +} +void User::unsetLastName() +{ + m_LastNameIsSet = false; +} +utility::string_t User::getEmail() const +{ + return m_Email; +} +void User::setEmail(utility::string_t value) +{ + m_Email = value; + m_EmailIsSet = true; +} +bool User::emailIsSet() const +{ + return m_EmailIsSet; +} +void User::unsetEmail() +{ + m_EmailIsSet = false; +} +utility::string_t User::getPassword() const +{ + return m_Password; +} +void User::setPassword(utility::string_t value) +{ + m_Password = value; + m_PasswordIsSet = true; +} +bool User::passwordIsSet() const +{ + return m_PasswordIsSet; +} +void User::unsetPassword() +{ + m_PasswordIsSet = false; +} +utility::string_t User::getPhone() const +{ + return m_Phone; +} +void User::setPhone(utility::string_t value) +{ + m_Phone = value; + m_PhoneIsSet = true; +} +bool User::phoneIsSet() const +{ + return m_PhoneIsSet; +} +void User::unsetPhone() +{ + m_PhoneIsSet = false; +} +int32_t User::getUserStatus() const +{ + return m_UserStatus; +} +void User::setUserStatus(int32_t value) +{ + m_UserStatus = value; + m_UserStatusIsSet = true; +} +bool User::userStatusIsSet() const +{ + return m_UserStatusIsSet; +} +void User::unsetUserStatus() +{ + m_UserStatusIsSet = false; +} + +} +} +} +} + diff --git a/samples/client/petstore/cpprest/model/User.h b/samples/client/petstore/cpprest/model/User.h new file mode 100644 index 00000000000..ba90e464cca --- /dev/null +++ b/samples/client/petstore/cpprest/model/User.h @@ -0,0 +1,125 @@ +/* + * User.h + * + * + */ + +#ifndef User_H_ +#define User_H_ + + +#include "ModelBase.h" + +#include + +namespace io { +namespace swagger { +namespace client { +namespace model { + +/// +/// +/// +class User + : public ModelBase +{ +public: + User(); + virtual ~User(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + void fromJson(web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// User members + + /// + /// + /// + int64_t getId() const; + void setId(int64_t value); + bool idIsSet() const; + void unsetId(); + /// + /// + /// + utility::string_t getUsername() const; + void setUsername(utility::string_t value); + bool usernameIsSet() const; + void unsetUsername(); + /// + /// + /// + utility::string_t getFirstName() const; + void setFirstName(utility::string_t value); + bool firstNameIsSet() const; + void unsetFirstName(); + /// + /// + /// + utility::string_t getLastName() const; + void setLastName(utility::string_t value); + bool lastNameIsSet() const; + void unsetLastName(); + /// + /// + /// + utility::string_t getEmail() const; + void setEmail(utility::string_t value); + bool emailIsSet() const; + void unsetEmail(); + /// + /// + /// + utility::string_t getPassword() const; + void setPassword(utility::string_t value); + bool passwordIsSet() const; + void unsetPassword(); + /// + /// + /// + utility::string_t getPhone() const; + void setPhone(utility::string_t value); + bool phoneIsSet() const; + void unsetPhone(); + /// + /// User Status + /// + int32_t getUserStatus() const; + void setUserStatus(int32_t value); + bool userStatusIsSet() const; + void unsetUserStatus(); + +protected: + int64_t m_Id; + bool m_IdIsSet; +utility::string_t m_Username; + bool m_UsernameIsSet; +utility::string_t m_FirstName; + bool m_FirstNameIsSet; +utility::string_t m_LastName; + bool m_LastNameIsSet; +utility::string_t m_Email; + bool m_EmailIsSet; +utility::string_t m_Password; + bool m_PasswordIsSet; +utility::string_t m_Phone; + bool m_PhoneIsSet; +int32_t m_UserStatus; + bool m_UserStatusIsSet; +}; + +} +} +} +} + +#endif /* User_H_ */ diff --git a/samples/client/petstore/go/go-petstore/README.md b/samples/client/petstore/go/go-petstore/README.md index 20083469110..5d6a957aa1e 100644 --- a/samples/client/petstore/go/go-petstore/README.md +++ b/samples/client/petstore/go/go-petstore/README.md @@ -7,7 +7,7 @@ This API client was generated by the [swagger-codegen](https://github.com/swagge - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-05-25T10:00:28.559-07:00 +- Build date: 2016-05-26T21:47:25.590-07:00 - Build package: class io.swagger.codegen.languages.GoClientCodegen ## Installation diff --git a/samples/client/petstore/javascript-promise/.swagger-codegen-ignore b/samples/client/petstore/javascript-promise/.swagger-codegen-ignore new file mode 100644 index 00000000000..19d3377182e --- /dev/null +++ b/samples/client/petstore/javascript-promise/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/javascript-promise/.travis.yml b/samples/client/petstore/javascript-promise/.travis.yml new file mode 100644 index 00000000000..e49f4692f7c --- /dev/null +++ b/samples/client/petstore/javascript-promise/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - "6" + - "6.1" + - "5" + - "5.11" + diff --git a/samples/client/petstore/javascript-promise/LICENSE b/samples/client/petstore/javascript-promise/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/samples/client/petstore/javascript-promise/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. diff --git a/samples/client/petstore/javascript-promise/README.md b/samples/client/petstore/javascript-promise/README.md index ba181cae089..c081f0f3cda 100644 --- a/samples/client/petstore/javascript-promise/README.md +++ b/samples/client/petstore/javascript-promise/README.md @@ -1,12 +1,12 @@ # swagger-petstore SwaggerPetstore - JavaScript client for swagger-petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-05-06T17:51:36.114+08:00 +- Build date: 2016-06-15T01:16:30.521+08:00 - Build package: class io.swagger.codegen.languages.JavascriptClientCodegen ## Installation @@ -88,7 +88,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*SwaggerPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters +*SwaggerPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *SwaggerPetstore.PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store *SwaggerPetstore.PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet *SwaggerPetstore.PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status @@ -113,20 +113,24 @@ Class | Method | HTTP request | Description ## Documentation for Models + - [SwaggerPetstore.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) - [SwaggerPetstore.Animal](docs/Animal.md) - [SwaggerPetstore.AnimalFarm](docs/AnimalFarm.md) - [SwaggerPetstore.ApiResponse](docs/ApiResponse.md) + - [SwaggerPetstore.ArrayTest](docs/ArrayTest.md) - [SwaggerPetstore.Cat](docs/Cat.md) - [SwaggerPetstore.Category](docs/Category.md) - [SwaggerPetstore.Dog](docs/Dog.md) - [SwaggerPetstore.EnumClass](docs/EnumClass.md) - [SwaggerPetstore.EnumTest](docs/EnumTest.md) - [SwaggerPetstore.FormatTest](docs/FormatTest.md) + - [SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [SwaggerPetstore.Model200Response](docs/Model200Response.md) - [SwaggerPetstore.ModelReturn](docs/ModelReturn.md) - [SwaggerPetstore.Name](docs/Name.md) - [SwaggerPetstore.Order](docs/Order.md) - [SwaggerPetstore.Pet](docs/Pet.md) + - [SwaggerPetstore.ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SwaggerPetstore.SpecialModelName](docs/SpecialModelName.md) - [SwaggerPetstore.Tag](docs/Tag.md) - [SwaggerPetstore.User](docs/User.md) @@ -135,6 +139,12 @@ Class | Method | HTTP request | Description ## Documentation for Authorization +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + ### petstore_auth - **Type**: OAuth @@ -144,9 +154,3 @@ Class | Method | HTTP request | Description - write:pets: modify pets in your account - read:pets: read your pets -### api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - diff --git a/samples/client/petstore/javascript-promise/docs/AdditionalPropertiesClass.md b/samples/client/petstore/javascript-promise/docs/AdditionalPropertiesClass.md new file mode 100644 index 00000000000..0ea13d4bb64 --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/AdditionalPropertiesClass.md @@ -0,0 +1,9 @@ +# SwaggerPetstore.AdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**mapProperty** | **{String: String}** | | [optional] +**mapOfMapProperty** | **{String: {String: String}}** | | [optional] + + diff --git a/samples/client/petstore/javascript-promise/docs/Animal.md b/samples/client/petstore/javascript-promise/docs/Animal.md index c37d95695a0..3ae52d9db17 100644 --- a/samples/client/petstore/javascript-promise/docs/Animal.md +++ b/samples/client/petstore/javascript-promise/docs/Animal.md @@ -4,5 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **className** | **String** | | +**color** | **String** | | [optional] [default to 'red'] diff --git a/samples/client/petstore/javascript-promise/docs/ArrayTest.md b/samples/client/petstore/javascript-promise/docs/ArrayTest.md new file mode 100644 index 00000000000..a2576512243 --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/ArrayTest.md @@ -0,0 +1,10 @@ +# SwaggerPetstore.ArrayTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**arrayOfString** | **[String]** | | [optional] +**arrayArrayOfInteger** | **[[Integer]]** | | [optional] +**arrayArrayOfModel** | **[[ReadOnlyFirst]]** | | [optional] + + diff --git a/samples/client/petstore/javascript-promise/docs/FakeApi.md b/samples/client/petstore/javascript-promise/docs/FakeApi.md index 83925c1266d..873139e3165 100644 --- a/samples/client/petstore/javascript-promise/docs/FakeApi.md +++ b/samples/client/petstore/javascript-promise/docs/FakeApi.md @@ -4,16 +4,16 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- -[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters +[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # **testEndpointParameters** > testEndpointParameters(_number, _double, _string, _byte, opts) -Fake endpoint for testing various parameters +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 -Fake endpoint for testing various parameters +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ### Example ```javascript @@ -74,6 +74,6 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Content-Type**: application/xml; charset=utf-8, application/json; charset=utf-8 + - **Accept**: application/xml; charset=utf-8, application/json; charset=utf-8 diff --git a/samples/client/petstore/javascript-promise/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/javascript-promise/docs/MixedPropertiesAndAdditionalPropertiesClass.md new file mode 100644 index 00000000000..31bf8b314ca --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -0,0 +1,10 @@ +# SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **String** | | [optional] +**dateTime** | **Date** | | [optional] +**map** | [**{String: Animal}**](Animal.md) | | [optional] + + diff --git a/samples/client/petstore/javascript-promise/docs/Name.md b/samples/client/petstore/javascript-promise/docs/Name.md index 3bdb76be085..6c47d402743 100644 --- a/samples/client/petstore/javascript-promise/docs/Name.md +++ b/samples/client/petstore/javascript-promise/docs/Name.md @@ -6,5 +6,6 @@ Name | Type | Description | Notes **name** | **Integer** | | **snakeCase** | **Integer** | | [optional] **property** | **String** | | [optional] +**_123Number** | **Integer** | | [optional] diff --git a/samples/client/petstore/javascript-promise/docs/ReadOnlyFirst.md b/samples/client/petstore/javascript-promise/docs/ReadOnlyFirst.md new file mode 100644 index 00000000000..5a16f8acce0 --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/ReadOnlyFirst.md @@ -0,0 +1,9 @@ +# SwaggerPetstore.ReadOnlyFirst + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **String** | | [optional] +**baz** | **String** | | [optional] + + diff --git a/samples/client/petstore/javascript-promise/mocha.opts b/samples/client/petstore/javascript-promise/mocha.opts new file mode 100644 index 00000000000..907011807d6 --- /dev/null +++ b/samples/client/petstore/javascript-promise/mocha.opts @@ -0,0 +1 @@ +--timeout 10000 diff --git a/samples/client/petstore/javascript-promise/package.json b/samples/client/petstore/javascript-promise/package.json index 8ff02a78ae3..53ea2d8faf9 100644 --- a/samples/client/petstore/javascript-promise/package.json +++ b/samples/client/petstore/javascript-promise/package.json @@ -1,8 +1,8 @@ { "name": "swagger-petstore", "version": "1.0.0", - "description": "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose.", - "license": "Apache 2.0", + "description": "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ ", + "license": "Apache-2.0", "main": "src/index.js", "scripts": { "test": "./node_modules/mocha/bin/mocha --recursive" diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index 4033ad41e00..d89eb4f4460 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. @@ -40,8 +64,8 @@ * @type {Array.} */ this.authentications = { - 'petstore_auth': {type: 'oauth2'}, - 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'} + 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'}, + 'petstore_auth': {type: 'oauth2'} }; /** * The default HTTP headers to be included for all API calls. diff --git a/samples/client/petstore/javascript-promise/src/api/FakeApi.js b/samples/client/petstore/javascript-promise/src/api/FakeApi.js index 84d262725a2..9512bbf1fb8 100644 --- a/samples/client/petstore/javascript-promise/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-promise/src/api/FakeApi.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. @@ -34,8 +58,8 @@ /** - * Fake endpoint for testing various parameters - * Fake endpoint for testing various parameters + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * @param {Number} _number None * @param {Number} _double None * @param {String} _string None @@ -97,8 +121,8 @@ }; var authNames = []; - var contentTypes = []; - var accepts = ['application/xml', 'application/json']; + var contentTypes = ['application/xml; charset=utf-8', 'application/json; charset=utf-8']; + var accepts = ['application/xml; charset=utf-8', 'application/json; charset=utf-8']; var returnType = null; return this.apiClient.callApi( diff --git a/samples/client/petstore/javascript-promise/src/api/PetApi.js b/samples/client/petstore/javascript-promise/src/api/PetApi.js index 572fe19dbf2..62be498b179 100644 --- a/samples/client/petstore/javascript-promise/src/api/PetApi.js +++ b/samples/client/petstore/javascript-promise/src/api/PetApi.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/api/StoreApi.js b/samples/client/petstore/javascript-promise/src/api/StoreApi.js index f8b889256b2..b980cdd6784 100644 --- a/samples/client/petstore/javascript-promise/src/api/StoreApi.js +++ b/samples/client/petstore/javascript-promise/src/api/StoreApi.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/api/UserApi.js b/samples/client/petstore/javascript-promise/src/api/UserApi.js index ff8f745735d..7ffd940184b 100644 --- a/samples/client/petstore/javascript-promise/src/api/UserApi.js +++ b/samples/client/petstore/javascript-promise/src/api/UserApi.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/index.js b/samples/client/petstore/javascript-promise/src/index.js index 727b4782f45..93f2e6cd4b8 100644 --- a/samples/client/petstore/javascript-promise/src/index.js +++ b/samples/client/petstore/javascript-promise/src/index.js @@ -1,16 +1,40 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['ApiClient', 'model/Animal', 'model/AnimalFarm', 'model/ApiResponse', 'model/Cat', 'model/Category', 'model/Dog', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/Order', 'model/Pet', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/FakeApi', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory); + define(['ApiClient', 'model/AdditionalPropertiesClass', 'model/Animal', 'model/AnimalFarm', 'model/ApiResponse', 'model/ArrayTest', 'model/Cat', 'model/Category', 'model/Dog', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/MixedPropertiesAndAdditionalPropertiesClass', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/Order', 'model/Pet', 'model/ReadOnlyFirst', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/FakeApi', '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/Animal'), require('./model/AnimalFarm'), require('./model/ApiResponse'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); + module.exports = factory(require('./ApiClient'), require('./model/AdditionalPropertiesClass'), require('./model/Animal'), require('./model/AnimalFarm'), require('./model/ApiResponse'), require('./model/ArrayTest'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/MixedPropertiesAndAdditionalPropertiesClass'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/ReadOnlyFirst'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); } -}(function(ApiClient, Animal, AnimalFarm, ApiResponse, Cat, Category, Dog, EnumClass, EnumTest, FormatTest, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) { +}(function(ApiClient, AdditionalPropertiesClass, Animal, AnimalFarm, ApiResponse, ArrayTest, Cat, Category, Dog, EnumClass, EnumTest, FormatTest, MixedPropertiesAndAdditionalPropertiesClass, Model200Response, ModelReturn, Name, Order, Pet, ReadOnlyFirst, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) { 'use strict'; /** - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose..
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ .
* The index module provides access to constructors for all the classes which comprise the public API. *

* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following: @@ -46,6 +70,11 @@ * @property {module:ApiClient} */ ApiClient: ApiClient, + /** + * The AdditionalPropertiesClass model constructor. + * @property {module:model/AdditionalPropertiesClass} + */ + AdditionalPropertiesClass: AdditionalPropertiesClass, /** * The Animal model constructor. * @property {module:model/Animal} @@ -61,6 +90,11 @@ * @property {module:model/ApiResponse} */ ApiResponse: ApiResponse, + /** + * The ArrayTest model constructor. + * @property {module:model/ArrayTest} + */ + ArrayTest: ArrayTest, /** * The Cat model constructor. * @property {module:model/Cat} @@ -91,6 +125,11 @@ * @property {module:model/FormatTest} */ FormatTest: FormatTest, + /** + * The MixedPropertiesAndAdditionalPropertiesClass model constructor. + * @property {module:model/MixedPropertiesAndAdditionalPropertiesClass} + */ + MixedPropertiesAndAdditionalPropertiesClass: MixedPropertiesAndAdditionalPropertiesClass, /** * The Model200Response model constructor. * @property {module:model/Model200Response} @@ -116,6 +155,11 @@ * @property {module:model/Pet} */ Pet: Pet, + /** + * The ReadOnlyFirst model constructor. + * @property {module:model/ReadOnlyFirst} + */ + ReadOnlyFirst: ReadOnlyFirst, /** * The SpecialModelName model constructor. * @property {module:model/SpecialModelName} diff --git a/samples/client/petstore/javascript-promise/src/model/AdditionalPropertiesClass.js b/samples/client/petstore/javascript-promise/src/model/AdditionalPropertiesClass.js new file mode 100644 index 00000000000..10183b1ea43 --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/AdditionalPropertiesClass.js @@ -0,0 +1,99 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(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.AdditionalPropertiesClass = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + + /** + * The AdditionalPropertiesClass model module. + * @module model/AdditionalPropertiesClass + * @version 1.0.0 + */ + + /** + * Constructs a new AdditionalPropertiesClass. + * @alias module:model/AdditionalPropertiesClass + * @class + */ + var exports = function() { + var _this = this; + + + + }; + + /** + * Constructs a AdditionalPropertiesClass from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/AdditionalPropertiesClass} obj Optional instance to populate. + * @return {module:model/AdditionalPropertiesClass} The populated AdditionalPropertiesClass instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('map_property')) { + obj['map_property'] = ApiClient.convertToType(data['map_property'], {'String': 'String'}); + } + if (data.hasOwnProperty('map_of_map_property')) { + obj['map_of_map_property'] = ApiClient.convertToType(data['map_of_map_property'], {'String': {'String': 'String'}}); + } + } + return obj; + } + + /** + * @member {Object.} map_property + */ + exports.prototype['map_property'] = undefined; + /** + * @member {Object.>} map_of_map_property + */ + exports.prototype['map_of_map_property'] = undefined; + + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript-promise/src/model/Animal.js b/samples/client/petstore/javascript-promise/src/model/Animal.js index e42874c669b..32042951cb1 100644 --- a/samples/client/petstore/javascript-promise/src/model/Animal.js +++ b/samples/client/petstore/javascript-promise/src/model/Animal.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. @@ -34,6 +58,7 @@ var _this = this; _this['className'] = className; + }; /** @@ -50,6 +75,9 @@ if (data.hasOwnProperty('className')) { obj['className'] = ApiClient.convertToType(data['className'], 'String'); } + if (data.hasOwnProperty('color')) { + obj['color'] = ApiClient.convertToType(data['color'], 'String'); + } } return obj; } @@ -58,6 +86,11 @@ * @member {String} className */ exports.prototype['className'] = undefined; + /** + * @member {String} color + * @default 'red' + */ + exports.prototype['color'] = 'red'; diff --git a/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js b/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js index d5f6aa2a424..1a54e0d611a 100644 --- a/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js +++ b/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/ApiResponse.js b/samples/client/petstore/javascript-promise/src/model/ApiResponse.js index 6d4c970264b..1cb041898d4 100644 --- a/samples/client/petstore/javascript-promise/src/model/ApiResponse.js +++ b/samples/client/petstore/javascript-promise/src/model/ApiResponse.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/ArrayTest.js b/samples/client/petstore/javascript-promise/src/model/ArrayTest.js new file mode 100644 index 00000000000..a2589f7ea0a --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/ArrayTest.js @@ -0,0 +1,107 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(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.ArrayTest = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + + /** + * The ArrayTest model module. + * @module model/ArrayTest + * @version 1.0.0 + */ + + /** + * Constructs a new ArrayTest. + * @alias module:model/ArrayTest + * @class + */ + var exports = function() { + var _this = this; + + + + + }; + + /** + * Constructs a ArrayTest from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/ArrayTest} obj Optional instance to populate. + * @return {module:model/ArrayTest} The populated ArrayTest instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('array_of_string')) { + obj['array_of_string'] = ApiClient.convertToType(data['array_of_string'], ['String']); + } + if (data.hasOwnProperty('array_array_of_integer')) { + obj['array_array_of_integer'] = ApiClient.convertToType(data['array_array_of_integer'], [['Integer']]); + } + if (data.hasOwnProperty('array_array_of_model')) { + obj['array_array_of_model'] = ApiClient.convertToType(data['array_array_of_model'], [[ReadOnlyFirst]]); + } + } + return obj; + } + + /** + * @member {Array.} array_of_string + */ + exports.prototype['array_of_string'] = undefined; + /** + * @member {Array.>} array_array_of_integer + */ + exports.prototype['array_array_of_integer'] = undefined; + /** + * @member {Array.>} array_array_of_model + */ + exports.prototype['array_array_of_model'] = undefined; + + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript-promise/src/model/Cat.js b/samples/client/petstore/javascript-promise/src/model/Cat.js index a6b25bc6d58..e6a771019f3 100644 --- a/samples/client/petstore/javascript-promise/src/model/Cat.js +++ b/samples/client/petstore/javascript-promise/src/model/Cat.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/Category.js b/samples/client/petstore/javascript-promise/src/model/Category.js index 9e2e19ac5bb..c415cbd1943 100644 --- a/samples/client/petstore/javascript-promise/src/model/Category.js +++ b/samples/client/petstore/javascript-promise/src/model/Category.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/Dog.js b/samples/client/petstore/javascript-promise/src/model/Dog.js index ee17ae3467f..719237dadd7 100644 --- a/samples/client/petstore/javascript-promise/src/model/Dog.js +++ b/samples/client/petstore/javascript-promise/src/model/Dog.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/EnumClass.js b/samples/client/petstore/javascript-promise/src/model/EnumClass.js index e9bf5219ee5..b0bb7813e7d 100644 --- a/samples/client/petstore/javascript-promise/src/model/EnumClass.js +++ b/samples/client/petstore/javascript-promise/src/model/EnumClass.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/EnumTest.js b/samples/client/petstore/javascript-promise/src/model/EnumTest.js index 6f8f0de3836..0ab961078b0 100644 --- a/samples/client/petstore/javascript-promise/src/model/EnumTest.js +++ b/samples/client/petstore/javascript-promise/src/model/EnumTest.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/FormatTest.js b/samples/client/petstore/javascript-promise/src/model/FormatTest.js index ed9e0cfcaf8..7a941cb5ffa 100644 --- a/samples/client/petstore/javascript-promise/src/model/FormatTest.js +++ b/samples/client/petstore/javascript-promise/src/model/FormatTest.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/MixedPropertiesAndAdditionalPropertiesClass.js b/samples/client/petstore/javascript-promise/src/model/MixedPropertiesAndAdditionalPropertiesClass.js new file mode 100644 index 00000000000..1db531b401f --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/MixedPropertiesAndAdditionalPropertiesClass.js @@ -0,0 +1,107 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['ApiClient', 'model/Animal'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient'), require('./Animal')); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Animal); + } +}(this, function(ApiClient, Animal) { + 'use strict'; + + + + + /** + * The MixedPropertiesAndAdditionalPropertiesClass model module. + * @module model/MixedPropertiesAndAdditionalPropertiesClass + * @version 1.0.0 + */ + + /** + * Constructs a new MixedPropertiesAndAdditionalPropertiesClass. + * @alias module:model/MixedPropertiesAndAdditionalPropertiesClass + * @class + */ + var exports = function() { + var _this = this; + + + + + }; + + /** + * Constructs a MixedPropertiesAndAdditionalPropertiesClass from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/MixedPropertiesAndAdditionalPropertiesClass} obj Optional instance to populate. + * @return {module:model/MixedPropertiesAndAdditionalPropertiesClass} The populated MixedPropertiesAndAdditionalPropertiesClass instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('uuid')) { + obj['uuid'] = ApiClient.convertToType(data['uuid'], 'String'); + } + if (data.hasOwnProperty('dateTime')) { + obj['dateTime'] = ApiClient.convertToType(data['dateTime'], 'Date'); + } + if (data.hasOwnProperty('map')) { + obj['map'] = ApiClient.convertToType(data['map'], {'String': Animal}); + } + } + return obj; + } + + /** + * @member {String} uuid + */ + exports.prototype['uuid'] = undefined; + /** + * @member {Date} dateTime + */ + exports.prototype['dateTime'] = undefined; + /** + * @member {Object.} map + */ + exports.prototype['map'] = undefined; + + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript-promise/src/model/Model200Response.js b/samples/client/petstore/javascript-promise/src/model/Model200Response.js index 1d83d420287..21ea07b2c39 100644 --- a/samples/client/petstore/javascript-promise/src/model/Model200Response.js +++ b/samples/client/petstore/javascript-promise/src/model/Model200Response.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/ModelReturn.js b/samples/client/petstore/javascript-promise/src/model/ModelReturn.js index d0236e77b17..b9dec2d30c4 100644 --- a/samples/client/petstore/javascript-promise/src/model/ModelReturn.js +++ b/samples/client/petstore/javascript-promise/src/model/ModelReturn.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/Name.js b/samples/client/petstore/javascript-promise/src/model/Name.js index 93d1d55deb2..cae738e0d90 100644 --- a/samples/client/petstore/javascript-promise/src/model/Name.js +++ b/samples/client/petstore/javascript-promise/src/model/Name.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. @@ -37,6 +61,7 @@ _this['name'] = name; + }; /** @@ -59,6 +84,9 @@ if (data.hasOwnProperty('property')) { obj['property'] = ApiClient.convertToType(data['property'], 'String'); } + if (data.hasOwnProperty('123Number')) { + obj['123Number'] = ApiClient.convertToType(data['123Number'], 'Integer'); + } } return obj; } @@ -75,6 +103,10 @@ * @member {String} property */ exports.prototype['property'] = undefined; + /** + * @member {Integer} 123Number + */ + exports.prototype['123Number'] = undefined; diff --git a/samples/client/petstore/javascript-promise/src/model/Order.js b/samples/client/petstore/javascript-promise/src/model/Order.js index 57f77d84ccd..f2b3726a04c 100644 --- a/samples/client/petstore/javascript-promise/src/model/Order.js +++ b/samples/client/petstore/javascript-promise/src/model/Order.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/Pet.js b/samples/client/petstore/javascript-promise/src/model/Pet.js index fe14361dbf2..19ed2096877 100644 --- a/samples/client/petstore/javascript-promise/src/model/Pet.js +++ b/samples/client/petstore/javascript-promise/src/model/Pet.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/ReadOnlyFirst.js b/samples/client/petstore/javascript-promise/src/model/ReadOnlyFirst.js new file mode 100644 index 00000000000..8ceb17f58bb --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/ReadOnlyFirst.js @@ -0,0 +1,99 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(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.ReadOnlyFirst = factory(root.SwaggerPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + + /** + * The ReadOnlyFirst model module. + * @module model/ReadOnlyFirst + * @version 1.0.0 + */ + + /** + * Constructs a new ReadOnlyFirst. + * @alias module:model/ReadOnlyFirst + * @class + */ + var exports = function() { + var _this = this; + + + + }; + + /** + * Constructs a ReadOnlyFirst from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/ReadOnlyFirst} obj Optional instance to populate. + * @return {module:model/ReadOnlyFirst} The populated ReadOnlyFirst instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + + if (data.hasOwnProperty('bar')) { + obj['bar'] = ApiClient.convertToType(data['bar'], 'String'); + } + if (data.hasOwnProperty('baz')) { + obj['baz'] = ApiClient.convertToType(data['baz'], 'String'); + } + } + return obj; + } + + /** + * @member {String} bar + */ + exports.prototype['bar'] = undefined; + /** + * @member {String} baz + */ + exports.prototype['baz'] = undefined; + + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js b/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js index d5a0e992a73..f06c2e46556 100644 --- a/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js +++ b/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/Tag.js b/samples/client/petstore/javascript-promise/src/model/Tag.js index 443d312b76a..8e188616107 100644 --- a/samples/client/petstore/javascript-promise/src/model/Tag.js +++ b/samples/client/petstore/javascript-promise/src/model/Tag.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/src/model/User.js b/samples/client/petstore/javascript-promise/src/model/User.js index 2360c7c6314..df334f1e623 100644 --- a/samples/client/petstore/javascript-promise/src/model/User.js +++ b/samples/client/petstore/javascript-promise/src/model/User.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript-promise/test/api/FakeApi.spec.js b/samples/client/petstore/javascript-promise/test/api/FakeApi.spec.js new file mode 100644 index 00000000000..47725845b51 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/api/FakeApi.spec.js @@ -0,0 +1,74 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.FakeApi(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('FakeApi', function() { + describe('testEndpointParameters', function() { + it('should call testEndpointParameters successfully', function(done) { + //uncomment below and update the code to test testEndpointParameters + //instance.testEndpointParameters(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/api/PetApiTest.js b/samples/client/petstore/javascript-promise/test/api/PetApi.spec.js similarity index 100% rename from samples/client/petstore/javascript-promise/test/api/PetApiTest.js rename to samples/client/petstore/javascript-promise/test/api/PetApi.spec.js diff --git a/samples/client/petstore/javascript-promise/test/api/StoreApi.spec.js b/samples/client/petstore/javascript-promise/test/api/StoreApi.spec.js new file mode 100644 index 00000000000..d4fd52c56a5 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/api/StoreApi.spec.js @@ -0,0 +1,104 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.StoreApi(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('StoreApi', function() { + describe('deleteOrder', function() { + it('should call deleteOrder successfully', function(done) { + //uncomment below and update the code to test deleteOrder + //instance.deleteOrder(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('getInventory', function() { + it('should call getInventory successfully', function(done) { + //uncomment below and update the code to test getInventory + //instance.getInventory(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('getOrderById', function() { + it('should call getOrderById successfully', function(done) { + //uncomment below and update the code to test getOrderById + //instance.getOrderById(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('placeOrder', function() { + it('should call placeOrder successfully', function(done) { + //uncomment below and update the code to test placeOrder + //instance.placeOrder(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/api/UserApi.spec.js b/samples/client/petstore/javascript-promise/test/api/UserApi.spec.js new file mode 100644 index 00000000000..f020f612b5b --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/api/UserApi.spec.js @@ -0,0 +1,144 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.UserApi(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('UserApi', function() { + describe('createUser', function() { + it('should call createUser successfully', function(done) { + //uncomment below and update the code to test createUser + //instance.createUser(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('createUsersWithArrayInput', function() { + it('should call createUsersWithArrayInput successfully', function(done) { + //uncomment below and update the code to test createUsersWithArrayInput + //instance.createUsersWithArrayInput(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('createUsersWithListInput', function() { + it('should call createUsersWithListInput successfully', function(done) { + //uncomment below and update the code to test createUsersWithListInput + //instance.createUsersWithListInput(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('deleteUser', function() { + it('should call deleteUser successfully', function(done) { + //uncomment below and update the code to test deleteUser + //instance.deleteUser(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('getUserByName', function() { + it('should call getUserByName successfully', function(done) { + //uncomment below and update the code to test getUserByName + //instance.getUserByName(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('loginUser', function() { + it('should call loginUser successfully', function(done) { + //uncomment below and update the code to test loginUser + //instance.loginUser(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('logoutUser', function() { + it('should call logoutUser successfully', function(done) { + //uncomment below and update the code to test logoutUser + //instance.logoutUser(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('updateUser', function() { + it('should call updateUser successfully', function(done) { + //uncomment below and update the code to test updateUser + //instance.updateUser(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/AdditionalPropertiesClass.spec.js b/samples/client/petstore/javascript-promise/test/model/AdditionalPropertiesClass.spec.js new file mode 100644 index 00000000000..cb5bdef3e4f --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/AdditionalPropertiesClass.spec.js @@ -0,0 +1,82 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.AdditionalPropertiesClass(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('AdditionalPropertiesClass', function() { + it('should create an instance of AdditionalPropertiesClass', function() { + // uncomment below and update the code to test AdditionalPropertiesClass + //var instane = new SwaggerPetstore.AdditionalPropertiesClass(); + //expect(instance).to.be.a(SwaggerPetstore.AdditionalPropertiesClass); + }); + + it('should have the property mapProperty (base name: "map_property")', function() { + // uncomment below and update the code to test the property mapProperty + //var instane = new SwaggerPetstore.AdditionalPropertiesClass(); + //expect(instance).to.be(); + }); + + it('should have the property mapOfMapProperty (base name: "map_of_map_property")', function() { + // uncomment below and update the code to test the property mapOfMapProperty + //var instane = new SwaggerPetstore.AdditionalPropertiesClass(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/Animal.spec.js b/samples/client/petstore/javascript-promise/test/model/Animal.spec.js new file mode 100644 index 00000000000..8995fe76806 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/Animal.spec.js @@ -0,0 +1,82 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Animal(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Animal', function() { + it('should create an instance of Animal', function() { + // uncomment below and update the code to test Animal + //var instane = new SwaggerPetstore.Animal(); + //expect(instance).to.be.a(SwaggerPetstore.Animal); + }); + + it('should have the property className (base name: "className")', function() { + // uncomment below and update the code to test the property className + //var instane = new SwaggerPetstore.Animal(); + //expect(instance).to.be(); + }); + + it('should have the property color (base name: "color")', function() { + // uncomment below and update the code to test the property color + //var instane = new SwaggerPetstore.Animal(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/AnimalFarm.spec.js b/samples/client/petstore/javascript-promise/test/model/AnimalFarm.spec.js new file mode 100644 index 00000000000..f030047b563 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/AnimalFarm.spec.js @@ -0,0 +1,70 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.AnimalFarm(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('AnimalFarm', function() { + it('should create an instance of AnimalFarm', function() { + // uncomment below and update the code to test AnimalFarm + //var instane = new SwaggerPetstore.AnimalFarm(); + //expect(instance).to.be.a(SwaggerPetstore.AnimalFarm); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/ApiResponse.spec.js b/samples/client/petstore/javascript-promise/test/model/ApiResponse.spec.js new file mode 100644 index 00000000000..a5c3b354318 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/ApiResponse.spec.js @@ -0,0 +1,88 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.ApiResponse(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('ApiResponse', function() { + it('should create an instance of ApiResponse', function() { + // uncomment below and update the code to test ApiResponse + //var instane = new SwaggerPetstore.ApiResponse(); + //expect(instance).to.be.a(SwaggerPetstore.ApiResponse); + }); + + it('should have the property code (base name: "code")', function() { + // uncomment below and update the code to test the property code + //var instane = new SwaggerPetstore.ApiResponse(); + //expect(instance).to.be(); + }); + + it('should have the property type (base name: "type")', function() { + // uncomment below and update the code to test the property type + //var instane = new SwaggerPetstore.ApiResponse(); + //expect(instance).to.be(); + }); + + it('should have the property message (base name: "message")', function() { + // uncomment below and update the code to test the property message + //var instane = new SwaggerPetstore.ApiResponse(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/ArrayTest.spec.js b/samples/client/petstore/javascript-promise/test/model/ArrayTest.spec.js new file mode 100644 index 00000000000..3db84909832 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/ArrayTest.spec.js @@ -0,0 +1,88 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.ArrayTest(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('ArrayTest', function() { + it('should create an instance of ArrayTest', function() { + // uncomment below and update the code to test ArrayTest + //var instane = new SwaggerPetstore.ArrayTest(); + //expect(instance).to.be.a(SwaggerPetstore.ArrayTest); + }); + + it('should have the property arrayOfString (base name: "array_of_string")', function() { + // uncomment below and update the code to test the property arrayOfString + //var instane = new SwaggerPetstore.ArrayTest(); + //expect(instance).to.be(); + }); + + it('should have the property arrayArrayOfInteger (base name: "array_array_of_integer")', function() { + // uncomment below and update the code to test the property arrayArrayOfInteger + //var instane = new SwaggerPetstore.ArrayTest(); + //expect(instance).to.be(); + }); + + it('should have the property arrayArrayOfModel (base name: "array_array_of_model")', function() { + // uncomment below and update the code to test the property arrayArrayOfModel + //var instane = new SwaggerPetstore.ArrayTest(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/Cat.spec.js b/samples/client/petstore/javascript-promise/test/model/Cat.spec.js new file mode 100644 index 00000000000..6d95151915a --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/Cat.spec.js @@ -0,0 +1,76 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Cat(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Cat', function() { + it('should create an instance of Cat', function() { + // uncomment below and update the code to test Cat + //var instane = new SwaggerPetstore.Cat(); + //expect(instance).to.be.a(SwaggerPetstore.Cat); + }); + + it('should have the property declawed (base name: "declawed")', function() { + // uncomment below and update the code to test the property declawed + //var instane = new SwaggerPetstore.Cat(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/Category.spec.js b/samples/client/petstore/javascript-promise/test/model/Category.spec.js new file mode 100644 index 00000000000..dfd425f001c --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/Category.spec.js @@ -0,0 +1,82 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Category(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Category', function() { + it('should create an instance of Category', function() { + // uncomment below and update the code to test Category + //var instane = new SwaggerPetstore.Category(); + //expect(instance).to.be.a(SwaggerPetstore.Category); + }); + + it('should have the property id (base name: "id")', function() { + // uncomment below and update the code to test the property id + //var instane = new SwaggerPetstore.Category(); + //expect(instance).to.be(); + }); + + it('should have the property name (base name: "name")', function() { + // uncomment below and update the code to test the property name + //var instane = new SwaggerPetstore.Category(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/Dog.spec.js b/samples/client/petstore/javascript-promise/test/model/Dog.spec.js new file mode 100644 index 00000000000..35beb92fbad --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/Dog.spec.js @@ -0,0 +1,76 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Dog(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Dog', function() { + it('should create an instance of Dog', function() { + // uncomment below and update the code to test Dog + //var instane = new SwaggerPetstore.Dog(); + //expect(instance).to.be.a(SwaggerPetstore.Dog); + }); + + it('should have the property breed (base name: "breed")', function() { + // uncomment below and update the code to test the property breed + //var instane = new SwaggerPetstore.Dog(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/EnumClass.spec.js b/samples/client/petstore/javascript-promise/test/model/EnumClass.spec.js new file mode 100644 index 00000000000..3f7f5365c05 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/EnumClass.spec.js @@ -0,0 +1,69 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('EnumClass', function() { + it('should create an instance of EnumClass', function() { + // uncomment below and update the code to test EnumClass + //var instane = new SwaggerPetstore.EnumClass(); + //expect(instance).to.be.a(SwaggerPetstore.EnumClass); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/EnumTest.spec.js b/samples/client/petstore/javascript-promise/test/model/EnumTest.spec.js new file mode 100644 index 00000000000..4aacb403ba9 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/EnumTest.spec.js @@ -0,0 +1,88 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.EnumTest(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('EnumTest', function() { + it('should create an instance of EnumTest', function() { + // uncomment below and update the code to test EnumTest + //var instane = new SwaggerPetstore.EnumTest(); + //expect(instance).to.be.a(SwaggerPetstore.EnumTest); + }); + + it('should have the property enumString (base name: "enum_string")', function() { + // uncomment below and update the code to test the property enumString + //var instane = new SwaggerPetstore.EnumTest(); + //expect(instance).to.be(); + }); + + it('should have the property enumInteger (base name: "enum_integer")', function() { + // uncomment below and update the code to test the property enumInteger + //var instane = new SwaggerPetstore.EnumTest(); + //expect(instance).to.be(); + }); + + it('should have the property enumNumber (base name: "enum_number")', function() { + // uncomment below and update the code to test the property enumNumber + //var instane = new SwaggerPetstore.EnumTest(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/FormatTest.spec.js b/samples/client/petstore/javascript-promise/test/model/FormatTest.spec.js new file mode 100644 index 00000000000..b4c3d199b47 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/FormatTest.spec.js @@ -0,0 +1,148 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.FormatTest(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('FormatTest', function() { + it('should create an instance of FormatTest', function() { + // uncomment below and update the code to test FormatTest + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be.a(SwaggerPetstore.FormatTest); + }); + + it('should have the property integer (base name: "integer")', function() { + // uncomment below and update the code to test the property integer + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property int32 (base name: "int32")', function() { + // uncomment below and update the code to test the property int32 + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property int64 (base name: "int64")', function() { + // uncomment below and update the code to test the property int64 + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property _number (base name: "number")', function() { + // uncomment below and update the code to test the property _number + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property _float (base name: "float")', function() { + // uncomment below and update the code to test the property _float + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property _double (base name: "double")', function() { + // uncomment below and update the code to test the property _double + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property _string (base name: "string")', function() { + // uncomment below and update the code to test the property _string + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property _byte (base name: "byte")', function() { + // uncomment below and update the code to test the property _byte + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property binary (base name: "binary")', function() { + // uncomment below and update the code to test the property binary + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property _date (base name: "date")', function() { + // uncomment below and update the code to test the property _date + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property dateTime (base name: "dateTime")', function() { + // uncomment below and update the code to test the property dateTime + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property uuid (base name: "uuid")', function() { + // uncomment below and update the code to test the property uuid + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property password (base name: "password")', function() { + // uncomment below and update the code to test the property password + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/MixedPropertiesAndAdditionalPropertiesClass.spec.js b/samples/client/petstore/javascript-promise/test/model/MixedPropertiesAndAdditionalPropertiesClass.spec.js new file mode 100644 index 00000000000..4cc81eb67d6 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/MixedPropertiesAndAdditionalPropertiesClass.spec.js @@ -0,0 +1,88 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('MixedPropertiesAndAdditionalPropertiesClass', function() { + it('should create an instance of MixedPropertiesAndAdditionalPropertiesClass', function() { + // uncomment below and update the code to test MixedPropertiesAndAdditionalPropertiesClass + //var instane = new SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass(); + //expect(instance).to.be.a(SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass); + }); + + it('should have the property uuid (base name: "uuid")', function() { + // uncomment below and update the code to test the property uuid + //var instane = new SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass(); + //expect(instance).to.be(); + }); + + it('should have the property dateTime (base name: "dateTime")', function() { + // uncomment below and update the code to test the property dateTime + //var instane = new SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass(); + //expect(instance).to.be(); + }); + + it('should have the property map (base name: "map")', function() { + // uncomment below and update the code to test the property map + //var instane = new SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/Model200Response.spec.js b/samples/client/petstore/javascript-promise/test/model/Model200Response.spec.js new file mode 100644 index 00000000000..1c984438224 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/Model200Response.spec.js @@ -0,0 +1,76 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Model200Response(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Model200Response', function() { + it('should create an instance of Model200Response', function() { + // uncomment below and update the code to test Model200Response + //var instane = new SwaggerPetstore.Model200Response(); + //expect(instance).to.be.a(SwaggerPetstore.Model200Response); + }); + + it('should have the property name (base name: "name")', function() { + // uncomment below and update the code to test the property name + //var instane = new SwaggerPetstore.Model200Response(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/ModelReturn.spec.js b/samples/client/petstore/javascript-promise/test/model/ModelReturn.spec.js new file mode 100644 index 00000000000..4dafa0d1446 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/ModelReturn.spec.js @@ -0,0 +1,76 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.ModelReturn(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('ModelReturn', function() { + it('should create an instance of ModelReturn', function() { + // uncomment below and update the code to test ModelReturn + //var instane = new SwaggerPetstore.ModelReturn(); + //expect(instance).to.be.a(SwaggerPetstore.ModelReturn); + }); + + it('should have the property _return (base name: "return")', function() { + // uncomment below and update the code to test the property _return + //var instane = new SwaggerPetstore.ModelReturn(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/Name.spec.js b/samples/client/petstore/javascript-promise/test/model/Name.spec.js new file mode 100644 index 00000000000..ba66272d894 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/Name.spec.js @@ -0,0 +1,94 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Name(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Name', function() { + it('should create an instance of Name', function() { + // uncomment below and update the code to test Name + //var instane = new SwaggerPetstore.Name(); + //expect(instance).to.be.a(SwaggerPetstore.Name); + }); + + it('should have the property name (base name: "name")', function() { + // uncomment below and update the code to test the property name + //var instane = new SwaggerPetstore.Name(); + //expect(instance).to.be(); + }); + + it('should have the property snakeCase (base name: "snake_case")', function() { + // uncomment below and update the code to test the property snakeCase + //var instane = new SwaggerPetstore.Name(); + //expect(instance).to.be(); + }); + + it('should have the property property (base name: "property")', function() { + // uncomment below and update the code to test the property property + //var instane = new SwaggerPetstore.Name(); + //expect(instance).to.be(); + }); + + it('should have the property _123Number (base name: "123Number")', function() { + // uncomment below and update the code to test the property _123Number + //var instane = new SwaggerPetstore.Name(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/Order.spec.js b/samples/client/petstore/javascript-promise/test/model/Order.spec.js new file mode 100644 index 00000000000..bc27c00cabd --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/Order.spec.js @@ -0,0 +1,106 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Order(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Order', function() { + it('should create an instance of Order', function() { + // uncomment below and update the code to test Order + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be.a(SwaggerPetstore.Order); + }); + + it('should have the property id (base name: "id")', function() { + // uncomment below and update the code to test the property id + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be(); + }); + + it('should have the property petId (base name: "petId")', function() { + // uncomment below and update the code to test the property petId + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be(); + }); + + it('should have the property quantity (base name: "quantity")', function() { + // uncomment below and update the code to test the property quantity + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be(); + }); + + it('should have the property shipDate (base name: "shipDate")', function() { + // uncomment below and update the code to test the property shipDate + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be(); + }); + + it('should have the property status (base name: "status")', function() { + // uncomment below and update the code to test the property status + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be(); + }); + + it('should have the property complete (base name: "complete")', function() { + // uncomment below and update the code to test the property complete + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/Pet.spec.js b/samples/client/petstore/javascript-promise/test/model/Pet.spec.js new file mode 100644 index 00000000000..f6c68015682 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/Pet.spec.js @@ -0,0 +1,106 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Pet(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Pet', function() { + it('should create an instance of Pet', function() { + // uncomment below and update the code to test Pet + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be.a(SwaggerPetstore.Pet); + }); + + it('should have the property id (base name: "id")', function() { + // uncomment below and update the code to test the property id + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be(); + }); + + it('should have the property category (base name: "category")', function() { + // uncomment below and update the code to test the property category + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be(); + }); + + it('should have the property name (base name: "name")', function() { + // uncomment below and update the code to test the property name + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be(); + }); + + it('should have the property photoUrls (base name: "photoUrls")', function() { + // uncomment below and update the code to test the property photoUrls + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be(); + }); + + it('should have the property tags (base name: "tags")', function() { + // uncomment below and update the code to test the property tags + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be(); + }); + + it('should have the property status (base name: "status")', function() { + // uncomment below and update the code to test the property status + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/ReadOnlyFirst.spec.js b/samples/client/petstore/javascript-promise/test/model/ReadOnlyFirst.spec.js new file mode 100644 index 00000000000..2a576c59f8c --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/ReadOnlyFirst.spec.js @@ -0,0 +1,82 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.ReadOnlyFirst(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('ReadOnlyFirst', function() { + it('should create an instance of ReadOnlyFirst', function() { + // uncomment below and update the code to test ReadOnlyFirst + //var instane = new SwaggerPetstore.ReadOnlyFirst(); + //expect(instance).to.be.a(SwaggerPetstore.ReadOnlyFirst); + }); + + it('should have the property bar (base name: "bar")', function() { + // uncomment below and update the code to test the property bar + //var instane = new SwaggerPetstore.ReadOnlyFirst(); + //expect(instance).to.be(); + }); + + it('should have the property baz (base name: "baz")', function() { + // uncomment below and update the code to test the property baz + //var instane = new SwaggerPetstore.ReadOnlyFirst(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/SpecialModelName.spec.js b/samples/client/petstore/javascript-promise/test/model/SpecialModelName.spec.js new file mode 100644 index 00000000000..0f6b7cbb8ef --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/SpecialModelName.spec.js @@ -0,0 +1,76 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.SpecialModelName(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('SpecialModelName', function() { + it('should create an instance of SpecialModelName', function() { + // uncomment below and update the code to test SpecialModelName + //var instane = new SwaggerPetstore.SpecialModelName(); + //expect(instance).to.be.a(SwaggerPetstore.SpecialModelName); + }); + + it('should have the property specialPropertyName (base name: "$special[property.name]")', function() { + // uncomment below and update the code to test the property specialPropertyName + //var instane = new SwaggerPetstore.SpecialModelName(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/Tag.spec.js b/samples/client/petstore/javascript-promise/test/model/Tag.spec.js new file mode 100644 index 00000000000..6ab32cf5b1f --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/Tag.spec.js @@ -0,0 +1,82 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Tag(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Tag', function() { + it('should create an instance of Tag', function() { + // uncomment below and update the code to test Tag + //var instane = new SwaggerPetstore.Tag(); + //expect(instance).to.be.a(SwaggerPetstore.Tag); + }); + + it('should have the property id (base name: "id")', function() { + // uncomment below and update the code to test the property id + //var instane = new SwaggerPetstore.Tag(); + //expect(instance).to.be(); + }); + + it('should have the property name (base name: "name")', function() { + // uncomment below and update the code to test the property name + //var instane = new SwaggerPetstore.Tag(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/test/model/User.spec.js b/samples/client/petstore/javascript-promise/test/model/User.spec.js new file mode 100644 index 00000000000..42ae42a3d68 --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/User.spec.js @@ -0,0 +1,118 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.User(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('User', function() { + it('should create an instance of User', function() { + // uncomment below and update the code to test User + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be.a(SwaggerPetstore.User); + }); + + it('should have the property id (base name: "id")', function() { + // uncomment below and update the code to test the property id + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property username (base name: "username")', function() { + // uncomment below and update the code to test the property username + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property firstName (base name: "firstName")', function() { + // uncomment below and update the code to test the property firstName + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property lastName (base name: "lastName")', function() { + // uncomment below and update the code to test the property lastName + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property email (base name: "email")', function() { + // uncomment below and update the code to test the property email + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property password (base name: "password")', function() { + // uncomment below and update the code to test the property password + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property phone (base name: "phone")', function() { + // uncomment below and update the code to test the property phone + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property userStatus (base name: "userStatus")', function() { + // uncomment below and update the code to test the property userStatus + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/.travis.yml b/samples/client/petstore/javascript/.travis.yml new file mode 100644 index 00000000000..e49f4692f7c --- /dev/null +++ b/samples/client/petstore/javascript/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - "6" + - "6.1" + - "5" + - "5.11" + diff --git a/samples/client/petstore/javascript/LICENSE b/samples/client/petstore/javascript/LICENSE index d9a10c0d8e8..8dada3edaf5 100644 --- a/samples/client/petstore/javascript/LICENSE +++ b/samples/client/petstore/javascript/LICENSE @@ -174,3 +174,28 @@ of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md index dfc15cba3f9..bba1f871bcf 100644 --- a/samples/client/petstore/javascript/README.md +++ b/samples/client/petstore/javascript/README.md @@ -6,7 +6,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-05-29T20:52:27.873+08:00 +- Build date: 2016-06-15T01:15:37.147+08:00 - Build package: class io.swagger.codegen.languages.JavascriptClientCodegen ## Installation diff --git a/samples/client/petstore/javascript/docs/AdditionalPropertiesClass.md b/samples/client/petstore/javascript/docs/AdditionalPropertiesClass.md index f25c4fceec7..0ea13d4bb64 100644 --- a/samples/client/petstore/javascript/docs/AdditionalPropertiesClass.md +++ b/samples/client/petstore/javascript/docs/AdditionalPropertiesClass.md @@ -3,5 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**mapProperty** | **{String: String}** | | [optional] +**mapOfMapProperty** | **{String: {String: String}}** | | [optional] diff --git a/samples/client/petstore/javascript/docs/ArrayTest.md b/samples/client/petstore/javascript/docs/ArrayTest.md index 2e056172023..a2576512243 100644 --- a/samples/client/petstore/javascript/docs/ArrayTest.md +++ b/samples/client/petstore/javascript/docs/ArrayTest.md @@ -3,5 +3,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**arrayOfString** | **[String]** | | [optional] +**arrayArrayOfInteger** | **[[Integer]]** | | [optional] +**arrayArrayOfModel** | **[[ReadOnlyFirst]]** | | [optional] diff --git a/samples/client/petstore/javascript/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/javascript/docs/MixedPropertiesAndAdditionalPropertiesClass.md index cecc4a1156a..31bf8b314ca 100644 --- a/samples/client/petstore/javascript/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/client/petstore/javascript/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -5,5 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **uuid** | **String** | | [optional] **dateTime** | **Date** | | [optional] +**map** | [**{String: Animal}**](Animal.md) | | [optional] diff --git a/samples/client/petstore/javascript/mocha.opts b/samples/client/petstore/javascript/mocha.opts new file mode 100644 index 00000000000..907011807d6 --- /dev/null +++ b/samples/client/petstore/javascript/mocha.opts @@ -0,0 +1 @@ +--timeout 10000 diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index d45704dcdac..9187f89af01 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/api/FakeApi.js b/samples/client/petstore/javascript/src/api/FakeApi.js index 9db45d334f5..95ffb2bd8c6 100644 --- a/samples/client/petstore/javascript/src/api/FakeApi.js +++ b/samples/client/petstore/javascript/src/api/FakeApi.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/api/PetApi.js b/samples/client/petstore/javascript/src/api/PetApi.js index 6e7193bd53e..a90880c8f46 100644 --- a/samples/client/petstore/javascript/src/api/PetApi.js +++ b/samples/client/petstore/javascript/src/api/PetApi.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/api/StoreApi.js b/samples/client/petstore/javascript/src/api/StoreApi.js index 8b9aa077de7..58cdb3a9c08 100644 --- a/samples/client/petstore/javascript/src/api/StoreApi.js +++ b/samples/client/petstore/javascript/src/api/StoreApi.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/api/UserApi.js b/samples/client/petstore/javascript/src/api/UserApi.js index 4bc7218fdce..f9b8fb4a118 100644 --- a/samples/client/petstore/javascript/src/api/UserApi.js +++ b/samples/client/petstore/javascript/src/api/UserApi.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/index.js b/samples/client/petstore/javascript/src/index.js index 2c3e34b4efd..93f2e6cd4b8 100644 --- a/samples/client/petstore/javascript/src/index.js +++ b/samples/client/petstore/javascript/src/index.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/AdditionalPropertiesClass.js b/samples/client/petstore/javascript/src/model/AdditionalPropertiesClass.js index 8dd4d1c9795..10183b1ea43 100644 --- a/samples/client/petstore/javascript/src/model/AdditionalPropertiesClass.js +++ b/samples/client/petstore/javascript/src/model/AdditionalPropertiesClass.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. @@ -28,12 +52,12 @@ * Constructs a new AdditionalPropertiesClass. * @alias module:model/AdditionalPropertiesClass * @class - * @extends Object */ var exports = function() { var _this = this; - return _this; + + }; /** @@ -46,12 +70,25 @@ exports.constructFromObject = function(data, obj) { if (data) { obj = obj || new exports(); - ApiClient.constructFromObject(data, obj, String); + if (data.hasOwnProperty('map_property')) { + obj['map_property'] = ApiClient.convertToType(data['map_property'], {'String': 'String'}); + } + if (data.hasOwnProperty('map_of_map_property')) { + obj['map_of_map_property'] = ApiClient.convertToType(data['map_of_map_property'], {'String': {'String': 'String'}}); + } } return obj; } + /** + * @member {Object.} map_property + */ + exports.prototype['map_property'] = undefined; + /** + * @member {Object.>} map_of_map_property + */ + exports.prototype['map_of_map_property'] = undefined; diff --git a/samples/client/petstore/javascript/src/model/Animal.js b/samples/client/petstore/javascript/src/model/Animal.js index 28e5904e840..32042951cb1 100644 --- a/samples/client/petstore/javascript/src/model/Animal.js +++ b/samples/client/petstore/javascript/src/model/Animal.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/AnimalFarm.js b/samples/client/petstore/javascript/src/model/AnimalFarm.js index d5f6aa2a424..1a54e0d611a 100644 --- a/samples/client/petstore/javascript/src/model/AnimalFarm.js +++ b/samples/client/petstore/javascript/src/model/AnimalFarm.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/ApiResponse.js b/samples/client/petstore/javascript/src/model/ApiResponse.js index 6d4c970264b..1cb041898d4 100644 --- a/samples/client/petstore/javascript/src/model/ApiResponse.js +++ b/samples/client/petstore/javascript/src/model/ApiResponse.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/ArrayTest.js b/samples/client/petstore/javascript/src/model/ArrayTest.js index 5a11c6a47bf..a2589f7ea0a 100644 --- a/samples/client/petstore/javascript/src/model/ArrayTest.js +++ b/samples/client/petstore/javascript/src/model/ArrayTest.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. @@ -32,6 +56,9 @@ var exports = function() { var _this = this; + + + }; /** @@ -45,10 +72,31 @@ if (data) { obj = obj || new exports(); + if (data.hasOwnProperty('array_of_string')) { + obj['array_of_string'] = ApiClient.convertToType(data['array_of_string'], ['String']); + } + if (data.hasOwnProperty('array_array_of_integer')) { + obj['array_array_of_integer'] = ApiClient.convertToType(data['array_array_of_integer'], [['Integer']]); + } + if (data.hasOwnProperty('array_array_of_model')) { + obj['array_array_of_model'] = ApiClient.convertToType(data['array_array_of_model'], [[ReadOnlyFirst]]); + } } return obj; } + /** + * @member {Array.} array_of_string + */ + exports.prototype['array_of_string'] = undefined; + /** + * @member {Array.>} array_array_of_integer + */ + exports.prototype['array_array_of_integer'] = undefined; + /** + * @member {Array.>} array_array_of_model + */ + exports.prototype['array_array_of_model'] = undefined; diff --git a/samples/client/petstore/javascript/src/model/Cat.js b/samples/client/petstore/javascript/src/model/Cat.js index a6b25bc6d58..e6a771019f3 100644 --- a/samples/client/petstore/javascript/src/model/Cat.js +++ b/samples/client/petstore/javascript/src/model/Cat.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/Category.js b/samples/client/petstore/javascript/src/model/Category.js index 9e2e19ac5bb..c415cbd1943 100644 --- a/samples/client/petstore/javascript/src/model/Category.js +++ b/samples/client/petstore/javascript/src/model/Category.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/Dog.js b/samples/client/petstore/javascript/src/model/Dog.js index ee17ae3467f..719237dadd7 100644 --- a/samples/client/petstore/javascript/src/model/Dog.js +++ b/samples/client/petstore/javascript/src/model/Dog.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/EnumClass.js b/samples/client/petstore/javascript/src/model/EnumClass.js index e9bf5219ee5..b0bb7813e7d 100644 --- a/samples/client/petstore/javascript/src/model/EnumClass.js +++ b/samples/client/petstore/javascript/src/model/EnumClass.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/EnumTest.js b/samples/client/petstore/javascript/src/model/EnumTest.js index 6f8f0de3836..0ab961078b0 100644 --- a/samples/client/petstore/javascript/src/model/EnumTest.js +++ b/samples/client/petstore/javascript/src/model/EnumTest.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/FormatTest.js b/samples/client/petstore/javascript/src/model/FormatTest.js index ed9e0cfcaf8..7a941cb5ffa 100644 --- a/samples/client/petstore/javascript/src/model/FormatTest.js +++ b/samples/client/petstore/javascript/src/model/FormatTest.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/MixedPropertiesAndAdditionalPropertiesClass.js b/samples/client/petstore/javascript/src/model/MixedPropertiesAndAdditionalPropertiesClass.js index 1d51ce6c3f8..1db531b401f 100644 --- a/samples/client/petstore/javascript/src/model/MixedPropertiesAndAdditionalPropertiesClass.js +++ b/samples/client/petstore/javascript/src/model/MixedPropertiesAndAdditionalPropertiesClass.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. @@ -28,14 +52,13 @@ * Constructs a new MixedPropertiesAndAdditionalPropertiesClass. * @alias module:model/MixedPropertiesAndAdditionalPropertiesClass * @class - * @extends Object */ var exports = function() { var _this = this; - return _this; + }; /** @@ -48,7 +71,6 @@ exports.constructFromObject = function(data, obj) { if (data) { obj = obj || new exports(); - ApiClient.constructFromObject(data, obj, Animal); if (data.hasOwnProperty('uuid')) { obj['uuid'] = ApiClient.convertToType(data['uuid'], 'String'); @@ -56,6 +78,9 @@ if (data.hasOwnProperty('dateTime')) { obj['dateTime'] = ApiClient.convertToType(data['dateTime'], 'Date'); } + if (data.hasOwnProperty('map')) { + obj['map'] = ApiClient.convertToType(data['map'], {'String': Animal}); + } } return obj; } @@ -68,6 +93,10 @@ * @member {Date} dateTime */ exports.prototype['dateTime'] = undefined; + /** + * @member {Object.} map + */ + exports.prototype['map'] = undefined; diff --git a/samples/client/petstore/javascript/src/model/Model200Response.js b/samples/client/petstore/javascript/src/model/Model200Response.js index 1d83d420287..21ea07b2c39 100644 --- a/samples/client/petstore/javascript/src/model/Model200Response.js +++ b/samples/client/petstore/javascript/src/model/Model200Response.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/ModelReturn.js b/samples/client/petstore/javascript/src/model/ModelReturn.js index d0236e77b17..b9dec2d30c4 100644 --- a/samples/client/petstore/javascript/src/model/ModelReturn.js +++ b/samples/client/petstore/javascript/src/model/ModelReturn.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/Name.js b/samples/client/petstore/javascript/src/model/Name.js index f8c24ef770c..cae738e0d90 100644 --- a/samples/client/petstore/javascript/src/model/Name.js +++ b/samples/client/petstore/javascript/src/model/Name.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/Order.js b/samples/client/petstore/javascript/src/model/Order.js index 57f77d84ccd..f2b3726a04c 100644 --- a/samples/client/petstore/javascript/src/model/Order.js +++ b/samples/client/petstore/javascript/src/model/Order.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/Pet.js b/samples/client/petstore/javascript/src/model/Pet.js index fe14361dbf2..19ed2096877 100644 --- a/samples/client/petstore/javascript/src/model/Pet.js +++ b/samples/client/petstore/javascript/src/model/Pet.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/ReadOnlyFirst.js b/samples/client/petstore/javascript/src/model/ReadOnlyFirst.js index 394af906e73..8ceb17f58bb 100644 --- a/samples/client/petstore/javascript/src/model/ReadOnlyFirst.js +++ b/samples/client/petstore/javascript/src/model/ReadOnlyFirst.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/SpecialModelName.js b/samples/client/petstore/javascript/src/model/SpecialModelName.js index d5a0e992a73..f06c2e46556 100644 --- a/samples/client/petstore/javascript/src/model/SpecialModelName.js +++ b/samples/client/petstore/javascript/src/model/SpecialModelName.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/Tag.js b/samples/client/petstore/javascript/src/model/Tag.js index 443d312b76a..8e188616107 100644 --- a/samples/client/petstore/javascript/src/model/Tag.js +++ b/samples/client/petstore/javascript/src/model/Tag.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/src/model/User.js b/samples/client/petstore/javascript/src/model/User.js index 2360c7c6314..df334f1e623 100644 --- a/samples/client/petstore/javascript/src/model/User.js +++ b/samples/client/petstore/javascript/src/model/User.js @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. diff --git a/samples/client/petstore/javascript/test/api/FakeApi.spec.js b/samples/client/petstore/javascript/test/api/FakeApi.spec.js new file mode 100644 index 00000000000..9f22eb2c3c6 --- /dev/null +++ b/samples/client/petstore/javascript/test/api/FakeApi.spec.js @@ -0,0 +1,50 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.FakeApi(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('FakeApi', function() { + describe('testEndpointParameters', function() { + it('should call testEndpointParameters successfully', function(done) { + //uncomment below and update the code to test testEndpointParameters + //instance.testEndpointParameters(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + }); + +})); diff --git a/samples/client/petstore/javascript/test/api/PetApiTest.js b/samples/client/petstore/javascript/test/api/PetApi.spec.js similarity index 100% rename from samples/client/petstore/javascript/test/api/PetApiTest.js rename to samples/client/petstore/javascript/test/api/PetApi.spec.js diff --git a/samples/client/petstore/javascript/test/api/StoreApiTest.js b/samples/client/petstore/javascript/test/api/StoreApi.spec.js similarity index 100% rename from samples/client/petstore/javascript/test/api/StoreApiTest.js rename to samples/client/petstore/javascript/test/api/StoreApi.spec.js diff --git a/samples/client/petstore/javascript/test/api/UserApi.spec.js b/samples/client/petstore/javascript/test/api/UserApi.spec.js new file mode 100644 index 00000000000..e9b4bb93f90 --- /dev/null +++ b/samples/client/petstore/javascript/test/api/UserApi.spec.js @@ -0,0 +1,120 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.UserApi(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('UserApi', function() { + describe('createUser', function() { + it('should call createUser successfully', function(done) { + //uncomment below and update the code to test createUser + //instance.createUser(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('createUsersWithArrayInput', function() { + it('should call createUsersWithArrayInput successfully', function(done) { + //uncomment below and update the code to test createUsersWithArrayInput + //instance.createUsersWithArrayInput(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('createUsersWithListInput', function() { + it('should call createUsersWithListInput successfully', function(done) { + //uncomment below and update the code to test createUsersWithListInput + //instance.createUsersWithListInput(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('deleteUser', function() { + it('should call deleteUser successfully', function(done) { + //uncomment below and update the code to test deleteUser + //instance.deleteUser(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('getUserByName', function() { + it('should call getUserByName successfully', function(done) { + //uncomment below and update the code to test getUserByName + //instance.getUserByName(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('loginUser', function() { + it('should call loginUser successfully', function(done) { + //uncomment below and update the code to test loginUser + //instance.loginUser(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('logoutUser', function() { + it('should call logoutUser successfully', function(done) { + //uncomment below and update the code to test logoutUser + //instance.logoutUser(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + describe('updateUser', function() { + it('should call updateUser successfully', function(done) { + //uncomment below and update the code to test updateUser + //instance.updateUser(pet, function(error) { + // if (error) throw error; + //expect().to.be(); + //}); + done(); + }); + }); + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/AdditionalPropertiesClass.spec.js b/samples/client/petstore/javascript/test/model/AdditionalPropertiesClass.spec.js new file mode 100644 index 00000000000..9a900762435 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/AdditionalPropertiesClass.spec.js @@ -0,0 +1,58 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.AdditionalPropertiesClass(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('AdditionalPropertiesClass', function() { + it('should create an instance of AdditionalPropertiesClass', function() { + // uncomment below and update the code to test AdditionalPropertiesClass + //var instane = new SwaggerPetstore.AdditionalPropertiesClass(); + //expect(instance).to.be.a(SwaggerPetstore.AdditionalPropertiesClass); + }); + + it('should have the property mapProperty (base name: "map_property")', function() { + // uncomment below and update the code to test the property mapProperty + //var instane = new SwaggerPetstore.AdditionalPropertiesClass(); + //expect(instance).to.be(); + }); + + it('should have the property mapOfMapProperty (base name: "map_of_map_property")', function() { + // uncomment below and update the code to test the property mapOfMapProperty + //var instane = new SwaggerPetstore.AdditionalPropertiesClass(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/Animal.spec.js b/samples/client/petstore/javascript/test/model/Animal.spec.js new file mode 100644 index 00000000000..dfc86e612dc --- /dev/null +++ b/samples/client/petstore/javascript/test/model/Animal.spec.js @@ -0,0 +1,58 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Animal(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Animal', function() { + it('should create an instance of Animal', function() { + // uncomment below and update the code to test Animal + //var instane = new SwaggerPetstore.Animal(); + //expect(instance).to.be.a(SwaggerPetstore.Animal); + }); + + it('should have the property className (base name: "className")', function() { + // uncomment below and update the code to test the property className + //var instane = new SwaggerPetstore.Animal(); + //expect(instance).to.be(); + }); + + it('should have the property color (base name: "color")', function() { + // uncomment below and update the code to test the property color + //var instane = new SwaggerPetstore.Animal(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/AnimalFarm.spec.js b/samples/client/petstore/javascript/test/model/AnimalFarm.spec.js new file mode 100644 index 00000000000..4cacc055dfa --- /dev/null +++ b/samples/client/petstore/javascript/test/model/AnimalFarm.spec.js @@ -0,0 +1,46 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.AnimalFarm(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('AnimalFarm', function() { + it('should create an instance of AnimalFarm', function() { + // uncomment below and update the code to test AnimalFarm + //var instane = new SwaggerPetstore.AnimalFarm(); + //expect(instance).to.be.a(SwaggerPetstore.AnimalFarm); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/ApiResponse.spec.js b/samples/client/petstore/javascript/test/model/ApiResponse.spec.js new file mode 100644 index 00000000000..972649fe24e --- /dev/null +++ b/samples/client/petstore/javascript/test/model/ApiResponse.spec.js @@ -0,0 +1,64 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.ApiResponse(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('ApiResponse', function() { + it('should create an instance of ApiResponse', function() { + // uncomment below and update the code to test ApiResponse + //var instane = new SwaggerPetstore.ApiResponse(); + //expect(instance).to.be.a(SwaggerPetstore.ApiResponse); + }); + + it('should have the property code (base name: "code")', function() { + // uncomment below and update the code to test the property code + //var instane = new SwaggerPetstore.ApiResponse(); + //expect(instance).to.be(); + }); + + it('should have the property type (base name: "type")', function() { + // uncomment below and update the code to test the property type + //var instane = new SwaggerPetstore.ApiResponse(); + //expect(instance).to.be(); + }); + + it('should have the property message (base name: "message")', function() { + // uncomment below and update the code to test the property message + //var instane = new SwaggerPetstore.ApiResponse(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/ArrayTest.spec.js b/samples/client/petstore/javascript/test/model/ArrayTest.spec.js new file mode 100644 index 00000000000..7bb512f1043 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/ArrayTest.spec.js @@ -0,0 +1,64 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.ArrayTest(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('ArrayTest', function() { + it('should create an instance of ArrayTest', function() { + // uncomment below and update the code to test ArrayTest + //var instane = new SwaggerPetstore.ArrayTest(); + //expect(instance).to.be.a(SwaggerPetstore.ArrayTest); + }); + + it('should have the property arrayOfString (base name: "array_of_string")', function() { + // uncomment below and update the code to test the property arrayOfString + //var instane = new SwaggerPetstore.ArrayTest(); + //expect(instance).to.be(); + }); + + it('should have the property arrayArrayOfInteger (base name: "array_array_of_integer")', function() { + // uncomment below and update the code to test the property arrayArrayOfInteger + //var instane = new SwaggerPetstore.ArrayTest(); + //expect(instance).to.be(); + }); + + it('should have the property arrayArrayOfModel (base name: "array_array_of_model")', function() { + // uncomment below and update the code to test the property arrayArrayOfModel + //var instane = new SwaggerPetstore.ArrayTest(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/Cat.spec.js b/samples/client/petstore/javascript/test/model/Cat.spec.js new file mode 100644 index 00000000000..f2dcc4749fe --- /dev/null +++ b/samples/client/petstore/javascript/test/model/Cat.spec.js @@ -0,0 +1,52 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Cat(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Cat', function() { + it('should create an instance of Cat', function() { + // uncomment below and update the code to test Cat + //var instane = new SwaggerPetstore.Cat(); + //expect(instance).to.be.a(SwaggerPetstore.Cat); + }); + + it('should have the property declawed (base name: "declawed")', function() { + // uncomment below and update the code to test the property declawed + //var instane = new SwaggerPetstore.Cat(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/Category.spec.js b/samples/client/petstore/javascript/test/model/Category.spec.js new file mode 100644 index 00000000000..8f1167d8c2a --- /dev/null +++ b/samples/client/petstore/javascript/test/model/Category.spec.js @@ -0,0 +1,58 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Category(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Category', function() { + it('should create an instance of Category', function() { + // uncomment below and update the code to test Category + //var instane = new SwaggerPetstore.Category(); + //expect(instance).to.be.a(SwaggerPetstore.Category); + }); + + it('should have the property id (base name: "id")', function() { + // uncomment below and update the code to test the property id + //var instane = new SwaggerPetstore.Category(); + //expect(instance).to.be(); + }); + + it('should have the property name (base name: "name")', function() { + // uncomment below and update the code to test the property name + //var instane = new SwaggerPetstore.Category(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/Dog.spec.js b/samples/client/petstore/javascript/test/model/Dog.spec.js new file mode 100644 index 00000000000..292a803e7a4 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/Dog.spec.js @@ -0,0 +1,52 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Dog(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Dog', function() { + it('should create an instance of Dog', function() { + // uncomment below and update the code to test Dog + //var instane = new SwaggerPetstore.Dog(); + //expect(instance).to.be.a(SwaggerPetstore.Dog); + }); + + it('should have the property breed (base name: "breed")', function() { + // uncomment below and update the code to test the property breed + //var instane = new SwaggerPetstore.Dog(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/EnumClass.spec.js b/samples/client/petstore/javascript/test/model/EnumClass.spec.js new file mode 100644 index 00000000000..dd95265d3ed --- /dev/null +++ b/samples/client/petstore/javascript/test/model/EnumClass.spec.js @@ -0,0 +1,45 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('EnumClass', function() { + it('should create an instance of EnumClass', function() { + // uncomment below and update the code to test EnumClass + //var instane = new SwaggerPetstore.EnumClass(); + //expect(instance).to.be.a(SwaggerPetstore.EnumClass); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/EnumTest.spec.js b/samples/client/petstore/javascript/test/model/EnumTest.spec.js new file mode 100644 index 00000000000..ec4841dc881 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/EnumTest.spec.js @@ -0,0 +1,64 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.EnumTest(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('EnumTest', function() { + it('should create an instance of EnumTest', function() { + // uncomment below and update the code to test EnumTest + //var instane = new SwaggerPetstore.EnumTest(); + //expect(instance).to.be.a(SwaggerPetstore.EnumTest); + }); + + it('should have the property enumString (base name: "enum_string")', function() { + // uncomment below and update the code to test the property enumString + //var instane = new SwaggerPetstore.EnumTest(); + //expect(instance).to.be(); + }); + + it('should have the property enumInteger (base name: "enum_integer")', function() { + // uncomment below and update the code to test the property enumInteger + //var instane = new SwaggerPetstore.EnumTest(); + //expect(instance).to.be(); + }); + + it('should have the property enumNumber (base name: "enum_number")', function() { + // uncomment below and update the code to test the property enumNumber + //var instane = new SwaggerPetstore.EnumTest(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/FormatTest.spec.js b/samples/client/petstore/javascript/test/model/FormatTest.spec.js new file mode 100644 index 00000000000..659d4ba46c2 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/FormatTest.spec.js @@ -0,0 +1,124 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.FormatTest(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('FormatTest', function() { + it('should create an instance of FormatTest', function() { + // uncomment below and update the code to test FormatTest + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be.a(SwaggerPetstore.FormatTest); + }); + + it('should have the property integer (base name: "integer")', function() { + // uncomment below and update the code to test the property integer + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property int32 (base name: "int32")', function() { + // uncomment below and update the code to test the property int32 + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property int64 (base name: "int64")', function() { + // uncomment below and update the code to test the property int64 + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property _number (base name: "number")', function() { + // uncomment below and update the code to test the property _number + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property _float (base name: "float")', function() { + // uncomment below and update the code to test the property _float + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property _double (base name: "double")', function() { + // uncomment below and update the code to test the property _double + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property _string (base name: "string")', function() { + // uncomment below and update the code to test the property _string + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property _byte (base name: "byte")', function() { + // uncomment below and update the code to test the property _byte + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property binary (base name: "binary")', function() { + // uncomment below and update the code to test the property binary + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property _date (base name: "date")', function() { + // uncomment below and update the code to test the property _date + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property dateTime (base name: "dateTime")', function() { + // uncomment below and update the code to test the property dateTime + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property uuid (base name: "uuid")', function() { + // uncomment below and update the code to test the property uuid + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + it('should have the property password (base name: "password")', function() { + // uncomment below and update the code to test the property password + //var instane = new SwaggerPetstore.FormatTest(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/MixedPropertiesAndAdditionalPropertiesClass.spec.js b/samples/client/petstore/javascript/test/model/MixedPropertiesAndAdditionalPropertiesClass.spec.js new file mode 100644 index 00000000000..712ac334966 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/MixedPropertiesAndAdditionalPropertiesClass.spec.js @@ -0,0 +1,64 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('MixedPropertiesAndAdditionalPropertiesClass', function() { + it('should create an instance of MixedPropertiesAndAdditionalPropertiesClass', function() { + // uncomment below and update the code to test MixedPropertiesAndAdditionalPropertiesClass + //var instane = new SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass(); + //expect(instance).to.be.a(SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass); + }); + + it('should have the property uuid (base name: "uuid")', function() { + // uncomment below and update the code to test the property uuid + //var instane = new SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass(); + //expect(instance).to.be(); + }); + + it('should have the property dateTime (base name: "dateTime")', function() { + // uncomment below and update the code to test the property dateTime + //var instane = new SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass(); + //expect(instance).to.be(); + }); + + it('should have the property map (base name: "map")', function() { + // uncomment below and update the code to test the property map + //var instane = new SwaggerPetstore.MixedPropertiesAndAdditionalPropertiesClass(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/Model200Response.spec.js b/samples/client/petstore/javascript/test/model/Model200Response.spec.js new file mode 100644 index 00000000000..a7549135636 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/Model200Response.spec.js @@ -0,0 +1,52 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Model200Response(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Model200Response', function() { + it('should create an instance of Model200Response', function() { + // uncomment below and update the code to test Model200Response + //var instane = new SwaggerPetstore.Model200Response(); + //expect(instance).to.be.a(SwaggerPetstore.Model200Response); + }); + + it('should have the property name (base name: "name")', function() { + // uncomment below and update the code to test the property name + //var instane = new SwaggerPetstore.Model200Response(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/ModelReturn.spec.js b/samples/client/petstore/javascript/test/model/ModelReturn.spec.js new file mode 100644 index 00000000000..f2cfd489138 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/ModelReturn.spec.js @@ -0,0 +1,52 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.ModelReturn(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('ModelReturn', function() { + it('should create an instance of ModelReturn', function() { + // uncomment below and update the code to test ModelReturn + //var instane = new SwaggerPetstore.ModelReturn(); + //expect(instance).to.be.a(SwaggerPetstore.ModelReturn); + }); + + it('should have the property _return (base name: "return")', function() { + // uncomment below and update the code to test the property _return + //var instane = new SwaggerPetstore.ModelReturn(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/Name.spec.js b/samples/client/petstore/javascript/test/model/Name.spec.js new file mode 100644 index 00000000000..13d85520601 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/Name.spec.js @@ -0,0 +1,70 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Name(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Name', function() { + it('should create an instance of Name', function() { + // uncomment below and update the code to test Name + //var instane = new SwaggerPetstore.Name(); + //expect(instance).to.be.a(SwaggerPetstore.Name); + }); + + it('should have the property name (base name: "name")', function() { + // uncomment below and update the code to test the property name + //var instane = new SwaggerPetstore.Name(); + //expect(instance).to.be(); + }); + + it('should have the property snakeCase (base name: "snake_case")', function() { + // uncomment below and update the code to test the property snakeCase + //var instane = new SwaggerPetstore.Name(); + //expect(instance).to.be(); + }); + + it('should have the property property (base name: "property")', function() { + // uncomment below and update the code to test the property property + //var instane = new SwaggerPetstore.Name(); + //expect(instance).to.be(); + }); + + it('should have the property _123Number (base name: "123Number")', function() { + // uncomment below and update the code to test the property _123Number + //var instane = new SwaggerPetstore.Name(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/Order.spec.js b/samples/client/petstore/javascript/test/model/Order.spec.js new file mode 100644 index 00000000000..070690ef131 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/Order.spec.js @@ -0,0 +1,82 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Order(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Order', function() { + it('should create an instance of Order', function() { + // uncomment below and update the code to test Order + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be.a(SwaggerPetstore.Order); + }); + + it('should have the property id (base name: "id")', function() { + // uncomment below and update the code to test the property id + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be(); + }); + + it('should have the property petId (base name: "petId")', function() { + // uncomment below and update the code to test the property petId + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be(); + }); + + it('should have the property quantity (base name: "quantity")', function() { + // uncomment below and update the code to test the property quantity + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be(); + }); + + it('should have the property shipDate (base name: "shipDate")', function() { + // uncomment below and update the code to test the property shipDate + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be(); + }); + + it('should have the property status (base name: "status")', function() { + // uncomment below and update the code to test the property status + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be(); + }); + + it('should have the property complete (base name: "complete")', function() { + // uncomment below and update the code to test the property complete + //var instane = new SwaggerPetstore.Order(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/Pet.spec.js b/samples/client/petstore/javascript/test/model/Pet.spec.js new file mode 100644 index 00000000000..ac66031152d --- /dev/null +++ b/samples/client/petstore/javascript/test/model/Pet.spec.js @@ -0,0 +1,82 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Pet(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Pet', function() { + it('should create an instance of Pet', function() { + // uncomment below and update the code to test Pet + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be.a(SwaggerPetstore.Pet); + }); + + it('should have the property id (base name: "id")', function() { + // uncomment below and update the code to test the property id + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be(); + }); + + it('should have the property category (base name: "category")', function() { + // uncomment below and update the code to test the property category + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be(); + }); + + it('should have the property name (base name: "name")', function() { + // uncomment below and update the code to test the property name + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be(); + }); + + it('should have the property photoUrls (base name: "photoUrls")', function() { + // uncomment below and update the code to test the property photoUrls + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be(); + }); + + it('should have the property tags (base name: "tags")', function() { + // uncomment below and update the code to test the property tags + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be(); + }); + + it('should have the property status (base name: "status")', function() { + // uncomment below and update the code to test the property status + //var instane = new SwaggerPetstore.Pet(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/ReadOnlyFirst.spec.js b/samples/client/petstore/javascript/test/model/ReadOnlyFirst.spec.js new file mode 100644 index 00000000000..1af5ea146b3 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/ReadOnlyFirst.spec.js @@ -0,0 +1,58 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.ReadOnlyFirst(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('ReadOnlyFirst', function() { + it('should create an instance of ReadOnlyFirst', function() { + // uncomment below and update the code to test ReadOnlyFirst + //var instane = new SwaggerPetstore.ReadOnlyFirst(); + //expect(instance).to.be.a(SwaggerPetstore.ReadOnlyFirst); + }); + + it('should have the property bar (base name: "bar")', function() { + // uncomment below and update the code to test the property bar + //var instane = new SwaggerPetstore.ReadOnlyFirst(); + //expect(instance).to.be(); + }); + + it('should have the property baz (base name: "baz")', function() { + // uncomment below and update the code to test the property baz + //var instane = new SwaggerPetstore.ReadOnlyFirst(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/SpecialModelName.spec.js b/samples/client/petstore/javascript/test/model/SpecialModelName.spec.js new file mode 100644 index 00000000000..8255ae7a8f5 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/SpecialModelName.spec.js @@ -0,0 +1,52 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.SpecialModelName(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('SpecialModelName', function() { + it('should create an instance of SpecialModelName', function() { + // uncomment below and update the code to test SpecialModelName + //var instane = new SwaggerPetstore.SpecialModelName(); + //expect(instance).to.be.a(SwaggerPetstore.SpecialModelName); + }); + + it('should have the property specialPropertyName (base name: "$special[property.name]")', function() { + // uncomment below and update the code to test the property specialPropertyName + //var instane = new SwaggerPetstore.SpecialModelName(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/Tag.spec.js b/samples/client/petstore/javascript/test/model/Tag.spec.js new file mode 100644 index 00000000000..1a33f7fb9f1 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/Tag.spec.js @@ -0,0 +1,58 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.Tag(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('Tag', function() { + it('should create an instance of Tag', function() { + // uncomment below and update the code to test Tag + //var instane = new SwaggerPetstore.Tag(); + //expect(instance).to.be.a(SwaggerPetstore.Tag); + }); + + it('should have the property id (base name: "id")', function() { + // uncomment below and update the code to test the property id + //var instane = new SwaggerPetstore.Tag(); + //expect(instance).to.be(); + }); + + it('should have the property name (base name: "name")', function() { + // uncomment below and update the code to test the property name + //var instane = new SwaggerPetstore.Tag(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/test/model/User.spec.js b/samples/client/petstore/javascript/test/model/User.spec.js new file mode 100644 index 00000000000..5c0e3dfc826 --- /dev/null +++ b/samples/client/petstore/javascript/test/model/User.spec.js @@ -0,0 +1,94 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.SwaggerPetstore); + } +}(this, function(expect, SwaggerPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new SwaggerPetstore.User(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('User', function() { + it('should create an instance of User', function() { + // uncomment below and update the code to test User + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be.a(SwaggerPetstore.User); + }); + + it('should have the property id (base name: "id")', function() { + // uncomment below and update the code to test the property id + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property username (base name: "username")', function() { + // uncomment below and update the code to test the property username + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property firstName (base name: "firstName")', function() { + // uncomment below and update the code to test the property firstName + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property lastName (base name: "lastName")', function() { + // uncomment below and update the code to test the property lastName + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property email (base name: "email")', function() { + // uncomment below and update the code to test the property email + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property password (base name: "password")', function() { + // uncomment below and update the code to test the property password + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property phone (base name: "phone")', function() { + // uncomment below and update the code to test the property phone + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + it('should have the property userStatus (base name: "userStatus")', function() { + // uncomment below and update the code to test the property userStatus + //var instane = new SwaggerPetstore.User(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/objc/README.md b/samples/client/petstore/objc/README.md index 44bff87c42e..dbaa3b6af1c 100644 --- a/samples/client/petstore/objc/README.md +++ b/samples/client/petstore/objc/README.md @@ -6,7 +6,7 @@ This ObjC package is automatically generated by the [Swagger Codegen](https://gi - API version: 1.0.0 - Package version: -- Build date: 2016-05-27T16:03:28.462+02:00 +- Build date: 2016-06-13T18:11:50.695+02:00 - Build package: class io.swagger.codegen.languages.ObjcClientCodegen ## Requirements diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGApiClient.h b/samples/client/petstore/objc/SwaggerClient/Core/SWGApiClient.h index a926598ce5f..2ec5c9b0fcc 100644 --- a/samples/client/petstore/objc/SwaggerClient/Core/SWGApiClient.h +++ b/samples/client/petstore/objc/SwaggerClient/Core/SWGApiClient.h @@ -1,6 +1,6 @@ #import #import -#import +#import #import "SWGJSONResponseSerializer.h" #import "SWGJSONRequestSerializer.h" #import "SWGQueryParamCollection.h" diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGApiClient.m b/samples/client/petstore/objc/SwaggerClient/Core/SWGApiClient.m index 66305707b17..f004200b2eb 100644 --- a/samples/client/petstore/objc/SwaggerClient/Core/SWGApiClient.m +++ b/samples/client/petstore/objc/SwaggerClient/Core/SWGApiClient.m @@ -50,6 +50,7 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) { - (instancetype)initWithBaseURL:(NSURL *)url { self = [super initWithBaseURL:url]; if (self) { + self.timeoutInterval = 60; self.requestSerializer = [AFJSONRequestSerializer serializer]; self.responseSerializer = [AFJSONResponseSerializer serializer]; self.securityPolicy = [self customSecurityPolicy]; @@ -87,6 +88,11 @@ static NSString * SWG__fileNameForResponse(NSURLResponse *response) { [self.requestSerializer setValue:value forHTTPHeaderField:forKey]; } +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + [super setRequestSerializer:requestSerializer]; + requestSerializer.timeoutInterval = self.timeoutInterval; +} + #pragma mark - Cache Methods +(void)clearCache { diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObject.h b/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObject.h index 021af11ec8d..87f971bdb3b 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObject.h +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObject.h @@ -35,12 +35,11 @@ NS_ASSUME_NONNULL_BEGIN @property (nullable, nonatomic, retain) NSNumber* _id; @property (nullable, nonatomic, retain) NSString* name; - @end @interface SWGCategoryManagedObject (GeneratedAccessors) - @end + NS_ASSUME_NONNULL_END diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObject.m b/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObject.m index aa4d5f4b822..af48c7a2d6f 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObject.m +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObject.m @@ -9,5 +9,4 @@ @dynamic _id; @dynamic name; - @end diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.h b/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.h index 51452aa5c89..da5d39da58c 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.h +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.h @@ -35,12 +35,12 @@ -(SWGCategoryManagedObject*)createNewSWGCategoryManagedObjectInContext:(NSManagedObjectContext*)context; --(SWGCategoryManagedObject*)SWGCategoryManagedObjectFromSWGCategory:(SWGCategory*)Category context:(NSManagedObjectContext*)context; +-(SWGCategoryManagedObject*)SWGCategoryManagedObjectFromSWGCategory:(SWGCategory*)object context:(NSManagedObjectContext*)context; --(void)updateSWGCategoryManagedObject:(SWGCategoryManagedObject*)Category withSWGCategory:(SWGCategory*)Category2; +-(void)updateSWGCategoryManagedObject:(SWGCategoryManagedObject*)object withSWGCategory:(SWGCategory*)object2; -(SWGCategory*)SWGCategoryFromSWGCategoryManagedObject:(SWGCategoryManagedObject*)obj; --(void)updateSWGCategory:(SWGCategory*)Category withSWGCategoryManagedObject:(SWGCategoryManagedObject*)Category2; +-(void)updateSWGCategory:(SWGCategory*)object withSWGCategoryManagedObject:(SWGCategoryManagedObject*)object2; @end diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.m b/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.m index 6c895a4c0d6..0672d46b217 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.m +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGCategoryManagedObjectBuilder.m @@ -13,7 +13,7 @@ -(instancetype)init { self = [super init]; if (self != nil) { - } + } return self; } @@ -22,9 +22,9 @@ return managedObject; } --(SWGCategoryManagedObject*)SWGCategoryManagedObjectFromSWGCategory:(SWGCategory*)Category context:(NSManagedObjectContext*)context { +-(SWGCategoryManagedObject*)SWGCategoryManagedObjectFromSWGCategory:(SWGCategory*)object context:(NSManagedObjectContext*)context { SWGCategoryManagedObject* newSWGCategory = [self createNewSWGCategoryManagedObjectInContext:context]; - [self updateSWGCategoryManagedObject:newSWGCategory withSWGCategory:Category]; + [self updateSWGCategoryManagedObject:newSWGCategory withSWGCategory:object]; return newSWGCategory; } @@ -34,6 +34,7 @@ } managedObject._id = [object._id copy]; managedObject.name = [object.name copy]; + } -(SWGCategory*)SWGCategoryFromSWGCategoryManagedObject:(SWGCategoryManagedObject*)obj { diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObject.h b/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObject.h index c0d9d471bac..cc892779159 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObject.h +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObject.h @@ -44,12 +44,11 @@ NS_ASSUME_NONNULL_BEGIN @property (nullable, nonatomic, retain) NSString* status; @property (nullable, nonatomic, retain) NSNumber* complete; - @end @interface SWGOrderManagedObject (GeneratedAccessors) - @end + NS_ASSUME_NONNULL_END diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObject.m b/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObject.m index 7a1b9298a95..7f391f93cbd 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObject.m +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObject.m @@ -13,5 +13,4 @@ @dynamic shipDate; @dynamic status; @dynamic complete; - @end diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObjectBuilder.h b/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObjectBuilder.h index fbabfedb404..9f7174b272b 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObjectBuilder.h +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObjectBuilder.h @@ -35,12 +35,12 @@ -(SWGOrderManagedObject*)createNewSWGOrderManagedObjectInContext:(NSManagedObjectContext*)context; --(SWGOrderManagedObject*)SWGOrderManagedObjectFromSWGOrder:(SWGOrder*)Order context:(NSManagedObjectContext*)context; +-(SWGOrderManagedObject*)SWGOrderManagedObjectFromSWGOrder:(SWGOrder*)object context:(NSManagedObjectContext*)context; --(void)updateSWGOrderManagedObject:(SWGOrderManagedObject*)Order withSWGOrder:(SWGOrder*)Order2; +-(void)updateSWGOrderManagedObject:(SWGOrderManagedObject*)object withSWGOrder:(SWGOrder*)object2; -(SWGOrder*)SWGOrderFromSWGOrderManagedObject:(SWGOrderManagedObject*)obj; --(void)updateSWGOrder:(SWGOrder*)Order withSWGOrderManagedObject:(SWGOrderManagedObject*)Order2; +-(void)updateSWGOrder:(SWGOrder*)object withSWGOrderManagedObject:(SWGOrderManagedObject*)object2; @end diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObjectBuilder.m b/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObjectBuilder.m index ce1c6352b11..22244f0cf95 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObjectBuilder.m +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGOrderManagedObjectBuilder.m @@ -13,7 +13,7 @@ -(instancetype)init { self = [super init]; if (self != nil) { - } + } return self; } @@ -22,9 +22,9 @@ return managedObject; } --(SWGOrderManagedObject*)SWGOrderManagedObjectFromSWGOrder:(SWGOrder*)Order context:(NSManagedObjectContext*)context { +-(SWGOrderManagedObject*)SWGOrderManagedObjectFromSWGOrder:(SWGOrder*)object context:(NSManagedObjectContext*)context { SWGOrderManagedObject* newSWGOrder = [self createNewSWGOrderManagedObjectInContext:context]; - [self updateSWGOrderManagedObject:newSWGOrder withSWGOrder:Order]; + [self updateSWGOrderManagedObject:newSWGOrder withSWGOrder:object]; return newSWGOrder; } @@ -38,6 +38,7 @@ managedObject.shipDate = [object.shipDate copy]; managedObject.status = [object.status copy]; managedObject.complete = [object.complete copy]; + } -(SWGOrder*)SWGOrderFromSWGOrderManagedObject:(SWGOrderManagedObject*)obj { diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObject.h b/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObject.h index 1f1c5d3cadb..e24f3a58975 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObject.h +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObject.h @@ -46,11 +46,9 @@ NS_ASSUME_NONNULL_BEGIN /* pet status in the store [optional] */ @property (nullable, nonatomic, retain) NSString* status; - @end @interface SWGPetManagedObject (GeneratedAccessors) - - (void)addTagsObject:(SWGTagManagedObject *)value; - (void)removeTagsObject:(SWGTagManagedObject *)value; - (void)addTags:(NSSet *)values; @@ -58,4 +56,5 @@ NS_ASSUME_NONNULL_BEGIN @end + NS_ASSUME_NONNULL_END diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObject.m b/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObject.m index 7526628c42b..9bfba2dc9e8 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObject.m +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObject.m @@ -13,5 +13,4 @@ @dynamic photoUrls; @dynamic tags; @dynamic status; - @end diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObjectBuilder.h b/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObjectBuilder.h index 09161aca3d7..6d145c7bc88 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObjectBuilder.h +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObjectBuilder.h @@ -39,12 +39,12 @@ -(SWGPetManagedObject*)createNewSWGPetManagedObjectInContext:(NSManagedObjectContext*)context; --(SWGPetManagedObject*)SWGPetManagedObjectFromSWGPet:(SWGPet*)Pet context:(NSManagedObjectContext*)context; +-(SWGPetManagedObject*)SWGPetManagedObjectFromSWGPet:(SWGPet*)object context:(NSManagedObjectContext*)context; --(void)updateSWGPetManagedObject:(SWGPetManagedObject*)Pet withSWGPet:(SWGPet*)Pet2; +-(void)updateSWGPetManagedObject:(SWGPetManagedObject*)object withSWGPet:(SWGPet*)object2; -(SWGPet*)SWGPetFromSWGPetManagedObject:(SWGPetManagedObject*)obj; --(void)updateSWGPet:(SWGPet*)Pet withSWGPetManagedObject:(SWGPetManagedObject*)Pet2; +-(void)updateSWGPet:(SWGPet*)object withSWGPetManagedObject:(SWGPetManagedObject*)object2; @end diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObjectBuilder.m b/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObjectBuilder.m index 84a3463ea78..49b9139c810 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObjectBuilder.m +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGPetManagedObjectBuilder.m @@ -15,7 +15,7 @@ if (self != nil) { _categoryBuilder = [[SWGCategoryManagedObjectBuilder alloc] init]; _tagsBuilder = [[SWGTagManagedObjectBuilder alloc] init]; - } + } return self; } @@ -24,9 +24,9 @@ return managedObject; } --(SWGPetManagedObject*)SWGPetManagedObjectFromSWGPet:(SWGPet*)Pet context:(NSManagedObjectContext*)context { +-(SWGPetManagedObject*)SWGPetManagedObjectFromSWGPet:(SWGPet*)object context:(NSManagedObjectContext*)context { SWGPetManagedObject* newSWGPet = [self createNewSWGPetManagedObjectInContext:context]; - [self updateSWGPetManagedObject:newSWGPet withSWGPet:Pet]; + [self updateSWGPetManagedObject:newSWGPet withSWGPet:object]; return newSWGPet; } @@ -52,6 +52,7 @@ managedObject.tags = convertedObjs; } managedObject.status = [object.status copy]; + } -(SWGPet*)SWGPetFromSWGPetManagedObject:(SWGPetManagedObject*)obj { diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObject.h b/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObject.h index cca64c327af..a72cf49cb8b 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObject.h +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObject.h @@ -35,12 +35,11 @@ NS_ASSUME_NONNULL_BEGIN @property (nullable, nonatomic, retain) NSNumber* _id; @property (nullable, nonatomic, retain) NSString* name; - @end @interface SWGTagManagedObject (GeneratedAccessors) - @end + NS_ASSUME_NONNULL_END diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObject.m b/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObject.m index 9f616af1ea8..f62f15b02c2 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObject.m +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObject.m @@ -9,5 +9,4 @@ @dynamic _id; @dynamic name; - @end diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObjectBuilder.h b/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObjectBuilder.h index 3c54b8f0660..1269d197c97 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObjectBuilder.h +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObjectBuilder.h @@ -35,12 +35,12 @@ -(SWGTagManagedObject*)createNewSWGTagManagedObjectInContext:(NSManagedObjectContext*)context; --(SWGTagManagedObject*)SWGTagManagedObjectFromSWGTag:(SWGTag*)Tag context:(NSManagedObjectContext*)context; +-(SWGTagManagedObject*)SWGTagManagedObjectFromSWGTag:(SWGTag*)object context:(NSManagedObjectContext*)context; --(void)updateSWGTagManagedObject:(SWGTagManagedObject*)Tag withSWGTag:(SWGTag*)Tag2; +-(void)updateSWGTagManagedObject:(SWGTagManagedObject*)object withSWGTag:(SWGTag*)object2; -(SWGTag*)SWGTagFromSWGTagManagedObject:(SWGTagManagedObject*)obj; --(void)updateSWGTag:(SWGTag*)Tag withSWGTagManagedObject:(SWGTagManagedObject*)Tag2; +-(void)updateSWGTag:(SWGTag*)object withSWGTagManagedObject:(SWGTagManagedObject*)object2; @end diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObjectBuilder.m b/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObjectBuilder.m index 2e26bfc555c..3c49ae2e49e 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObjectBuilder.m +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGTagManagedObjectBuilder.m @@ -13,7 +13,7 @@ -(instancetype)init { self = [super init]; if (self != nil) { - } + } return self; } @@ -22,9 +22,9 @@ return managedObject; } --(SWGTagManagedObject*)SWGTagManagedObjectFromSWGTag:(SWGTag*)Tag context:(NSManagedObjectContext*)context { +-(SWGTagManagedObject*)SWGTagManagedObjectFromSWGTag:(SWGTag*)object context:(NSManagedObjectContext*)context { SWGTagManagedObject* newSWGTag = [self createNewSWGTagManagedObjectInContext:context]; - [self updateSWGTagManagedObject:newSWGTag withSWGTag:Tag]; + [self updateSWGTagManagedObject:newSWGTag withSWGTag:object]; return newSWGTag; } @@ -34,6 +34,7 @@ } managedObject._id = [object._id copy]; managedObject.name = [object.name copy]; + } -(SWGTag*)SWGTagFromSWGTagManagedObject:(SWGTagManagedObject*)obj { diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObject.h b/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObject.h index 30405f3658a..8f4d094f87f 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObject.h +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObject.h @@ -48,12 +48,11 @@ NS_ASSUME_NONNULL_BEGIN /* User Status [optional] */ @property (nullable, nonatomic, retain) NSNumber* userStatus; - @end @interface SWGUserManagedObject (GeneratedAccessors) - @end + NS_ASSUME_NONNULL_END diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObject.m b/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObject.m index f6779715858..12e6966a0e7 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObject.m +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObject.m @@ -15,5 +15,4 @@ @dynamic password; @dynamic phone; @dynamic userStatus; - @end diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObjectBuilder.h b/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObjectBuilder.h index 1c39fa6de5b..9c6e4957313 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObjectBuilder.h +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObjectBuilder.h @@ -35,12 +35,12 @@ -(SWGUserManagedObject*)createNewSWGUserManagedObjectInContext:(NSManagedObjectContext*)context; --(SWGUserManagedObject*)SWGUserManagedObjectFromSWGUser:(SWGUser*)User context:(NSManagedObjectContext*)context; +-(SWGUserManagedObject*)SWGUserManagedObjectFromSWGUser:(SWGUser*)object context:(NSManagedObjectContext*)context; --(void)updateSWGUserManagedObject:(SWGUserManagedObject*)User withSWGUser:(SWGUser*)User2; +-(void)updateSWGUserManagedObject:(SWGUserManagedObject*)object withSWGUser:(SWGUser*)object2; -(SWGUser*)SWGUserFromSWGUserManagedObject:(SWGUserManagedObject*)obj; --(void)updateSWGUser:(SWGUser*)User withSWGUserManagedObject:(SWGUserManagedObject*)User2; +-(void)updateSWGUser:(SWGUser*)object withSWGUserManagedObject:(SWGUserManagedObject*)object2; @end diff --git a/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObjectBuilder.m b/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObjectBuilder.m index 8086e6a20e6..72cefa95b89 100644 --- a/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObjectBuilder.m +++ b/samples/client/petstore/objc/SwaggerClient/Model/SWGUserManagedObjectBuilder.m @@ -13,7 +13,7 @@ -(instancetype)init { self = [super init]; if (self != nil) { - } + } return self; } @@ -22,9 +22,9 @@ return managedObject; } --(SWGUserManagedObject*)SWGUserManagedObjectFromSWGUser:(SWGUser*)User context:(NSManagedObjectContext*)context { +-(SWGUserManagedObject*)SWGUserManagedObjectFromSWGUser:(SWGUser*)object context:(NSManagedObjectContext*)context { SWGUserManagedObject* newSWGUser = [self createNewSWGUserManagedObjectInContext:context]; - [self updateSWGUserManagedObject:newSWGUser withSWGUser:User]; + [self updateSWGUserManagedObject:newSWGUser withSWGUser:object]; return newSWGUser; } @@ -40,6 +40,7 @@ managedObject.password = [object.password copy]; managedObject.phone = [object.phone copy]; managedObject.userStatus = [object.userStatus copy]; + } -(SWGUser*)SWGUserFromSWGUserManagedObject:(SWGUserManagedObject*)obj { diff --git a/samples/client/petstore/objc/docs/SWG200Response.md b/samples/client/petstore/objc/docs/SWG200Response.md new file mode 100644 index 00000000000..31392772201 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWG200Response.md @@ -0,0 +1,10 @@ +# SWG200Response + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **NSNumber*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGAdditionalPropertiesClass.md b/samples/client/petstore/objc/docs/SWGAdditionalPropertiesClass.md new file mode 100644 index 00000000000..930b5b886d9 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGAdditionalPropertiesClass.md @@ -0,0 +1,11 @@ +# SWGAdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**mapProperty** | **NSDictionary<NSString*, NSString*>*** | | [optional] +**mapOfMapProperty** | [**NSDictionary<NSString*, NSDictionary<NSString*, NSString*>*>***](NSDictionary.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGAnimal.md b/samples/client/petstore/objc/docs/SWGAnimal.md new file mode 100644 index 00000000000..a54bdefe8af --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGAnimal.md @@ -0,0 +1,11 @@ +# SWGAnimal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **NSString*** | | +**color** | **NSString*** | | [optional] [default to @"red"] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGAnimalFarm.md b/samples/client/petstore/objc/docs/SWGAnimalFarm.md new file mode 100644 index 00000000000..48b268a95f3 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGAnimalFarm.md @@ -0,0 +1,9 @@ +# SWGAnimalFarm + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGApiResponse.md b/samples/client/petstore/objc/docs/SWGApiResponse.md new file mode 100644 index 00000000000..88ff755faf7 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGApiResponse.md @@ -0,0 +1,12 @@ +# SWGApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **NSNumber*** | | [optional] +**type** | **NSString*** | | [optional] +**message** | **NSString*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGArrayTest.md b/samples/client/petstore/objc/docs/SWGArrayTest.md new file mode 100644 index 00000000000..089bd48dc16 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGArrayTest.md @@ -0,0 +1,12 @@ +# SWGArrayTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**arrayOfString** | **NSArray<NSString*>*** | | [optional] +**arrayArrayOfInteger** | [**NSArray<NSArray<NSNumber*>*>***](NSArray.md) | | [optional] +**arrayArrayOfModel** | [**NSArray<NSArray<SWGReadOnlyFirst>*>***](NSArray.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGCat.md b/samples/client/petstore/objc/docs/SWGCat.md new file mode 100644 index 00000000000..9fd46b05af0 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGCat.md @@ -0,0 +1,12 @@ +# SWGCat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **NSString*** | | +**color** | **NSString*** | | [optional] [default to @"red"] +**declawed** | **NSNumber*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGDog.md b/samples/client/petstore/objc/docs/SWGDog.md new file mode 100644 index 00000000000..1b3deb35c3f --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGDog.md @@ -0,0 +1,12 @@ +# SWGDog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **NSString*** | | +**color** | **NSString*** | | [optional] [default to @"red"] +**breed** | **NSString*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGEnumClass.md b/samples/client/petstore/objc/docs/SWGEnumClass.md new file mode 100644 index 00000000000..6acdf03e456 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGEnumClass.md @@ -0,0 +1,9 @@ +# SWGEnumClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGEnumTest.md b/samples/client/petstore/objc/docs/SWGEnumTest.md new file mode 100644 index 00000000000..4f0c5f3285e --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGEnumTest.md @@ -0,0 +1,12 @@ +# SWGEnumTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enumString** | **NSString*** | | [optional] +**enumInteger** | **NSNumber*** | | [optional] +**enumNumber** | **NSNumber*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGFakeApi.md b/samples/client/petstore/objc/docs/SWGFakeApi.md new file mode 100644 index 00000000000..536f88dee8e --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGFakeApi.md @@ -0,0 +1,100 @@ +# SWGFakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testEndpointParameters**](SWGFakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + + +# **testEndpointParameters** +```objc +-(NSNumber*) testEndpointParametersWithNumber: (NSNumber*) number + _double: (NSNumber*) _double + string: (NSString*) string + byte: (NSData*) byte + integer: (NSNumber*) integer + int32: (NSNumber*) int32 + int64: (NSNumber*) int64 + _float: (NSNumber*) _float + binary: (NSData*) binary + date: (NSDate*) date + dateTime: (NSDate*) dateTime + password: (NSString*) password + completionHandler: (void (^)(NSError* error)) handler; +``` + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +### Example +```objc + +NSNumber* number = @3.4; // None +NSNumber* _double = @1.2; // None +NSString* string = @"string_example"; // None +NSData* byte = [[NSData alloc] init]; // None +NSNumber* integer = @56; // None (optional) +NSNumber* int32 = @56; // None (optional) +NSNumber* int64 = @789; // None (optional) +NSNumber* _float = @3.4; // None (optional) +NSData* binary = [[NSData alloc] init]; // None (optional) +NSDate* date = @"2013-10-20"; // None (optional) +NSDate* dateTime = @"2013-10-20T19:20:30+01:00"; // None (optional) +NSString* password = @"password_example"; // None (optional) + +SWGFakeApi*apiInstance = [[SWGFakeApi alloc] init]; + +// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[apiInstance testEndpointParametersWithNumber:number + _double:_double + string:string + byte:byte + integer:integer + int32:int32 + int64:int64 + _float:_float + binary:binary + date:date + dateTime:dateTime + password:password + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error calling SWGFakeApi->testEndpointParameters: %@", error); + } + }]; +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **NSNumber***| None | + **_double** | **NSNumber***| None | + **string** | **NSString***| None | + **byte** | **NSData***| None | + **integer** | **NSNumber***| None | [optional] + **int32** | **NSNumber***| None | [optional] + **int64** | **NSNumber***| None | [optional] + **_float** | **NSNumber***| None | [optional] + **binary** | **NSData***| None | [optional] + **date** | **NSDate***| None | [optional] + **dateTime** | **NSDate***| None | [optional] + **password** | **NSString***| None | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/xml; charset=utf-8, application/json; charset=utf-8 + - **Accept**: application/xml; charset=utf-8, application/json; charset=utf-8 + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/objc/docs/SWGFormatTest.md b/samples/client/petstore/objc/docs/SWGFormatTest.md new file mode 100644 index 00000000000..2682c4a3a78 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGFormatTest.md @@ -0,0 +1,22 @@ +# SWGFormatTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **NSNumber*** | | [optional] +**int32** | **NSNumber*** | | [optional] +**int64** | **NSNumber*** | | [optional] +**number** | **NSNumber*** | | +**_float** | **NSNumber*** | | [optional] +**_double** | **NSNumber*** | | [optional] +**string** | **NSString*** | | [optional] +**byte** | **NSData*** | | +**binary** | **NSData*** | | [optional] +**date** | **NSDate*** | | +**dateTime** | **NSDate*** | | [optional] +**uuid** | **NSString*** | | [optional] +**password** | **NSString*** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGMixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/objc/docs/SWGMixedPropertiesAndAdditionalPropertiesClass.md new file mode 100644 index 00000000000..707e45b9840 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGMixedPropertiesAndAdditionalPropertiesClass.md @@ -0,0 +1,12 @@ +# SWGMixedPropertiesAndAdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **NSString*** | | [optional] +**dateTime** | **NSDate*** | | [optional] +**map** | [**NSDictionary<NSString*, SWGAnimal>***](SWGAnimal.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGName.md b/samples/client/petstore/objc/docs/SWGName.md new file mode 100644 index 00000000000..89dd0ff47e5 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGName.md @@ -0,0 +1,13 @@ +# SWGName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **NSNumber*** | | +**snakeCase** | **NSNumber*** | | [optional] +**_property** | **NSString*** | | [optional] +**_123Number** | **NSNumber*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGReadOnlyFirst.md b/samples/client/petstore/objc/docs/SWGReadOnlyFirst.md new file mode 100644 index 00000000000..d9260a1b83e --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGReadOnlyFirst.md @@ -0,0 +1,11 @@ +# SWGReadOnlyFirst + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **NSString*** | | [optional] +**baz** | **NSString*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGReturn.md b/samples/client/petstore/objc/docs/SWGReturn.md new file mode 100644 index 00000000000..5fd23efdadc --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGReturn.md @@ -0,0 +1,10 @@ +# SWGReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_return** | **NSNumber*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGSpecialModelName_.md b/samples/client/petstore/objc/docs/SWGSpecialModelName_.md new file mode 100644 index 00000000000..4e62042d6f6 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGSpecialModelName_.md @@ -0,0 +1,10 @@ +# SWGSpecialModelName_ + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**specialPropertyName** | **NSNumber*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index 8d69c7da9e4..4a5af697efb 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -4,8 +4,7 @@ This spec is mainly for testing Petstore server and contains fake endpoints, mod This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: 1.0.0 -- Package version: -- Build date: 2016-05-25T22:55:19.912+02:00 +- Build date: 2016-06-13T23:22:10.454+02:00 - Build package: class io.swagger.codegen.languages.PhpClientCodegen ## Requirements diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Model/AdditionalPropertiesClass.md b/samples/client/petstore/php/SwaggerClient-php/docs/Model/AdditionalPropertiesClass.md index 420ac6efe67..b162fe9595f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Model/AdditionalPropertiesClass.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Model/AdditionalPropertiesClass.md @@ -3,6 +3,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**map_property** | **map[string,string]** | | [optional] +**map_of_map_property** | [**map[string,map[string,string]]**](map.md) | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Model/ArrayTest.md b/samples/client/petstore/php/SwaggerClient-php/docs/Model/ArrayTest.md index 9dcc2c97264..f982dc2e4c7 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Model/ArrayTest.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Model/ArrayTest.md @@ -3,6 +3,9 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**array_of_string** | **string[]** | | [optional] +**array_array_of_integer** | [**int[][]**](array.md) | | [optional] +**array_array_of_model** | [**\Swagger\Client\Model\ReadOnlyFirst[][]**](array.md) | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/php/SwaggerClient-php/docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md index c05cee84500..1e3c4f7bfe1 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **uuid** | **string** | | [optional] **date_time** | [**\DateTime**](\DateTime.md) | | [optional] +**map** | [**map[string,\Swagger\Client\Model\Animal]**](Animal.md) | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php index d68bf418a00..b916802b2ea 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php @@ -289,6 +289,7 @@ class FakeApi $httpBody, $headerParams ); + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { 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 9cca7063a53..f601a6c9aaa 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -182,6 +182,7 @@ class PetApi $httpBody, $headerParams ); + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -278,6 +279,7 @@ class PetApi $httpBody, $headerParams ); + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -369,9 +371,6 @@ class PetApi $headerParams, '\Swagger\Client\Model\Pet[]' ); - if (!$response) { - return array(null, $statusCode, $httpHeader); - } return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader); } catch (ApiException $e) { @@ -468,9 +467,6 @@ class PetApi $headerParams, '\Swagger\Client\Model\Pet[]' ); - if (!$response) { - return array(null, $statusCode, $httpHeader); - } return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader); } catch (ApiException $e) { @@ -570,9 +566,6 @@ class PetApi $headerParams, '\Swagger\Client\Model\Pet' ); - if (!$response) { - return array(null, $statusCode, $httpHeader); - } return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader), $statusCode, $httpHeader); } catch (ApiException $e) { @@ -666,6 +659,7 @@ class PetApi $httpBody, $headerParams ); + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -767,6 +761,7 @@ class PetApi $httpBody, $headerParams ); + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -875,9 +870,6 @@ class PetApi $headerParams, '\Swagger\Client\Model\ApiResponse' ); - if (!$response) { - return array(null, $statusCode, $httpHeader); - } return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\ApiResponse', $httpHeader), $statusCode, $httpHeader); } catch (ApiException $e) { 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 d19ddb6f8c5..a04cbec2276 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -184,6 +184,7 @@ class StoreApi $httpBody, $headerParams ); + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -264,9 +265,6 @@ class StoreApi $headerParams, 'map[string,int]' ); - if (!$response) { - return array(null, $statusCode, $httpHeader); - } return array($this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader), $statusCode, $httpHeader); } catch (ApiException $e) { @@ -366,9 +364,6 @@ class StoreApi $headerParams, '\Swagger\Client\Model\Order' ); - if (!$response) { - return array(null, $statusCode, $httpHeader); - } return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader); } catch (ApiException $e) { @@ -458,9 +453,6 @@ class StoreApi $headerParams, '\Swagger\Client\Model\Order' ); - if (!$response) { - return array(null, $statusCode, $httpHeader); - } return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader); } catch (ApiException $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 d735c083522..6e5a4cfcddd 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -177,6 +177,7 @@ class UserApi $httpBody, $headerParams ); + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -260,6 +261,7 @@ class UserApi $httpBody, $headerParams ); + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -343,6 +345,7 @@ class UserApi $httpBody, $headerParams ); + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -429,6 +432,7 @@ class UserApi $httpBody, $headerParams ); + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -516,9 +520,6 @@ class UserApi $headerParams, '\Swagger\Client\Model\User' ); - if (!$response) { - return array(null, $statusCode, $httpHeader); - } return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader), $statusCode, $httpHeader); } catch (ApiException $e) { @@ -617,9 +618,6 @@ class UserApi $headerParams, 'string' ); - if (!$response) { - return array(null, $statusCode, $httpHeader); - } return array($this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader); } catch (ApiException $e) { @@ -697,6 +695,7 @@ class UserApi $httpBody, $headerParams ); + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -794,6 +793,7 @@ class UserApi $httpBody, $headerParams ); + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php b/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php index 30b1b6c2dff..98bb4ab2c17 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php @@ -116,7 +116,7 @@ class Configuration * * @var string */ - protected $userAgent = "Swagger-Codegen//php"; + protected $userAgent = "Swagger-Codegen/1.0.0/php"; /** * Debug switch (default set to false) @@ -519,12 +519,11 @@ class Configuration */ public static function toDebugReport() { - $report = "PHP SDK (Swagger\Client) Debug Report:".PHP_EOL; - $report .= " OS: ".php_uname().PHP_EOL; - $report .= " PHP Version: ".phpversion().PHP_EOL; - $report .= " OpenAPI Spec Version: 1.0.0".PHP_EOL; - $report .= " SDK Package Version: ".PHP_EOL; - $report .= " Temp Folder Path: ".self::getDefaultConfiguration()->getTempFolderPath().PHP_EOL; + $report = 'PHP SDK (Swagger\Client) Debug Report:' . PHP_EOL; + $report .= ' OS: ' . php_uname() . PHP_EOL; + $report .= ' PHP Version: ' . phpversion() . PHP_EOL; + $report .= ' OpenAPI Spec Version: 1.0.0' . PHP_EOL; + $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; return $report; } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/AdditionalPropertiesClass.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/AdditionalPropertiesClass.php index 4b5703134c1..9b77e2bf1ca 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/AdditionalPropertiesClass.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/AdditionalPropertiesClass.php @@ -65,7 +65,8 @@ class AdditionalPropertiesClass implements ArrayAccess * @var string[] */ protected static $swaggerTypes = array( - + 'map_property' => 'map[string,string]', + 'map_of_map_property' => 'map[string,map[string,string]]' ); public static function swaggerTypes() @@ -78,7 +79,8 @@ class AdditionalPropertiesClass implements ArrayAccess * @var string[] */ protected static $attributeMap = array( - + 'map_property' => 'map_property', + 'map_of_map_property' => 'map_of_map_property' ); public static function attributeMap() @@ -91,7 +93,8 @@ class AdditionalPropertiesClass implements ArrayAccess * @var string[] */ protected static $setters = array( - + 'map_property' => 'setMapProperty', + 'map_of_map_property' => 'setMapOfMapProperty' ); public static function setters() @@ -104,7 +107,8 @@ class AdditionalPropertiesClass implements ArrayAccess * @var string[] */ protected static $getters = array( - + 'map_property' => 'getMapProperty', + 'map_of_map_property' => 'getMapOfMapProperty' ); public static function getters() @@ -128,6 +132,8 @@ class AdditionalPropertiesClass implements ArrayAccess */ public function __construct(array $data = null) { + $this->container['map_property'] = isset($data['map_property']) ? $data['map_property'] : null; + $this->container['map_of_map_property'] = isset($data['map_of_map_property']) ? $data['map_of_map_property'] : null; } /** @@ -152,6 +158,48 @@ class AdditionalPropertiesClass implements ArrayAccess return true; } + + /** + * Gets map_property + * @return map[string,string] + */ + public function getMapProperty() + { + return $this->container['map_property']; + } + + /** + * Sets map_property + * @param map[string,string] $map_property + * @return $this + */ + public function setMapProperty($map_property) + { + $this->container['map_property'] = $map_property; + + return $this; + } + + /** + * Gets map_of_map_property + * @return map[string,map[string,string]] + */ + public function getMapOfMapProperty() + { + return $this->container['map_of_map_property']; + } + + /** + * Sets map_of_map_property + * @param map[string,map[string,string]] $map_of_map_property + * @return $this + */ + public function setMapOfMapProperty($map_of_map_property) + { + $this->container['map_of_map_property'] = $map_of_map_property; + + return $this; + } /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayTest.php index 44af1286a6d..e1a4ea91179 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayTest.php @@ -65,7 +65,9 @@ class ArrayTest implements ArrayAccess * @var string[] */ protected static $swaggerTypes = array( - + 'array_of_string' => 'string[]', + 'array_array_of_integer' => 'int[][]', + 'array_array_of_model' => '\Swagger\Client\Model\ReadOnlyFirst[][]' ); public static function swaggerTypes() @@ -78,7 +80,9 @@ class ArrayTest implements ArrayAccess * @var string[] */ protected static $attributeMap = array( - + 'array_of_string' => 'array_of_string', + 'array_array_of_integer' => 'array_array_of_integer', + 'array_array_of_model' => 'array_array_of_model' ); public static function attributeMap() @@ -91,7 +95,9 @@ class ArrayTest implements ArrayAccess * @var string[] */ protected static $setters = array( - + 'array_of_string' => 'setArrayOfString', + 'array_array_of_integer' => 'setArrayArrayOfInteger', + 'array_array_of_model' => 'setArrayArrayOfModel' ); public static function setters() @@ -104,7 +110,9 @@ class ArrayTest implements ArrayAccess * @var string[] */ protected static $getters = array( - + 'array_of_string' => 'getArrayOfString', + 'array_array_of_integer' => 'getArrayArrayOfInteger', + 'array_array_of_model' => 'getArrayArrayOfModel' ); public static function getters() @@ -128,6 +136,9 @@ class ArrayTest implements ArrayAccess */ public function __construct(array $data = null) { + $this->container['array_of_string'] = isset($data['array_of_string']) ? $data['array_of_string'] : null; + $this->container['array_array_of_integer'] = isset($data['array_array_of_integer']) ? $data['array_array_of_integer'] : null; + $this->container['array_array_of_model'] = isset($data['array_array_of_model']) ? $data['array_array_of_model'] : null; } /** @@ -152,6 +163,69 @@ class ArrayTest implements ArrayAccess return true; } + + /** + * Gets array_of_string + * @return string[] + */ + public function getArrayOfString() + { + return $this->container['array_of_string']; + } + + /** + * Sets array_of_string + * @param string[] $array_of_string + * @return $this + */ + public function setArrayOfString($array_of_string) + { + $this->container['array_of_string'] = $array_of_string; + + return $this; + } + + /** + * Gets array_array_of_integer + * @return int[][] + */ + public function getArrayArrayOfInteger() + { + return $this->container['array_array_of_integer']; + } + + /** + * Sets array_array_of_integer + * @param int[][] $array_array_of_integer + * @return $this + */ + public function setArrayArrayOfInteger($array_array_of_integer) + { + $this->container['array_array_of_integer'] = $array_array_of_integer; + + return $this; + } + + /** + * Gets array_array_of_model + * @return \Swagger\Client\Model\ReadOnlyFirst[][] + */ + public function getArrayArrayOfModel() + { + return $this->container['array_array_of_model']; + } + + /** + * Sets array_array_of_model + * @param \Swagger\Client\Model\ReadOnlyFirst[][] $array_array_of_model + * @return $this + */ + public function setArrayArrayOfModel($array_array_of_model) + { + $this->container['array_array_of_model'] = $array_array_of_model; + + return $this; + } /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php index fd397440cfc..c7ec6100988 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php @@ -66,7 +66,8 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ArrayAccess */ protected static $swaggerTypes = array( 'uuid' => 'string', - 'date_time' => '\DateTime' + 'date_time' => '\DateTime', + 'map' => 'map[string,\Swagger\Client\Model\Animal]' ); public static function swaggerTypes() @@ -80,7 +81,8 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ArrayAccess */ protected static $attributeMap = array( 'uuid' => 'uuid', - 'date_time' => 'dateTime' + 'date_time' => 'dateTime', + 'map' => 'map' ); public static function attributeMap() @@ -94,7 +96,8 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ArrayAccess */ protected static $setters = array( 'uuid' => 'setUuid', - 'date_time' => 'setDateTime' + 'date_time' => 'setDateTime', + 'map' => 'setMap' ); public static function setters() @@ -108,7 +111,8 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ArrayAccess */ protected static $getters = array( 'uuid' => 'getUuid', - 'date_time' => 'getDateTime' + 'date_time' => 'getDateTime', + 'map' => 'getMap' ); public static function getters() @@ -134,6 +138,7 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ArrayAccess { $this->container['uuid'] = isset($data['uuid']) ? $data['uuid'] : null; $this->container['date_time'] = isset($data['date_time']) ? $data['date_time'] : null; + $this->container['map'] = isset($data['map']) ? $data['map'] : null; } /** @@ -200,6 +205,27 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ArrayAccess return $this; } + + /** + * Gets map + * @return map[string,\Swagger\Client\Model\Animal] + */ + public function getMap() + { + return $this->container['map']; + } + + /** + * Sets map + * @param map[string,\Swagger\Client\Model\Animal] $map + * @return $this + */ + public function setMap($map) + { + $this->container['map'] = $map; + + return $this; + } /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php index 800cd512e4f..6b926c1d29d 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php @@ -66,4 +66,30 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase $this->assertInternalType("int", $get_response['available']); } */ + + /** + * test empty array response + * + * Make sure empty arrays from a producer is actually returned as + * an empty array and not some other value. At some point it was + * returned as null because the code stumbled on PHP loose type + * checking (not on empty array is true, same thing could happen + * with careless use of empty()). + */ + public function testEmptyArrayResponse() + { + // initialize the API client + $config = (new Configuration())->setHost('http://petstore.swagger.io/v2'); + $apiClient = new ApiClient($config); + $storeApi = new Api\PetApi($apiClient); + // this call returns and empty array + $response = $storeApi->findPetsByStatus(array()); + + // make sure this is an array as we want it to be + $this->assertInternalType("array", $response); + + // make sure the array is empty just in case the petstore + // server changes its output + $this->assertEmpty($response); + } } diff --git a/samples/client/petstore/python/.travis.yml b/samples/client/petstore/python/.travis.yml index bde258c4161..86211e2d4a2 100644 --- a/samples/client/petstore/python/.travis.yml +++ b/samples/client/petstore/python/.travis.yml @@ -1,12 +1,14 @@ +# ref: https://docs.travis-ci.com/user/languages/python language: python python: - - "2.6" - "2.7" - "3.2" - "3.3" - "3.4" -install: - - pip install . --use-mirrors - - pip install -r dev-requirements.txt --use-mirrors -script: - - nosetests + - "3.5" + #- "3.5-dev" # 3.5 development branch + #- "nightly" # points to the latest development branch e.g. 3.6-dev +# command to install dependencies +install: "pip install -r requirements.txt" +# command to run tests +script: nosetests diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 8fc15c13eec..c429ada359d 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https:// - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-06-09T08:00:02.342+09:00 +- Build date: 2016-06-17T00:41:00.422+08:00 - Build package: class io.swagger.codegen.languages.PythonClientCodegen ## Requirements. @@ -130,6 +130,12 @@ Class | Method | HTTP request | Description ## Documentation For Authorization +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + ## petstore_auth - **Type**: OAuth @@ -139,12 +145,6 @@ Class | Method | HTTP request | Description - **write:pets**: modify pets in your account - **read:pets**: read your pets -## api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - ## Author diff --git a/samples/client/petstore/python/petstore_api/configuration.py b/samples/client/petstore/python/petstore_api/configuration.py index 76f1f57c784..ec940b71413 100644 --- a/samples/client/petstore/python/petstore_api/configuration.py +++ b/samples/client/petstore/python/petstore_api/configuration.py @@ -221,6 +221,13 @@ class Configuration(object): :return: The Auth Settings information dict. """ return { + 'api_key': + { + 'type': 'api_key', + 'in': 'header', + 'key': 'api_key', + 'value': self.get_api_key_with_prefix('api_key') + }, 'petstore_auth': { @@ -229,13 +236,6 @@ class Configuration(object): 'key': 'Authorization', 'value': 'Bearer ' + self.access_token }, - 'api_key': - { - 'type': 'api_key', - 'in': 'header', - 'key': 'api_key', - 'value': self.get_api_key_with_prefix('api_key') - }, } diff --git a/samples/client/petstore/qt5cpp/PetStore/PetApiTests.cpp b/samples/client/petstore/qt5cpp/PetStore/PetApiTests.cpp index e2d0ffb5d37..4b1d5f5cd5f 100644 --- a/samples/client/petstore/qt5cpp/PetStore/PetApiTests.cpp +++ b/samples/client/petstore/qt5cpp/PetStore/PetApiTests.cpp @@ -228,7 +228,7 @@ void PetApiTests::updatePetWithFormTest() { connect(api, &SWGPetApi::updatePetWithFormSignal, this, [](){loop.quit();}); connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); - api->updatePetWithForm(new QString(QString::number(id)), new QString("gorilla"), NULL); + api->updatePetWithForm(id, new QString("gorilla"), NULL); timer.start(); loop.exec(); QVERIFY2(timer.isActive(), "didn't finish within timeout"); diff --git a/samples/client/petstore/qt5cpp/PetStore/PetStore.pro b/samples/client/petstore/qt5cpp/PetStore/PetStore.pro index 70b3618cba6..64f27a3c924 100644 --- a/samples/client/petstore/qt5cpp/PetStore/PetStore.pro +++ b/samples/client/petstore/qt5cpp/PetStore/PetStore.pro @@ -28,6 +28,7 @@ SOURCES += main.cpp \ ../client/SWGTag.cpp \ ../client/SWGUser.cpp \ ../client/SWGUserApi.cpp \ + ../client/SWGApiResponse.cpp \ PetApiTests.cpp HEADERS += \ @@ -43,4 +44,5 @@ HEADERS += \ ../client/SWGUser.h \ ../client/SWGUserApi.h \ PetApiTests.h \ + ../client/SWGApiResponse.h \ ../client/SWGModelFactory.h diff --git a/samples/client/petstore/qt5cpp/client/SWGApiResponse.cpp b/samples/client/petstore/qt5cpp/client/SWGApiResponse.cpp index 3c813677bf1..d3260c7c399 100644 --- a/samples/client/petstore/qt5cpp/client/SWGApiResponse.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGApiResponse.cpp @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #include "SWGApiResponse.h" diff --git a/samples/client/petstore/qt5cpp/client/SWGApiResponse.h b/samples/client/petstore/qt5cpp/client/SWGApiResponse.h index 0b9b0c1acac..afd7b29be49 100644 --- a/samples/client/petstore/qt5cpp/client/SWGApiResponse.h +++ b/samples/client/petstore/qt5cpp/client/SWGApiResponse.h @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + /* * SWGApiResponse.h * diff --git a/samples/client/petstore/qt5cpp/client/SWGCategory.cpp b/samples/client/petstore/qt5cpp/client/SWGCategory.cpp index c2f0a7e59b6..3ac679a863c 100644 --- a/samples/client/petstore/qt5cpp/client/SWGCategory.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGCategory.cpp @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #include "SWGCategory.h" diff --git a/samples/client/petstore/qt5cpp/client/SWGCategory.h b/samples/client/petstore/qt5cpp/client/SWGCategory.h index 248d0630ed7..44e03dd3a3c 100644 --- a/samples/client/petstore/qt5cpp/client/SWGCategory.h +++ b/samples/client/petstore/qt5cpp/client/SWGCategory.h @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + /* * SWGCategory.h * diff --git a/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp b/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp index 6b439996724..27518392f06 100644 --- a/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #include "SWGHelpers.h" #include "SWGModelFactory.h" #include "SWGObject.h" @@ -53,6 +77,46 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) { qDebug() << "Can't set value because the target pointer is NULL"; } } + else if (QStringLiteral("QDateTime").compare(type) == 0) { + QDateTime **val = static_cast(value); + + if(val != NULL) { + if(!obj.isNull()) { + // create a new value and return + delete *val; + *val = new QDateTime(QDateTime::fromString(obj.toString(), Qt::ISODate)); + return; + } + else { + // set target to NULL + delete *val; + *val = NULL; + } + } + else { + qDebug() << "Can't set value because the target pointer is NULL"; + } + } + else if (QStringLiteral("QDate").compare(type) == 0) { + QDate **val = static_cast(value); + + if(val != NULL) { + if(!obj.isNull()) { + // create a new value and return + delete *val; + *val = new QDate(QDate::fromString(obj.toString(), Qt::ISODate)); + return; + } + else { + // set target to NULL + delete *val; + *val = NULL; + } + } + else { + qDebug() << "Can't set value because the target pointer is NULL"; + } + } else if(type.startsWith("SWG") && obj.isObject()) { // complex type QJsonObject jsonObj = obj.toObject(); @@ -104,6 +168,21 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) { setValue(&val, jval, QStringLiteral("double"), QStringLiteral("")); output->append((void*)&val); } + else if(QStringLiteral("QString").compare(complexType) == 0) { + QString val; + setValue(&val, jval, QStringLiteral("QString"), QStringLiteral("")); + output->append((void*)&val); + } + else if(QStringLiteral("QDate").compare(complexType) == 0) { + QDate val; + setValue(&val, jval, QStringLiteral("QDate"), QStringLiteral("")); + output->append((void*)&val); + } + else if(QStringLiteral("QDateTime").compare(complexType) == 0) { + QDateTime val; + setValue(&val, jval, QStringLiteral("QDateTime"), QStringLiteral("")); + output->append((void*)&val); + } } } QList **val = static_cast**>(value); @@ -139,23 +218,31 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) { } else if(QStringLiteral("qint32").compare(type) == 0) { qint32* str = static_cast(value); - output->insert(name, QJsonValue(*str)); + output->insert(name, QJsonValue(*str)); } else if(QStringLiteral("qint64").compare(type) == 0) { qint64* str = static_cast(value); - output->insert(name, QJsonValue(*str)); + output->insert(name, QJsonValue(*str)); } else if(QStringLiteral("bool").compare(type) == 0) { bool* str = static_cast(value); - output->insert(name, QJsonValue(*str)); + output->insert(name, QJsonValue(*str)); } else if(QStringLiteral("float").compare(type) == 0) { float* str = static_cast(value); - output->insert(name, QJsonValue((double)*str)); + output->insert(name, QJsonValue((double)*str)); } else if(QStringLiteral("double").compare(type) == 0) { double* str = static_cast(value); - output->insert(name, QJsonValue(*str)); + output->insert(name, QJsonValue(*str)); + } + else if(QStringLiteral("QDate").compare(type) == 0) { + QDate* date = static_cast(value); + output->insert(name, QJsonValue(date->toString(Qt::ISODate))); + } + else if(QStringLiteral("QDateTime").compare(type) == 0) { + QDateTime* datetime = static_cast(value); + output->insert(name, QJsonValue(datetime->toString(Qt::ISODate))); } } diff --git a/samples/client/petstore/qt5cpp/client/SWGHelpers.h b/samples/client/petstore/qt5cpp/client/SWGHelpers.h index 3a02c0952d5..2180948e9c3 100644 --- a/samples/client/petstore/qt5cpp/client/SWGHelpers.h +++ b/samples/client/petstore/qt5cpp/client/SWGHelpers.h @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #ifndef SWGHELPERS_H #define SWGHELPERS_H diff --git a/samples/client/petstore/qt5cpp/client/SWGHttpRequest.cpp b/samples/client/petstore/qt5cpp/client/SWGHttpRequest.cpp index f1e79c4d197..5ab58d8f11e 100644 --- a/samples/client/petstore/qt5cpp/client/SWGHttpRequest.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGHttpRequest.cpp @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #include "SWGHttpRequest.h" #include #include diff --git a/samples/client/petstore/qt5cpp/client/SWGHttpRequest.h b/samples/client/petstore/qt5cpp/client/SWGHttpRequest.h index a2e91a0765e..6e2e4cd1d26 100644 --- a/samples/client/petstore/qt5cpp/client/SWGHttpRequest.h +++ b/samples/client/petstore/qt5cpp/client/SWGHttpRequest.h @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + /** * Based on http://www.creativepulse.gr/en/blog/2014/restful-api-requests-using-qt-cpp-for-linux-mac-osx-ms-windows * By Alex Stylianos diff --git a/samples/client/petstore/qt5cpp/client/SWGModelFactory.h b/samples/client/petstore/qt5cpp/client/SWGModelFactory.h index 18cc79911ab..d40170cb4f1 100644 --- a/samples/client/petstore/qt5cpp/client/SWGModelFactory.h +++ b/samples/client/petstore/qt5cpp/client/SWGModelFactory.h @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #ifndef ModelFactory_H_ #define ModelFactory_H_ diff --git a/samples/client/petstore/qt5cpp/client/SWGObject.h b/samples/client/petstore/qt5cpp/client/SWGObject.h index 6cb5c042772..e0b60b6fe16 100644 --- a/samples/client/petstore/qt5cpp/client/SWGObject.h +++ b/samples/client/petstore/qt5cpp/client/SWGObject.h @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #ifndef _SWG_OBJECT_H_ #define _SWG_OBJECT_H_ diff --git a/samples/client/petstore/qt5cpp/client/SWGOrder.cpp b/samples/client/petstore/qt5cpp/client/SWGOrder.cpp index 2be083bbb3e..7c1c5bf273f 100644 --- a/samples/client/petstore/qt5cpp/client/SWGOrder.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGOrder.cpp @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #include "SWGOrder.h" diff --git a/samples/client/petstore/qt5cpp/client/SWGOrder.h b/samples/client/petstore/qt5cpp/client/SWGOrder.h index fd3855000ea..e5dc8d75041 100644 --- a/samples/client/petstore/qt5cpp/client/SWGOrder.h +++ b/samples/client/petstore/qt5cpp/client/SWGOrder.h @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + /* * SWGOrder.h * @@ -10,7 +34,7 @@ #include -#include "QDateTime.h" +#include #include #include "SWGObject.h" diff --git a/samples/client/petstore/qt5cpp/client/SWGPet.cpp b/samples/client/petstore/qt5cpp/client/SWGPet.cpp index 7152738ad8b..5c2ec3f8653 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPet.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGPet.cpp @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #include "SWGPet.h" diff --git a/samples/client/petstore/qt5cpp/client/SWGPet.h b/samples/client/petstore/qt5cpp/client/SWGPet.h index a58e599d218..aa1676d0f87 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPet.h +++ b/samples/client/petstore/qt5cpp/client/SWGPet.h @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + /* * SWGPet.h * diff --git a/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp b/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp index b5e383575be..1c607da1071 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #include "SWGPetApi.h" #include "SWGHelpers.h" #include "SWGModelFactory.h" @@ -438,7 +462,7 @@ SWGPetApi::uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestI input.add_var("additionalMetadata", *additionalMetadata); } if (file != NULL) { - input.add_file("file", *file.local_filename, *file.request_filename, *file.mime_type); + input.add_file("file", (*file).local_filename, (*file).request_filename, (*file).mime_type); } diff --git a/samples/client/petstore/qt5cpp/client/SWGPetApi.h b/samples/client/petstore/qt5cpp/client/SWGPetApi.h index a18a6375555..cc115fa33bf 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPetApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGPetApi.h @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #ifndef _SWG_SWGPetApi_H_ #define _SWG_SWGPetApi_H_ @@ -54,4 +78,4 @@ signals: }; } -#endif \ No newline at end of file +#endif diff --git a/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp b/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp index 968b89a4116..efa097dcffd 100644 --- a/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #include "SWGStoreApi.h" #include "SWGHelpers.h" #include "SWGModelFactory.h" diff --git a/samples/client/petstore/qt5cpp/client/SWGStoreApi.h b/samples/client/petstore/qt5cpp/client/SWGStoreApi.h index a90a297499c..398349289d6 100644 --- a/samples/client/petstore/qt5cpp/client/SWGStoreApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGStoreApi.h @@ -1,10 +1,34 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #ifndef _SWG_SWGStoreApi_H_ #define _SWG_SWGStoreApi_H_ #include "SWGHttpRequest.h" #include -#include "QMap.h" +#include #include "SWGOrder.h" #include @@ -41,4 +65,4 @@ signals: }; } -#endif \ No newline at end of file +#endif diff --git a/samples/client/petstore/qt5cpp/client/SWGTag.cpp b/samples/client/petstore/qt5cpp/client/SWGTag.cpp index 0f10c5ceec7..06ed3297b86 100644 --- a/samples/client/petstore/qt5cpp/client/SWGTag.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGTag.cpp @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #include "SWGTag.h" diff --git a/samples/client/petstore/qt5cpp/client/SWGTag.h b/samples/client/petstore/qt5cpp/client/SWGTag.h index 15ab44f1ac1..681d74f9eca 100644 --- a/samples/client/petstore/qt5cpp/client/SWGTag.h +++ b/samples/client/petstore/qt5cpp/client/SWGTag.h @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + /* * SWGTag.h * diff --git a/samples/client/petstore/qt5cpp/client/SWGUser.cpp b/samples/client/petstore/qt5cpp/client/SWGUser.cpp index 98704b8ac6a..6b926d25334 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUser.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGUser.cpp @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #include "SWGUser.h" diff --git a/samples/client/petstore/qt5cpp/client/SWGUser.h b/samples/client/petstore/qt5cpp/client/SWGUser.h index c9b0e0509ca..ef08a994ea5 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUser.h +++ b/samples/client/petstore/qt5cpp/client/SWGUser.h @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + /* * SWGUser.h * diff --git a/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp b/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp index 45bafbfdc32..a2089cf24bb 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #include "SWGUserApi.h" #include "SWGHelpers.h" #include "SWGModelFactory.h" diff --git a/samples/client/petstore/qt5cpp/client/SWGUserApi.h b/samples/client/petstore/qt5cpp/client/SWGUserApi.h index 9a7577a4103..94aa2a69dcb 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUserApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGUserApi.h @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + #ifndef _SWG_SWGUserApi_H_ #define _SWG_SWGUserApi_H_ @@ -53,4 +77,4 @@ signals: }; } -#endif \ No newline at end of file +#endif diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb index 35d498fc9af..58bc4b1ae28 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -26,15 +26,28 @@ require 'date' module Petstore class ArrayTest + attr_accessor :array_of_string + + attr_accessor :array_array_of_integer + + attr_accessor :array_array_of_model + + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'array_of_string' => :'array_of_string', + :'array_array_of_integer' => :'array_array_of_integer', + :'array_array_of_model' => :'array_array_of_model' } end # Attribute type mapping. def self.swagger_types { + :'array_of_string' => :'Array', + :'array_array_of_integer' => :'Array>', + :'array_array_of_model' => :'Array>' } end @@ -46,6 +59,24 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} + if attributes.has_key?(:'array_of_string') + if (value = attributes[:'array_of_string']).is_a?(Array) + self.array_of_string = value + end + end + + if attributes.has_key?(:'array_array_of_integer') + if (value = attributes[:'array_array_of_integer']).is_a?(Array) + self.array_array_of_integer = value + end + end + + if attributes.has_key?(:'array_array_of_model') + if (value = attributes[:'array_array_of_model']).is_a?(Array) + self.array_array_of_model = value + end + end + end # Show invalid properties with the reasons. Usually used together with valid? @@ -58,13 +89,17 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return true end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) - self.class == o.class + self.class == o.class && + array_of_string == o.array_of_string && + array_array_of_integer == o.array_array_of_integer && + array_array_of_model == o.array_array_of_model end # @see the `==` method @@ -76,7 +111,7 @@ module Petstore # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash - [].hash + [array_of_string, array_array_of_integer, array_array_of_model].hash end # Builds the object from hash diff --git a/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIHelper.swift b/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIHelper.swift index 7041709f365..23e727b6b54 100644 --- a/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIHelper.swift +++ b/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIHelper.swift @@ -19,18 +19,19 @@ class APIHelper { return destination } - static func convertBoolToString(source: [String: AnyObject]?) -> [String:AnyObject] { + static func convertBoolToString(source: [String: AnyObject]?) -> [String:AnyObject]? { + guard let source = source else { + return nil + } var destination = [String:AnyObject]() let theTrue = NSNumber(bool: true) let theFalse = NSNumber(bool: false) - if (source != nil) { - for (key, value) in source! { - switch value { - case let x where x === theTrue || x === theFalse: - destination[key] = "\(value as! Bool)" - default: - destination[key] = value - } + for (key, value) in source { + switch value { + case let x where x === theTrue || x === theFalse: + destination[key] = "\(value as! Bool)" + default: + destination[key] = value } } return destination diff --git a/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift b/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift index 6e4ddc4227b..cdbd4323e70 100644 --- a/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift +++ b/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift @@ -108,13 +108,13 @@ public class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/json, example={ + - examples: [{example={ "name" : "Puma", "type" : "Dog", "color" : "Black", "gender" : "Female", "breed" : "Mixed" -}}] +}, contentType=application/json}] - parameter status: (query) Status values that need to be considered for filter (optional, default to available) @@ -157,20 +157,20 @@ public class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", + - examples: [{example=[ { + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], "id" : 123456789, "category" : { - "name" : "aeiou", - "id" : 123456789 + "id" : 123456789, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 123456789 - } ], - "status" : "aeiou" -} ]}, {contentType=application/xml, example= + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}, {example= 123456 doggie @@ -179,21 +179,21 @@ public class PetAPI: APIBase { string -}] - - examples: [{contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}] + - examples: [{example=[ { + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], "id" : 123456789, "category" : { - "name" : "aeiou", - "id" : 123456789 + "id" : 123456789, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 123456789 - } ], - "status" : "aeiou" -} ]}, {contentType=application/xml, example= + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}, {example= 123456 doggie @@ -202,7 +202,7 @@ public class PetAPI: APIBase { string -}] +, contentType=application/xml}] - parameter tags: (query) Tags to filter by (optional) @@ -242,26 +242,26 @@ public class PetAPI: APIBase { Find pet by ID - GET /pet/{petId} - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - - OAuth: - - type: oauth2 - - name: petstore_auth - API Key: - type: apiKey api_key - name: api_key - - examples: [{contentType=application/json, example={ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", + - OAuth: + - type: oauth2 + - name: petstore_auth + - examples: [{example={ + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], "id" : 123456789, "category" : { - "name" : "aeiou", - "id" : 123456789 + "id" : 123456789, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 123456789 - } ], - "status" : "aeiou" -}}, {contentType=application/xml, example= + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +}, contentType=application/json}, {example= 123456 doggie @@ -270,21 +270,21 @@ public class PetAPI: APIBase { string -}] - - examples: [{contentType=application/json, example={ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}] + - examples: [{example={ + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], "id" : 123456789, "category" : { - "name" : "aeiou", - "id" : 123456789 + "id" : 123456789, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 123456789 - } ], - "status" : "aeiou" -}}, {contentType=application/xml, example= + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +}, contentType=application/json}, {example= 123456 doggie @@ -293,7 +293,7 @@ public class PetAPI: APIBase { string -}] +, contentType=application/xml}] - parameter petId: (path) ID of pet that needs to be fetched diff --git a/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift b/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift index 362dc968182..b708f5c7978 100644 --- a/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift +++ b/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift @@ -67,12 +67,12 @@ public class StoreAPI: APIBase { - API Key: - type: apiKey api_key - name: api_key - - examples: [{contentType=application/json, example={ + - examples: [{example={ "key" : 123 -}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}] - - examples: [{contentType=application/json, example={ +}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}] + - examples: [{example={ "key" : 123 -}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}] +}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}] - returns: RequestBuilder<[String:Int32]> */ @@ -108,36 +108,36 @@ public class StoreAPI: APIBase { Find purchase order by ID - GET /store/order/{orderId} - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - - examples: [{contentType=application/json, example={ - "petId" : 123456789, - "quantity" : 123, + - examples: [{example={ "id" : 123456789, - "shipDate" : "2000-01-23T04:56:07.000+0000", + "petId" : 123456789, "complete" : true, - "status" : "aeiou" -}}, {contentType=application/xml, example= + "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 -}] - - examples: [{contentType=application/json, example={ - "petId" : 123456789, - "quantity" : 123, +, contentType=application/xml}] + - examples: [{example={ "id" : 123456789, - "shipDate" : "2000-01-23T04:56:07.000+0000", + "petId" : 123456789, "complete" : true, - "status" : "aeiou" -}}, {contentType=application/xml, example= + "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 pet that needs to be fetched @@ -176,36 +176,36 @@ public class StoreAPI: APIBase { Place an order for a pet - POST /store/order - - - examples: [{contentType=application/json, example={ - "petId" : 123456789, - "quantity" : 123, + - examples: [{example={ "id" : 123456789, - "shipDate" : "2000-01-23T04:56:07.000+0000", + "petId" : 123456789, "complete" : true, - "status" : "aeiou" -}}, {contentType=application/xml, example= + "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 -}] - - examples: [{contentType=application/json, example={ - "petId" : 123456789, - "quantity" : 123, +, contentType=application/xml}] + - examples: [{example={ "id" : 123456789, - "shipDate" : "2000-01-23T04:56:07.000+0000", + "petId" : 123456789, "complete" : true, - "status" : "aeiou" -}}, {contentType=application/xml, example= + "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 (optional) diff --git a/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift b/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift index d6df7754683..a7497487f85 100644 --- a/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift +++ b/samples/client/petstore/swift/default/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift @@ -167,16 +167,16 @@ public class UserAPI: APIBase { Get user by user name - GET /user/{username} - - - examples: [{contentType=application/json, example={ - "firstName" : "aeiou", - "lastName" : "aeiou", - "password" : "aeiou", - "userStatus" : 123, - "phone" : "aeiou", + - examples: [{example={ "id" : 123456789, + "lastName" : "aeiou", + "phone" : "aeiou", + "username" : "aeiou", "email" : "aeiou", - "username" : "aeiou" -}}, {contentType=application/xml, example= + "userStatus" : 123, + "firstName" : "aeiou", + "password" : "aeiou" +}, contentType=application/json}, {example= 123456 string string @@ -185,17 +185,17 @@ public class UserAPI: APIBase { string string 0 -}] - - examples: [{contentType=application/json, example={ - "firstName" : "aeiou", - "lastName" : "aeiou", - "password" : "aeiou", - "userStatus" : 123, - "phone" : "aeiou", +, contentType=application/xml}] + - examples: [{example={ "id" : 123456789, + "lastName" : "aeiou", + "phone" : "aeiou", + "username" : "aeiou", "email" : "aeiou", - "username" : "aeiou" -}}, {contentType=application/xml, example= + "userStatus" : 123, + "firstName" : "aeiou", + "password" : "aeiou" +}, contentType=application/json}, {example= 123456 string string @@ -204,7 +204,7 @@ public class UserAPI: APIBase { string string 0 -}] +, contentType=application/xml}] - parameter username: (path) The name that needs to be fetched. Use user1 for testing. @@ -244,8 +244,8 @@ public class UserAPI: APIBase { Logs user into the system - GET /user/login - - - examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}] - - examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}] + - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}] + - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}] - parameter username: (query) The user name for login (optional) - parameter password: (query) The password for login in clear text (optional) diff --git a/samples/client/petstore/swift/promisekit/PetstoreClient/Classes/Swaggers/APIHelper.swift b/samples/client/petstore/swift/promisekit/PetstoreClient/Classes/Swaggers/APIHelper.swift index 7041709f365..23e727b6b54 100644 --- a/samples/client/petstore/swift/promisekit/PetstoreClient/Classes/Swaggers/APIHelper.swift +++ b/samples/client/petstore/swift/promisekit/PetstoreClient/Classes/Swaggers/APIHelper.swift @@ -19,18 +19,19 @@ class APIHelper { return destination } - static func convertBoolToString(source: [String: AnyObject]?) -> [String:AnyObject] { + static func convertBoolToString(source: [String: AnyObject]?) -> [String:AnyObject]? { + guard let source = source else { + return nil + } var destination = [String:AnyObject]() let theTrue = NSNumber(bool: true) let theFalse = NSNumber(bool: false) - if (source != nil) { - for (key, value) in source! { - switch value { - case let x where x === theTrue || x === theFalse: - destination[key] = "\(value as! Bool)" - default: - destination[key] = value - } + for (key, value) in source { + switch value { + case let x where x === theTrue || x === theFalse: + destination[key] = "\(value as! Bool)" + default: + destination[key] = value } } return destination diff --git a/samples/client/petstore/typescript-angular2/default/.swagger-codegen-ignore b/samples/client/petstore/typescript-angular2/default/.swagger-codegen-ignore new file mode 100644 index 00000000000..c5fa491b4c5 --- /dev/null +++ b/samples/client/petstore/typescript-angular2/default/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/typescript-angular2/default/LICENSE b/samples/client/petstore/typescript-angular2/default/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/samples/client/petstore/typescript-angular2/default/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. diff --git a/samples/client/petstore/typescript-angular2/default/api/PetApi.ts b/samples/client/petstore/typescript-angular2/default/api/PetApi.ts index a708d49e9f9..9693b85b9d0 100644 --- a/samples/client/petstore/typescript-angular2/default/api/PetApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/PetApi.ts @@ -27,7 +27,7 @@ export class PetApi { public addPet (body?: models.Pet, extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/pet'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'POST', @@ -37,7 +37,13 @@ export class PetApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -50,7 +56,7 @@ export class PetApi { const path = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'petId' is set if (!petId) { @@ -65,7 +71,13 @@ export class PetApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -73,13 +85,13 @@ export class PetApi { * Multiple status values can be provided with comma seperated strings * @param status Status values that need to be considered for filter */ - public findPetsByStatus (status?: models.Array, extraHttpRequestParams?: any ) : Observable> { + public findPetsByStatus (status?: Array, extraHttpRequestParams?: any ) : Observable> { const path = this.basePath + '/pet/findByStatus'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; if (status !== undefined) { - queryParameters['status'] = status; + queryParameters.set('status', status); } let requestOptions: RequestOptionsArgs = { @@ -89,7 +101,13 @@ export class PetApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -97,13 +115,13 @@ export class PetApi { * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - public findPetsByTags (tags?: models.Array, extraHttpRequestParams?: any ) : Observable> { + public findPetsByTags (tags?: Array, extraHttpRequestParams?: any ) : Observable> { const path = this.basePath + '/pet/findByTags'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; if (tags !== undefined) { - queryParameters['tags'] = tags; + queryParameters.set('tags', tags); } let requestOptions: RequestOptionsArgs = { @@ -113,7 +131,13 @@ export class PetApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -125,7 +149,7 @@ export class PetApi { const path = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'petId' is set if (!petId) { @@ -138,7 +162,13 @@ export class PetApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -149,7 +179,7 @@ export class PetApi { public updatePet (body?: models.Pet, extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/pet'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'PUT', @@ -159,7 +189,13 @@ export class PetApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -173,7 +209,7 @@ export class PetApi { const path = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let formParams = new URLSearchParams(); @@ -195,7 +231,13 @@ export class PetApi { requestOptions.body = formParams.toString(); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -205,11 +247,11 @@ export class PetApi { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - public uploadFile (petId: number, additionalMetadata?: string, file?: models.any, extraHttpRequestParams?: any ) : Observable<{}> { + public uploadFile (petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/pet/{petId}/uploadImage' .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let formParams = new URLSearchParams(); @@ -231,7 +273,13 @@ export class PetApi { requestOptions.body = formParams.toString(); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } } diff --git a/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts index e6602884a81..78066b05da9 100644 --- a/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts @@ -28,7 +28,7 @@ export class StoreApi { const path = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', String(orderId)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'orderId' is set if (!orderId) { @@ -41,7 +41,13 @@ export class StoreApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -51,7 +57,7 @@ export class StoreApi { public getInventory (extraHttpRequestParams?: any ) : Observable<{ [key: string]: number; }> { const path = this.basePath + '/store/inventory'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'GET', @@ -60,7 +66,13 @@ export class StoreApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -72,7 +84,7 @@ export class StoreApi { const path = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', String(orderId)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'orderId' is set if (!orderId) { @@ -85,7 +97,13 @@ export class StoreApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -96,7 +114,7 @@ export class StoreApi { public placeOrder (body?: models.Order, extraHttpRequestParams?: any ) : Observable { const path = this.basePath + '/store/order'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'POST', @@ -106,7 +124,13 @@ export class StoreApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } } diff --git a/samples/client/petstore/typescript-angular2/default/api/UserApi.ts b/samples/client/petstore/typescript-angular2/default/api/UserApi.ts index 04d2e8155d5..6b8a5f538d9 100644 --- a/samples/client/petstore/typescript-angular2/default/api/UserApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/UserApi.ts @@ -27,7 +27,7 @@ export class UserApi { public createUser (body?: models.User, extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/user'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'POST', @@ -37,7 +37,13 @@ export class UserApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -45,10 +51,10 @@ export class UserApi { * * @param body List of user object */ - public createUsersWithArrayInput (body?: models.Array, extraHttpRequestParams?: any ) : Observable<{}> { + public createUsersWithArrayInput (body?: Array, extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/user/createWithArray'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'POST', @@ -58,7 +64,13 @@ export class UserApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -66,10 +78,10 @@ export class UserApi { * * @param body List of user object */ - public createUsersWithListInput (body?: models.Array, extraHttpRequestParams?: any ) : Observable<{}> { + public createUsersWithListInput (body?: Array, extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/user/createWithList'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'POST', @@ -79,7 +91,13 @@ export class UserApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -91,7 +109,7 @@ export class UserApi { const path = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'username' is set if (!username) { @@ -104,7 +122,13 @@ export class UserApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -116,7 +140,7 @@ export class UserApi { const path = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'username' is set if (!username) { @@ -129,7 +153,13 @@ export class UserApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -141,14 +171,14 @@ export class UserApi { public loginUser (username?: string, password?: string, extraHttpRequestParams?: any ) : Observable { const path = this.basePath + '/user/login'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; if (username !== undefined) { - queryParameters['username'] = username; + queryParameters.set('username', username); } if (password !== undefined) { - queryParameters['password'] = password; + queryParameters.set('password', password); } let requestOptions: RequestOptionsArgs = { @@ -158,7 +188,13 @@ export class UserApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -168,7 +204,7 @@ export class UserApi { public logoutUser (extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/user/logout'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'GET', @@ -177,7 +213,13 @@ export class UserApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -190,7 +232,7 @@ export class UserApi { const path = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'username' is set if (!username) { @@ -204,7 +246,13 @@ export class UserApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } } diff --git a/samples/client/petstore/typescript-angular2/default/api/api.ts b/samples/client/petstore/typescript-angular2/default/api/api.ts index a7020497be6..056206bfaca 100644 --- a/samples/client/petstore/typescript-angular2/default/api/api.ts +++ b/samples/client/petstore/typescript-angular2/default/api/api.ts @@ -1,5 +1,3 @@ -export * from '../api/PetApi'; -export * from '../api/StoreApi'; -export * from '../api/UserApi'; - - +export * from './PetApi'; +export * from './StoreApi'; +export * from './UserApi'; diff --git a/samples/client/petstore/typescript-angular2/default/model/Category.ts b/samples/client/petstore/typescript-angular2/default/model/Category.ts index 3a9eb603184..e3080b62f97 100644 --- a/samples/client/petstore/typescript-angular2/default/model/Category.ts +++ b/samples/client/petstore/typescript-angular2/default/model/Category.ts @@ -2,9 +2,9 @@ import * as models from './models'; export interface Category { + id?: number; name?: string; } - diff --git a/samples/client/petstore/typescript-angular2/default/model/Order.ts b/samples/client/petstore/typescript-angular2/default/model/Order.ts index ed557b454d4..4507b05bb5b 100644 --- a/samples/client/petstore/typescript-angular2/default/model/Order.ts +++ b/samples/client/petstore/typescript-angular2/default/model/Order.ts @@ -2,6 +2,7 @@ import * as models from './models'; export interface Order { + id?: number; @@ -18,7 +19,6 @@ export interface Order { complete?: boolean; } - export namespace Order { export enum StatusEnum { diff --git a/samples/client/petstore/typescript-angular2/default/model/Pet.ts b/samples/client/petstore/typescript-angular2/default/model/Pet.ts index e1235c90052..1fbd617a35e 100644 --- a/samples/client/petstore/typescript-angular2/default/model/Pet.ts +++ b/samples/client/petstore/typescript-angular2/default/model/Pet.ts @@ -2,6 +2,7 @@ import * as models from './models'; export interface Pet { + id?: number; @@ -18,7 +19,6 @@ export interface Pet { */ status?: Pet.StatusEnum; } - export namespace Pet { export enum StatusEnum { diff --git a/samples/client/petstore/typescript-angular2/default/model/Tag.ts b/samples/client/petstore/typescript-angular2/default/model/Tag.ts index fba08175c1e..489e7b5d51a 100644 --- a/samples/client/petstore/typescript-angular2/default/model/Tag.ts +++ b/samples/client/petstore/typescript-angular2/default/model/Tag.ts @@ -2,9 +2,9 @@ import * as models from './models'; export interface Tag { + id?: number; name?: string; } - diff --git a/samples/client/petstore/typescript-angular2/default/model/User.ts b/samples/client/petstore/typescript-angular2/default/model/User.ts index 3f14a356307..40711a0f677 100644 --- a/samples/client/petstore/typescript-angular2/default/model/User.ts +++ b/samples/client/petstore/typescript-angular2/default/model/User.ts @@ -2,6 +2,7 @@ import * as models from './models'; export interface User { + id?: number; @@ -22,4 +23,3 @@ export interface User { */ userStatus?: number; } - diff --git a/samples/client/petstore/typescript-angular2/default/model/models.ts b/samples/client/petstore/typescript-angular2/default/model/models.ts index cd7700a649e..92dac02846c 100644 --- a/samples/client/petstore/typescript-angular2/default/model/models.ts +++ b/samples/client/petstore/typescript-angular2/default/model/models.ts @@ -3,6 +3,3 @@ export * from './Order'; export * from './Pet'; export * from './Tag'; export * from './User'; - - - diff --git a/samples/client/petstore/typescript-angular2/npm/.swagger-codegen-ignore b/samples/client/petstore/typescript-angular2/npm/.swagger-codegen-ignore new file mode 100644 index 00000000000..c5fa491b4c5 --- /dev/null +++ b/samples/client/petstore/typescript-angular2/npm/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/typescript-angular2/npm/LICENSE b/samples/client/petstore/typescript-angular2/npm/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/samples/client/petstore/typescript-angular2/npm/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. diff --git a/samples/client/petstore/typescript-angular2/npm/README.md b/samples/client/petstore/typescript-angular2/npm/README.md index 0fdbf4a4ded..07995864843 100644 --- a/samples/client/petstore/typescript-angular2/npm/README.md +++ b/samples/client/petstore/typescript-angular2/npm/README.md @@ -1,4 +1,4 @@ -## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201605120027 +## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201606142149 ### Building @@ -19,7 +19,7 @@ navigate to the folder of your consuming project and run one of next commando's. _published:_ ``` -npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201605120027 --save +npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201606142149 --save ``` _unPublished (not recommended):_ diff --git a/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts b/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts index a708d49e9f9..9693b85b9d0 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts @@ -27,7 +27,7 @@ export class PetApi { public addPet (body?: models.Pet, extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/pet'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'POST', @@ -37,7 +37,13 @@ export class PetApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -50,7 +56,7 @@ export class PetApi { const path = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'petId' is set if (!petId) { @@ -65,7 +71,13 @@ export class PetApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -73,13 +85,13 @@ export class PetApi { * Multiple status values can be provided with comma seperated strings * @param status Status values that need to be considered for filter */ - public findPetsByStatus (status?: models.Array, extraHttpRequestParams?: any ) : Observable> { + public findPetsByStatus (status?: Array, extraHttpRequestParams?: any ) : Observable> { const path = this.basePath + '/pet/findByStatus'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; if (status !== undefined) { - queryParameters['status'] = status; + queryParameters.set('status', status); } let requestOptions: RequestOptionsArgs = { @@ -89,7 +101,13 @@ export class PetApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -97,13 +115,13 @@ export class PetApi { * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - public findPetsByTags (tags?: models.Array, extraHttpRequestParams?: any ) : Observable> { + public findPetsByTags (tags?: Array, extraHttpRequestParams?: any ) : Observable> { const path = this.basePath + '/pet/findByTags'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; if (tags !== undefined) { - queryParameters['tags'] = tags; + queryParameters.set('tags', tags); } let requestOptions: RequestOptionsArgs = { @@ -113,7 +131,13 @@ export class PetApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -125,7 +149,7 @@ export class PetApi { const path = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'petId' is set if (!petId) { @@ -138,7 +162,13 @@ export class PetApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -149,7 +179,7 @@ export class PetApi { public updatePet (body?: models.Pet, extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/pet'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'PUT', @@ -159,7 +189,13 @@ export class PetApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -173,7 +209,7 @@ export class PetApi { const path = this.basePath + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let formParams = new URLSearchParams(); @@ -195,7 +231,13 @@ export class PetApi { requestOptions.body = formParams.toString(); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -205,11 +247,11 @@ export class PetApi { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - public uploadFile (petId: number, additionalMetadata?: string, file?: models.any, extraHttpRequestParams?: any ) : Observable<{}> { + public uploadFile (petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/pet/{petId}/uploadImage' .replace('{' + 'petId' + '}', String(petId)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let formParams = new URLSearchParams(); @@ -231,7 +273,13 @@ export class PetApi { requestOptions.body = formParams.toString(); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } } diff --git a/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts index e6602884a81..78066b05da9 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts @@ -28,7 +28,7 @@ export class StoreApi { const path = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', String(orderId)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'orderId' is set if (!orderId) { @@ -41,7 +41,13 @@ export class StoreApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -51,7 +57,7 @@ export class StoreApi { public getInventory (extraHttpRequestParams?: any ) : Observable<{ [key: string]: number; }> { const path = this.basePath + '/store/inventory'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'GET', @@ -60,7 +66,13 @@ export class StoreApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -72,7 +84,7 @@ export class StoreApi { const path = this.basePath + '/store/order/{orderId}' .replace('{' + 'orderId' + '}', String(orderId)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'orderId' is set if (!orderId) { @@ -85,7 +97,13 @@ export class StoreApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -96,7 +114,7 @@ export class StoreApi { public placeOrder (body?: models.Order, extraHttpRequestParams?: any ) : Observable { const path = this.basePath + '/store/order'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'POST', @@ -106,7 +124,13 @@ export class StoreApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } } diff --git a/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts b/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts index 04d2e8155d5..6b8a5f538d9 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts @@ -27,7 +27,7 @@ export class UserApi { public createUser (body?: models.User, extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/user'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'POST', @@ -37,7 +37,13 @@ export class UserApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -45,10 +51,10 @@ export class UserApi { * * @param body List of user object */ - public createUsersWithArrayInput (body?: models.Array, extraHttpRequestParams?: any ) : Observable<{}> { + public createUsersWithArrayInput (body?: Array, extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/user/createWithArray'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'POST', @@ -58,7 +64,13 @@ export class UserApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -66,10 +78,10 @@ export class UserApi { * * @param body List of user object */ - public createUsersWithListInput (body?: models.Array, extraHttpRequestParams?: any ) : Observable<{}> { + public createUsersWithListInput (body?: Array, extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/user/createWithList'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'POST', @@ -79,7 +91,13 @@ export class UserApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -91,7 +109,7 @@ export class UserApi { const path = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'username' is set if (!username) { @@ -104,7 +122,13 @@ export class UserApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -116,7 +140,7 @@ export class UserApi { const path = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'username' is set if (!username) { @@ -129,7 +153,13 @@ export class UserApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -141,14 +171,14 @@ export class UserApi { public loginUser (username?: string, password?: string, extraHttpRequestParams?: any ) : Observable { const path = this.basePath + '/user/login'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; if (username !== undefined) { - queryParameters['username'] = username; + queryParameters.set('username', username); } if (password !== undefined) { - queryParameters['password'] = password; + queryParameters.set('password', password); } let requestOptions: RequestOptionsArgs = { @@ -158,7 +188,13 @@ export class UserApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -168,7 +204,7 @@ export class UserApi { public logoutUser (extraHttpRequestParams?: any ) : Observable<{}> { const path = this.basePath + '/user/logout'; - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; let requestOptions: RequestOptionsArgs = { method: 'GET', @@ -177,7 +213,13 @@ export class UserApi { }; return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } /** @@ -190,7 +232,7 @@ export class UserApi { const path = this.basePath + '/user/{username}' .replace('{' + 'username' + '}', String(username)); - let queryParameters: any = ""; // This should probably be an object in the future + let queryParameters = new URLSearchParams(); let headerParams = this.defaultHeaders; // verify required parameter 'username' is set if (!username) { @@ -204,7 +246,13 @@ export class UserApi { requestOptions.body = JSON.stringify(body); return this.http.request(path, requestOptions) - .map((response: Response) => response.json()); + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json(); + } + }); } } diff --git a/samples/client/petstore/typescript-angular2/npm/api/api.ts b/samples/client/petstore/typescript-angular2/npm/api/api.ts index a7020497be6..056206bfaca 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/api.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/api.ts @@ -1,5 +1,3 @@ -export * from '../api/PetApi'; -export * from '../api/StoreApi'; -export * from '../api/UserApi'; - - +export * from './PetApi'; +export * from './StoreApi'; +export * from './UserApi'; diff --git a/samples/client/petstore/typescript-angular2/npm/model/Category.ts b/samples/client/petstore/typescript-angular2/npm/model/Category.ts index 3a9eb603184..e3080b62f97 100644 --- a/samples/client/petstore/typescript-angular2/npm/model/Category.ts +++ b/samples/client/petstore/typescript-angular2/npm/model/Category.ts @@ -2,9 +2,9 @@ import * as models from './models'; export interface Category { + id?: number; name?: string; } - diff --git a/samples/client/petstore/typescript-angular2/npm/model/Order.ts b/samples/client/petstore/typescript-angular2/npm/model/Order.ts index ed557b454d4..4507b05bb5b 100644 --- a/samples/client/petstore/typescript-angular2/npm/model/Order.ts +++ b/samples/client/petstore/typescript-angular2/npm/model/Order.ts @@ -2,6 +2,7 @@ import * as models from './models'; export interface Order { + id?: number; @@ -18,7 +19,6 @@ export interface Order { complete?: boolean; } - export namespace Order { export enum StatusEnum { diff --git a/samples/client/petstore/typescript-angular2/npm/model/Pet.ts b/samples/client/petstore/typescript-angular2/npm/model/Pet.ts index e1235c90052..1fbd617a35e 100644 --- a/samples/client/petstore/typescript-angular2/npm/model/Pet.ts +++ b/samples/client/petstore/typescript-angular2/npm/model/Pet.ts @@ -2,6 +2,7 @@ import * as models from './models'; export interface Pet { + id?: number; @@ -18,7 +19,6 @@ export interface Pet { */ status?: Pet.StatusEnum; } - export namespace Pet { export enum StatusEnum { diff --git a/samples/client/petstore/typescript-angular2/npm/model/Tag.ts b/samples/client/petstore/typescript-angular2/npm/model/Tag.ts index fba08175c1e..489e7b5d51a 100644 --- a/samples/client/petstore/typescript-angular2/npm/model/Tag.ts +++ b/samples/client/petstore/typescript-angular2/npm/model/Tag.ts @@ -2,9 +2,9 @@ import * as models from './models'; export interface Tag { + id?: number; name?: string; } - diff --git a/samples/client/petstore/typescript-angular2/npm/model/User.ts b/samples/client/petstore/typescript-angular2/npm/model/User.ts index 3f14a356307..40711a0f677 100644 --- a/samples/client/petstore/typescript-angular2/npm/model/User.ts +++ b/samples/client/petstore/typescript-angular2/npm/model/User.ts @@ -2,6 +2,7 @@ import * as models from './models'; export interface User { + id?: number; @@ -22,4 +23,3 @@ export interface User { */ userStatus?: number; } - diff --git a/samples/client/petstore/typescript-angular2/npm/model/models.ts b/samples/client/petstore/typescript-angular2/npm/model/models.ts index cd7700a649e..92dac02846c 100644 --- a/samples/client/petstore/typescript-angular2/npm/model/models.ts +++ b/samples/client/petstore/typescript-angular2/npm/model/models.ts @@ -3,6 +3,3 @@ export * from './Order'; export * from './Pet'; export * from './Tag'; export * from './User'; - - - diff --git a/samples/client/petstore/typescript-angular2/npm/package.json b/samples/client/petstore/typescript-angular2/npm/package.json index 8447881dafc..f2fc68546ed 100644 --- a/samples/client/petstore/typescript-angular2/npm/package.json +++ b/samples/client/petstore/typescript-angular2/npm/package.json @@ -1,12 +1,12 @@ { "name": "@swagger/angular2-typescript-petstore", - "version": "0.0.1-SNAPSHOT.201605120027", + "version": "0.0.1-SNAPSHOT.201606142149", "description": "swagger client for @swagger/angular2-typescript-petstore", "author": "Swagger Codegen Contributors", "keywords": [ "swagger-client" ], - "license": "MIT", + "license": "Apache-2.0", "files": [ "lib" ], @@ -16,15 +16,8 @@ "build": "typings install && tsc" }, "peerDependencies": { - "@angular/common": "^2.0.0-rc.1", - "@angular/compiler": "^2.0.0-rc.1", "@angular/core": "^2.0.0-rc.1", - "@angular/http": "^2.0.0-rc.1", - "@angular/platform-browser": "^2.0.0-rc.1", - "@angular/platform-browser-dynamic": "^2.0.0-rc.1", - "core-js": "^2.3.0", - "rxjs": "^5.0.0-beta.6", - "zone.js": "^0.6.12" + "@angular/http": "^2.0.0-rc.1" }, "devDependencies": { "@angular/common": "^2.0.0-rc.1", diff --git a/samples/server/petstore/go-api-server/.swagger-codegen-ignore b/samples/server/petstore/go-api-server/.swagger-codegen-ignore new file mode 100644 index 00000000000..19d3377182e --- /dev/null +++ b/samples/server/petstore/go-api-server/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Console/Commands/.gitkeep b/samples/server/petstore/go-api-server/api/swagger.yaml similarity index 100% rename from modules/swagger-codegen/src/main/resources/lumen/app/Console/Commands/.gitkeep rename to samples/server/petstore/go-api-server/api/swagger.yaml diff --git a/samples/server/petstore/go-api-server/go/README.md b/samples/server/petstore/go-api-server/go/README.md new file mode 100644 index 00000000000..62ca0d76901 --- /dev/null +++ b/samples/server/petstore/go-api-server/go/README.md @@ -0,0 +1,25 @@ +# Go API Server for petstoreserver + +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +## Overview +This server was generated by the [swagger-codegen] +(https://github.com/swagger-api/swagger-codegen) project. +By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub. +- + +To see how to make this your own, look here: + +[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md) + +- API version: 1.0.0 +- Build date: 2016-05-27T09:17:10.992-07:00 + + +### Running the server +To run the server, follow these simple steps: + +``` +go run main.go +``` + diff --git a/samples/server/petstore/go-api-server/go/app.yaml b/samples/server/petstore/go-api-server/go/app.yaml new file mode 100644 index 00000000000..ea684a7280a --- /dev/null +++ b/samples/server/petstore/go-api-server/go/app.yaml @@ -0,0 +1 @@ +application: petstoreserver \ No newline at end of file diff --git a/samples/server/petstore/go-api-server/go/logger.go b/samples/server/petstore/go-api-server/go/logger.go new file mode 100644 index 00000000000..1ff51c3f16d --- /dev/null +++ b/samples/server/petstore/go-api-server/go/logger.go @@ -0,0 +1,23 @@ +package petstoreserver + +import ( + "log" + "net/http" + "time" +) + +func Logger(inner http.Handler, name string) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() + + inner.ServeHTTP(w, r) + + log.Printf( + "%s %s %s %s", + r.Method, + r.RequestURI, + name, + time.Since(start), + ) + }) +} \ No newline at end of file diff --git a/samples/server/petstore/go-api-server/go/pet.go b/samples/server/petstore/go-api-server/go/pet.go new file mode 100644 index 00000000000..21252983217 --- /dev/null +++ b/samples/server/petstore/go-api-server/go/pet.go @@ -0,0 +1,50 @@ +package petstoreserver + +import ( + "net/http" +) + +type Pet struct { + +} + +func AddPet(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func DeletePet(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func FindPetsByStatus(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func FindPetsByTags(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func GetPetById(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func UpdatePet(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func UpdatePetWithForm(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func UploadFile(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + diff --git a/samples/server/petstore/go-api-server/go/routers.go b/samples/server/petstore/go-api-server/go/routers.go new file mode 100644 index 00000000000..8704c12c4bd --- /dev/null +++ b/samples/server/petstore/go-api-server/go/routers.go @@ -0,0 +1,187 @@ +package petstoreserver + +import ( + "net/http" + "fmt" + "github.com/gorilla/mux" +) + +type Route struct { + Name string + Method string + Pattern string + HandlerFunc http.HandlerFunc +} + +type Routes []Route + +func NewRouter() *mux.Router { + router := mux.NewRouter().StrictSlash(true) + for _, route := range routes { + var handler http.Handler + handler = route.HandlerFunc + handler = Logger(handler, route.Name) + + router. + Methods(route.Method). + Path(route.Pattern). + Name(route.Name). + Handler(handler) + } + + return router +} + +func Index(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Hello World!") +} + +var routes = Routes{ + Route{ + "Index", + "GET", + "/", + Index, + }, + + Route{ + "AddPet", + "POST", + "/pet", + AddPet, + }, + + Route{ + "DeletePet", + "DELETE", + "/pet/{petId}", + DeletePet, + }, + + Route{ + "FindPetsByStatus", + "GET", + "/pet/findByStatus", + FindPetsByStatus, + }, + + Route{ + "FindPetsByTags", + "GET", + "/pet/findByTags", + FindPetsByTags, + }, + + Route{ + "GetPetById", + "GET", + "/pet/{petId}", + GetPetById, + }, + + Route{ + "UpdatePet", + "PUT", + "/pet", + UpdatePet, + }, + + Route{ + "UpdatePetWithForm", + "POST", + "/pet/{petId}", + UpdatePetWithForm, + }, + + Route{ + "UploadFile", + "POST", + "/pet/{petId}/uploadImage", + UploadFile, + }, + + Route{ + "DeleteOrder", + "DELETE", + "/store/order/{orderId}", + DeleteOrder, + }, + + Route{ + "GetInventory", + "GET", + "/store/inventory", + GetInventory, + }, + + Route{ + "GetOrderById", + "GET", + "/store/order/{orderId}", + GetOrderById, + }, + + Route{ + "PlaceOrder", + "POST", + "/store/order", + PlaceOrder, + }, + + Route{ + "CreateUser", + "POST", + "/user", + CreateUser, + }, + + Route{ + "CreateUsersWithArrayInput", + "POST", + "/user/createWithArray", + CreateUsersWithArrayInput, + }, + + Route{ + "CreateUsersWithListInput", + "POST", + "/user/createWithList", + CreateUsersWithListInput, + }, + + Route{ + "DeleteUser", + "DELETE", + "/user/{username}", + DeleteUser, + }, + + Route{ + "GetUserByName", + "GET", + "/user/{username}", + GetUserByName, + }, + + Route{ + "LoginUser", + "GET", + "/user/login", + LoginUser, + }, + + Route{ + "LogoutUser", + "GET", + "/user/logout", + LogoutUser, + }, + + Route{ + "UpdateUser", + "PUT", + "/user/{username}", + UpdateUser, + }, + +} \ No newline at end of file diff --git a/samples/server/petstore/go-api-server/go/store.go b/samples/server/petstore/go-api-server/go/store.go new file mode 100644 index 00000000000..9af921d3a54 --- /dev/null +++ b/samples/server/petstore/go-api-server/go/store.go @@ -0,0 +1,30 @@ +package petstoreserver + +import ( + "net/http" +) + +type Store struct { + +} + +func DeleteOrder(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func GetInventory(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func GetOrderById(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func PlaceOrder(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + diff --git a/samples/server/petstore/go-api-server/go/user.go b/samples/server/petstore/go-api-server/go/user.go new file mode 100644 index 00000000000..5c7d0cd2f1b --- /dev/null +++ b/samples/server/petstore/go-api-server/go/user.go @@ -0,0 +1,50 @@ +package petstoreserver + +import ( + "net/http" +) + +type User struct { + +} + +func CreateUser(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func CreateUsersWithArrayInput(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func CreateUsersWithListInput(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func DeleteUser(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func GetUserByName(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func LoginUser(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func LogoutUser(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + +func UpdateUser(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) +} + diff --git a/samples/server/petstore/go-api-server/main.go b/samples/server/petstore/go-api-server/main.go new file mode 100644 index 00000000000..915963a6095 --- /dev/null +++ b/samples/server/petstore/go-api-server/main.go @@ -0,0 +1,22 @@ +package main + +import ( + // WARNING! + // Change this to a fully-qualified import path + // once you place this file into your project. + // For example, + // + // sw "github.com/myname/myrepo/go" + // + sw "./go" + "log" + "net/http" +) + +func main() { + log.Printf("Server started") + + router := sw.NewRouter() + + log.Fatal(http.ListenAndServe(":8080", router)) +} diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java index 52ca606b544..a57fbd04d81 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java @@ -1,8 +1,8 @@ package io.swagger.api; import io.swagger.model.Pet; -import java.io.File; import io.swagger.model.ModelApiResponse; +import java.io.File; import java.io.InputStream; import java.io.OutputStream; diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java index 2b2d460203b..80d4ccbfc40 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java @@ -19,8 +19,10 @@ import javax.xml.bind.annotation.XmlEnum; public class Category { + @XmlElement(name="id") private Long id = null; + @XmlElement(name="name") private String name = null; /** diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java index b0babb254e7..7c6356ec4b5 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java @@ -19,19 +19,23 @@ import javax.xml.bind.annotation.XmlEnum; public class Order { + @XmlElement(name="id") private Long id = null; + @XmlElement(name="petId") private Long petId = null; + @XmlElement(name="quantity") private Integer quantity = null; + @XmlElement(name="shipDate") private javax.xml.datatype.XMLGregorianCalendar shipDate = null; @XmlType(name="StatusEnum") @XmlEnum public enum StatusEnum { - PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered")); + PLACED(String.valueOf(""placed"")), APPROVED(String.valueOf(""approved"")), DELIVERED(String.valueOf(""delivered"")); private String value; @@ -49,8 +53,10 @@ public enum StatusEnum { } } + @XmlElement(name="status") private StatusEnum status = null; + @XmlElement(name="complete") private Boolean complete = false; /** diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java index 58a58752122..52682bcdd0a 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java @@ -23,21 +23,26 @@ import javax.xml.bind.annotation.XmlEnum; public class Pet { + @XmlElement(name="id") private Long id = null; + @XmlElement(name="category") private Category category = null; + @XmlElement(name="name") private String name = null; + @XmlElement(name="photoUrls") private List photoUrls = new ArrayList(); + @XmlElement(name="tags") private List tags = new ArrayList(); @XmlType(name="StatusEnum") @XmlEnum public enum StatusEnum { - AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold")); + AVAILABLE(String.valueOf(""available"")), PENDING(String.valueOf(""pending"")), SOLD(String.valueOf(""sold"")); private String value; @@ -55,6 +60,7 @@ public enum StatusEnum { } } + @XmlElement(name="status") private StatusEnum status = null; /** diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java index 4e1921add9b..25927e8d4cb 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java @@ -19,8 +19,10 @@ import javax.xml.bind.annotation.XmlEnum; public class Tag { + @XmlElement(name="id") private Long id = null; + @XmlElement(name="name") private String name = null; /** diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java index 007344a2687..e3e3f234123 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java @@ -19,20 +19,28 @@ import javax.xml.bind.annotation.XmlEnum; public class User { + @XmlElement(name="id") private Long id = null; + @XmlElement(name="username") private String username = null; + @XmlElement(name="firstName") private String firstName = null; + @XmlElement(name="lastName") private String lastName = null; + @XmlElement(name="email") private String email = null; + @XmlElement(name="password") private String password = null; + @XmlElement(name="phone") private String phone = null; + @XmlElement(name="userStatus") private Integer userStatus = null; /** diff --git a/samples/server/petstore/lumen/.swagger-codegen-ignore b/samples/server/petstore/lumen/.swagger-codegen-ignore new file mode 100644 index 00000000000..19d3377182e --- /dev/null +++ b/samples/server/petstore/lumen/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/server/petstore/lumen/LICENSE b/samples/server/petstore/lumen/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/samples/server/petstore/lumen/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. diff --git a/samples/server/petstore/lumen/app/Console/Kernel.php b/samples/server/petstore/lumen/app/Console/Kernel.php new file mode 100644 index 00000000000..6f10d9f838e --- /dev/null +++ b/samples/server/petstore/lumen/app/Console/Kernel.php @@ -0,0 +1,47 @@ + 543.2) { + throw new \InvalidArgumentException('invalid value for $number when calling FakeApi.testEndpointParameters, must be smaller than or equal to 543.2.'); + } + if ($input['number'] < 32.1) { + throw new \InvalidArgumentException('invalid value for $number when calling FakeApi.testEndpointParameters, must be bigger than or equal to 32.1.'); + } + $number = $input['number']; + + if (!isset($input['double'])) { + throw new \InvalidArgumentException('Missing the required parameter $double when calling testEndpointParameters'); + } + if ($input['double'] > 123.4) { + throw new \InvalidArgumentException('invalid value for $double when calling FakeApi.testEndpointParameters, must be smaller than or equal to 123.4.'); + } + if ($input['double'] < 67.8) { + throw new \InvalidArgumentException('invalid value for $double when calling FakeApi.testEndpointParameters, must be bigger than or equal to 67.8.'); + } + $double = $input['double']; + + if (!isset($input['string'])) { + throw new \InvalidArgumentException('Missing the required parameter $string when calling testEndpointParameters'); + } + if (!preg_match("/[a-z]/i", $input['string'])) { + throw new \InvalidArgumentException('invalid value for $string when calling FakeApi.testEndpointParameters, must conform to the pattern /[a-z]/i.'); + } + $string = $input['string']; + + if (!isset($input['byte'])) { + throw new \InvalidArgumentException('Missing the required parameter $byte when calling testEndpointParameters'); + } + $byte = $input['byte']; + + if ($input['integer'] > 100.0) { + throw new \InvalidArgumentException('invalid value for $integer when calling FakeApi.testEndpointParameters, must be smaller than or equal to 100.0.'); + } + if ($input['integer'] < 10.0) { + throw new \InvalidArgumentException('invalid value for $integer when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.0.'); + } + $integer = $input['integer']; + + if ($input['int32'] > 200.0) { + throw new \InvalidArgumentException('invalid value for $int32 when calling FakeApi.testEndpointParameters, must be smaller than or equal to 200.0.'); + } + if ($input['int32'] < 20.0) { + throw new \InvalidArgumentException('invalid value for $int32 when calling FakeApi.testEndpointParameters, must be bigger than or equal to 20.0.'); + } + $int32 = $input['int32']; + + $int64 = $input['int64']; + + if ($input['float'] > 987.6) { + throw new \InvalidArgumentException('invalid value for $float when calling FakeApi.testEndpointParameters, must be smaller than or equal to 987.6.'); + } + $float = $input['float']; + + $binary = $input['binary']; + + $date = $input['date']; + + $dateTime = $input['dateTime']; + + if (strlen($input['password']) > 64) { + throw new \InvalidArgumentException('invalid length for $password when calling FakeApi.testEndpointParameters, must be smaller than or equal to 64.'); + } + if (strlen($input['password']) < 10) { + throw new \InvalidArgumentException('invalid length for $password when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.'); + } + $password = $input['password']; + + + return response('How about implementing testEndpointParameters as a POST method ?'); + } +} diff --git a/samples/server/petstore/lumen/app/Http/controllers/PetApi.php b/samples/server/petstore/lumen/app/Http/controllers/PetApi.php new file mode 100644 index 00000000000..dd6a838eaef --- /dev/null +++ b/samples/server/petstore/lumen/app/Http/controllers/PetApi.php @@ -0,0 +1,217 @@ + 5.0) { + throw new \InvalidArgumentException('invalid value for $orderId when calling StoreApi.getOrderById, must be smaller than or equal to 5.0.'); + } + if ($orderId] < 1.0) { + throw new \InvalidArgumentException('invalid value for $orderId when calling StoreApi.getOrderById, must be bigger than or equal to 1.0.'); + } + + + //not path params validation + + return response('How about implementing getOrderById as a GET method ?'); + } + /** + * Operation placeOrder + * + * Place an order for a pet. + * + * + * @return Http response + */ + public function placeOrder() + { + $input = Request::all(); + + //path params validation + + + //not path params validation + if (!isset($input['body'])) { + throw new \InvalidArgumentException('Missing the required parameter $body when calling placeOrder'); + } + $body = $input['body']; + + + return response('How about implementing placeOrder as a POST method ?'); + } +} diff --git a/samples/server/petstore/lumen/app/Http/controllers/UserApi.php b/samples/server/petstore/lumen/app/Http/controllers/UserApi.php new file mode 100644 index 00000000000..f9ade75e98a --- /dev/null +++ b/samples/server/petstore/lumen/app/Http/controllers/UserApi.php @@ -0,0 +1,221 @@ +get('/', function () use ($app) { + return $app->version(); +}); + +/** + * POST testEndpointParameters + * Summary: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Notes: Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Output-Formats: [application/xml; charset=utf-8, application/json; charset=utf-8] + */ +$app->POST('/fake', 'FakeApi@testEndpointParameters'); +/** + * POST addPet + * Summary: Add a new pet to the store + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/pet', 'PetApi@addPet'); +/** + * DELETE deletePet + * Summary: Deletes a pet + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->DELETE('/pet/{petId}', 'PetApi@deletePet'); +/** + * GET findPetsByStatus + * Summary: Finds Pets by status + * Notes: Multiple status values can be provided with comma separated strings + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/pet/findByStatus', 'PetApi@findPetsByStatus'); +/** + * GET findPetsByTags + * Summary: Finds Pets by tags + * Notes: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/pet/findByTags', 'PetApi@findPetsByTags'); +/** + * GET getPetById + * Summary: Find pet by ID + * Notes: Returns a single pet + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/pet/{petId}', 'PetApi@getPetById'); +/** + * PUT updatePet + * Summary: Update an existing pet + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->PUT('/pet', 'PetApi@updatePet'); +/** + * POST updatePetWithForm + * Summary: Updates a pet in the store with form data + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/pet/{petId}', 'PetApi@updatePetWithForm'); +/** + * POST uploadFile + * Summary: uploads an image + * Notes: + * Output-Formats: [application/json] + */ +$app->POST('/pet/{petId}/uploadImage', 'PetApi@uploadFile'); +/** + * DELETE deleteOrder + * Summary: Delete purchase order by ID + * Notes: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Output-Formats: [application/xml, application/json] + */ +$app->DELETE('/store/order/{orderId}', 'StoreApi@deleteOrder'); +/** + * GET getInventory + * Summary: Returns pet inventories by status + * Notes: Returns a map of status codes to quantities + * Output-Formats: [application/json] + */ +$app->GET('/store/inventory', 'StoreApi@getInventory'); +/** + * GET getOrderById + * Summary: Find purchase order by ID + * Notes: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/store/order/{orderId}', 'StoreApi@getOrderById'); +/** + * POST placeOrder + * Summary: Place an order for a pet + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/store/order', 'StoreApi@placeOrder'); +/** + * POST createUser + * Summary: Create user + * Notes: This can only be done by the logged in user. + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/user', 'UserApi@createUser'); +/** + * POST createUsersWithArrayInput + * Summary: Creates list of users with given input array + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/user/createWithArray', 'UserApi@createUsersWithArrayInput'); +/** + * POST createUsersWithListInput + * Summary: Creates list of users with given input array + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/user/createWithList', 'UserApi@createUsersWithListInput'); +/** + * DELETE deleteUser + * Summary: Delete user + * Notes: This can only be done by the logged in user. + * Output-Formats: [application/xml, application/json] + */ +$app->DELETE('/user/{username}', 'UserApi@deleteUser'); +/** + * GET getUserByName + * Summary: Get user by user name + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/user/{username}', 'UserApi@getUserByName'); +/** + * GET loginUser + * Summary: Logs user into the system + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/user/login', 'UserApi@loginUser'); +/** + * GET logoutUser + * Summary: Logs out current logged in user session + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/user/logout', 'UserApi@logoutUser'); +/** + * PUT updateUser + * Summary: Updated user + * Notes: This can only be done by the logged in user. + * Output-Formats: [application/xml, application/json] + */ +$app->PUT('/user/{username}', 'UserApi@updateUser'); + diff --git a/samples/server/petstore/lumen/app/User.php b/samples/server/petstore/lumen/app/User.php new file mode 100644 index 00000000000..df7e66efc04 --- /dev/null +++ b/samples/server/petstore/lumen/app/User.php @@ -0,0 +1,52 @@ +withFacades(); +$app->withFacades(); // $app->withEloquent(); @@ -48,8 +66,6 @@ $app->singleton( App\Console\Kernel::class ); -class_alias('Illuminate\Support\Facades\Request', 'Request'); //to use the Reqesut facade - /* |-------------------------------------------------------------------------- | Register Middleware diff --git a/samples/server/petstore/lumen/composer.json b/samples/server/petstore/lumen/composer.json new file mode 100644 index 00000000000..55559dfaac9 --- /dev/null +++ b/samples/server/petstore/lumen/composer.json @@ -0,0 +1,28 @@ +{ + "name": "GIT_USER_ID/GIT_REPO_ID", + "description": "", + "keywords": [ + "swagger", + "php", + "sdk", + "api" + ], + "homepage": "http://swagger.io", + "license": "Apache v2", + "authors": [ + { + "name": "Swagger and contributors", + "homepage": "https://github.com/swagger-api/swagger-codegen" + } + ], + "require": { + "php": ">=5.5.9", + "laravel/lumen-framework": "5.2.*", + "vlucas/phpdotenv": "~2.2" + }, + "autoload": { + "psr-4": { + "App\\": "app/" + } + } +} diff --git a/samples/server/petstore/lumen/lumen/app/Console/Kernel.php b/samples/server/petstore/lumen/lumen/app/Console/Kernel.php deleted file mode 100644 index ad6e311cdd0..00000000000 --- a/samples/server/petstore/lumen/lumen/app/Console/Kernel.php +++ /dev/null @@ -1,29 +0,0 @@ -get('/', function () use ($app) { - return $app->version(); -}); - - -/** - * POST addPet - * Summary: Add a new pet to the store - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->POST('/pet', function($null = null) use ($app) { - - - - - return response('How about implementing addPet as a POST method ?'); - }); - - -/** - * DELETE deletePet - * Summary: Deletes a pet - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->DELETE('/pet/{petId}', function($petId, $null = null) use ($app) { - $headers = Request::header(); - - - - return response('How about implementing deletePet as a DELETE method ?'); - }); - - -/** - * GET findPetsByStatus - * Summary: Finds Pets by status - * Notes: Multiple status values can be provided with comma separated strings - * Output-Formats: [application/xml, application/json] - */ -$app->GET('/pet/findByStatus', function($null = null) use ($app) { - - $status = Request::input('status'); - - - - return response('How about implementing findPetsByStatus as a GET method ?'); - }); - - -/** - * GET findPetsByTags - * Summary: Finds Pets by tags - * Notes: Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * Output-Formats: [application/xml, application/json] - */ -$app->GET('/pet/findByTags', function($null = null) use ($app) { - - $tags = Request::input('tags'); - - - - return response('How about implementing findPetsByTags as a GET method ?'); - }); - - -/** - * GET getPetById - * Summary: Find pet by ID - * Notes: Returns a single pet - * Output-Formats: [application/xml, application/json] - */ -$app->GET('/pet/{petId}', function($petId, $null = null) use ($app) { - - - - - return response('How about implementing getPetById as a GET method ?'); - }); - - -/** - * PUT updatePet - * Summary: Update an existing pet - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->PUT('/pet', function($null = null) use ($app) { - - - - - return response('How about implementing updatePet as a PUT method ?'); - }); - - -/** - * POST updatePetWithForm - * Summary: Updates a pet in the store with form data - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->POST('/pet/{petId}', function($petId, $null = null) use ($app) { - - - $name = Request::input('name'); $status = Request::input('status'); - - return response('How about implementing updatePetWithForm as a POST method ?'); - }); - - -/** - * POST uploadFile - * Summary: uploads an image - * Notes: - * Output-Formats: [application/json] - */ -$app->POST('/pet/{petId}/uploadImage', function($petId, $null = null) use ($app) { - - - $additionalMetadata = Request::input('additionalMetadata'); $file = Request::input('file'); - - return response('How about implementing uploadFile as a POST method ?'); - }); - - -/** - * DELETE deleteOrder - * Summary: Delete purchase order by ID - * Notes: For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors - * Output-Formats: [application/xml, application/json] - */ -$app->DELETE('/store/order/{orderId}', function($orderId, $null = null) use ($app) { - - - - - return response('How about implementing deleteOrder as a DELETE method ?'); - }); - - -/** - * GET getInventory - * Summary: Returns pet inventories by status - * Notes: Returns a map of status codes to quantities - * Output-Formats: [application/json] - */ -$app->GET('/store/inventory', function($null = null) use ($app) { - - - - - return response('How about implementing getInventory as a GET method ?'); - }); - - -/** - * GET getOrderById - * Summary: Find purchase order by ID - * Notes: For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions - * Output-Formats: [application/xml, application/json] - */ -$app->GET('/store/order/{orderId}', function($orderId, $null = null) use ($app) { - - - - - return response('How about implementing getOrderById as a GET method ?'); - }); - - -/** - * POST placeOrder - * Summary: Place an order for a pet - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->POST('/store/order', function($null = null) use ($app) { - - - - - return response('How about implementing placeOrder as a POST method ?'); - }); - - -/** - * POST createUser - * Summary: Create user - * Notes: This can only be done by the logged in user. - * Output-Formats: [application/xml, application/json] - */ -$app->POST('/user', function($null = null) use ($app) { - - - - - return response('How about implementing createUser as a POST method ?'); - }); - - -/** - * POST createUsersWithArrayInput - * Summary: Creates list of users with given input array - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->POST('/user/createWithArray', function($null = null) use ($app) { - - - - - return response('How about implementing createUsersWithArrayInput as a POST method ?'); - }); - - -/** - * POST createUsersWithListInput - * Summary: Creates list of users with given input array - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->POST('/user/createWithList', function($null = null) use ($app) { - - - - - return response('How about implementing createUsersWithListInput as a POST method ?'); - }); - - -/** - * DELETE deleteUser - * Summary: Delete user - * Notes: This can only be done by the logged in user. - * Output-Formats: [application/xml, application/json] - */ -$app->DELETE('/user/{username}', function($username, $null = null) use ($app) { - - - - - return response('How about implementing deleteUser as a DELETE method ?'); - }); - - -/** - * GET getUserByName - * Summary: Get user by user name - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->GET('/user/{username}', function($username, $null = null) use ($app) { - - - - - return response('How about implementing getUserByName as a GET method ?'); - }); - - -/** - * GET loginUser - * Summary: Logs user into the system - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->GET('/user/login', function($null = null) use ($app) { - - $username = Request::input('username'); - $password = Request::input('password'); - - - - return response('How about implementing loginUser as a GET method ?'); - }); - - -/** - * GET logoutUser - * Summary: Logs out current logged in user session - * Notes: - * Output-Formats: [application/xml, application/json] - */ -$app->GET('/user/logout', function($null = null) use ($app) { - - - - - return response('How about implementing logoutUser as a GET method ?'); - }); - - -/** - * PUT updateUser - * Summary: Updated user - * Notes: This can only be done by the logged in user. - * Output-Formats: [application/xml, application/json] - */ -$app->PUT('/user/{username}', function($username, $null = null) use ($app) { - - - - - return response('How about implementing updateUser as a PUT method ?'); - }); - - - diff --git a/samples/server/petstore/lumen/lumen/app/Providers/AppServiceProvider.php b/samples/server/petstore/lumen/lumen/app/Providers/AppServiceProvider.php deleted file mode 100644 index ddec04694c3..00000000000 --- a/samples/server/petstore/lumen/lumen/app/Providers/AppServiceProvider.php +++ /dev/null @@ -1,18 +0,0 @@ -input('api_token')) { - return User::where('api_token', $request->input('api_token'))->first(); - } - }); - } -} diff --git a/samples/server/petstore/lumen/lumen/app/Providers/EventServiceProvider.php b/samples/server/petstore/lumen/lumen/app/Providers/EventServiceProvider.php deleted file mode 100644 index 0b8f3934fb3..00000000000 --- a/samples/server/petstore/lumen/lumen/app/Providers/EventServiceProvider.php +++ /dev/null @@ -1,19 +0,0 @@ - [ - 'App\Listeners\EventListener', - ], - ]; -} diff --git a/samples/server/petstore/lumen/lumen/app/User.php b/samples/server/petstore/lumen/lumen/app/User.php deleted file mode 100644 index fd4de31172c..00000000000 --- a/samples/server/petstore/lumen/lumen/app/User.php +++ /dev/null @@ -1,34 +0,0 @@ -make( - 'Illuminate\Contracts\Console\Kernel' -); - -exit($kernel->handle(new ArgvInput, new ConsoleOutput)); diff --git a/samples/server/petstore/lumen/lumen/composer.json b/samples/server/petstore/lumen/lumen/composer.json deleted file mode 100644 index 62df199e76a..00000000000 --- a/samples/server/petstore/lumen/lumen/composer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "laravel/lumen", - "description": "The Laravel Lumen Framework.", - "keywords": ["framework", "laravel", "lumen"], - "license": "MIT", - "type": "project", - "require": { - "php": ">=5.5.9", - "laravel/lumen-framework": "5.2.*", - "vlucas/phpdotenv": "~2.2" - }, - "autoload": { - "psr-4": { - "App\\": "app/" - } - } -} diff --git a/samples/server/petstore/lumen/lumen/readme.md b/samples/server/petstore/lumen/lumen/readme.md deleted file mode 100644 index 9605e5f3f45..00000000000 --- a/samples/server/petstore/lumen/lumen/readme.md +++ /dev/null @@ -1,21 +0,0 @@ -## Lumen PHP Framework - -[![Build Status](https://travis-ci.org/laravel/lumen-framework.svg)](https://travis-ci.org/laravel/lumen-framework) -[![Total Downloads](https://poser.pugx.org/laravel/lumen-framework/d/total.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![Latest Stable Version](https://poser.pugx.org/laravel/lumen-framework/v/stable.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![Latest Unstable Version](https://poser.pugx.org/laravel/lumen-framework/v/unstable.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![License](https://poser.pugx.org/laravel/lumen-framework/license.svg)](https://packagist.org/packages/laravel/lumen-framework) - -Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching. - -## Official Documentation - -Documentation for the framework can be found on the [Lumen website](http://lumen.laravel.com/docs). - -## Security Vulnerabilities - -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. - -### License - -The Lumen framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) diff --git a/modules/swagger-codegen/src/main/resources/lumen/public/index.php b/samples/server/petstore/lumen/public/index.php similarity index 55% rename from modules/swagger-codegen/src/main/resources/lumen/public/index.php rename to samples/server/petstore/lumen/public/index.php index 04aa08688e0..3fc94132231 100644 --- a/modules/swagger-codegen/src/main/resources/lumen/public/index.php +++ b/samples/server/petstore/lumen/public/index.php @@ -1,5 +1,23 @@ e.printStackTrace() diff --git a/samples/server/petstore/scalatra/src/main/scala/ServletApp.scala b/samples/server/petstore/scalatra/src/main/scala/ServletApp.scala index e5063473ebe..35c8a3a84d0 100644 --- a/samples/server/petstore/scalatra/src/main/scala/ServletApp.scala +++ b/samples/server/petstore/scalatra/src/main/scala/ServletApp.scala @@ -1,28 +1,52 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + package io.swagger.app import _root_.akka.actor.ActorSystem import org.scalatra.swagger.{ ApiInfo, SwaggerWithAuth, Swagger } -import org.scalatra.swagger.{ JacksonSwaggerBase, Swagger } +import org.scalatra.swagger.{JacksonSwaggerBase, Swagger} import org.scalatra.ScalatraServlet -import org.json4s.{ DefaultFormats, Formats } +import org.json4s.{DefaultFormats, Formats} class ResourcesApp(implicit protected val system: ActorSystem, val swagger: SwaggerApp) - extends ScalatraServlet with JacksonSwaggerBase { + extends ScalatraServlet with JacksonSwaggerBase { before() { response.headers += ("Access-Control-Allow-Origin" -> "*") } protected def buildFullUrl(path: String) = if (path.startsWith("http")) path else { - val port = request.getServerPort - val h = request.getServerName - val prot = if (port == 443) "https" else "http" - val (proto, host) = if (port != 80 && port != 443) ("http", h + ":" + port.toString) else (prot, h) - "%s://%s%s%s".format( - proto, - host, - request.getContextPath, - path) + val port = request.getServerPort + val h = request.getServerName + val prot = if (port == 443) "https" else "http" + val (proto, host) = if (port != 80 && port != 443) ("http", h+":"+port.toString) else (prot, h) + "%s://%s%s%s".format( + proto, + host, + request.getContextPath, + path) } } diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/PetApi.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/PetApi.scala index 58984f1783c..56288e3518f 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/PetApi.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/PetApi.scala @@ -1,8 +1,32 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + package com.wordnik.client.api import com.wordnik.client.model.Pet -import com.wordnik.client.model.ApiResponse import java.io.File +import com.wordnik.client.model.ApiResponse import java.io.File diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/StoreApi.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/StoreApi.scala index 934eb329fca..b2a8df92b39 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/StoreApi.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/StoreApi.scala @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + package com.wordnik.client.api import com.wordnik.client.model.Order @@ -9,11 +33,11 @@ import org.scalatra.swagger._ import org.json4s._ import org.json4s.JsonDSL._ import org.scalatra.json.{ JValueResult, JacksonJsonSupport } -import org.scalatra.servlet.{ FileUploadSupport, MultipartConfig, SizeConstraintExceededException } +import org.scalatra.servlet.{FileUploadSupport, MultipartConfig, SizeConstraintExceededException} import scala.collection.JavaConverters._ -class StoreApi(implicit val swagger: Swagger) extends ScalatraServlet +class StoreApi (implicit val swagger: Swagger) extends ScalatraServlet with FileUploadSupport with JacksonJsonSupport with SwaggerSupport { @@ -26,46 +50,56 @@ class StoreApi(implicit val swagger: Swagger) extends ScalatraServlet contentType = formats("json") response.headers += ("Access-Control-Allow-Origin" -> "*") } + val deleteOrderOperation = (apiOperation[Unit]("deleteOrder") - summary "Delete purchase order by ID" - parameters (pathParam[String]("orderId").description("")) + summary "Delete purchase order by ID" + parameters(pathParam[String]("orderId").description("")) ) - delete("/store/order/{orderId}", operation(deleteOrderOperation)) { - - val orderId = params.getOrElse("orderId", halt(400)) - + delete("/store/order/{orderId}",operation(deleteOrderOperation)) { + + + val orderId = params.getOrElse("orderId", halt(400)) + println("orderId: " + orderId) } + + val getInventoryOperation = (apiOperation[Map[String, Int]]("getInventory") - summary "Returns pet inventories by status" - parameters () + summary "Returns pet inventories by status" + parameters() ) - get("/store/inventory", operation(getInventoryOperation)) { + get("/store/inventory",operation(getInventoryOperation)) { } + + val getOrderByIdOperation = (apiOperation[Order]("getOrderById") - summary "Find purchase order by ID" - parameters (pathParam[Long]("orderId").description("")) + summary "Find purchase order by ID" + parameters(pathParam[Long]("orderId").description("")) ) - get("/store/order/{orderId}", operation(getOrderByIdOperation)) { - - val orderId = params.getOrElse("orderId", halt(400)) - + get("/store/order/{orderId}",operation(getOrderByIdOperation)) { + + + val orderId = params.getOrElse("orderId", halt(400)) + println("orderId: " + orderId) } + + val placeOrderOperation = (apiOperation[Order]("placeOrder") - summary "Place an order for a pet" - parameters (bodyParam[Order]("body").description("")) + summary "Place an order for a pet" + parameters(bodyParam[Order]("body").description("")) ) - post("/store/order", operation(placeOrderOperation)) { - + post("/store/order",operation(placeOrderOperation)) { + + bodyParam[Order]("body").description("") println("body: " + body) } diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/UserApi.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/UserApi.scala index 0d5bc6c276b..7103ade331e 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/UserApi.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/api/UserApi.scala @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + package com.wordnik.client.api import com.wordnik.client.model.User @@ -9,11 +33,11 @@ import org.scalatra.swagger._ import org.json4s._ import org.json4s.JsonDSL._ import org.scalatra.json.{ JValueResult, JacksonJsonSupport } -import org.scalatra.servlet.{ FileUploadSupport, MultipartConfig, SizeConstraintExceededException } +import org.scalatra.servlet.{FileUploadSupport, MultipartConfig, SizeConstraintExceededException} import scala.collection.JavaConverters._ -class UserApi(implicit val swagger: Swagger) extends ScalatraServlet +class UserApi (implicit val swagger: Swagger) extends ScalatraServlet with FileUploadSupport with JacksonJsonSupport with SwaggerSupport { @@ -26,101 +50,125 @@ class UserApi(implicit val swagger: Swagger) extends ScalatraServlet contentType = formats("json") response.headers += ("Access-Control-Allow-Origin" -> "*") } + val createUserOperation = (apiOperation[Unit]("createUser") - summary "Create user" - parameters (bodyParam[User]("body").description("")) + summary "Create user" + parameters(bodyParam[User]("body").description("")) ) - post("/user", operation(createUserOperation)) { - + post("/user",operation(createUserOperation)) { + + bodyParam[User]("body").description("") println("body: " + body) } + + val createUsersWithArrayInputOperation = (apiOperation[Unit]("createUsersWithArrayInput") - summary "Creates list of users with given input array" - parameters (bodyParam[List[User]]("body").description("")) + summary "Creates list of users with given input array" + parameters(bodyParam[List[User]]("body").description("")) ) - post("/user/createWithArray", operation(createUsersWithArrayInputOperation)) { - + post("/user/createWithArray",operation(createUsersWithArrayInputOperation)) { + + bodyParam[List[User]]("body").description("") println("body: " + body) } + + val createUsersWithListInputOperation = (apiOperation[Unit]("createUsersWithListInput") - summary "Creates list of users with given input array" - parameters (bodyParam[List[User]]("body").description("")) + summary "Creates list of users with given input array" + parameters(bodyParam[List[User]]("body").description("")) ) - post("/user/createWithList", operation(createUsersWithListInputOperation)) { - + post("/user/createWithList",operation(createUsersWithListInputOperation)) { + + bodyParam[List[User]]("body").description("") println("body: " + body) } + + val deleteUserOperation = (apiOperation[Unit]("deleteUser") - summary "Delete user" - parameters (pathParam[String]("username").description("")) + summary "Delete user" + parameters(pathParam[String]("username").description("")) ) - delete("/user/{username}", operation(deleteUserOperation)) { - - val username = params.getOrElse("username", halt(400)) - + delete("/user/{username}",operation(deleteUserOperation)) { + + + val username = params.getOrElse("username", halt(400)) + println("username: " + username) } + + val getUserByNameOperation = (apiOperation[User]("getUserByName") - summary "Get user by user name" - parameters (pathParam[String]("username").description("")) + summary "Get user by user name" + parameters(pathParam[String]("username").description("")) ) - get("/user/{username}", operation(getUserByNameOperation)) { - - val username = params.getOrElse("username", halt(400)) - + get("/user/{username}",operation(getUserByNameOperation)) { + + + val username = params.getOrElse("username", halt(400)) + println("username: " + username) } + + val loginUserOperation = (apiOperation[String]("loginUser") - summary "Logs user into the system" - parameters (queryParam[String]("username").description(""), - queryParam[String]("password").description("")) + summary "Logs user into the system" + parameters(queryParam[String]("username").description(""), + queryParam[String]("password").description("")) ) - get("/user/login", operation(loginUserOperation)) { - - val username = params.getAs[String]("username") + get("/user/login",operation(loginUserOperation)) { + + + val username = params.getAs[String]("username") println("username: " + username) - - val password = params.getAs[String]("password") + + + val password = params.getAs[String]("password") println("password: " + password) } + + val logoutUserOperation = (apiOperation[Unit]("logoutUser") - summary "Logs out current logged in user session" - parameters () + summary "Logs out current logged in user session" + parameters() ) - get("/user/logout", operation(logoutUserOperation)) { + get("/user/logout",operation(logoutUserOperation)) { } + + val updateUserOperation = (apiOperation[Unit]("updateUser") - summary "Updated user" - parameters (pathParam[String]("username").description(""), - bodyParam[User]("body").description("")) + summary "Updated user" + parameters(pathParam[String]("username").description(""), + bodyParam[User]("body").description("")) ) - put("/user/{username}", operation(updateUserOperation)) { - - val username = params.getOrElse("username", halt(400)) - + put("/user/{username}",operation(updateUserOperation)) { + + + val username = params.getOrElse("username", halt(400)) + println("username: " + username) - + + bodyParam[User]("body").description("") println("body: " + body) } diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/ApiResponse.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/ApiResponse.scala index 9020d9e3d50..90396f5de75 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/ApiResponse.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/ApiResponse.scala @@ -1,3 +1,27 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + package com.wordnik.client.model diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Category.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Category.scala index bb77cbc1771..4bdadfbbe5c 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Category.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Category.scala @@ -1,5 +1,32 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + package com.wordnik.client.model -case class Category( + + +case class Category ( id: Option[Long], - name: Option[String]) +name: Option[String] +) diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Order.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Order.scala index 763803bc4b9..6f399b0d1c3 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Order.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Order.scala @@ -1,11 +1,37 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + package com.wordnik.client.model import java.util.Date -case class Order( + +case class Order ( id: Option[Long], - petId: Option[Long], - quantity: Option[Int], - shipDate: Option[Date], - status: Option[String], // Order Status - complete: Option[Boolean]) +petId: Option[Long], +quantity: Option[Int], +shipDate: Option[Date], +status: Option[String], // Order Status +complete: Option[Boolean] +) diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Pet.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Pet.scala index 0f8fdddfed2..01aa08e73ce 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Pet.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Pet.scala @@ -1,13 +1,38 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + package com.wordnik.client.model import com.wordnik.client.model.Category import com.wordnik.client.model.Tag -case class Pet( + +case class Pet ( id: Option[Long], - category: Option[Category], - name: String, - photoUrls: List[String], - tags: Option[List[Tag]], - status: Option[String] // pet status in the store - ) +category: Option[Category], +name: String, +photoUrls: List[String], +tags: Option[List[Tag]], +status: Option[String] // pet status in the store +) diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Tag.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Tag.scala index 0e803adca38..a3d34e8d557 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Tag.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/Tag.scala @@ -1,5 +1,32 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + package com.wordnik.client.model -case class Tag( + + +case class Tag ( id: Option[Long], - name: Option[String]) +name: Option[String] +) diff --git a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/User.scala b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/User.scala index 77b7ec5d70c..ff792d91371 100644 --- a/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/User.scala +++ b/samples/server/petstore/scalatra/src/main/scala/com/wordnik/client/model/User.scala @@ -1,12 +1,38 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + * + * 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. + */ + package com.wordnik.client.model -case class User( + + +case class User ( id: Option[Long], - username: Option[String], - firstName: Option[String], - lastName: Option[String], - email: Option[String], - password: Option[String], - phone: Option[String], - userStatus: Option[Int] // User Status - ) +username: Option[String], +firstName: Option[String], +lastName: Option[String], +email: Option[String], +password: Option[String], +phone: Option[String], +userStatus: Option[Int] // User Status +) diff --git a/samples/server/petstore/springboot/pom.xml b/samples/server/petstore/springboot/pom.xml index 0002871db8f..65c935c9ef6 100644 --- a/samples/server/petstore/springboot/pom.xml +++ b/samples/server/petstore/springboot/pom.xml @@ -1,63 +1,63 @@ - 4.0.0 - io.swagger - swagger-springboot-server - jar - swagger-springboot-server - 1.0.0 - - 2.4.0 - - - org.springframework.boot - spring-boot-starter-parent - 1.3.3.RELEASE - - - src/main/java - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - provided - - - - io.springfox - springfox-swagger2 - ${springfox-version} - - - io.springfox - springfox-swagger-ui - ${springfox-version} - + 4.0.0 + io.swagger + swagger-springboot-server + jar + swagger-springboot-server + 1.0.0 + + 2.4.0 + + + org.springframework.boot + spring-boot-starter-parent + 1.3.3.RELEASE + + + src/main/java + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + io.springfox + springfox-swagger2 + ${springfox-version} + + + io.springfox + springfox-swagger-ui + ${springfox-version} + - - com.fasterxml.jackson.datatype - jackson-datatype-joda - - - joda-time - joda-time - - + + com.fasterxml.jackson.datatype + jackson-datatype-joda + + + joda-time + joda-time + + \ No newline at end of file diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/Swagger2SpringBoot.java b/samples/server/petstore/springboot/src/main/java/io/swagger/Swagger2SpringBoot.java index 4317ba2f1a6..2cc65db2b81 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/Swagger2SpringBoot.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/Swagger2SpringBoot.java @@ -33,4 +33,4 @@ public class Swagger2SpringBoot implements CommandLineRunner { } } -} +} \ No newline at end of file diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java index bb63b7e11d6..f0f76394bf3 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java @@ -1,13 +1,10 @@ package io.swagger.api; -import io.swagger.model.*; - import io.swagger.model.Pet; import io.swagger.model.ModelApiResponse; import java.io.File; import io.swagger.annotations.*; - import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -20,133 +17,131 @@ import org.springframework.web.multipart.MultipartFile; import java.util.List; -import static org.springframework.http.MediaType.*; @Api(value = "pet", description = "the pet API") - public interface PetApi { - @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) - @RequestMapping(value = "/pet", - produces = { "application/xml", "application/json" }, - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) - ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body); + @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }) + @ApiResponses(value = { + @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) + @RequestMapping(value = "/pet", + produces = { "application/xml", "application/json" }, + consumes = { "application/json", "application/xml" }, + method = RequestMethod.POST) + ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body); - @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); + @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) }) + @RequestMapping(value = "/pet/{petId}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.DELETE) + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, + @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); - @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Pet.class), - @ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) }) - @RequestMapping(value = "/pet/findByStatus", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true) @RequestParam(value = "status", required = true) List status); + @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class), + @ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) }) + @RequestMapping(value = "/pet/findByStatus", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true) @RequestParam(value = "status", required = true) List status); - @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Pet.class), - @ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) }) - @RequestMapping(value = "/pet/findByTags", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags); + @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class), + @ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) }) + @RequestMapping(value = "/pet/findByTags", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags); - @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { - @Authorization(value = "api_key") - }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Pet.class), - @ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class), - @ApiResponse(code = 404, message = "Pet not found", response = Pet.class) }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId); + @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { + @Authorization(value = "api_key") + }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class), + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class), + @ApiResponse(code = 404, message = "Pet not found", response = Pet.class) }) + @RequestMapping(value = "/pet/{petId}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId); - @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), - @ApiResponse(code = 404, message = "Pet not found", response = Void.class), - @ApiResponse(code = 405, message = "Validation exception", response = Void.class) }) - @RequestMapping(value = "/pet", - produces = { "application/xml", "application/json" }, - consumes = { "application/json", "application/xml" }, - method = RequestMethod.PUT) - ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body); + @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), + @ApiResponse(code = 404, message = "Pet not found", response = Void.class), + @ApiResponse(code = 405, message = "Validation exception", response = Void.class) }) + @RequestMapping(value = "/pet", + produces = { "application/xml", "application/json" }, + consumes = { "application/json", "application/xml" }, + method = RequestMethod.PUT) + ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body); - @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) - @RequestMapping(value = "/pet/{petId}", - produces = { "application/xml", "application/json" }, - consumes = { "application/x-www-form-urlencoded" }, - method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "Updated name of the pet" ) @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet" ) @RequestPart(value="status", required=false) String status); + @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }) + @ApiResponses(value = { + @ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) + @RequestMapping(value = "/pet/{petId}", + produces = { "application/xml", "application/json" }, + consumes = { "application/x-www-form-urlencoded" }, + method = RequestMethod.POST) + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, + @ApiParam(value = "Updated name of the pet" ) @RequestPart(value="name", required=false) String name, + @ApiParam(value = "Updated status of the pet" ) @RequestPart(value="status", required=false) String status); - @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) - @RequestMapping(value = "/pet/{petId}/uploadImage", - produces = { "application/json" }, - consumes = { "multipart/form-data" }, - method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "Additional data to pass to server" ) @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file); + @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { + @Authorization(value = "petstore_auth", scopes = { + @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), + @AuthorizationScope(scope = "read:pets", description = "read your pets") + }) + }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) + @RequestMapping(value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, + @ApiParam(value = "Additional data to pass to server" ) @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, + @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java index ec3bbf3e747..3a2dcab47b6 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java @@ -1,7 +1,5 @@ package io.swagger.api; -import io.swagger.model.*; - import io.swagger.model.Pet; import io.swagger.model.ModelApiResponse; import java.io.File; @@ -20,52 +18,54 @@ import org.springframework.web.multipart.MultipartFile; import java.util.List; -@Controller + +@Controller public class PetApiController implements PetApi { + public ResponseEntity addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true) @RequestParam(value = "status", required = true) List status) { - // do some magic! - return new ResponseEntity>(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity>(HttpStatus.OK); + } public ResponseEntity> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List tags) { - // do some magic! - return new ResponseEntity>(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity>(HttpStatus.OK); + } public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "Updated name of the pet" ) @RequestPart(value="name", required=false) String name, - @ApiParam(value = "Updated status of the pet" ) @RequestPart(value="status", required=false) String status) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + @ApiParam(value = "Updated name of the pet" ) @RequestPart(value="name", required=false) String name, + @ApiParam(value = "Updated status of the pet" ) @RequestPart(value="status", required=false) String status) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, - @ApiParam(value = "Additional data to pass to server" ) @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, - @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + @ApiParam(value = "Additional data to pass to server" ) @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, + @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java index 2fb7585dbdd..f67745dfa32 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java @@ -1,12 +1,9 @@ package io.swagger.api; -import io.swagger.model.*; - import java.util.Map; import io.swagger.model.Order; import io.swagger.annotations.*; - import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -19,51 +16,49 @@ import org.springframework.web.multipart.MultipartFile; import java.util.List; -import static org.springframework.http.MediaType.*; @Api(value = "store", description = "the store API") - public interface StoreApi { - @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), - @ApiResponse(code = 404, message = "Order not found", response = Void.class) }) - @RequestMapping(value = "/store/order/{orderId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId); + @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), + @ApiResponse(code = 404, message = "Order not found", response = Void.class) }) + @RequestMapping(value = "/store/order/{orderId}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.DELETE) + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId); - @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { - @Authorization(value = "api_key") - }) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Integer.class) }) - @RequestMapping(value = "/store/inventory", - produces = { "application/json" }, - method = RequestMethod.GET) - ResponseEntity> getInventory(); + @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { + @Authorization(value = "api_key") + }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Integer.class) }) + @RequestMapping(value = "/store/inventory", + produces = { "application/json" }, + method = RequestMethod.GET) + ResponseEntity> getInventory(); - @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Order.class), - @ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class), - @ApiResponse(code = 404, message = "Order not found", response = Order.class) }) - @RequestMapping(value = "/store/order/{orderId}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId); + @ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Order.class), + @ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class), + @ApiResponse(code = 404, message = "Order not found", response = Order.class) }) + @RequestMapping(value = "/store/order/{orderId}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId); - @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Order.class), - @ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) - @RequestMapping(value = "/store/order", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) - ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @RequestBody Order body); + @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Order.class), + @ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) + @RequestMapping(value = "/store/order", + produces = { "application/xml", "application/json" }, + method = RequestMethod.POST) + ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @RequestBody Order body); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java index 92de5eb86b4..bd582ae1a94 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java @@ -1,7 +1,5 @@ package io.swagger.api; -import io.swagger.model.*; - import java.util.Map; import io.swagger.model.Order; @@ -19,27 +17,29 @@ import org.springframework.web.multipart.MultipartFile; import java.util.List; -@Controller + +@Controller public class StoreApiController implements StoreApi { + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity> getInventory() { - // do some magic! - return new ResponseEntity>(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity>(HttpStatus.OK); + } public ResponseEntity getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @RequestBody Order body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java index 3877be4e8ad..508a5c1863d 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java @@ -1,12 +1,9 @@ package io.swagger.api; -import io.swagger.model.*; - import io.swagger.model.User; import java.util.List; import io.swagger.annotations.*; - import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -19,88 +16,86 @@ import org.springframework.web.multipart.MultipartFile; import java.util.List; -import static org.springframework.http.MediaType.*; @Api(value = "user", description = "the user API") - public interface UserApi { - @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - @RequestMapping(value = "/user", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) - ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @RequestBody User body); + @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + @RequestMapping(value = "/user", + produces = { "application/xml", "application/json" }, + method = RequestMethod.POST) + ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @RequestBody User body); - @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - @RequestMapping(value = "/user/createWithArray", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) - ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List body); + @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + @RequestMapping(value = "/user/createWithArray", + produces = { "application/xml", "application/json" }, + method = RequestMethod.POST) + ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List body); - @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - @RequestMapping(value = "/user/createWithList", - produces = { "application/xml", "application/json" }, - method = RequestMethod.POST) - ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List body); + @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + @RequestMapping(value = "/user/createWithList", + produces = { "application/xml", "application/json" }, + method = RequestMethod.POST) + ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List body); - @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), - @ApiResponse(code = 404, message = "User not found", response = Void.class) }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username); + @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), + @ApiResponse(code = 404, message = "User not found", response = Void.class) }) + @RequestMapping(value = "/user/{username}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.DELETE) + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username); - @ApiOperation(value = "Get user by user name", notes = "", response = User.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = User.class), - @ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), - @ApiResponse(code = 404, message = "User not found", response = User.class) }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username); + @ApiOperation(value = "Get user by user name", notes = "", response = User.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = User.class), + @ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), + @ApiResponse(code = 404, message = "User not found", response = User.class) }) + @RequestMapping(value = "/user/{username}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username); - @ApiOperation(value = "Logs user into the system", notes = "", response = String.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = String.class), - @ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) - @RequestMapping(value = "/user/login", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, - @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password); + @ApiOperation(value = "Logs user into the system", notes = "", response = String.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = String.class), + @ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) + @RequestMapping(value = "/user/login", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, + @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password); - @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) - @RequestMapping(value = "/user/logout", - produces = { "application/xml", "application/json" }, - method = RequestMethod.GET) - ResponseEntity logoutUser(); + @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Void.class) }) + @RequestMapping(value = "/user/logout", + produces = { "application/xml", "application/json" }, + method = RequestMethod.GET) + ResponseEntity logoutUser(); - @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class), - @ApiResponse(code = 404, message = "User not found", response = Void.class) }) - @RequestMapping(value = "/user/{username}", - produces = { "application/xml", "application/json" }, - method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @RequestBody User body); + @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class), + @ApiResponse(code = 404, message = "User not found", response = Void.class) }) + @RequestMapping(value = "/user/{username}", + produces = { "application/xml", "application/json" }, + method = RequestMethod.PUT) + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, + @ApiParam(value = "Updated user object" ,required=true ) @RequestBody User body); } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java index f855d358ea5..a5a6d4d4505 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java @@ -1,7 +1,5 @@ package io.swagger.api; -import io.swagger.model.*; - import io.swagger.model.User; import java.util.List; @@ -19,49 +17,51 @@ import org.springframework.web.multipart.MultipartFile; import java.util.List; -@Controller + +@Controller public class UserApiController implements UserApi { + public ResponseEntity createUser(@ApiParam(value = "Created user object" ,required=true ) @RequestBody User body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username, - @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity logoutUser() { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, - @ApiParam(value = "Updated user object" ,required=true ) @RequestBody User body) { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } + @ApiParam(value = "Updated user object" ,required=true ) @RequestBody User body) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java b/samples/server/petstore/springboot/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java index 282773a2d30..29c6a7bf85f 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/configuration/SwaggerDocumentationConfig.java @@ -30,13 +30,13 @@ public class SwaggerDocumentationConfig { @Bean public Docket customImplementation(){ - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("io.swagger.api")) - .build() - .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class) - .apiInfo(apiInfo()); + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("io.swagger.api")) + .build() + .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class) + .apiInfo(apiInfo()); } }