From ce6ec20feff944fd7dece44cb2c788e84a863c64 Mon Sep 17 00:00:00 2001 From: Ole Lensmar Date: Wed, 24 Jun 2015 00:11:13 +0200 Subject: [PATCH 001/109] added config parameters for all default parameters and a configOptions map for language specific parameters --- .../codegen/plugin/AdditionalParams.java | 8 ++- .../swagger/codegen/plugin/CodeGenMojo.java | 67 ++++++++++++++++++- 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/AdditionalParams.java b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/AdditionalParams.java index aa137cbf6c39..62fb530f0f05 100644 --- a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/AdditionalParams.java +++ b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/AdditionalParams.java @@ -7,10 +7,12 @@ package io.swagger.codegen.plugin; */ public final class AdditionalParams { public static final String TEMPLATE_DIR_PARAM = "templateDir"; + public static final String MODEL_PACKAGE_PARAM = "modelPackage"; + public static final String API_PACKAGE_PARAM = "apiPackage"; + public static final String INVOKER_PACKAGE_PARAM = "invokerPackage"; + public static final String SOURCE_FOLDER_PARAM = "sourceFolder"; + public static final String IMPL_FOLDER_PARAM = "implFolder"; private AdditionalParams() { - } - - } diff --git a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java index 26b6fef11359..e136ebf43aab 100644 --- a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java +++ b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java @@ -16,6 +16,7 @@ package io.swagger.codegen.plugin; * limitations under the License. */ +import io.swagger.codegen.CliOption; import io.swagger.codegen.ClientOptInput; import io.swagger.codegen.ClientOpts; import io.swagger.codegen.CodegenConfig; @@ -30,16 +31,16 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import java.io.File; +import java.util.Map; import java.util.ServiceLoader; -import static io.swagger.codegen.plugin.AdditionalParams.TEMPLATE_DIR_PARAM; +import static io.swagger.codegen.plugin.AdditionalParams.*; /** * Goal which generates client/server code from a swagger json/yaml definition. */ @Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES) public class CodeGenMojo extends AbstractMojo { - /** * Location of the output directory. */ @@ -60,12 +61,47 @@ public class CodeGenMojo extends AbstractMojo { @Parameter(name = "templateDirectory") private File templateDirectory; + /** + * Folder containing the template files. + */ + @Parameter(name = "modelPackage") + private String modelPackage; + + /** + * Folder containing the template files. + */ + @Parameter(name = "apiPackage") + private String apiPackage; + + /** + * Folder containing the template files. + */ + @Parameter(name = "invokerPackage") + private String invokerPackage; + + /** + * Folder containing the template files. + */ + @Parameter(name = "implFolder") + private String implFolder; + + /** + * Folder containing the template files. + */ + @Parameter(name = "sourceFolder") + private File sourceFolder; + /** * Client language to generate. */ @Parameter(name = "language", required = true) private String language; + /** + * A map of language-specific properties as passed with the -c option to the command line + */ + @Parameter(name ="configOptions") + private Map configOptions; /** * Add the output directory to the project as a source root, so that the @@ -90,8 +126,33 @@ public class CodeGenMojo extends AbstractMojo { if (null != templateDirectory) { config.additionalProperties().put(TEMPLATE_DIR_PARAM, templateDirectory.getAbsolutePath()); } + if (null != modelPackage) { + config.additionalProperties().put(MODEL_PACKAGE_PARAM, modelPackage ); + } + if (null != apiPackage) { + config.additionalProperties().put(API_PACKAGE_PARAM, apiPackage); + } + if (null != invokerPackage) { + config.additionalProperties().put(INVOKER_PACKAGE_PARAM, invokerPackage); + } + if (null != sourceFolder) { + config.additionalProperties().put(SOURCE_FOLDER_PARAM, sourceFolder.getAbsolutePath()); + } + if (null != implFolder) { + config.additionalProperties().put(IMPL_FOLDER_PARAM, implFolder); + } - ClientOptInput input = new ClientOptInput().opts(new ClientOpts()).swagger(swagger); + ClientOpts clientOpts = new ClientOpts(); + if( configOptions != null ){ + for (CliOption langCliOption : config.cliOptions()) { + if (configOptions.containsKey(langCliOption.getOpt())) { + config.additionalProperties().put(langCliOption.getOpt(), + configOptions.get(langCliOption.getOpt())); + } + } + } + + ClientOptInput input = new ClientOptInput().opts(clientOpts).swagger(swagger); input.setConfig(config); new DefaultGenerator().opts(input).generate(); From 50dd196d4224bdb72c668f02e825cddd909ee317 Mon Sep 17 00:00:00 2001 From: Ole Lensmar Date: Wed, 24 Jun 2015 00:12:50 +0200 Subject: [PATCH 002/109] fixed code formatting and imports --- modules/swagger-codegen-maven-plugin/pom.xml | 2 +- .../java/io/swagger/codegen/plugin/CodeGenMojo.java | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen-maven-plugin/pom.xml b/modules/swagger-codegen-maven-plugin/pom.xml index 7ad4496872ce..08c1ffef2ad5 100644 --- a/modules/swagger-codegen-maven-plugin/pom.xml +++ b/modules/swagger-codegen-maven-plugin/pom.xml @@ -17,7 +17,7 @@ UTF-8 - + org.apache.maven maven-core 3.2.5 diff --git a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java index e136ebf43aab..58eadc62523b 100644 --- a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java +++ b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java @@ -34,7 +34,12 @@ import java.io.File; import java.util.Map; import java.util.ServiceLoader; -import static io.swagger.codegen.plugin.AdditionalParams.*; +import static io.swagger.codegen.plugin.AdditionalParams.API_PACKAGE_PARAM; +import static io.swagger.codegen.plugin.AdditionalParams.IMPL_FOLDER_PARAM; +import static io.swagger.codegen.plugin.AdditionalParams.INVOKER_PACKAGE_PARAM; +import static io.swagger.codegen.plugin.AdditionalParams.MODEL_PACKAGE_PARAM; +import static io.swagger.codegen.plugin.AdditionalParams.SOURCE_FOLDER_PARAM; +import static io.swagger.codegen.plugin.AdditionalParams.TEMPLATE_DIR_PARAM; /** * Goal which generates client/server code from a swagger json/yaml definition. @@ -100,7 +105,7 @@ public class CodeGenMojo extends AbstractMojo { /** * A map of language-specific properties as passed with the -c option to the command line */ - @Parameter(name ="configOptions") + @Parameter(name = "configOptions") private Map configOptions; /** @@ -127,7 +132,7 @@ public class CodeGenMojo extends AbstractMojo { config.additionalProperties().put(TEMPLATE_DIR_PARAM, templateDirectory.getAbsolutePath()); } if (null != modelPackage) { - config.additionalProperties().put(MODEL_PACKAGE_PARAM, modelPackage ); + config.additionalProperties().put(MODEL_PACKAGE_PARAM, modelPackage); } if (null != apiPackage) { config.additionalProperties().put(API_PACKAGE_PARAM, apiPackage); @@ -143,7 +148,7 @@ public class CodeGenMojo extends AbstractMojo { } ClientOpts clientOpts = new ClientOpts(); - if( configOptions != null ){ + if (configOptions != null) { for (CliOption langCliOption : config.cliOptions()) { if (configOptions.containsKey(langCliOption.getOpt())) { config.additionalProperties().put(langCliOption.getOpt(), From 8e6c0f96fba7f1796f7b9251767560216d4371a8 Mon Sep 17 00:00:00 2001 From: Ole Lensmar Date: Wed, 24 Jun 2015 07:31:10 +0200 Subject: [PATCH 003/109] updated documentation and removed java-specific parameters from general configuration --- .../swagger-codegen-maven-plugin/README.md | 16 ++++++++++- .../codegen/plugin/AdditionalParams.java | 2 -- .../swagger/codegen/plugin/CodeGenMojo.java | 28 +++---------------- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/modules/swagger-codegen-maven-plugin/README.md b/modules/swagger-codegen-maven-plugin/README.md index a7eaf852a223..372b2c90adf6 100644 --- a/modules/swagger-codegen-maven-plugin/README.md +++ b/modules/swagger-codegen-maven-plugin/README.md @@ -20,6 +20,9 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase) src/main/resources/api.yaml java + + src/gen/java/main + @@ -32,10 +35,21 @@ Followed by: mvn clean compile ``` -### Configuration parameters +### General Configuration parameters - `inputSpec` - swagger spec file path - `language` - target generation language - `output` - target output path (default is `${project.build.directory}/generated-sources/swagger`) - `templateDirectory` - directory with mustache templates - `addCompileSourceRoot` - add the output directory to the project as a source root (`true` by default) +- `modelPackage` - the package to use for generated model objects/classes +- `apiPackage` - the package to use for generated api objects/classes +- `invokerPackage` - the package to use for the generated invoker objects +- `configOptions` - a map of language-specific parameters (see below) + +### Java-specific parameters (under configOptions) + +- `sourceFolder` - the folder to use for generated sources under the output folder +- `groupId` - groupId in generated pom.xml +- `artifactId` - artifactId in generated pom.xml +- `artifactVersion` - artifact version in generated pom.xml diff --git a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/AdditionalParams.java b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/AdditionalParams.java index 62fb530f0f05..f3678e783e09 100644 --- a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/AdditionalParams.java +++ b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/AdditionalParams.java @@ -10,8 +10,6 @@ public final class AdditionalParams { public static final String MODEL_PACKAGE_PARAM = "modelPackage"; public static final String API_PACKAGE_PARAM = "apiPackage"; public static final String INVOKER_PACKAGE_PARAM = "invokerPackage"; - public static final String SOURCE_FOLDER_PARAM = "sourceFolder"; - public static final String IMPL_FOLDER_PARAM = "implFolder"; private AdditionalParams() { } diff --git a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java index 58eadc62523b..32ea914fa643 100644 --- a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java +++ b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java @@ -35,10 +35,8 @@ import java.util.Map; import java.util.ServiceLoader; import static io.swagger.codegen.plugin.AdditionalParams.API_PACKAGE_PARAM; -import static io.swagger.codegen.plugin.AdditionalParams.IMPL_FOLDER_PARAM; import static io.swagger.codegen.plugin.AdditionalParams.INVOKER_PACKAGE_PARAM; import static io.swagger.codegen.plugin.AdditionalParams.MODEL_PACKAGE_PARAM; -import static io.swagger.codegen.plugin.AdditionalParams.SOURCE_FOLDER_PARAM; import static io.swagger.codegen.plugin.AdditionalParams.TEMPLATE_DIR_PARAM; /** @@ -67,35 +65,23 @@ public class CodeGenMojo extends AbstractMojo { private File templateDirectory; /** - * Folder containing the template files. + * The package to use for generated model objects/classes */ @Parameter(name = "modelPackage") private String modelPackage; /** - * Folder containing the template files. + * The package to use for generated api objects/classes */ @Parameter(name = "apiPackage") private String apiPackage; /** - * Folder containing the template files. + * The package to use for the generated invoker objects */ @Parameter(name = "invokerPackage") private String invokerPackage; - /** - * Folder containing the template files. - */ - @Parameter(name = "implFolder") - private String implFolder; - - /** - * Folder containing the template files. - */ - @Parameter(name = "sourceFolder") - private File sourceFolder; - /** * Client language to generate. */ @@ -103,7 +89,7 @@ public class CodeGenMojo extends AbstractMojo { private String language; /** - * A map of language-specific properties as passed with the -c option to the command line + * A map of language-specific parameters as passed with the -c option to the command line */ @Parameter(name = "configOptions") private Map configOptions; @@ -140,12 +126,6 @@ public class CodeGenMojo extends AbstractMojo { if (null != invokerPackage) { config.additionalProperties().put(INVOKER_PACKAGE_PARAM, invokerPackage); } - if (null != sourceFolder) { - config.additionalProperties().put(SOURCE_FOLDER_PARAM, sourceFolder.getAbsolutePath()); - } - if (null != implFolder) { - config.additionalProperties().put(IMPL_FOLDER_PARAM, implFolder); - } ClientOpts clientOpts = new ClientOpts(); if (configOptions != null) { From dfd8d5ef64ec5b0d85305ce4e1e1b79ff1279061 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Mon, 6 Jul 2015 04:55:12 -0700 Subject: [PATCH 004/109] updated to latest release version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2c44ebf7183..a0045247e7a1 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The Swagger Specification has undergone 3 revisions since initial creation in 20 Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes ----------------------- | ------------ | -------------------------- | ----- -2.1.0 | 2015-06-09 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen) +2.1.2 | 2015-06-09 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen) 2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17) 1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1) From 4c16366f45e0c149145ea4fcefb00dfc4bae1f95 Mon Sep 17 00:00:00 2001 From: Tobias Pfeifer Date: Tue, 7 Jul 2015 16:51:54 +0200 Subject: [PATCH 005/109] fix SpringMVCServerCodegen for maps as in JavaClientCodegen --- .../codegen/languages/SpringMVCServerCodegen.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java index a90533a36143..199fd1251e13 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java @@ -98,21 +98,6 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen } - @Override - public String getTypeDeclaration(Property p) { - if (p instanceof ArrayProperty) { - ArrayProperty ap = (ArrayProperty) p; - Property inner = ap.getItems(); - return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">"; - } else if (p instanceof MapProperty) { - MapProperty mp = (MapProperty) p; - Property inner = mp.getAdditionalProperties(); - - return getTypeDeclaration(inner); - } - return super.getTypeDeclaration(p); - } - @Override public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map> operations) { String basePath = resourcePath; From 90f152da75a4ba42fd493fe369b110699c0923fa Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Fri, 24 Jul 2015 11:44:30 -0700 Subject: [PATCH 006/109] Fix path in instructions for making your own codegen modules --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a0045247e7a1..59970a80d672 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ You can look at `modules/swagger-codegen/src/main/resources/${your-language}` fo If you're starting a project with a new language and don't see what you need, swagger-codegen can help you create a project to generate your own libraries: ``` -java -jar modules/swagger-codegen-distribution/target/swagger-codegen-cli.jar meta \ +java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar meta \ -o output/myLibrary -n myClientCodegen -p com.my.company.codegen ``` From 9c3fad3040ec513b066c575605ac3df34d9b4ea1 Mon Sep 17 00:00:00 2001 From: Ole Lensmar Date: Tue, 28 Jul 2015 14:40:43 -0700 Subject: [PATCH 007/109] fixed generated code to go to target/generated-sources, added maven-codegen-plugin to generated jaxrs project together with initial swagger definition, fixed overwrite flag to kick in only if file exists, fixed initial readme --- .../io/swagger/codegen/DefaultGenerator.java | 6 ++-- .../codegen/languages/JaxRSServerCodegen.java | 35 ++++++++++++++++--- .../main/resources/JavaJaxRS/README.mustache | 9 ++--- .../src/main/resources/JavaJaxRS/pom.mustache | 22 ++++++++++-- .../swagger/generator/online/Generator.java | 4 +-- 5 files changed, 56 insertions(+), 20 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index d48238c24895..0cdfa30dc333 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -138,7 +138,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { for (String templateName : config.modelTemplateFiles().keySet()) { String suffix = config.modelTemplateFiles().get(templateName); String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix; - if (!config.shouldOverwrite(filename)) { + if ( new File(filename).exists() && !config.shouldOverwrite(filename)) { continue; } String template = readTemplate(config.templateDir() + File.separator + templateName); @@ -189,7 +189,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { for (String templateName : config.apiTemplateFiles().keySet()) { String filename = config.apiFilename(templateName, tag); - if (!config.shouldOverwrite(filename)) { + if( new File( filename ).exists() && !config.shouldOverwrite(filename)) { continue; } @@ -260,7 +260,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { of.mkdirs(); } String outputFilename = outputFolder + File.separator + support.destinationFilename; - if (!config.shouldOverwrite(outputFilename)) { + if (new File( outputFilename ).exists() && !config.shouldOverwrite(outputFilename)) { continue; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java index 99121f8d297a..01a61b4e9354 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java @@ -5,11 +5,15 @@ import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.CodegenType; import io.swagger.codegen.SupportingFile; import io.swagger.models.Operation; +import io.swagger.models.Swagger; import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.MapProperty; import io.swagger.models.properties.Property; +import io.swagger.util.Json; import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -17,6 +21,7 @@ import java.util.List; import java.util.Map; public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConfig { + public static final String DEFAULT_IMPL_SOURCE_FOLDER = "src/main/java"; protected String invokerPackage = "io.swagger.api"; protected String groupId = "io.swagger"; protected String artifactId = "swagger-jaxrs-server"; @@ -26,9 +31,9 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf public JaxRSServerCodegen() { super.processOpts(); - sourceFolder = "src/gen/java"; + sourceFolder = "target/generated-sources"; - outputFolder = System.getProperty("swagger.codegen.jaxrs.genfolder", "generated-code/javaJaxRS"); + outputFolder = System.getProperty("swagger.codegen.jaxrs.genfolder", "target/generated-sources"); modelTemplateFiles.put("model.mustache", ".java"); apiTemplateFiles.put("api.mustache", ".java"); apiTemplateFiles.put("apiService.mustache", ".java"); @@ -184,7 +189,7 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf int ix = result.lastIndexOf('/'); result = result.substring(0, ix) + "/impl" + result.substring(ix, result.length() - 5) + "ServiceImpl.java"; - String output = System.getProperty("swagger.codegen.jaxrs.impl.source"); + String output = System.getProperty("swagger.codegen.jaxrs.impl.source", DEFAULT_IMPL_SOURCE_FOLDER); if (output != null) { result = result.replace(apiFileFolder(), implFileFolder(output)); } @@ -192,7 +197,7 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf int ix = result.lastIndexOf('/'); result = result.substring(0, ix) + "/factories" + result.substring(ix, result.length() - 5) + "ServiceFactory.java"; - String output = System.getProperty("swagger.codegen.jaxrs.impl.source"); + String output = System.getProperty("swagger.codegen.jaxrs.impl.source", DEFAULT_IMPL_SOURCE_FOLDER); if (output != null) { result = result.replace(apiFileFolder(), implFileFolder(output)); } @@ -204,11 +209,31 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf return result; } + @Override + public void processSwagger(Swagger swagger) { + super.processSwagger(swagger); + + try { + File file = new File( outputFolder + "/src/main/resources/swagger.json" ); + file.getParentFile().mkdirs(); + + FileWriter swaggerFile = new FileWriter(file); + swaggerFile.write( Json.pretty(swagger)); + swaggerFile.flush(); + swaggerFile.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + private String implFileFolder(String output) { return outputFolder + "/" + output + "/" + apiPackage().replace('.', File.separatorChar); } public boolean shouldOverwrite(String filename) { - return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") && !filename.endsWith("ServiceFactory.java"); + return filename.startsWith( outputFolder + File.separatorChar + sourceFolder); + +// return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") +// && !filename.endsWith("ServiceFactory.java"); } } diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/README.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/README.mustache index 3ffa01fb2571..a5281c3eac30 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/README.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/README.mustache @@ -1,10 +1,5 @@ # Swagger generated server ## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the -[swagger-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 swagger-enabled scalatra server. - -This example uses the [scalatra](http://scalatra.org/) framework. To see how to make this your own, look here: - -[README](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/scalatra) \ No newline at end of file +This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project using the +JAX-RS template. diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache index 708ca6cac4d0..c68c755a5716 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache @@ -50,7 +50,6 @@ 0 - true @@ -75,12 +74,29 @@ - src/gen/java + target/generated-sources + + io.swagger + swagger-codegen-maven-plugin + 2.1.3-SNAPSHOT + + + + generate + + + src/main/resources/swagger.json + jaxrs + . + + + + @@ -148,7 +164,7 @@ - 1.5.0 + 1.5.1-SNAPSHOT 9.2.9.v20150224 1.13 1.6.3 diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java index 2faef30744ba..d59060f39ef2 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java @@ -37,7 +37,7 @@ public class Generator { throw new BadRequestException(400, "No swagger specification was supplied"); } } else { - swagger = new SwaggerParser().read(node, true); + swagger = new SwaggerParser().read(node); } if (swagger == null) { throw new BadRequestException(400, "The swagger specification supplied was not valid"); @@ -97,7 +97,7 @@ public class Generator { throw new BadRequestException(400, "No swagger specification was supplied"); } } else { - swagger = new SwaggerParser().read(node, true); + swagger = new SwaggerParser().read(node); } if (swagger == null) { throw new BadRequestException(400, "The swagger specification supplied was not valid"); From 26336356cff8e393f43c83cd78ab5907949292b9 Mon Sep 17 00:00:00 2001 From: Ole Lensmar Date: Tue, 28 Jul 2015 14:56:23 -0700 Subject: [PATCH 008/109] added generated samples for jaxrs and inflector --- .../server/petstore/java-inflector/README.md | 8 + .../petstore/java-inflector/inflector.yaml | 10 + .../server/petstore/java-inflector/pom.xml | 174 ++++ .../io/swagger/handler/PetController.java | 51 ++ .../io/swagger/handler/StoreController.java | 35 + .../io/swagger/handler/UserController.java | 51 ++ .../main}/java/io/swagger/model/Category.java | 0 .../main}/java/io/swagger/model/Order.java | 0 .../src/main}/java/io/swagger/model/Pet.java | 6 +- .../src/main}/java/io/swagger/model/Tag.java | 0 .../src/main}/java/io/swagger/model/User.java | 0 .../src/main/swagger/swagger.json | 762 ++++++++++++++++++ .../src/main/webapp/WEB-INF/web.xml | 24 + samples/server/petstore/jaxrs/README.md | 9 +- samples/server/petstore/jaxrs/pom.xml | 22 +- .../gen/java/io/swagger/api/ApiException.java | 9 - .../java/io/swagger/api/ApiOriginFilter.java | 26 - .../io/swagger/api/ApiResponseMessage.java | 68 -- .../io/swagger/api/NotFoundException.java | 9 - .../src/gen/java/io/swagger/api/PetApi.java | 148 ---- .../java/io/swagger/api/PetApiService.java | 47 -- .../src/gen/java/io/swagger/api/StoreApi.java | 90 --- .../java/io/swagger/api/StoreApiService.java | 35 - .../src/gen/java/io/swagger/api/UserApi.java | 142 ---- .../java/io/swagger/api/UserApiService.java | 47 -- .../api/factories/PetApiServiceFactory.java | 9 +- .../api/factories/StoreApiServiceFactory.java | 9 +- .../api/factories/UserApiServiceFactory.java | 9 +- .../swagger/api/impl/PetApiServiceImpl.java | 130 +-- .../swagger/api/impl/StoreApiServiceImpl.java | 72 +- .../swagger/api/impl/UserApiServiceImpl.java | 129 +-- .../jaxrs/src/main/resources/swagger.json | 762 ++++++++++++++++++ 32 files changed, 2098 insertions(+), 795 deletions(-) create mode 100644 samples/server/petstore/java-inflector/README.md create mode 100644 samples/server/petstore/java-inflector/inflector.yaml create mode 100644 samples/server/petstore/java-inflector/pom.xml create mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java create mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java create mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java rename samples/server/petstore/{jaxrs/src/gen => java-inflector/src/main}/java/io/swagger/model/Category.java (100%) rename samples/server/petstore/{jaxrs/src/gen => java-inflector/src/main}/java/io/swagger/model/Order.java (100%) rename samples/server/petstore/{jaxrs/src/gen => java-inflector/src/main}/java/io/swagger/model/Pet.java (95%) rename samples/server/petstore/{jaxrs/src/gen => java-inflector/src/main}/java/io/swagger/model/Tag.java (100%) rename samples/server/petstore/{jaxrs/src/gen => java-inflector/src/main}/java/io/swagger/model/User.java (100%) create mode 100644 samples/server/petstore/java-inflector/src/main/swagger/swagger.json create mode 100644 samples/server/petstore/java-inflector/src/main/webapp/WEB-INF/web.xml delete mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java delete mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java delete mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java delete mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java delete mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java delete mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java delete mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java delete mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java delete mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java delete mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java create mode 100644 samples/server/petstore/jaxrs/src/main/resources/swagger.json diff --git a/samples/server/petstore/java-inflector/README.md b/samples/server/petstore/java-inflector/README.md new file mode 100644 index 000000000000..c1309670c5ad --- /dev/null +++ b/samples/server/petstore/java-inflector/README.md @@ -0,0 +1,8 @@ +# Swagger Inflector + +Run with + +``` +mvn package jetty:run +`` + diff --git a/samples/server/petstore/java-inflector/inflector.yaml b/samples/server/petstore/java-inflector/inflector.yaml new file mode 100644 index 000000000000..25ec6dde3f2e --- /dev/null +++ b/samples/server/petstore/java-inflector/inflector.yaml @@ -0,0 +1,10 @@ +controllerPackage: io.swagger.handler +modelPackage: io.swagger.model +swaggerUrl: ./src/main/swagger/swagger.json +modelMappings: + User : io.swagger.model.User + Category : io.swagger.model.Category + Pet : io.swagger.model.Pet + Tag : io.swagger.model.Tag + Order : io.swagger.model.Order + diff --git a/samples/server/petstore/java-inflector/pom.xml b/samples/server/petstore/java-inflector/pom.xml new file mode 100644 index 000000000000..6d7dee18a58e --- /dev/null +++ b/samples/server/petstore/java-inflector/pom.xml @@ -0,0 +1,174 @@ + + + org.sonatype.oss + oss-parent + 5 + + 4.0.0 + io.swagger + swagger-inflector-server + jar + swagger-inflector-server + 1.0.0 + + 2.2.0 + + + + install + target + ${project.artifactId}-${project.version} + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + **/logback.xml + + + + development + ${project.url} + ${project.version} + io.swagger + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty-version} + + . + + inflector.yaml + src/main/swagger/swagger.yaml + + 1 + + / + + + 8080 + 60000 + + + + + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-annotations + 2.4.0 + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-version} + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + ${jackson-version} + + + + org.glassfish.jersey.containers + jersey-container-servlet-core + ${jersey2-version} + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey2-version} + + + org.glassfish.jersey.core + jersey-client + ${jersey2-version} + + + javax.servlet + servlet-api + ${servlet-api-version} + provided + + + + ch.qos.logback + logback-classic + ${logback-version} + + + ch.qos.logback + logback-core + ${logback-version} + + + org.slf4j + slf4j-ext + ${slf4j-version} + + + org.slf4j + slf4j-api + ${slf4j-version} + + + + + commons-lang + commons-lang + ${commons-lang-version} + + + + + io.swagger + swagger-inflector + 1.0.0-SNAPSHOT + + + + + 1.0.0 + 1.5.0 + 1.0.8 + 2.4.2 + 2.2 + 1.2 + 9.2.9.v20150224 + 2.6 + 2.5 + 2.4 + 2.4 + 1.1 + 1.0.1 + 4.8.2 + 1.6.3 + + \ No newline at end of file diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java new file mode 100644 index 000000000000..69325871d166 --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java @@ -0,0 +1,51 @@ +package io.swagger.handler; + +import io.swagger.inflector.models.RequestContext; +import io.swagger.inflector.models.ResponseContext; +import javax.ws.rs.core.Response.Status; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import java.io.File; +import java.util.List; + +import io.swagger.model.*; + +import io.swagger.model.Pet; +import java.io.File; + +public class PetController { + + public ResponseContext updatePet(RequestContext request ,Pet body) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext addPet(RequestContext request ,Pet body) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext findPetsByStatus(RequestContext request ,List status) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext findPetsByTags(RequestContext request ,List tags) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext getPetById(RequestContext request ,Long petId) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext updatePetWithForm(RequestContext request ,String petId,String name,String status) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext deletePet(RequestContext request ,Long petId,String apiKey) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext uploadFile(RequestContext request ,Long petId,String additionalMetadata,FormDataContentDisposition fileDetail) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } +} + diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java new file mode 100644 index 000000000000..9afb704b726b --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java @@ -0,0 +1,35 @@ +package io.swagger.handler; + +import io.swagger.inflector.models.RequestContext; +import io.swagger.inflector.models.ResponseContext; +import javax.ws.rs.core.Response.Status; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import java.io.File; +import java.util.List; + +import io.swagger.model.*; + +import java.util.Map; +import io.swagger.model.Order; + +public class StoreController { + + public ResponseContext getInventory(RequestContext request ) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext placeOrder(RequestContext request ,Order body) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext getOrderById(RequestContext request ,String orderId) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext deleteOrder(RequestContext request ,String orderId) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } +} + diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java new file mode 100644 index 000000000000..da907dc9fa35 --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java @@ -0,0 +1,51 @@ +package io.swagger.handler; + +import io.swagger.inflector.models.RequestContext; +import io.swagger.inflector.models.ResponseContext; +import javax.ws.rs.core.Response.Status; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import java.io.File; +import java.util.List; + +import io.swagger.model.*; + +import io.swagger.model.User; +import java.util.*; + +public class UserController { + + public ResponseContext createUser(RequestContext request ,User body) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext createUsersWithArrayInput(RequestContext request ,List body) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext createUsersWithListInput(RequestContext request ,List body) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext loginUser(RequestContext request ,String username,String password) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext logoutUser(RequestContext request ) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext getUserByName(RequestContext request ,String username) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext updateUser(RequestContext request ,String username,User body) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + public ResponseContext deleteUser(RequestContext request ,String username) + { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } +} + diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java similarity index 100% rename from samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java rename to samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java similarity index 100% rename from samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java rename to samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java similarity index 95% rename from samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java rename to samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java index 076a8cf8142f..9c233d082898 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java @@ -1,8 +1,8 @@ package io.swagger.model; import io.swagger.model.Category; -import java.util.*; import io.swagger.model.Tag; +import java.util.*; import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; @@ -14,8 +14,8 @@ public class Pet { private Long id = null; private Category category = null; private String name = null; - private List photoUrls = new ArrayList() ; - private List tags = new ArrayList() ; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); public enum StatusEnum { available, pending, sold, }; diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java similarity index 100% rename from samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java rename to samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java similarity index 100% rename from samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java rename to samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java diff --git a/samples/server/petstore/java-inflector/src/main/swagger/swagger.json b/samples/server/petstore/java-inflector/src/main/swagger/swagger.json new file mode 100644 index 000000000000..5ca489f09296 --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/swagger/swagger.json @@ -0,0 +1,762 @@ +{ + "swagger" : "2.0", + "info" : { + "description" : "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", + "version" : "1.0.0", + "title" : "Swagger Petstore", + "termsOfService" : "http://swagger.io/terms/", + "contact" : { + "email" : "apiteam@swagger.io" + }, + "license" : { + "name" : "Apache 2.0", + "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "host" : "petstore.swagger.io", + "basePath" : "/v2", + "schemes" : [ "http" ], + "paths" : { + "/pet" : { + "post" : { + "tags" : [ "pet" ], + "summary" : "Add a new pet to the store", + "description" : "", + "operationId" : "addPet", + "consumes" : [ "application/json", "application/xml" ], + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "Pet object that needs to be added to the store", + "required" : false, + "schema" : { + "$ref" : "#/definitions/Pet" + } + } ], + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + }, + "put" : { + "tags" : [ "pet" ], + "summary" : "Update an existing pet", + "description" : "", + "operationId" : "updatePet", + "consumes" : [ "application/json", "application/xml" ], + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "Pet object that needs to be added to the store", + "required" : false, + "schema" : { + "$ref" : "#/definitions/Pet" + } + } ], + "responses" : { + "405" : { + "description" : "Validation exception" + }, + "404" : { + "description" : "Pet not found" + }, + "400" : { + "description" : "Invalid ID supplied" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/pet/findByStatus" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by status", + "description" : "Multiple status values can be provided with comma seperated strings", + "operationId" : "findPetsByStatus", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "status", + "in" : "query", + "description" : "Status values that need to be considered for filter", + "required" : false, + "type" : "array", + "items" : { + "type" : "string" + }, + "collectionFormat" : "multi", + "default" : "available" + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/Pet" + } + } + }, + "400" : { + "description" : "Invalid status value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/pet/findByTags" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by tags", + "description" : "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "tags", + "in" : "query", + "description" : "Tags to filter by", + "required" : false, + "type" : "array", + "items" : { + "type" : "string" + }, + "collectionFormat" : "multi" + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/Pet" + } + } + }, + "400" : { + "description" : "Invalid tag value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/pet/{petId}" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Find pet by ID", + "description" : "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", + "operationId" : "getPetById", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet that needs to be fetched", + "required" : true, + "type" : "integer", + "format" : "int64" + } ], + "responses" : { + "404" : { + "description" : "Pet not found" + }, + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/Pet" + } + }, + "400" : { + "description" : "Invalid ID supplied" + } + }, + "security" : [ { + "api_key" : [ ] + }, { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + }, + "post" : { + "tags" : [ "pet" ], + "summary" : "Updates a pet in the store with form data", + "description" : "", + "operationId" : "updatePetWithForm", + "consumes" : [ "application/x-www-form-urlencoded" ], + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet that needs to be updated", + "required" : true, + "type" : "string" + }, { + "name" : "name", + "in" : "formData", + "description" : "Updated name of the pet", + "required" : false, + "type" : "string" + }, { + "name" : "status", + "in" : "formData", + "description" : "Updated status of the pet", + "required" : false, + "type" : "string" + } ], + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + }, + "delete" : { + "tags" : [ "pet" ], + "summary" : "Deletes a pet", + "description" : "", + "operationId" : "deletePet", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "api_key", + "in" : "header", + "description" : "", + "required" : false, + "type" : "string" + }, { + "name" : "petId", + "in" : "path", + "description" : "Pet id to delete", + "required" : true, + "type" : "integer", + "format" : "int64" + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "tags" : [ "pet" ], + "summary" : "uploads an image", + "description" : "", + "operationId" : "uploadFile", + "consumes" : [ "multipart/form-data" ], + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet to update", + "required" : true, + "type" : "integer", + "format" : "int64" + }, { + "name" : "additionalMetadata", + "in" : "formData", + "description" : "Additional data to pass to server", + "required" : false, + "type" : "string" + }, { + "name" : "file", + "in" : "formData", + "description" : "file to upload", + "required" : false, + "type" : "file" + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/store/inventory" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Returns pet inventories by status", + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "type" : "object", + "additionalProperties" : { + "type" : "integer", + "format" : "int32" + } + } + } + }, + "security" : [ { + "api_key" : [ ] + } ] + } + }, + "/store/order" : { + "post" : { + "tags" : [ "store" ], + "summary" : "Place an order for a pet", + "description" : "", + "operationId" : "placeOrder", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "order placed for purchasing the pet", + "required" : false, + "schema" : { + "$ref" : "#/definitions/Order" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/Order" + } + }, + "400" : { + "description" : "Invalid Order" + } + } + } + }, + "/store/order/{orderId}" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Find purchase order by ID", + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", + "operationId" : "getOrderById", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of pet that needs to be fetched", + "required" : true, + "type" : "string" + } ], + "responses" : { + "404" : { + "description" : "Order not found" + }, + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/Order" + } + }, + "400" : { + "description" : "Invalid ID supplied" + } + } + }, + "delete" : { + "tags" : [ "store" ], + "summary" : "Delete purchase order by ID", + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of the order that needs to be deleted", + "required" : true, + "type" : "string" + } ], + "responses" : { + "404" : { + "description" : "Order not found" + }, + "400" : { + "description" : "Invalid ID supplied" + } + } + } + }, + "/user" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Create user", + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "Created user object", + "required" : false, + "schema" : { + "$ref" : "#/definitions/User" + } + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + } + } + }, + "/user/createWithArray" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "description" : "", + "operationId" : "createUsersWithArrayInput", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "List of user object", + "required" : false, + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/User" + } + } + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + } + } + }, + "/user/createWithList" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "description" : "", + "operationId" : "createUsersWithListInput", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "List of user object", + "required" : false, + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/User" + } + } + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + } + } + }, + "/user/login" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs user into the system", + "description" : "", + "operationId" : "loginUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "username", + "in" : "query", + "description" : "The user name for login", + "required" : false, + "type" : "string" + }, { + "name" : "password", + "in" : "query", + "description" : "The password for login in clear text", + "required" : false, + "type" : "string" + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "type" : "string" + } + }, + "400" : { + "description" : "Invalid username/password supplied" + } + } + } + }, + "/user/logout" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs out current logged in user session", + "description" : "", + "operationId" : "logoutUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ ], + "responses" : { + "default" : { + "description" : "successful operation" + } + } + } + }, + "/user/{username}" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Get user by user name", + "description" : "", + "operationId" : "getUserByName", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be fetched. Use user1 for testing. ", + "required" : true, + "type" : "string" + } ], + "responses" : { + "404" : { + "description" : "User not found" + }, + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/User" + }, + "examples" : { + "application/json" : { + "id" : 1, + "username" : "johnp", + "firstName" : "John", + "lastName" : "Public", + "email" : "johnp@swagger.io", + "password" : "-secret-", + "phone" : "0123456789", + "userStatus" : 0 + } + } + }, + "400" : { + "description" : "Invalid username supplied" + } + } + }, + "put" : { + "tags" : [ "user" ], + "summary" : "Updated user", + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "name that need to be deleted", + "required" : true, + "type" : "string" + }, { + "in" : "body", + "name" : "body", + "description" : "Updated user object", + "required" : false, + "schema" : { + "$ref" : "#/definitions/User" + } + } ], + "responses" : { + "404" : { + "description" : "User not found" + }, + "400" : { + "description" : "Invalid user supplied" + } + } + }, + "delete" : { + "tags" : [ "user" ], + "summary" : "Delete user", + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be deleted", + "required" : true, + "type" : "string" + } ], + "responses" : { + "404" : { + "description" : "User not found" + }, + "400" : { + "description" : "Invalid username supplied" + } + } + } + } + }, + "securityDefinitions" : { + "api_key" : { + "type" : "apiKey", + "name" : "api_key", + "in" : "header" + }, + "petstore_auth" : { + "type" : "oauth2", + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "flow" : "implicit", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, + "definitions" : { + "User" : { + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "type" : "integer", + "format" : "int32", + "description" : "User Status" + } + }, + "xml" : { + "name" : "User" + } + }, + "Category" : { + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "xml" : { + "name" : "Category" + } + }, + "Pet" : { + "required" : [ "name", "photoUrls" ], + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "category" : { + "$ref" : "#/definitions/Category" + }, + "name" : { + "type" : "string", + "example" : "doggie" + }, + "photoUrls" : { + "type" : "array", + "items" : { + "type" : "string" + } + }, + "tags" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/Tag" + } + }, + "status" : { + "type" : "string", + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ] + } + }, + "xml" : { + "name" : "Pet" + } + }, + "Tag" : { + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "xml" : { + "name" : "Tag" + } + }, + "Order" : { + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "petId" : { + "type" : "integer", + "format" : "int64" + }, + "quantity" : { + "type" : "integer", + "format" : "int32" + }, + "shipDate" : { + "type" : "string", + "format" : "date-time" + }, + "status" : { + "type" : "string", + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ] + }, + "complete" : { + "type" : "boolean" + } + }, + "xml" : { + "name" : "Order" + } + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-inflector/src/main/webapp/WEB-INF/web.xml b/samples/server/petstore/java-inflector/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..34a2eea6bcfa --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + swagger-inflector + org.glassfish.jersey.servlet.ServletContainer + + javax.ws.rs.Application + io.swagger.inflector.SwaggerInflector + + 1 + + + swagger-inflector + /* + + + CORSFilter + io.swagger.inflector.utils.CORSFilter + + + CORSFilter + /* + + \ No newline at end of file diff --git a/samples/server/petstore/jaxrs/README.md b/samples/server/petstore/jaxrs/README.md index 3ffa01fb2571..a5281c3eac30 100644 --- a/samples/server/petstore/jaxrs/README.md +++ b/samples/server/petstore/jaxrs/README.md @@ -1,10 +1,5 @@ # Swagger generated server ## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the -[swagger-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 swagger-enabled scalatra server. - -This example uses the [scalatra](http://scalatra.org/) framework. To see how to make this your own, look here: - -[README](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/scalatra) \ No newline at end of file +This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project using the +JAX-RS template. diff --git a/samples/server/petstore/jaxrs/pom.xml b/samples/server/petstore/jaxrs/pom.xml index cac2f6daf795..9a7e179cc721 100644 --- a/samples/server/petstore/jaxrs/pom.xml +++ b/samples/server/petstore/jaxrs/pom.xml @@ -50,7 +50,6 @@ 0 - true @@ -75,12 +74,29 @@ - src/gen/java + target/generated-sources + + io.swagger + swagger-codegen-maven-plugin + 2.1.3-SNAPSHOT + + + + generate + + + src/main/resources/swagger.json + jaxrs + . + + + + @@ -148,7 +164,7 @@ - 1.5.0 + 1.5.1-SNAPSHOT 9.2.9.v20150224 1.13 1.6.3 diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java deleted file mode 100644 index cae767c0393f..000000000000 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.swagger.api; - -public class ApiException extends Exception{ - private int code; - public ApiException (int code, String msg) { - super(msg); - this.code = code; - } -} diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java deleted file mode 100644 index c2eeacf13d3f..000000000000 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.swagger.api; - -import java.io.IOException; - -import javax.servlet.*; -import javax.servlet.http.HttpServletResponse; - -public class ApiOriginFilter implements javax.servlet.Filter { - @Override - public void doFilter(ServletRequest request, ServletResponse response, - FilterChain chain) throws IOException, ServletException { - HttpServletResponse res = (HttpServletResponse) response; - res.addHeader("Access-Control-Allow-Origin", "*"); - res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); - res.addHeader("Access-Control-Allow-Headers", "Content-Type"); - chain.doFilter(request, response); - } - - @Override - public void destroy() { - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } -} \ No newline at end of file diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java deleted file mode 100644 index 9e5b0ee44e2d..000000000000 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.swagger.api; - -import javax.xml.bind.annotation.XmlTransient; - -@javax.xml.bind.annotation.XmlRootElement -public class ApiResponseMessage { - public static final int ERROR = 1; - public static final int WARNING = 2; - public static final int INFO = 3; - public static final int OK = 4; - public static final int TOO_BUSY = 5; - - int code; - String type; - String message; - - public ApiResponseMessage(){} - - public ApiResponseMessage(int code, String message){ - this.code = code; - switch(code){ - case ERROR: - setType("error"); - break; - case WARNING: - setType("warning"); - break; - case INFO: - setType("info"); - break; - case OK: - setType("ok"); - break; - case TOO_BUSY: - setType("too busy"); - break; - default: - setType("unknown"); - break; - } - this.message = message; - } - - @XmlTransient - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java deleted file mode 100644 index 9c8410e47ab8..000000000000 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.swagger.api; - -public class NotFoundException extends ApiException { - private int code; - public NotFoundException (int code, String msg) { - super(code, msg); - this.code = code; - } -} diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java deleted file mode 100644 index 055fa75c80bc..000000000000 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java +++ /dev/null @@ -1,148 +0,0 @@ -package io.swagger.api; - -import io.swagger.model.*; -import io.swagger.api.PetApiService; -import io.swagger.api.factories.PetApiServiceFactory; - -import io.swagger.annotations.ApiParam; - -import com.sun.jersey.multipart.FormDataParam; - -import io.swagger.model.Pet; -import java.io.File; - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import com.sun.jersey.core.header.FormDataContentDisposition; -import com.sun.jersey.multipart.FormDataParam; - -import javax.ws.rs.core.Response; -import javax.ws.rs.*; - -@Path("/pet") - - -@io.swagger.annotations.Api(value = "/pet", description = "the pet API") -public class PetApi { - - private final PetApiService delegate = PetApiServiceFactory.getPetApi(); - - @PUT - - @Consumes({ "application/json", "application/xml" }) - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception"), - - @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) - - public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body) - throws NotFoundException { - return delegate.updatePet(body); - } - @POST - - @Consumes({ "application/json", "application/xml" }) - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") }) - - public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body) - throws NotFoundException { - return delegate.addPet(body); - } - @GET - @Path("/findByStatus") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List") - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value") }) - - public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue="available") @QueryParam("status") List status) - throws NotFoundException { - return delegate.findPetsByStatus(status); - } - @GET - @Path("/findByTags") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List") - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value") }) - - public Response findPetsByTags(@ApiParam(value = "Tags to filter by") @QueryParam("tags") List tags) - throws NotFoundException { - return delegate.findPetsByTags(tags); - } - @GET - @Path("/{petId}") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"), - - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) - - public Response getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("petId") Long petId) - throws NotFoundException { - return delegate.getPetById(petId); - } - @POST - @Path("/{petId}") - @Consumes({ "application/x-www-form-urlencoded" }) - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") }) - - public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathParam("petId") String petId, - @ApiParam(value = "Updated name of the pet" )@FormParam("name") String name, - @ApiParam(value = "Updated status of the pet" )@FormParam("status") String status) - throws NotFoundException { - return delegate.updatePetWithForm(petId,name,status); - } - @DELETE - @Path("/{petId}") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value") }) - - public Response deletePet(@ApiParam(value = "" )@HeaderParam("api_key") String apiKey, - @ApiParam(value = "Pet id to delete",required=true ) @PathParam("petId") Long petId) - throws NotFoundException { - return delegate.deletePet(apiKey,petId); - } - @POST - @Path("/{petId}/uploadImage") - @Consumes({ "multipart/form-data" }) - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) - - public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathParam("petId") Long petId, - @ApiParam(value = "Additional data to pass to server" )@FormParam("additionalMetadata") String additionalMetadata, - @ApiParam(value = "file to upload") @FormDataParam("file") InputStream inputStream, - @ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail) - throws NotFoundException { - return delegate.uploadFile(petId,additionalMetadata,fileDetail); - } -} - diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java deleted file mode 100644 index 6e8060269eb6..000000000000 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.swagger.api; - -import io.swagger.api.*; -import io.swagger.model.*; - -import com.sun.jersey.multipart.FormDataParam; - -import io.swagger.model.Pet; -import java.io.File; - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import com.sun.jersey.core.header.FormDataContentDisposition; -import com.sun.jersey.multipart.FormDataParam; - -import javax.ws.rs.core.Response; - -public abstract class PetApiService { - - public abstract Response updatePet(Pet body) - throws NotFoundException; - - public abstract Response addPet(Pet body) - throws NotFoundException; - - public abstract Response findPetsByStatus(List status) - throws NotFoundException; - - public abstract Response findPetsByTags(List tags) - throws NotFoundException; - - public abstract Response getPetById(Long petId) - throws NotFoundException; - - public abstract Response updatePetWithForm(String petId,String name,String status) - throws NotFoundException; - - public abstract Response deletePet(String apiKey,Long petId) - throws NotFoundException; - - public abstract Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail) - throws NotFoundException; - -} diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java deleted file mode 100644 index f5215862ba78..000000000000 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java +++ /dev/null @@ -1,90 +0,0 @@ -package io.swagger.api; - -import io.swagger.model.*; -import io.swagger.api.StoreApiService; -import io.swagger.api.factories.StoreApiServiceFactory; - -import io.swagger.annotations.ApiParam; - -import com.sun.jersey.multipart.FormDataParam; - -import java.util.Map; -import io.swagger.model.Order; - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import com.sun.jersey.core.header.FormDataContentDisposition; -import com.sun.jersey.multipart.FormDataParam; - -import javax.ws.rs.core.Response; -import javax.ws.rs.*; - -@Path("/store") - - -@io.swagger.annotations.Api(value = "/store", description = "the store API") -public class StoreApi { - - private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi(); - - @GET - @Path("/inventory") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map") - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation") }) - - public Response getInventory() - throws NotFoundException { - return delegate.getInventory(); - } - @POST - @Path("/order") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order") }) - - public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body) - throws NotFoundException { - return delegate.placeOrder(body); - } - @GET - @Path("/order/{orderId}") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.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) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found"), - - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) - - public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("orderId") String orderId) - throws NotFoundException { - return delegate.getOrderById(orderId); - } - @DELETE - @Path("/order/{orderId}") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.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) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) - - public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathParam("orderId") String orderId) - throws NotFoundException { - return delegate.deleteOrder(orderId); - } -} - diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java deleted file mode 100644 index 5566e9c9b570..000000000000 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.swagger.api; - -import io.swagger.api.*; -import io.swagger.model.*; - -import com.sun.jersey.multipart.FormDataParam; - -import java.util.Map; -import io.swagger.model.Order; - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import com.sun.jersey.core.header.FormDataContentDisposition; -import com.sun.jersey.multipart.FormDataParam; - -import javax.ws.rs.core.Response; - -public abstract class StoreApiService { - - public abstract Response getInventory() - throws NotFoundException; - - public abstract Response placeOrder(Order body) - throws NotFoundException; - - public abstract Response getOrderById(String orderId) - throws NotFoundException; - - public abstract Response deleteOrder(String orderId) - throws NotFoundException; - -} diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java deleted file mode 100644 index f904b77746b4..000000000000 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java +++ /dev/null @@ -1,142 +0,0 @@ -package io.swagger.api; - -import io.swagger.model.*; -import io.swagger.api.UserApiService; -import io.swagger.api.factories.UserApiServiceFactory; - -import io.swagger.annotations.ApiParam; - -import com.sun.jersey.multipart.FormDataParam; - -import io.swagger.model.User; -import java.util.*; - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import com.sun.jersey.core.header.FormDataContentDisposition; -import com.sun.jersey.multipart.FormDataParam; - -import javax.ws.rs.core.Response; -import javax.ws.rs.*; - -@Path("/user") - - -@io.swagger.annotations.Api(value = "/user", description = "the user API") -public class UserApi { - - private final UserApiService delegate = UserApiServiceFactory.getUserApi(); - - @POST - - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) - - public Response createUser(@ApiParam(value = "Created user object" ) User body) - throws NotFoundException { - return delegate.createUser(body); - } - @POST - @Path("/createWithArray") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) - - public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ) List body) - throws NotFoundException { - return delegate.createUsersWithArrayInput(body); - } - @POST - @Path("/createWithList") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) - - public Response createUsersWithListInput(@ApiParam(value = "List of user object" ) List body) - throws NotFoundException { - return delegate.createUsersWithListInput(body); - } - @GET - @Path("/login") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied") }) - - public Response loginUser(@ApiParam(value = "The user name for login") @QueryParam("username") String username, - @ApiParam(value = "The password for login in clear text") @QueryParam("password") String password) - throws NotFoundException { - return delegate.loginUser(username,password); - } - @GET - @Path("/logout") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) - - public Response logoutUser() - throws NotFoundException { - return delegate.logoutUser(); - } - @GET - @Path("/{username}") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 404, message = "User not found"), - - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") }) - - public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathParam("username") String username) - throws NotFoundException { - return delegate.getUserByName(username); - } - @PUT - @Path("/{username}") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 404, message = "User not found"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied") }) - - public Response updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathParam("username") String username, - @ApiParam(value = "Updated user object" ) User body) - throws NotFoundException { - return delegate.updateUser(username,body); - } - @DELETE - @Path("/{username}") - - @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 404, message = "User not found"), - - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") }) - - public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathParam("username") String username) - throws NotFoundException { - return delegate.deleteUser(username); - } -} - diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java deleted file mode 100644 index 6a09fcd0feb5..000000000000 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.swagger.api; - -import io.swagger.api.*; -import io.swagger.model.*; - -import com.sun.jersey.multipart.FormDataParam; - -import io.swagger.model.User; -import java.util.*; - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import com.sun.jersey.core.header.FormDataContentDisposition; -import com.sun.jersey.multipart.FormDataParam; - -import javax.ws.rs.core.Response; - -public abstract class UserApiService { - - public abstract Response createUser(User body) - throws NotFoundException; - - public abstract Response createUsersWithArrayInput(List body) - throws NotFoundException; - - public abstract Response createUsersWithListInput(List body) - throws NotFoundException; - - public abstract Response loginUser(String username,String password) - throws NotFoundException; - - public abstract Response logoutUser() - throws NotFoundException; - - public abstract Response getUserByName(String username) - throws NotFoundException; - - public abstract Response updateUser(String username,User body) - throws NotFoundException; - - public abstract Response deleteUser(String username) - throws NotFoundException; - -} diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java index fb0bb2bc3ded..56ad64c3212a 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java @@ -5,9 +5,10 @@ import io.swagger.api.impl.PetApiServiceImpl; public class PetApiServiceFactory { - private final static PetApiService service = new PetApiServiceImpl(); + private final static PetApiService service = new PetApiServiceImpl(); - public static PetApiService getPetApi() { - return service; - } + public static PetApiService getPetApi() + { + return service; + } } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java index 325f5ba7ae0c..d60aa7d8660d 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java @@ -5,9 +5,10 @@ import io.swagger.api.impl.StoreApiServiceImpl; public class StoreApiServiceFactory { - private final static StoreApiService service = new StoreApiServiceImpl(); + private final static StoreApiService service = new StoreApiServiceImpl(); - public static StoreApiService getStoreApi() { - return service; - } + public static StoreApiService getStoreApi() + { + return service; + } } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java index 9a802740e2ca..5db4914a878d 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java @@ -5,9 +5,10 @@ import io.swagger.api.impl.UserApiServiceImpl; public class UserApiServiceFactory { - private final static UserApiService service = new UserApiServiceImpl(); + private final static UserApiService service = new UserApiServiceImpl(); - public static UserApiService getUserApi() { - return service; - } + public static UserApiService getUserApi() + { + return service; + } } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java index 3af5a9cd420e..a330f65530c3 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java @@ -1,69 +1,79 @@ package io.swagger.api.impl; -import com.sun.jersey.core.header.FormDataContentDisposition; import io.swagger.api.*; -import io.swagger.api.NotFoundException; +import io.swagger.model.*; + +import com.sun.jersey.multipart.FormDataParam; + import io.swagger.model.Pet; +import java.io.File; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; -import java.util.List; public class PetApiServiceImpl extends PetApiService { - - @Override - public Response updatePet(Pet body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response addPet(Pet body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response findPetsByStatus(List status) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response findPetsByTags(List tags) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response getPetById(Long petId) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response updatePetWithForm(String petId, String name, String status) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response deletePet(String apiKey, Long petId) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response uploadFile(Long petId, String additionalMetadata, FormDataContentDisposition fileDetail) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - + + @Override + public Response updatePet(Pet body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response addPet(Pet body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response findPetsByStatus(List status) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response findPetsByTags(List tags) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getPetById(Long petId) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response updatePetWithForm(String petId,String name,String status) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response deletePet(Long petId,String apiKey) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java index 9494c3adc89f..84e8938f2f9e 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java @@ -1,39 +1,51 @@ package io.swagger.api.impl; import io.swagger.api.*; -import io.swagger.api.NotFoundException; +import io.swagger.model.*; + +import com.sun.jersey.multipart.FormDataParam; + +import java.util.Map; import io.swagger.model.Order; +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; + import javax.ws.rs.core.Response; public class StoreApiServiceImpl extends StoreApiService { - - @Override - public Response getInventory() - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response placeOrder(Order body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response getOrderById(String orderId) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response deleteOrder(String orderId) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - + + @Override + public Response getInventory() + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response placeOrder(Order body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getOrderById(String orderId) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response deleteOrder(String orderId) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java index 5a8e7a976c4b..b7735c7ac9ea 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java @@ -1,68 +1,79 @@ package io.swagger.api.impl; import io.swagger.api.*; -import io.swagger.api.NotFoundException; +import io.swagger.model.*; + +import com.sun.jersey.multipart.FormDataParam; + import io.swagger.model.User; +import java.util.*; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; -import java.util.List; public class UserApiServiceImpl extends UserApiService { - - @Override - public Response createUser(User body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response createUsersWithArrayInput(List body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response createUsersWithListInput(List body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response loginUser(String username, String password) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response logoutUser() - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response getUserByName(String username) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response updateUser(String username, User body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response deleteUser(String username) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - + + @Override + public Response createUser(User body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response createUsersWithArrayInput(List body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response createUsersWithListInput(List body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response loginUser(String username,String password) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response logoutUser() + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getUserByName(String username) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response updateUser(String username,User body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response deleteUser(String username) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + } diff --git a/samples/server/petstore/jaxrs/src/main/resources/swagger.json b/samples/server/petstore/jaxrs/src/main/resources/swagger.json new file mode 100644 index 000000000000..5ca489f09296 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/main/resources/swagger.json @@ -0,0 +1,762 @@ +{ + "swagger" : "2.0", + "info" : { + "description" : "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", + "version" : "1.0.0", + "title" : "Swagger Petstore", + "termsOfService" : "http://swagger.io/terms/", + "contact" : { + "email" : "apiteam@swagger.io" + }, + "license" : { + "name" : "Apache 2.0", + "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "host" : "petstore.swagger.io", + "basePath" : "/v2", + "schemes" : [ "http" ], + "paths" : { + "/pet" : { + "post" : { + "tags" : [ "pet" ], + "summary" : "Add a new pet to the store", + "description" : "", + "operationId" : "addPet", + "consumes" : [ "application/json", "application/xml" ], + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "Pet object that needs to be added to the store", + "required" : false, + "schema" : { + "$ref" : "#/definitions/Pet" + } + } ], + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + }, + "put" : { + "tags" : [ "pet" ], + "summary" : "Update an existing pet", + "description" : "", + "operationId" : "updatePet", + "consumes" : [ "application/json", "application/xml" ], + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "Pet object that needs to be added to the store", + "required" : false, + "schema" : { + "$ref" : "#/definitions/Pet" + } + } ], + "responses" : { + "405" : { + "description" : "Validation exception" + }, + "404" : { + "description" : "Pet not found" + }, + "400" : { + "description" : "Invalid ID supplied" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/pet/findByStatus" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by status", + "description" : "Multiple status values can be provided with comma seperated strings", + "operationId" : "findPetsByStatus", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "status", + "in" : "query", + "description" : "Status values that need to be considered for filter", + "required" : false, + "type" : "array", + "items" : { + "type" : "string" + }, + "collectionFormat" : "multi", + "default" : "available" + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/Pet" + } + } + }, + "400" : { + "description" : "Invalid status value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/pet/findByTags" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by tags", + "description" : "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "tags", + "in" : "query", + "description" : "Tags to filter by", + "required" : false, + "type" : "array", + "items" : { + "type" : "string" + }, + "collectionFormat" : "multi" + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/Pet" + } + } + }, + "400" : { + "description" : "Invalid tag value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/pet/{petId}" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Find pet by ID", + "description" : "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", + "operationId" : "getPetById", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet that needs to be fetched", + "required" : true, + "type" : "integer", + "format" : "int64" + } ], + "responses" : { + "404" : { + "description" : "Pet not found" + }, + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/Pet" + } + }, + "400" : { + "description" : "Invalid ID supplied" + } + }, + "security" : [ { + "api_key" : [ ] + }, { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + }, + "post" : { + "tags" : [ "pet" ], + "summary" : "Updates a pet in the store with form data", + "description" : "", + "operationId" : "updatePetWithForm", + "consumes" : [ "application/x-www-form-urlencoded" ], + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet that needs to be updated", + "required" : true, + "type" : "string" + }, { + "name" : "name", + "in" : "formData", + "description" : "Updated name of the pet", + "required" : false, + "type" : "string" + }, { + "name" : "status", + "in" : "formData", + "description" : "Updated status of the pet", + "required" : false, + "type" : "string" + } ], + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + }, + "delete" : { + "tags" : [ "pet" ], + "summary" : "Deletes a pet", + "description" : "", + "operationId" : "deletePet", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "api_key", + "in" : "header", + "description" : "", + "required" : false, + "type" : "string" + }, { + "name" : "petId", + "in" : "path", + "description" : "Pet id to delete", + "required" : true, + "type" : "integer", + "format" : "int64" + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "tags" : [ "pet" ], + "summary" : "uploads an image", + "description" : "", + "operationId" : "uploadFile", + "consumes" : [ "multipart/form-data" ], + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet to update", + "required" : true, + "type" : "integer", + "format" : "int64" + }, { + "name" : "additionalMetadata", + "in" : "formData", + "description" : "Additional data to pass to server", + "required" : false, + "type" : "string" + }, { + "name" : "file", + "in" : "formData", + "description" : "file to upload", + "required" : false, + "type" : "file" + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/store/inventory" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Returns pet inventories by status", + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "type" : "object", + "additionalProperties" : { + "type" : "integer", + "format" : "int32" + } + } + } + }, + "security" : [ { + "api_key" : [ ] + } ] + } + }, + "/store/order" : { + "post" : { + "tags" : [ "store" ], + "summary" : "Place an order for a pet", + "description" : "", + "operationId" : "placeOrder", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "order placed for purchasing the pet", + "required" : false, + "schema" : { + "$ref" : "#/definitions/Order" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/Order" + } + }, + "400" : { + "description" : "Invalid Order" + } + } + } + }, + "/store/order/{orderId}" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Find purchase order by ID", + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", + "operationId" : "getOrderById", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of pet that needs to be fetched", + "required" : true, + "type" : "string" + } ], + "responses" : { + "404" : { + "description" : "Order not found" + }, + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/Order" + } + }, + "400" : { + "description" : "Invalid ID supplied" + } + } + }, + "delete" : { + "tags" : [ "store" ], + "summary" : "Delete purchase order by ID", + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of the order that needs to be deleted", + "required" : true, + "type" : "string" + } ], + "responses" : { + "404" : { + "description" : "Order not found" + }, + "400" : { + "description" : "Invalid ID supplied" + } + } + } + }, + "/user" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Create user", + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "Created user object", + "required" : false, + "schema" : { + "$ref" : "#/definitions/User" + } + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + } + } + }, + "/user/createWithArray" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "description" : "", + "operationId" : "createUsersWithArrayInput", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "List of user object", + "required" : false, + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/User" + } + } + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + } + } + }, + "/user/createWithList" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "description" : "", + "operationId" : "createUsersWithListInput", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "List of user object", + "required" : false, + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/User" + } + } + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + } + } + }, + "/user/login" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs user into the system", + "description" : "", + "operationId" : "loginUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "username", + "in" : "query", + "description" : "The user name for login", + "required" : false, + "type" : "string" + }, { + "name" : "password", + "in" : "query", + "description" : "The password for login in clear text", + "required" : false, + "type" : "string" + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "type" : "string" + } + }, + "400" : { + "description" : "Invalid username/password supplied" + } + } + } + }, + "/user/logout" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs out current logged in user session", + "description" : "", + "operationId" : "logoutUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ ], + "responses" : { + "default" : { + "description" : "successful operation" + } + } + } + }, + "/user/{username}" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Get user by user name", + "description" : "", + "operationId" : "getUserByName", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be fetched. Use user1 for testing. ", + "required" : true, + "type" : "string" + } ], + "responses" : { + "404" : { + "description" : "User not found" + }, + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/User" + }, + "examples" : { + "application/json" : { + "id" : 1, + "username" : "johnp", + "firstName" : "John", + "lastName" : "Public", + "email" : "johnp@swagger.io", + "password" : "-secret-", + "phone" : "0123456789", + "userStatus" : 0 + } + } + }, + "400" : { + "description" : "Invalid username supplied" + } + } + }, + "put" : { + "tags" : [ "user" ], + "summary" : "Updated user", + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "name that need to be deleted", + "required" : true, + "type" : "string" + }, { + "in" : "body", + "name" : "body", + "description" : "Updated user object", + "required" : false, + "schema" : { + "$ref" : "#/definitions/User" + } + } ], + "responses" : { + "404" : { + "description" : "User not found" + }, + "400" : { + "description" : "Invalid user supplied" + } + } + }, + "delete" : { + "tags" : [ "user" ], + "summary" : "Delete user", + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be deleted", + "required" : true, + "type" : "string" + } ], + "responses" : { + "404" : { + "description" : "User not found" + }, + "400" : { + "description" : "Invalid username supplied" + } + } + } + } + }, + "securityDefinitions" : { + "api_key" : { + "type" : "apiKey", + "name" : "api_key", + "in" : "header" + }, + "petstore_auth" : { + "type" : "oauth2", + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "flow" : "implicit", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, + "definitions" : { + "User" : { + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "type" : "integer", + "format" : "int32", + "description" : "User Status" + } + }, + "xml" : { + "name" : "User" + } + }, + "Category" : { + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "xml" : { + "name" : "Category" + } + }, + "Pet" : { + "required" : [ "name", "photoUrls" ], + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "category" : { + "$ref" : "#/definitions/Category" + }, + "name" : { + "type" : "string", + "example" : "doggie" + }, + "photoUrls" : { + "type" : "array", + "items" : { + "type" : "string" + } + }, + "tags" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/Tag" + } + }, + "status" : { + "type" : "string", + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ] + } + }, + "xml" : { + "name" : "Pet" + } + }, + "Tag" : { + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "xml" : { + "name" : "Tag" + } + }, + "Order" : { + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "petId" : { + "type" : "integer", + "format" : "int64" + }, + "quantity" : { + "type" : "integer", + "format" : "int32" + }, + "shipDate" : { + "type" : "string", + "format" : "date-time" + }, + "status" : { + "type" : "string", + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ] + }, + "complete" : { + "type" : "boolean" + } + }, + "xml" : { + "name" : "Order" + } + } + } +} \ No newline at end of file From 112a7ec8c1c80d187f4fbb0e7bafbe419fa1b3bf Mon Sep 17 00:00:00 2001 From: xhh Date: Mon, 3 Aug 2015 18:33:42 +0800 Subject: [PATCH 009/109] Java client: move form params handling to ApiClient --- .../main/resources/Java/ApiClient.mustache | 113 +++++++++--------- .../src/main/resources/Java/api.mustache | 35 +----- 2 files changed, 63 insertions(+), 85 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache index fb4351d444de..7a52b0016848 100644 --- a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache @@ -11,7 +11,9 @@ import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.client.filter.LoggingFilter; import com.sun.jersey.api.client.WebResource.Builder; + import com.sun.jersey.multipart.FormDataMultiPart; +import com.sun.jersey.multipart.file.FileDataBodyPart; import javax.ws.rs.core.Response.Status.Family; import javax.ws.rs.core.MediaType; @@ -29,6 +31,7 @@ import java.util.TimeZone; import java.net.URLEncoder; import java.io.IOException; +import java.io.File; import java.io.UnsupportedEncodingException; import java.text.DateFormat; @@ -398,7 +401,7 @@ public class ApiClient { * @param authNames The authentications to apply * @return The response body in type of string */ - public String invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException { + public String invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException { updateParamsForAuth(authNames, queryParams, headerParams); Client client = getClient(); @@ -424,90 +427,90 @@ public class ApiClient { else builder = client.resource(basePath + path + querystring).accept(accept); - for(String key : headerParams.keySet()) { + for (String key : headerParams.keySet()) { builder = builder.header(key, headerParams.get(key)); } - for(String key : defaultHeaderMap.keySet()) { - if(!headerParams.containsKey(key)) { + for (String key : defaultHeaderMap.keySet()) { + if (!headerParams.containsKey(key)) { builder = builder.header(key, defaultHeaderMap.get(key)); } } + String encodedFormParams = null; + if (contentType.startsWith("multipart/form-data")) { + FormDataMultiPart mp = new FormDataMultiPart(); + for (Entry param: formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + mp.field(param.getKey(), file.getName()); + mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE)); + } else { + mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE); + } + } + body = mp; + } else if (contentType.startsWith("application/x-www-form-urlencoded")) { + encodedFormParams = this.getXWWWFormUrlencodedParams(formParams); + } + ClientResponse response = null; - if("GET".equals(method)) { + if ("GET".equals(method)) { response = (ClientResponse) builder.get(ClientResponse.class); - } - else if ("POST".equals(method)) { - if (contentType.startsWith("application/x-www-form-urlencoded")) { - String encodedFormParams = this - .getXWWWFormUrlencodedParams(formParams); - response = builder.type(contentType).post(ClientResponse.class, - encodedFormParams); + } else if ("POST".equals(method)) { + if (encodedFormParams != null) { + response = builder.type(contentType).post(ClientResponse.class, encodedFormParams); } else if (body == null) { response = builder.post(ClientResponse.class, null); - } else if(body instanceof FormDataMultiPart) { + } else if (body instanceof FormDataMultiPart) { response = builder.type(contentType).post(ClientResponse.class, body); - } - else + } else { response = builder.type(contentType).post(ClientResponse.class, serialize(body)); - } - else if ("PUT".equals(method)) { - if ("application/x-www-form-urlencoded".equals(contentType)) { - String encodedFormParams = this - .getXWWWFormUrlencodedParams(formParams); - response = builder.type(contentType).put(ClientResponse.class, - encodedFormParams); + } + } else if ("PUT".equals(method)) { + if (encodedFormParams != null) { + response = builder.type(contentType).put(ClientResponse.class, encodedFormParams); } else if(body == null) { response = builder.put(ClientResponse.class, serialize(body)); } else { - response = builder.type(contentType).put(ClientResponse.class, serialize(body)); + response = builder.type(contentType).put(ClientResponse.class, serialize(body)); } - } - else if ("DELETE".equals(method)) { - if ("application/x-www-form-urlencoded".equals(contentType)) { - String encodedFormParams = this - .getXWWWFormUrlencodedParams(formParams); - response = builder.type(contentType).delete(ClientResponse.class, - encodedFormParams); + } else if ("DELETE".equals(method)) { + if (encodedFormParams != null) { + response = builder.type(contentType).delete(ClientResponse.class, encodedFormParams); } else if(body == null) { response = builder.delete(ClientResponse.class); } else { response = builder.type(contentType).delete(ClientResponse.class, serialize(body)); } - } - else { + } else { throw new ApiException(500, "unknown method type " + method); } - if(response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) { + if (response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) { return null; - } - else if(response.getStatusInfo().getFamily() == Family.SUCCESSFUL) { - if(response.hasEntity()) { + } else if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) { + if (response.hasEntity()) { return (String) response.getEntity(String.class); - } - else { + } else { return ""; } - } - else { + } else { String message = "error"; String respBody = null; - if(response.hasEntity()) { - try{ + if (response.hasEntity()) { + try { respBody = String.valueOf(response.getEntity(String.class)); message = respBody; - } - catch (RuntimeException e) { + } catch (RuntimeException e) { // e.printStackTrace(); } } throw new ApiException( - response.getStatusInfo().getStatusCode(), - message, - response.getHeaders(), - respBody); + response.getStatusInfo().getStatusCode(), + message, + response.getHeaders(), + respBody); } } @@ -527,15 +530,14 @@ public class ApiClient { /** * Encode the given form parameters as request body. */ - private String getXWWWFormUrlencodedParams(Map formParams) { + private String getXWWWFormUrlencodedParams(Map formParams) { StringBuilder formParamBuilder = new StringBuilder(); - for (Entry param : formParams.entrySet()) { - String keyStr = parameterToString(param.getKey()); + for (Entry param : formParams.entrySet()) { + String keyStr = param.getKey(); String valueStr = parameterToString(param.getValue()); - try { - formParamBuilder.append(URLEncoder.encode(keyStr, "utf8")) + formParamBuilder.append(URLEncoder.encode(param.getKey(), "utf8")) .append("=") .append(URLEncoder.encode(valueStr, "utf8")); formParamBuilder.append("&"); @@ -543,11 +545,12 @@ public class ApiClient { // move on to next } } + String encodedFormParams = formParamBuilder.toString(); if (encodedFormParams.endsWith("&")) { - encodedFormParams = encodedFormParams.substring(0, - encodedFormParams.length() - 1); + encodedFormParams = encodedFormParams.substring(0, encodedFormParams.length() - 1); } + return encodedFormParams; } diff --git a/modules/swagger-codegen/src/main/resources/Java/api.mustache b/modules/swagger-codegen/src/main/resources/Java/api.mustache index 39b71dbff9a5..29a56119e768 100644 --- a/modules/swagger-codegen/src/main/resources/Java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/api.mustache @@ -12,11 +12,6 @@ import java.util.*; {{#imports}}import {{import}}; {{/imports}} -import com.sun.jersey.multipart.FormDataMultiPart; -import com.sun.jersey.multipart.file.FileDataBodyPart; - -import javax.ws.rs.core.MediaType; - import java.io.File; import java.util.Map; import java.util.HashMap; @@ -64,7 +59,7 @@ public class {{classname}} { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); {{#queryParams}} queryParams.addAll(apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); @@ -74,6 +69,10 @@ public class {{classname}} { headerParams.put("{{baseName}}", apiClient.parameterToString({{paramName}})); {{/headerParams}} + {{#formParams}}if ({{paramName}} != null) + formParams.put("{{baseName}}", {{paramName}}); + {{/formParams}} + final String[] accepts = { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }; @@ -84,30 +83,6 @@ public class {{classname}} { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - {{#formParams}}{{#notFile}} - if ({{paramName}} != null) { - hasFields = true; - mp.field("{{baseName}}", apiClient.parameterToString({{paramName}}), MediaType.MULTIPART_FORM_DATA_TYPE); - } - {{/notFile}}{{#isFile}} - if ({{paramName}} != null) { - hasFields = true; - mp.field("{{baseName}}", {{paramName}}.getName()); - mp.bodyPart(new FileDataBodyPart("{{baseName}}", {{paramName}}, MediaType.MULTIPART_FORM_DATA_TYPE)); - } - {{/isFile}}{{/formParams}} - if(hasFields) - postBody = mp; - } - else { - {{#formParams}}{{#notFile}}if ({{paramName}} != null) - formParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));{{/notFile}} - {{/formParams}} - } - try { String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; String response = apiClient.invokeAPI(path, "{{httpMethod}}", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); From aff766b7855f9baa217a6de2529aac593cab1407 Mon Sep 17 00:00:00 2001 From: Rogercf Date: Mon, 3 Aug 2015 19:19:10 -0300 Subject: [PATCH 010/109] Update CodegenProperty.java Added a "items" field to keep track of the inner type to be accessed in the mustache templates --- .../src/main/java/io/swagger/codegen/CodegenProperty.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java index 7872da2c707f..12d603a7bcbd 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java @@ -34,4 +34,6 @@ public class CodegenProperty { public boolean isEnum; public List _enum; public Map allowableValues; + public CodegenProperty items; + } From a30b66beb1aa4dd63b02a6749b735c816f73647d Mon Sep 17 00:00:00 2001 From: Rogercf Date: Mon, 3 Aug 2015 19:20:51 -0300 Subject: [PATCH 011/109] Update DefaultCodegen.java Setting the "items" field when the type is array and updating some values if the array is an array of enums --- .../io/swagger/codegen/DefaultCodegen.java | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) 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 0e3c3a34ef9b..c7e24e1ab9f3 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 @@ -667,22 +667,29 @@ public class DefaultCodegen { property.baseType = getSwaggerType(p); - if (p instanceof ArrayProperty) { - property.isContainer = true; - property.containerType = "array"; - ArrayProperty ap = (ArrayProperty) p; - CodegenProperty cp = fromProperty("inner", ap.getItems()); - if (cp == null) { - LOGGER.warn("skipping invalid property " + Json.pretty(p)); - } else { - property.baseType = getSwaggerType(p); - if (!languageSpecificPrimitives.contains(cp.baseType)) { - property.complexType = cp.baseType; - } else { - property.isPrimitiveType = true; - } - } - } else if (p instanceof MapProperty) { + if (p instanceof ArrayProperty) { + property.isContainer = true; + property.containerType = "array"; + ArrayProperty ap = (ArrayProperty) p; + CodegenProperty cp = fromProperty(property.name, ap.getItems()); + if (cp == null) { + LOGGER.warn("skipping invalid property " + Json.pretty(p)); + } else { + property.baseType = getSwaggerType(p); + if (!languageSpecificPrimitives.contains(cp.baseType)) { + property.complexType = cp.baseType; + } else { + property.isPrimitiveType = true; + } + property.items = cp; + if (property.items.isEnum) { + property.datatypeWithEnum = property.datatypeWithEnum.replace("String", + property.items.datatypeWithEnum); + property.defaultValue = property.defaultValue.replace("String", property.items.datatypeWithEnum); + } + } + + } else if (p instanceof MapProperty) { property.isContainer = true; property.containerType = "map"; MapProperty ap = (MapProperty) p; From c5dc070685df5b7ae8e4994278d766b04e0cddc5 Mon Sep 17 00:00:00 2001 From: Rogercf Date: Mon, 3 Aug 2015 19:21:54 -0300 Subject: [PATCH 012/109] Update model.mustache Fixed generating array of enums properties in the java template --- .../swagger-codegen/src/main/resources/Java/model.mustache | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/model.mustache b/modules/swagger-codegen/src/main/resources/Java/model.mustache index 0e12f514c488..24218494e07b 100644 --- a/modules/swagger-codegen/src/main/resources/Java/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/model.mustache @@ -14,11 +14,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "{{{description}}}") public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{#vars}}{{#isEnum}} + public enum {{datatypeWithEnum}} { + {{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}} + };{{/isEnum}}{{#items.isEnum}}{{#items}} public enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}} }; - private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{^isEnum}} - private {{{datatype}}} {{name}} = {{{defaultValue}}};{{/isEnum}}{{/vars}} +{{/items}}{{/items.isEnum}} + private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}} {{#vars}} /**{{#description}} From 13038d2a124c14a1c5e35203d2fde6d567a8ffe7 Mon Sep 17 00:00:00 2001 From: Rogercf Date: Mon, 3 Aug 2015 19:46:10 -0300 Subject: [PATCH 013/109] Update DefaultCodegen.java Replaced hardcoded "String" with property.items.baseType --- .../src/main/java/io/swagger/codegen/DefaultCodegen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 c7e24e1ab9f3..83c30af66dfe 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 @@ -683,9 +683,9 @@ public class DefaultCodegen { } property.items = cp; if (property.items.isEnum) { - property.datatypeWithEnum = property.datatypeWithEnum.replace("String", + property.datatypeWithEnum = property.datatypeWithEnum.replace(property.items.baseType, property.items.datatypeWithEnum); - property.defaultValue = property.defaultValue.replace("String", property.items.datatypeWithEnum); + property.defaultValue = property.defaultValue.replace(property.items.baseType, property.items.datatypeWithEnum); } } From 97d24a711924eae888d009103972a56835194628 Mon Sep 17 00:00:00 2001 From: Rogercf Date: Mon, 3 Aug 2015 19:50:29 -0300 Subject: [PATCH 014/109] Update DefaultCodegen.java Fixed indentation --- .../io/swagger/codegen/DefaultCodegen.java | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) 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 83c30af66dfe..9f9b398011d0 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 @@ -667,29 +667,28 @@ public class DefaultCodegen { property.baseType = getSwaggerType(p); - if (p instanceof ArrayProperty) { - property.isContainer = true; - property.containerType = "array"; - ArrayProperty ap = (ArrayProperty) p; - CodegenProperty cp = fromProperty(property.name, ap.getItems()); - if (cp == null) { - LOGGER.warn("skipping invalid property " + Json.pretty(p)); + if (p instanceof ArrayProperty) { + property.isContainer = true; + property.containerType = "array"; + ArrayProperty ap = (ArrayProperty) p; + CodegenProperty cp = fromProperty(property.name, ap.getItems()); + if (cp == null) { + LOGGER.warn("skipping invalid property " + Json.pretty(p)); + } else { + property.baseType = getSwaggerType(p); + if (!languageSpecificPrimitives.contains(cp.baseType)) { + property.complexType = cp.baseType; } else { - property.baseType = getSwaggerType(p); - if (!languageSpecificPrimitives.contains(cp.baseType)) { - property.complexType = cp.baseType; - } else { - property.isPrimitiveType = true; - } - property.items = cp; - if (property.items.isEnum) { - property.datatypeWithEnum = property.datatypeWithEnum.replace(property.items.baseType, - property.items.datatypeWithEnum); - property.defaultValue = property.defaultValue.replace(property.items.baseType, property.items.datatypeWithEnum); - } + property.isPrimitiveType = true; } - - } else if (p instanceof MapProperty) { + property.items = cp; + if (property.items.isEnum) { + property.datatypeWithEnum = property.datatypeWithEnum.replace(property.items.baseType, + property.items.datatypeWithEnum); + property.defaultValue = property.defaultValue.replace(property.items.baseType, property.items.datatypeWithEnum); + } + } + } else if (p instanceof MapProperty) { property.isContainer = true; property.containerType = "map"; MapProperty ap = (MapProperty) p; From bfb4629ab78542bb4566ee58922bfbf1f2a1a5ce Mon Sep 17 00:00:00 2001 From: xhh Date: Tue, 4 Aug 2015 15:47:55 +0800 Subject: [PATCH 015/109] Java client: decouple JSON handling --- .../codegen/languages/JavaClientCodegen.java | 5 +- .../main/resources/Java/ApiClient.mustache | 87 ++++++++----------- .../src/main/resources/Java/JSON.mustache | 51 +++++++++++ .../src/main/resources/Java/JsonUtil.mustache | 23 ----- .../src/main/resources/Java/TypeRef.mustache | 25 ++++++ .../src/main/resources/Java/api.mustache | 20 ++--- 6 files changed, 124 insertions(+), 87 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/Java/JSON.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/Java/JsonUtil.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/TypeRef.mustache 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 f272343a7955..88266aa76cc1 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 @@ -116,9 +116,10 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java")); supportingFiles.add(new SupportingFile("apiException.mustache", invokerFolder, "ApiException.java")); supportingFiles.add(new SupportingFile("Configuration.mustache", invokerFolder, "Configuration.java")); - supportingFiles.add(new SupportingFile("JsonUtil.mustache", invokerFolder, "JsonUtil.java")); - supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java")); + supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java")); supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java")); + supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java")); + supportingFiles.add(new SupportingFile("TypeRef.mustache", invokerFolder, "TypeRef.java")); final String authFolder = (sourceFolder + File.separator + invokerPackage + ".auth").replace(".", File.separator); supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java")); diff --git a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache index 7a52b0016848..b356dd365583 100644 --- a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache @@ -1,9 +1,7 @@ package {{invokerPackage}}; -import com.fasterxml.jackson.core.JsonGenerator.Feature; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.annotation.*; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; @@ -48,6 +46,7 @@ public class ApiClient { private Map defaultHeaderMap = new HashMap(); private boolean debugging = false; private String basePath = "{{basePath}}"; + private JSON json = new JSON(); private Map authentications; @@ -340,50 +339,38 @@ public class ApiClient { } /** - * Deserialize the given JSON string to Java object. - * - * @param json The JSON string - * @param containerType The container type, one of "list", "array" or "" - * @param cls The type of the Java object - * @return The deserialized Java object + * Serialize the given Java object into string according the given + * Content-Type (only JSON is supported for now). */ - public Object deserialize(String json, String containerType, Class cls) throws ApiException { - if(null != containerType) { - containerType = containerType.toLowerCase(); - } - try{ - if("list".equals(containerType) || "array".equals(containerType)) { - JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls); - List response = (List) JsonUtil.getJsonMapper().readValue(json, typeInfo); - return response; - } - else if(String.class.equals(cls)) { - if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1) - return json.substring(1, json.length() - 2); - else - return json; - } - else { - return JsonUtil.getJsonMapper().readValue(json, cls); - } - } - catch (IOException e) { - throw new ApiException(500, e.getMessage(), null, json); + public String serialize(Object obj, String contentType) throws ApiException { + if (contentType.startsWith("application/json")) { + return json.serialize(obj); + } else { + throw new ApiException(400, "can not serialize object into Content-Type: " + contentType); } } /** - * Serialize the given Java object into JSON string. + * Deserialize response body to Java object according to the Content-Type. */ - public String serialize(Object obj) throws ApiException { - try { - if (obj != null) - return JsonUtil.getJsonMapper().writeValueAsString(obj); - else - return null; - } - catch (Exception e) { - throw new ApiException(500, e.getMessage()); + public T deserialize(ClientResponse response, TypeRef returnType) throws ApiException { + String contentType = null; + List contentTypes = response.getHeaders().get("Content-Type"); + if (contentTypes != null && !contentTypes.isEmpty()) + contentType = contentTypes.get(0); + if (contentType == null) + throw new ApiException(500, "missing Content-Type in response"); + + String body; + if (response.hasEntity()) + body = (String) response.getEntity(String.class); + else + body = ""; + + if (contentType.startsWith("application/json")) { + return json.deserialize(body, returnType); + } else { + throw new ApiException(500, "can not deserialize Content-Type: " + contentType); } } @@ -399,9 +386,10 @@ public class ApiClient { * @param accept The request's Accept header * @param contentType The request's Content-Type header * @param authNames The authentications to apply + * @param returnType The return type into which to deserialize the response * @return The response body in type of string */ - public String invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException { + public T invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, TypeRef returnType) throws ApiException { updateParamsForAuth(authNames, queryParams, headerParams); Client client = getClient(); @@ -465,15 +453,15 @@ public class ApiClient { } else if (body instanceof FormDataMultiPart) { response = builder.type(contentType).post(ClientResponse.class, body); } else { - response = builder.type(contentType).post(ClientResponse.class, serialize(body)); + response = builder.type(contentType).post(ClientResponse.class, serialize(body, contentType)); } } else if ("PUT".equals(method)) { if (encodedFormParams != null) { response = builder.type(contentType).put(ClientResponse.class, encodedFormParams); } else if(body == null) { - response = builder.put(ClientResponse.class, serialize(body)); + response = builder.put(ClientResponse.class, serialize(body, contentType)); } else { - response = builder.type(contentType).put(ClientResponse.class, serialize(body)); + response = builder.type(contentType).put(ClientResponse.class, serialize(body, contentType)); } } else if ("DELETE".equals(method)) { if (encodedFormParams != null) { @@ -481,7 +469,7 @@ public class ApiClient { } else if(body == null) { response = builder.delete(ClientResponse.class); } else { - response = builder.type(contentType).delete(ClientResponse.class, serialize(body)); + response = builder.type(contentType).delete(ClientResponse.class, serialize(body, contentType)); } } else { throw new ApiException(500, "unknown method type " + method); @@ -490,11 +478,10 @@ public class ApiClient { if (response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) { return null; } else if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) { - if (response.hasEntity()) { - return (String) response.getEntity(String.class); - } else { - return ""; - } + if (returnType == null) + return null; + else + return deserialize(response, returnType); } else { String message = "error"; String respBody = null; diff --git a/modules/swagger-codegen/src/main/resources/Java/JSON.mustache b/modules/swagger-codegen/src/main/resources/Java/JSON.mustache new file mode 100644 index 000000000000..842920f26621 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/JSON.mustache @@ -0,0 +1,51 @@ +package {{invokerPackage}}; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.datatype.joda.*; + +import java.io.IOException; + +public class JSON { + private ObjectMapper mapper; + + public JSON() { + mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.registerModule(new JodaModule()); + } + + /** + * Serialize the given Java object into JSON string. + */ + public String serialize(Object obj) throws ApiException { + try { + if (obj != null) + return mapper.writeValueAsString(obj); + else + return null; + } catch (Exception e) { + throw new ApiException(400, e.getMessage()); + } + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param body The JSON string + * @param returnType The type to deserialize inot + * @return The deserialized Java object + */ + public T deserialize(String body, TypeRef returnType) throws ApiException { + JavaType javaType = mapper.constructType(returnType.getType()); + try { + return mapper.readValue(body, javaType); + } catch (IOException e) { + if (returnType.getType().equals(String.class)) + return (T) body; + else + throw new ApiException(500, e.getMessage(), null, body); + } + } +} diff --git a/modules/swagger-codegen/src/main/resources/Java/JsonUtil.mustache b/modules/swagger-codegen/src/main/resources/Java/JsonUtil.mustache deleted file mode 100644 index 29d5f55eceea..000000000000 --- a/modules/swagger-codegen/src/main/resources/Java/JsonUtil.mustache +++ /dev/null @@ -1,23 +0,0 @@ -package {{invokerPackage}}; - -import com.fasterxml.jackson.annotation.*; -import com.fasterxml.jackson.databind.*; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.core.JsonGenerator.Feature; - -import com.fasterxml.jackson.datatype.joda.*; - -public class JsonUtil { - public static ObjectMapper mapper; - - static { - mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); - mapper.registerModule(new JodaModule()); - } - - public static ObjectMapper getJsonMapper() { - return mapper; - } -} diff --git a/modules/swagger-codegen/src/main/resources/Java/TypeRef.mustache b/modules/swagger-codegen/src/main/resources/Java/TypeRef.mustache new file mode 100644 index 000000000000..5de0b840aa73 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/TypeRef.mustache @@ -0,0 +1,25 @@ +package {{invokerPackage}}; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; + +public class TypeRef { + private final Type type; + + public TypeRef() { + this.type = getGenericType(getClass()); + } + + private static Type getGenericType(Class klass) { + Type superclass = klass.getGenericSuperclass(); + if (superclass instanceof Class) { + throw new RuntimeException("No type parameter provided"); + } + ParameterizedType parameterized = (ParameterizedType) superclass; + return parameterized.getActualTypeArguments()[0]; + } + + public Type getType() { + return type; + } +} diff --git a/modules/swagger-codegen/src/main/resources/Java/api.mustache b/modules/swagger-codegen/src/main/resources/Java/api.mustache index 29a56119e768..4168c3a173ab 100644 --- a/modules/swagger-codegen/src/main/resources/Java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/api.mustache @@ -4,6 +4,7 @@ import {{invokerPackage}}.ApiException; import {{invokerPackage}}.ApiClient; import {{invokerPackage}}.Configuration; import {{invokerPackage}}.Pair; +import {{invokerPackage}}.TypeRef; import {{modelPackage}}.*; @@ -83,18 +84,13 @@ public class {{classname}} { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - try { - String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; - String response = apiClient.invokeAPI(path, "{{httpMethod}}", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return {{#returnType}}({{{returnType}}}) apiClient.deserialize(response, "{{returnContainer}}", {{returnBaseType}}.class){{/returnType}}; - } - else { - return {{#returnType}}null{{/returnType}}; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; + {{#returnType}} + TypeRef returnType = new TypeRef<{{{returnType}}}>() {}; + return apiClient.invokeAPI(path, "{{httpMethod}}", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + {{/returnType}}{{^returnType}} + apiClient.invokeAPI(path, "{{httpMethod}}", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + {{/returnType}} } {{/operation}} } From aff21e5e6b047e29ed99dff9a558a62afbab2869 Mon Sep 17 00:00:00 2001 From: xhh Date: Tue, 4 Aug 2015 18:32:54 +0800 Subject: [PATCH 016/109] Add a "library" option to generate with sub-template --- .../java/io/swagger/codegen/cmd/Generate.java | 5 ++ .../io/swagger/codegen/AbstractGenerator.java | 4 ++ .../io/swagger/codegen/CodegenConfig.java | 7 +++ .../io/swagger/codegen/DefaultCodegen.java | 16 ++++++- .../io/swagger/codegen/DefaultGenerator.java | 48 ++++++++++++------- 5 files changed, 61 insertions(+), 19 deletions(-) diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java index 035fa1a21d35..1386ae469a9b 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java @@ -40,6 +40,10 @@ public class Generate implements Runnable { description = "client language to generate (maybe class name in classpath, required)") private String lang; + @Option(name = {"-L", "--library"}, title = "library", + description = "library template (sub-template) to use") + private String library; + @Option(name = {"-o", "--output"}, title = "output directory", description = "where to write the generated files (current dir by default)") private String output = ""; @@ -105,6 +109,7 @@ public class Generate implements Runnable { } CodegenConfig config = forName(lang); + config.setLibrary(library); config.setOutputDir(new File(output).getAbsolutePath()); if (null != templateDir) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java index ac3771536252..0d530e7c959a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java @@ -60,6 +60,10 @@ public abstract class AbstractGenerator { throw new RuntimeException("can't load template " + name); } + public boolean templateExists(String name) { + return this.getClass().getClassLoader().getResource(getCPResourcePath(name)) != null; + } + public String getCPResourcePath(String name) { if (!"/".equals(File.separator)) { return name.replaceAll(Pattern.quote(File.separator), "/"); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java index 4ef8bb23e664..45c8cc5e9f83 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java @@ -108,4 +108,11 @@ public interface CodegenConfig { boolean isSkipOverwrite(); void setSkipOverwrite(boolean skipOverwrite); + + void setLibrary(String library); + + /** + * Library template (sub-template). + */ + String getLibrary(); } 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 0e3c3a34ef9b..aaf62b4a11b9 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 @@ -81,6 +81,7 @@ public class DefaultCodegen { protected List cliOptions = new ArrayList(); protected boolean skipOverwrite; protected boolean supportsInheritance = false; + protected String library = null; public List cliOptions() { return cliOptions; @@ -1287,7 +1288,7 @@ public class DefaultCodegen { m.emptyVars = true; } } - + /** * Remove characters not suitable for variable or method name from the input and camelize it @@ -1308,7 +1309,7 @@ public class DefaultCodegen { name = name.substring(0, 1).toLowerCase() + name.substring(1); } return name; - } + } public static String camelize(String word) { return camelize(word, false); @@ -1387,4 +1388,15 @@ public class DefaultCodegen { public void setSkipOverwrite(boolean skipOverwrite) { this.skipOverwrite = skipOverwrite; } + + public void setLibrary(String library) { + this.library = library; + } + + /** + * Library template (sub-template). + */ + public String getLibrary() { + return library; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index d48238c24895..4feb75acf4ea 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -125,7 +125,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { Map definitions = swagger.getDefinitions(); if (definitions != null) { List sortedModelKeys = sortModelsByInheritance(definitions); - + for (String name : sortedModelKeys) { Model model = definitions.get(name); Map modelMap = new HashMap(); @@ -264,8 +264,22 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { continue; } - if (support.templateFile.endsWith("mustache")) { - String template = readTemplate(config.templateDir() + File.separator + support.templateFile); + String templateFile = null; + String library = config.getLibrary(); + if (library != null) { + String libTemplateFile = config.templateDir() + File.separator + + "libraries" + File.separator + library + File.separator + + support.templateFile; + if (templateExists(libTemplateFile)) { + templateFile = libTemplateFile; + } + } + if (templateFile == null) { + templateFile = config.templateDir() + File.separator + support.templateFile; + } + + if (templateFile.endsWith("mustache")) { + String template = readTemplate(templateFile); Template tmpl = Mustache.compiler() .withLoader(new Mustache.TemplateLoader() { public Reader getTemplate(String name) { @@ -281,12 +295,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { InputStream in = null; try { - in = new FileInputStream(config.templateDir() + File.separator + support.templateFile); + in = new FileInputStream(templateFile); } catch (Exception e) { // continue } if (in == null) { - in = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(config.templateDir() + File.separator + support.templateFile)); + in = this.getClass().getClassLoader().getResourceAsStream(getCPResourcePath(templateFile)); } File outputFile = new File(outputFilename); OutputStream out = new FileOutputStream(outputFile, false); @@ -295,7 +309,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { IOUtils.copy(in, out); } else { if (in == null) { - System.out.println("can't open " + config.templateDir() + File.separator + support.templateFile + " for input"); + System.out.println("can't open " + templateFile + " for input"); } if (out == null) { System.out.println("can't open " + outputFile + " for output"); @@ -333,7 +347,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { operation.put(flagFieldName, true); } } - + private List sortModelsByInheritance(final Map definitions) { List sortedModelKeys = new ArrayList(definitions.keySet()); Comparator cmp = new Comparator() { @@ -341,10 +355,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { public int compare(String o1, String o2) { Model model1 = definitions.get(o1); Model model2 = definitions.get(o2); - + int model1InheritanceDepth = getInheritanceDepth(model1); int model2InheritanceDepth = getInheritanceDepth(model2); - + if (model1InheritanceDepth == model2InheritanceDepth) { return 0; } else if (model1InheritanceDepth > model2InheritanceDepth) { @@ -353,30 +367,30 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { return -1; } } - + private int getInheritanceDepth(Model model) { int inheritanceDepth = 0; Model parent = getParent(model); - + while (parent != null) { inheritanceDepth++; parent = getParent(parent); } - + return inheritanceDepth; } - + private Model getParent(Model model) { if (model instanceof ComposedModel) { return definitions.get(((ComposedModel) model).getParent().getReference()); } - + return null; } }; - + Collections.sort(sortedModelKeys, cmp); - + return sortedModelKeys; } @@ -445,7 +459,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { } authMethods.put(securityName, oauth2Operation); } else { - authMethods.put(securityName, securityDefinition); + authMethods.put(securityName, securityDefinition); } } } From 7c16dfcf135272b5c617ac37ca898a6dd8ef9ba9 Mon Sep 17 00:00:00 2001 From: xhh Date: Tue, 4 Aug 2015 18:36:03 +0800 Subject: [PATCH 017/109] Rebuild Java petstore sample --- .../java/io/swagger/client/ApiClient.java | 194 ++++++------ .../src/main/java/io/swagger/client/JSON.java | 51 +++ .../main/java/io/swagger/client/JsonUtil.java | 23 -- .../main/java/io/swagger/client/TypeRef.java | 25 ++ .../java/io/swagger/client/api/PetApi.java | 293 ++++-------------- .../java/io/swagger/client/api/StoreApi.java | 133 ++------ .../java/io/swagger/client/api/UserApi.java | 256 ++++----------- .../java/io/swagger/client/model/Pet.java | 2 +- 8 files changed, 328 insertions(+), 649 deletions(-) create mode 100644 samples/client/petstore/java/src/main/java/io/swagger/client/JSON.java delete mode 100644 samples/client/petstore/java/src/main/java/io/swagger/client/JsonUtil.java create mode 100644 samples/client/petstore/java/src/main/java/io/swagger/client/TypeRef.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java index 87ecc8312514..305f91ce7207 100644 --- a/samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java @@ -1,9 +1,7 @@ package io.swagger.client; -import com.fasterxml.jackson.core.JsonGenerator.Feature; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.annotation.*; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; @@ -11,7 +9,9 @@ import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.client.filter.LoggingFilter; import com.sun.jersey.api.client.WebResource.Builder; + import com.sun.jersey.multipart.FormDataMultiPart; +import com.sun.jersey.multipart.file.FileDataBodyPart; import javax.ws.rs.core.Response.Status.Family; import javax.ws.rs.core.MediaType; @@ -29,6 +29,7 @@ import java.util.TimeZone; import java.net.URLEncoder; import java.io.IOException; +import java.io.File; import java.io.UnsupportedEncodingException; import java.text.DateFormat; @@ -45,6 +46,7 @@ public class ApiClient { private Map defaultHeaderMap = new HashMap(); private boolean debugging = false; private String basePath = "http://petstore.swagger.io/v2"; + private JSON json = new JSON(); private Map authentications; @@ -336,50 +338,38 @@ public class ApiClient { } /** - * Deserialize the given JSON string to Java object. - * - * @param json The JSON string - * @param containerType The container type, one of "list", "array" or "" - * @param cls The type of the Java object - * @return The deserialized Java object + * Serialize the given Java object into string according the given + * Content-Type (only JSON is supported for now). */ - public Object deserialize(String json, String containerType, Class cls) throws ApiException { - if(null != containerType) { - containerType = containerType.toLowerCase(); - } - try{ - if("list".equals(containerType) || "array".equals(containerType)) { - JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls); - List response = (List) JsonUtil.getJsonMapper().readValue(json, typeInfo); - return response; - } - else if(String.class.equals(cls)) { - if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1) - return json.substring(1, json.length() - 2); - else - return json; - } - else { - return JsonUtil.getJsonMapper().readValue(json, cls); - } - } - catch (IOException e) { - throw new ApiException(500, e.getMessage(), null, json); + public String serialize(Object obj, String contentType) throws ApiException { + if (contentType.startsWith("application/json")) { + return json.serialize(obj); + } else { + throw new ApiException(400, "can not serialize object into Content-Type: " + contentType); } } /** - * Serialize the given Java object into JSON string. + * Deserialize response body to Java object according to the Content-Type. */ - public String serialize(Object obj) throws ApiException { - try { - if (obj != null) - return JsonUtil.getJsonMapper().writeValueAsString(obj); - else - return null; - } - catch (Exception e) { - throw new ApiException(500, e.getMessage()); + public T deserialize(ClientResponse response, TypeRef returnType) throws ApiException { + String contentType = null; + List contentTypes = response.getHeaders().get("Content-Type"); + if (contentTypes != null && !contentTypes.isEmpty()) + contentType = contentTypes.get(0); + if (contentType == null) + throw new ApiException(500, "missing Content-Type in response"); + + String body; + if (response.hasEntity()) + body = (String) response.getEntity(String.class); + else + body = ""; + + if (contentType.startsWith("application/json")) { + return json.deserialize(body, returnType); + } else { + throw new ApiException(500, "can not deserialize Content-Type: " + contentType); } } @@ -395,9 +385,10 @@ public class ApiClient { * @param accept The request's Accept header * @param contentType The request's Content-Type header * @param authNames The authentications to apply + * @param returnType The return type into which to deserialize the response * @return The response body in type of string */ - public String invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException { + public T invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, TypeRef returnType) throws ApiException { updateParamsForAuth(authNames, queryParams, headerParams); Client client = getClient(); @@ -423,90 +414,89 @@ public class ApiClient { else builder = client.resource(basePath + path + querystring).accept(accept); - for(String key : headerParams.keySet()) { + for (String key : headerParams.keySet()) { builder = builder.header(key, headerParams.get(key)); } - for(String key : defaultHeaderMap.keySet()) { - if(!headerParams.containsKey(key)) { + for (String key : defaultHeaderMap.keySet()) { + if (!headerParams.containsKey(key)) { builder = builder.header(key, defaultHeaderMap.get(key)); } } + String encodedFormParams = null; + if (contentType.startsWith("multipart/form-data")) { + FormDataMultiPart mp = new FormDataMultiPart(); + for (Entry param: formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + mp.field(param.getKey(), file.getName()); + mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE)); + } else { + mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE); + } + } + body = mp; + } else if (contentType.startsWith("application/x-www-form-urlencoded")) { + encodedFormParams = this.getXWWWFormUrlencodedParams(formParams); + } + ClientResponse response = null; - if("GET".equals(method)) { + if ("GET".equals(method)) { response = (ClientResponse) builder.get(ClientResponse.class); - } - else if ("POST".equals(method)) { - if (contentType.startsWith("application/x-www-form-urlencoded")) { - String encodedFormParams = this - .getXWWWFormUrlencodedParams(formParams); - response = builder.type(contentType).post(ClientResponse.class, - encodedFormParams); + } else if ("POST".equals(method)) { + if (encodedFormParams != null) { + response = builder.type(contentType).post(ClientResponse.class, encodedFormParams); } else if (body == null) { response = builder.post(ClientResponse.class, null); - } else if(body instanceof FormDataMultiPart) { + } else if (body instanceof FormDataMultiPart) { response = builder.type(contentType).post(ClientResponse.class, body); - } - else - response = builder.type(contentType).post(ClientResponse.class, serialize(body)); - } - else if ("PUT".equals(method)) { - if ("application/x-www-form-urlencoded".equals(contentType)) { - String encodedFormParams = this - .getXWWWFormUrlencodedParams(formParams); - response = builder.type(contentType).put(ClientResponse.class, - encodedFormParams); - } else if(body == null) { - response = builder.put(ClientResponse.class, serialize(body)); } else { - response = builder.type(contentType).put(ClientResponse.class, serialize(body)); + response = builder.type(contentType).post(ClientResponse.class, serialize(body, contentType)); } - } - else if ("DELETE".equals(method)) { - if ("application/x-www-form-urlencoded".equals(contentType)) { - String encodedFormParams = this - .getXWWWFormUrlencodedParams(formParams); - response = builder.type(contentType).delete(ClientResponse.class, - encodedFormParams); + } else if ("PUT".equals(method)) { + if (encodedFormParams != null) { + response = builder.type(contentType).put(ClientResponse.class, encodedFormParams); + } else if(body == null) { + response = builder.put(ClientResponse.class, serialize(body, contentType)); + } else { + response = builder.type(contentType).put(ClientResponse.class, serialize(body, contentType)); + } + } else if ("DELETE".equals(method)) { + if (encodedFormParams != null) { + response = builder.type(contentType).delete(ClientResponse.class, encodedFormParams); } else if(body == null) { response = builder.delete(ClientResponse.class); } else { - response = builder.type(contentType).delete(ClientResponse.class, serialize(body)); + response = builder.type(contentType).delete(ClientResponse.class, serialize(body, contentType)); } - } - else { + } else { throw new ApiException(500, "unknown method type " + method); } - if(response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) { + if (response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) { return null; - } - else if(response.getStatusInfo().getFamily() == Family.SUCCESSFUL) { - if(response.hasEntity()) { - return (String) response.getEntity(String.class); - } - else { - return ""; - } - } - else { + } else if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) { + if (returnType == null) + return null; + else + return deserialize(response, returnType); + } else { String message = "error"; String respBody = null; - if(response.hasEntity()) { - try{ + if (response.hasEntity()) { + try { respBody = String.valueOf(response.getEntity(String.class)); message = respBody; - } - catch (RuntimeException e) { + } catch (RuntimeException e) { // e.printStackTrace(); } } throw new ApiException( - response.getStatusInfo().getStatusCode(), - message, - response.getHeaders(), - respBody); + response.getStatusInfo().getStatusCode(), + message, + response.getHeaders(), + respBody); } } @@ -526,15 +516,14 @@ public class ApiClient { /** * Encode the given form parameters as request body. */ - private String getXWWWFormUrlencodedParams(Map formParams) { + private String getXWWWFormUrlencodedParams(Map formParams) { StringBuilder formParamBuilder = new StringBuilder(); - for (Entry param : formParams.entrySet()) { - String keyStr = parameterToString(param.getKey()); + for (Entry param : formParams.entrySet()) { + String keyStr = param.getKey(); String valueStr = parameterToString(param.getValue()); - try { - formParamBuilder.append(URLEncoder.encode(keyStr, "utf8")) + formParamBuilder.append(URLEncoder.encode(param.getKey(), "utf8")) .append("=") .append(URLEncoder.encode(valueStr, "utf8")); formParamBuilder.append("&"); @@ -542,11 +531,12 @@ public class ApiClient { // move on to next } } + String encodedFormParams = formParamBuilder.toString(); if (encodedFormParams.endsWith("&")) { - encodedFormParams = encodedFormParams.substring(0, - encodedFormParams.length() - 1); + encodedFormParams = encodedFormParams.substring(0, encodedFormParams.length() - 1); } + return encodedFormParams; } diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/src/main/java/io/swagger/client/JSON.java new file mode 100644 index 000000000000..4c1fa53430b2 --- /dev/null +++ b/samples/client/petstore/java/src/main/java/io/swagger/client/JSON.java @@ -0,0 +1,51 @@ +package io.swagger.client; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.datatype.joda.*; + +import java.io.IOException; + +public class JSON { + private ObjectMapper mapper; + + public JSON() { + mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.registerModule(new JodaModule()); + } + + /** + * Serialize the given Java object into JSON string. + */ + public String serialize(Object obj) throws ApiException { + try { + if (obj != null) + return mapper.writeValueAsString(obj); + else + return null; + } catch (Exception e) { + throw new ApiException(400, e.getMessage()); + } + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param body The JSON string + * @param returnType The type to deserialize inot + * @return The deserialized Java object + */ + public T deserialize(String body, TypeRef returnType) throws ApiException { + JavaType javaType = mapper.constructType(returnType.getType()); + try { + return mapper.readValue(body, javaType); + } catch (IOException e) { + if (returnType.getType().equals(String.class)) + return (T) body; + else + throw new ApiException(500, e.getMessage(), null, body); + } + } +} diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/JsonUtil.java b/samples/client/petstore/java/src/main/java/io/swagger/client/JsonUtil.java deleted file mode 100644 index 8e7e686dd0ce..000000000000 --- a/samples/client/petstore/java/src/main/java/io/swagger/client/JsonUtil.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.swagger.client; - -import com.fasterxml.jackson.annotation.*; -import com.fasterxml.jackson.databind.*; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.core.JsonGenerator.Feature; - -import com.fasterxml.jackson.datatype.joda.*; - -public class JsonUtil { - public static ObjectMapper mapper; - - static { - mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); - mapper.registerModule(new JodaModule()); - } - - public static ObjectMapper getJsonMapper() { - return mapper; - } -} diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/TypeRef.java b/samples/client/petstore/java/src/main/java/io/swagger/client/TypeRef.java new file mode 100644 index 000000000000..6081df1082fa --- /dev/null +++ b/samples/client/petstore/java/src/main/java/io/swagger/client/TypeRef.java @@ -0,0 +1,25 @@ +package io.swagger.client; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; + +public class TypeRef { + private final Type type; + + public TypeRef() { + this.type = getGenericType(getClass()); + } + + private static Type getGenericType(Class klass) { + Type superclass = klass.getGenericSuperclass(); + if (superclass instanceof Class) { + throw new RuntimeException("No type parameter provided"); + } + ParameterizedType parameterized = (ParameterizedType) superclass; + return parameterized.getActualTypeArguments()[0]; + } + + public Type getType() { + return type; + } +} diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java index c9b7a2a917a6..c1657233fdc1 100644 --- a/samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java @@ -4,6 +4,7 @@ import io.swagger.client.ApiException; import io.swagger.client.ApiClient; import io.swagger.client.Configuration; import io.swagger.client.Pair; +import io.swagger.client.TypeRef; import io.swagger.client.model.*; @@ -12,11 +13,6 @@ import java.util.*; import io.swagger.client.model.Pet; import java.io.File; -import com.sun.jersey.multipart.FormDataMultiPart; -import com.sun.jersey.multipart.file.FileDataBodyPart; - -import javax.ws.rs.core.MediaType; - import java.io.File; import java.util.Map; import java.util.HashMap; @@ -57,7 +53,9 @@ public class PetApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -73,29 +71,10 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { "petstore_auth" }; - String response = apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + } /** @@ -114,7 +93,9 @@ public class PetApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -130,29 +111,10 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { "petstore_auth" }; - String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + } /** @@ -171,7 +133,7 @@ public class PetApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); queryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); @@ -179,6 +141,8 @@ public class PetApi { + + final String[] accepts = { "application/json", "application/xml" }; @@ -189,29 +153,11 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { "petstore_auth" }; - String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return (List) apiClient.deserialize(response, "array", Pet.class); - } - else { - return null; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { "petstore_auth" }; + + TypeRef returnType = new TypeRef>() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } /** @@ -230,7 +176,7 @@ public class PetApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); queryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); @@ -238,6 +184,8 @@ public class PetApi { + + final String[] accepts = { "application/json", "application/xml" }; @@ -248,29 +196,11 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { "petstore_auth" }; - String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return (List) apiClient.deserialize(response, "array", Pet.class); - } - else { - return null; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { "petstore_auth" }; + + TypeRef returnType = new TypeRef>() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } /** @@ -295,7 +225,9 @@ public class PetApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -311,29 +243,11 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { "api_key", "petstore_auth" }; - String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return (Pet) apiClient.deserialize(response, "", Pet.class); - } - else { - return null; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { "petstore_auth", "api_key" }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } /** @@ -360,12 +274,18 @@ public class PetApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + if (name != null) + formParams.put("name", name); + if (status != null) + formParams.put("status", status); + + final String[] accepts = { "application/json", "application/xml" }; @@ -376,43 +296,10 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if (name != null) { - hasFields = true; - mp.field("name", apiClient.parameterToString(name), MediaType.MULTIPART_FORM_DATA_TYPE); - } - - if (status != null) { - hasFields = true; - mp.field("status", apiClient.parameterToString(status), MediaType.MULTIPART_FORM_DATA_TYPE); - } - - if(hasFields) - postBody = mp; - } - else { - if (name != null) - formParams.put("name", apiClient.parameterToString(name)); - if (status != null) - formParams.put("status", apiClient.parameterToString(status)); - - } - - try { - String[] authNames = new String[] { "petstore_auth" }; - String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + } /** @@ -438,7 +325,7 @@ public class PetApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); @@ -446,6 +333,8 @@ public class PetApi { headerParams.put("api_key", apiClient.parameterToString(apiKey)); + + final String[] accepts = { "application/json", "application/xml" }; @@ -456,29 +345,10 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { "petstore_auth" }; - String response = apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + } /** @@ -505,12 +375,18 @@ public class PetApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + if (additionalMetadata != null) + formParams.put("additionalMetadata", additionalMetadata); + if (file != null) + formParams.put("file", file); + + final String[] accepts = { "application/json", "application/xml" }; @@ -521,43 +397,10 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if (additionalMetadata != null) { - hasFields = true; - mp.field("additionalMetadata", apiClient.parameterToString(additionalMetadata), MediaType.MULTIPART_FORM_DATA_TYPE); - } - - if (file != null) { - hasFields = true; - mp.field("file", file.getName()); - mp.bodyPart(new FileDataBodyPart("file", file, MediaType.MULTIPART_FORM_DATA_TYPE)); - } - - if(hasFields) - postBody = mp; - } - else { - if (additionalMetadata != null) - formParams.put("additionalMetadata", apiClient.parameterToString(additionalMetadata)); - - - } - - try { - String[] authNames = new String[] { "petstore_auth" }; - String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + } } diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java index 498b6d4a6b89..6a0c014f266d 100644 --- a/samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java @@ -4,6 +4,7 @@ import io.swagger.client.ApiException; import io.swagger.client.ApiClient; import io.swagger.client.Configuration; import io.swagger.client.Pair; +import io.swagger.client.TypeRef; import io.swagger.client.model.*; @@ -12,11 +13,6 @@ import java.util.*; import java.util.Map; import io.swagger.client.model.Order; -import com.sun.jersey.multipart.FormDataMultiPart; -import com.sun.jersey.multipart.file.FileDataBodyPart; - -import javax.ws.rs.core.MediaType; - import java.io.File; import java.util.Map; import java.util.HashMap; @@ -56,7 +52,9 @@ public class StoreApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -72,29 +70,11 @@ public class StoreApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { "api_key" }; - String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return (Map) apiClient.deserialize(response, "map", Map.class); - } - else { - return null; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { "api_key" }; + + TypeRef returnType = new TypeRef>() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } /** @@ -113,7 +93,9 @@ public class StoreApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -129,29 +111,11 @@ public class StoreApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { }; - String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return (Order) apiClient.deserialize(response, "", Order.class); - } - else { - return null; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } /** @@ -176,7 +140,9 @@ public class StoreApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -192,29 +158,11 @@ public class StoreApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { }; - String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return (Order) apiClient.deserialize(response, "", Order.class); - } - else { - return null; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } /** @@ -239,7 +187,9 @@ public class StoreApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -255,29 +205,10 @@ public class StoreApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { }; - String response = apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + } } diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java index 3bff204ac02b..0d408637cea8 100644 --- a/samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java @@ -4,6 +4,7 @@ import io.swagger.client.ApiException; import io.swagger.client.ApiClient; import io.swagger.client.Configuration; import io.swagger.client.Pair; +import io.swagger.client.TypeRef; import io.swagger.client.model.*; @@ -12,11 +13,6 @@ import java.util.*; import io.swagger.client.model.User; import java.util.*; -import com.sun.jersey.multipart.FormDataMultiPart; -import com.sun.jersey.multipart.file.FileDataBodyPart; - -import javax.ws.rs.core.MediaType; - import java.io.File; import java.util.Map; import java.util.HashMap; @@ -57,7 +53,9 @@ public class UserApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -73,29 +71,10 @@ public class UserApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { }; - String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + } /** @@ -114,7 +93,9 @@ public class UserApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -130,29 +111,10 @@ public class UserApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { }; - String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + } /** @@ -171,7 +133,9 @@ public class UserApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -187,29 +151,10 @@ public class UserApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { }; - String response = apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + } /** @@ -229,7 +174,7 @@ public class UserApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); queryParams.addAll(apiClient.parameterToPairs("", "username", username)); @@ -239,6 +184,8 @@ public class UserApi { + + final String[] accepts = { "application/json", "application/xml" }; @@ -249,29 +196,11 @@ public class UserApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { }; - String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return (String) apiClient.deserialize(response, "", String.class); - } - else { - return null; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } /** @@ -289,7 +218,9 @@ public class UserApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -305,29 +236,10 @@ public class UserApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { }; - String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + } /** @@ -352,7 +264,9 @@ public class UserApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -368,29 +282,11 @@ public class UserApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { }; - String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return (User) apiClient.deserialize(response, "", User.class); - } - else { - return null; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } /** @@ -416,7 +312,9 @@ public class UserApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -432,29 +330,10 @@ public class UserApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { }; - String response = apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + } /** @@ -479,7 +358,9 @@ public class UserApi { // query params List queryParams = new ArrayList(); Map headerParams = new HashMap(); - Map formParams = new HashMap(); + Map formParams = new HashMap(); + + @@ -495,29 +376,10 @@ public class UserApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - if(contentType.startsWith("multipart/form-data")) { - boolean hasFields = false; - FormDataMultiPart mp = new FormDataMultiPart(); - - if(hasFields) - postBody = mp; - } - else { - - } - - try { - String[] authNames = new String[] { }; - String response = apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames); - if(response != null){ - return ; - } - else { - return ; - } - } catch (ApiException ex) { - throw ex; - } + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + } } diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/src/main/java/io/swagger/client/model/Pet.java index d7c2038dead8..f5cdc5fb71f0 100644 --- a/samples/client/petstore/java/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/src/main/java/io/swagger/client/model/Pet.java @@ -1,8 +1,8 @@ package io.swagger.client.model; import io.swagger.client.model.Category; -import io.swagger.client.model.Tag; import java.util.*; +import io.swagger.client.model.Tag; import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; From d88ec847ae250ce74bb4e40f318216a065cf2958 Mon Sep 17 00:00:00 2001 From: xhh Date: Wed, 5 Aug 2015 09:43:15 +0800 Subject: [PATCH 018/109] Remave unused imports --- .../src/main/resources/Java/ApiClient.mustache | 3 --- .../swagger-codegen/src/main/resources/Java/pom.mustache | 6 +++++- samples/client/petstore/java/pom.xml | 6 +++++- .../java/src/main/java/io/swagger/client/ApiClient.java | 3 --- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache index b356dd365583..5e87f9e1a5af 100644 --- a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache @@ -1,8 +1,5 @@ package {{invokerPackage}}; -import com.fasterxml.jackson.databind.*; -import com.fasterxml.jackson.annotation.*; - import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.config.ClientConfig; diff --git a/modules/swagger-codegen/src/main/resources/Java/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/pom.mustache index 592edeec0518..315ea9e5b924 100644 --- a/modules/swagger-codegen/src/main/resources/Java/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/pom.mustache @@ -112,6 +112,8 @@ swagger-annotations ${swagger-annotations-version} + + com.sun.jersey jersey-client @@ -122,6 +124,8 @@ jersey-multipart ${jersey-version} + + com.fasterxml.jackson.core jackson-core @@ -141,7 +145,7 @@ com.fasterxml.jackson.datatype jackson-datatype-joda 2.1.5 - + joda-time joda-time diff --git a/samples/client/petstore/java/pom.xml b/samples/client/petstore/java/pom.xml index 058733e08fcd..3cef1c564c91 100644 --- a/samples/client/petstore/java/pom.xml +++ b/samples/client/petstore/java/pom.xml @@ -112,6 +112,8 @@ swagger-annotations ${swagger-annotations-version} + + com.sun.jersey jersey-client @@ -122,6 +124,8 @@ jersey-multipart ${jersey-version} + + com.fasterxml.jackson.core jackson-core @@ -141,7 +145,7 @@ com.fasterxml.jackson.datatype jackson-datatype-joda 2.1.5 - + joda-time joda-time diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java index 305f91ce7207..c02c9877df4b 100644 --- a/samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java @@ -1,8 +1,5 @@ package io.swagger.client; -import com.fasterxml.jackson.databind.*; -import com.fasterxml.jackson.annotation.*; - import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.config.ClientConfig; From 4ba521a5c081996139bdb91c7838ede21e20a8db Mon Sep 17 00:00:00 2001 From: xhh Date: Wed, 5 Aug 2015 15:37:26 +0800 Subject: [PATCH 019/109] Add jersey2 library template for Java client --- .../Java/libraries/jersey2/ApiClient.mustache | 533 ++++++++++++++++++ .../Java/libraries/jersey2/pom.mustache | 171 ++++++ 2 files changed, 704 insertions(+) create mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache new file mode 100644 index 000000000000..35a1cf242427 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiClient.mustache @@ -0,0 +1,533 @@ +package {{invokerPackage}}; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.Form; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; + +import org.glassfish.jersey.client.ClientConfig; +import org.glassfish.jersey.filter.LoggingFilter; +import org.glassfish.jersey.media.multipart.FormDataBodyPart; +import org.glassfish.jersey.media.multipart.FormDataMultiPart; +import org.glassfish.jersey.media.multipart.MultiPart; +import org.glassfish.jersey.media.multipart.MultiPartFeature; +import org.glassfish.jersey.media.multipart.file.FileDataBodyPart; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.Map.Entry; +import java.util.HashMap; +import java.util.List; +import java.util.ArrayList; +import java.util.Date; +import java.util.TimeZone; + +import java.net.URLEncoder; + +import java.io.IOException; +import java.io.File; +import java.io.UnsupportedEncodingException; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.text.ParseException; + +import {{invokerPackage}}.auth.Authentication; +import {{invokerPackage}}.auth.HttpBasicAuth; +import {{invokerPackage}}.auth.ApiKeyAuth; +import {{invokerPackage}}.auth.OAuth; + +public class ApiClient { + private Map hostMap = new HashMap(); + private Map defaultHeaderMap = new HashMap(); + private boolean debugging = false; + private String basePath = "{{basePath}}"; + private JSON json = new JSON(); + + private Map authentications; + + private DateFormat dateFormat; + + public ApiClient() { + // Use ISO 8601 format for date and datetime. + // See https://en.wikipedia.org/wiki/ISO_8601 + this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + + // Use UTC as the default time zone. + this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + + // Set default User-Agent. + setUserAgent("Java-Swagger"); + + // Setup authentications (key: authentication name, value: authentication). + authentications = new HashMap();{{#authMethods}}{{#isBasic}} + authentications.put("{{name}}", new HttpBasicAuth());{{/isBasic}}{{#isApiKey}} + authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}} + authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}} + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + public String getBasePath() { + return basePath; + } + + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + /** + * Helper method to set username for the first HTTP basic authentication. + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + */ + public ApiClient setDebugging(boolean debugging) { + this.debugging = debugging; + return this; + } + + /** + * Get the date format used to parse/format date parameters. + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + * Set the date format used to parse/format date parameters. + */ + public ApiClient getDateFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + return this; + } + + /** + * Parse the given string into Date object. + */ + public Date parseDate(String str) { + try { + return dateFormat.parse(str); + } catch (java.text.ParseException e) { + throw new RuntimeException(e); + } + } + + /** + * Format the given Date object into string. + */ + public String formatDate(Date date) { + return dateFormat.format(date); + } + + /** + * Format the given parameter object into string. + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date) { + return formatDate((Date) param); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for(Object o : (Collection)param) { + if(b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /* + Format to {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Object value){ + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null) return params; + + Collection valueCollection = null; + if (value instanceof Collection) { + valueCollection = (Collection) value; + } else { + params.add(new Pair(name, parameterToString(value))); + return params; + } + + if (valueCollection.isEmpty()){ + return params; + } + + // get the collection format + collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv + + // create the params based on the collection format + if (collectionFormat.equals("multi")) { + for (Object item : valueCollection) { + params.add(new Pair(name, parameterToString(item))); + } + + return params; + } + + String delimiter = ","; + + if (collectionFormat.equals("csv")) { + delimiter = ","; + } else if (collectionFormat.equals("ssv")) { + delimiter = " "; + } else if (collectionFormat.equals("tsv")) { + delimiter = "\t"; + } else if (collectionFormat.equals("pipes")) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : valueCollection) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + params.add(new Pair(name, sb.substring(1))); + + return params; + } + + /** + * Select the Accept header's value from the given accepts array: + * if JSON exists in the given array, use it; + * otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, + * null will be returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) return null; + if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json"; + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: + * if JSON exists in the given array, use it; + * otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, + * JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) return "application/json"; + if (StringUtil.containsIgnoreCase(contentTypes, "application/json")) return "application/json"; + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Serialize the given Java object into string entity according the given + * Content-Type (only JSON is supported for now). + */ + public Entity serialize(Object obj, String contentType) throws ApiException { + if (contentType.startsWith("application/json")) { + return Entity.json(json.serialize(obj)); + } else { + throw new ApiException(400, "can not serialize object into Content-Type: " + contentType); + } + } + + /** + * Deserialize response body to Java object according to the Content-Type. + */ + public T deserialize(Response response, TypeRef returnType) throws ApiException { + String contentType = null; + List contentTypes = response.getHeaders().get("Content-Type"); + if (contentTypes != null && !contentTypes.isEmpty()) + contentType = String.valueOf(contentTypes.get(0)); + if (contentType == null) + throw new ApiException(500, "missing Content-Type in response"); + + String body; + if (response.hasEntity()) + body = (String) response.readEntity(String.class); + else + body = ""; + + if (contentType.startsWith("application/json")) { + return json.deserialize(body, returnType); + } else { + throw new ApiException(500, "can not deserialize Content-Type: " + contentType); + } + } + + /** + * Invoke API by sending HTTP request with the given options. + * + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "POST", "PUT", and "DELETE" + * @param queryParams The query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param formParams The form parameters + * @param accept The request's Accept header + * @param contentType The request's Content-Type header + * @param authNames The authentications to apply + * @param returnType The return type into which to deserialize the response + * @return The response body in type of string + */ + public T invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, TypeRef returnType) throws ApiException { + updateParamsForAuth(authNames, queryParams, headerParams); + + final ClientConfig clientConfig = new ClientConfig(); + clientConfig.register(MultiPartFeature.class); + if (debugging) { + clientConfig.register(LoggingFilter.class); + } + Client client = ClientBuilder.newClient(clientConfig); + + WebTarget target = client.target(this.basePath).path(path); + + if (queryParams != null) { + for (Pair queryParam : queryParams) { + if (queryParam.getValue() != null) { + target = target.queryParam(queryParam.getName(), queryParam.getValue()); + } + } + } + + Invocation.Builder invocationBuilder = target.request(contentType).accept(accept); + + for (String key : headerParams.keySet()) { + String value = headerParams.get(key); + if (value != null) { + invocationBuilder = invocationBuilder.header(key, value); + } + } + + for (String key : defaultHeaderMap.keySet()) { + if (!headerParams.containsKey(key)) { + String value = defaultHeaderMap.get(key); + if (value != null) { + invocationBuilder = invocationBuilder.header(key, value); + } + } + } + + Entity formEntity = null; + + if (contentType.startsWith("multipart/form-data")) { + MultiPart multipart = new MultiPart(); + for (Entry param: formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + + FormDataMultiPart mp = new FormDataMultiPart(); + mp.bodyPart(new FormDataBodyPart(param.getKey(), file.getName())); + multipart.bodyPart(mp, MediaType.MULTIPART_FORM_DATA_TYPE); + + multipart.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.APPLICATION_OCTET_STREAM_TYPE)); + } else { + FormDataMultiPart mp = new FormDataMultiPart(); + mp.bodyPart(new FormDataBodyPart(param.getKey(), parameterToString(param.getValue()))); + multipart.bodyPart(mp, MediaType.MULTIPART_FORM_DATA_TYPE); + } + } + formEntity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE); + } else if (contentType.startsWith("application/x-www-form-urlencoded")) { + Form form = new Form(); + for (Entry param: formParams.entrySet()) { + form.param(param.getKey(), parameterToString(param.getValue())); + } + formEntity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE); + } + + Response response = null; + + if ("GET".equals(method)) { + response = invocationBuilder.get(); + } else if ("POST".equals(method)) { + if (formEntity != null) { + response = invocationBuilder.post(formEntity); + } else if (body == null) { + response = invocationBuilder.post(null); + } else { + response = invocationBuilder.post(serialize(body, contentType)); + } + } else if ("PUT".equals(method)) { + if (formEntity != null) { + response = invocationBuilder.put(formEntity); + } else if (body == null) { + response = invocationBuilder.put(null); + } else { + response = invocationBuilder.put(serialize(body, contentType)); + } + } else if ("DELETE".equals(method)) { + response = invocationBuilder.delete(); + } else { + throw new ApiException(500, "unknown method type " + method); + } + + if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) { + return null; + } else if (response.getStatusInfo().getFamily().equals(Status.Family.SUCCESSFUL)) { + if (returnType == null) + return null; + else + return deserialize(response, returnType); + } else { + String message = "error"; + String respBody = null; + if (response.hasEntity()) { + try { + respBody = String.valueOf(response.readEntity(String.class)); + message = respBody; + } catch (RuntimeException e) { + // e.printStackTrace(); + } + } + Map> responseHeaders = new HashMap>(); + for (String key: response.getHeaders().keySet()) { + List values = response.getHeaders().get(key); + List headers = new ArrayList(); + for (Object o : values) { + headers.add(String.valueOf(o)); + } + responseHeaders.put(key, headers); + } + throw new ApiException( + response.getStatus(), + message, + responseHeaders, + respBody); + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + */ + private void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams) { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); + auth.applyToParams(queryParams, headerParams); + } + } +} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache new file mode 100644 index 000000000000..e2d0f73d408e --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache @@ -0,0 +1,171 @@ + + 4.0.0 + {{groupId}} + {{artifactId}} + jar + {{artifactId}} + {{artifactVersion}} + + scm:git:git@github.com:swagger-api/swagger-mustache.git + scm:git:git@github.com:swagger-api/swagger-codegen.git + https://github.com/swagger-api/swagger-codegen + + + 2.2.0 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + pertest + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add_sources + generate-sources + + add-source + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + + + + io.swagger + swagger-annotations + ${swagger-annotations-version} + + + + + org.glassfish.jersey.core + jersey-client + ${jersey-version} + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey-version} + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-version} + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + 2.1.5 + + + joda-time + joda-time + ${jodatime-version} + + + + + junit + junit + ${junit-version} + test + + + + 1.5.0 + 2.6 + 2.4.2 + 2.3 + 1.0.0 + 4.8.1 + + From 07f10a8abc7204594df2369bee77513a507f955b Mon Sep 17 00:00:00 2001 From: xhh Date: Wed, 5 Aug 2015 16:37:08 +0800 Subject: [PATCH 020/109] Add command to display all library templates supported for a specific language --- README.md | 23 +++++++- .../io/swagger/codegen/SwaggerCodegen.java | 4 +- .../java/io/swagger/codegen/cmd/Generate.java | 3 +- .../io/swagger/codegen/cmd/LibraryHelp.java | 55 +++++++++++++++++++ .../io/swagger/codegen/CodegenConfig.java | 2 + .../io/swagger/codegen/DefaultCodegen.java | 10 ++++ .../io/swagger/codegen/DefaultGenerator.java | 2 +- .../codegen/languages/JavaClientCodegen.java | 3 + 8 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/LibraryHelp.java diff --git a/README.md b/README.md index f52c4097347c..72daf8612512 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,10 @@ OPTIONS client language to generate (maybe class name in classpath, required) + -L , --library + Library template (sub-template) to use. Run library-help -l {lang} + command for a list of supported libraries. + -o , --output where to write the generated files (current dir by default) @@ -128,7 +132,7 @@ OPTIONS -s , --skip-overwrite specifies if the existing files should be overwritten during the generation - ``` +``` You can then compile and run the client, as well as unit tests against it: @@ -144,6 +148,23 @@ Other languages have petstore samples, too: ./bin/objc-petstore.sh ``` +Various library templates (sub-templates) might be available for a specific language. Running `library-help -l {lang}` will show all library templates supported. + +``` +java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar library-help -l java +``` + +Output + +``` +LIBRARY OPTIONS + + HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2 + + jersey2 + HTTP client: Jersey client 2.6 +``` + ### Generating libraries from your server It's just as easy--just use the `-i` flag to point to either a server or file. diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java index 3cdc01fe3f5a..2dec1fe26daa 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java @@ -5,6 +5,7 @@ import io.airlift.airline.Help; import io.swagger.codegen.cmd.ConfigHelp; import io.swagger.codegen.cmd.Generate; import io.swagger.codegen.cmd.Langs; +import io.swagger.codegen.cmd.LibraryHelp; import io.swagger.codegen.cmd.Meta; /** @@ -29,7 +30,8 @@ public class SwaggerCodegen { Meta.class, Langs.class, Help.class, - ConfigHelp.class + ConfigHelp.class, + LibraryHelp.class ); builder.build().parse(args).run(); diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java index 1386ae469a9b..99f597740d9d 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java @@ -41,7 +41,8 @@ public class Generate implements Runnable { private String lang; @Option(name = {"-L", "--library"}, title = "library", - description = "library template (sub-template) to use") + description = "Library template (sub-template) to use. Run library-help -l {lang} " + + "command for a list of supported libraries.") private String library; @Option(name = {"-o", "--output"}, title = "output directory", diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/LibraryHelp.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/LibraryHelp.java new file mode 100644 index 000000000000..480286f90f7c --- /dev/null +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/LibraryHelp.java @@ -0,0 +1,55 @@ +package io.swagger.codegen.cmd; + +import io.airlift.airline.Command; +import io.airlift.airline.Option; +import io.swagger.codegen.CliOption; +import io.swagger.codegen.CodegenConfig; + +import java.util.ServiceLoader; + +import static java.util.ServiceLoader.load; + +@Command(name = "library-help", description = "Library help for chosen lang") +public class LibraryHelp implements Runnable { + + @Option(name = {"-l", "--lang"}, title = "language", required = true, + description = "language to get library help for") + private String lang; + + /** + * Tries to load config class with SPI first, then with class name directly from classpath + * + * @param name name of config, or full qualified class name in classpath + * @return config class + */ + private static CodegenConfig forName(String name) { + ServiceLoader loader = load(CodegenConfig.class); + for (CodegenConfig config : loader) { + if (config.getName().equals(name)) { + return config; + } + } + + // else try to load directly + try { + return (CodegenConfig) Class.forName(name).newInstance(); + } catch (Exception e) { + throw new RuntimeException("Can't load config class with name ".concat(name), e); + } + } + + @Override + public void run() { + System.out.println(); + CodegenConfig config = forName(lang); + System.out.println("LIBRARY OPTIONS"); + for (String library : config.supportedLibraries().keySet()) { + String description = config.supportedLibraries().get(library); + if ("".equals(library)) + library = ""; + System.out.println("\t" + library); + System.out.println("\t " + description); + System.out.println(); + } + } +} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java index 45c8cc5e9f83..9cbf32a154c7 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java @@ -109,6 +109,8 @@ public interface CodegenConfig { void setSkipOverwrite(boolean skipOverwrite); + Map supportedLibraries(); + void setLibrary(String library); /** 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 aaf62b4a11b9..641fa43b6d4b 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 @@ -81,6 +81,7 @@ public class DefaultCodegen { protected List cliOptions = new ArrayList(); protected boolean skipOverwrite; protected boolean supportsInheritance = false; + protected Map supportedLibraries = new HashMap(); protected String library = null; public List cliOptions() { @@ -1389,7 +1390,16 @@ public class DefaultCodegen { this.skipOverwrite = skipOverwrite; } + /** + * All library templates supported. + */ + public Map supportedLibraries() { + return supportedLibraries; + } + public void setLibrary(String library) { + if (library != null && !supportedLibraries.containsKey(library)) + throw new RuntimeException("unknown library: " + library); this.library = library; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 4feb75acf4ea..50b549dd6f60 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -266,7 +266,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { String templateFile = null; String library = config.getLibrary(); - if (library != null) { + if (library != null && !"".equals(library)) { String libTemplateFile = config.templateDir() + File.separator + "libraries" + File.separator + library + File.separator + support.templateFile; 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 88266aa76cc1..4df04fc9a1c8 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 @@ -61,6 +61,9 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { cliOptions.add(new CliOption("artifactId", "artifactId in generated pom.xml")); cliOptions.add(new CliOption("artifactVersion", "artifact version in generated pom.xml")); cliOptions.add(new CliOption("sourceFolder", "source folder for generated code")); + + supportedLibraries.put("", "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2"); + supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6"); } public CodegenType getTag() { From 4321339d4f88493787127707290eb0b3a167551d Mon Sep 17 00:00:00 2001 From: xhh Date: Wed, 5 Aug 2015 17:28:45 +0800 Subject: [PATCH 021/109] Java petstore sample: move to "default" sub-folder, add jersey2 --- bin/all-petstore.sh | 1 + bin/java-petstore-jersey2.json | 1 + bin/java-petstore-jersey2.sh | 31 + bin/java-petstore.sh | 2 +- pom.xml | 17 +- .../client/petstore/java/default/hello.txt | 1 + .../petstore/java/{ => default}/pom.xml | 0 .../java/io/swagger/client/ApiClient.java | 0 .../java/io/swagger/client/ApiException.java | 0 .../java/io/swagger/client/Configuration.java | 0 .../src/main/java/io/swagger/client/JSON.java | 0 .../src/main/java/io/swagger/client/Pair.java | 0 .../java/io/swagger/client/StringUtil.java | 0 .../main/java/io/swagger/client/TypeRef.java | 0 .../java/io/swagger/client/api/PetApi.java | 2 +- .../java/io/swagger/client/api/StoreApi.java | 0 .../java/io/swagger/client/api/UserApi.java | 0 .../io/swagger/client/auth/ApiKeyAuth.java | 0 .../swagger/client/auth/Authentication.java | 0 .../io/swagger/client/auth/HttpBasicAuth.java | 0 .../java/io/swagger/client/auth/OAuth.java | 0 .../io/swagger/client/model/Category.java | 0 .../java/io/swagger/client/model/Order.java | 0 .../java/io/swagger/client/model/Pet.java | 2 +- .../java/io/swagger/client/model/Tag.java | 0 .../java/io/swagger/client/model/User.java | 0 .../java/io/swagger/client/ApiClientTest.java | 0 .../io/swagger/client/ConfigurationTest.java | 0 .../io/swagger/client/StringUtilTest.java | 0 .../swagger/client/auth/ApiKeyAuthTest.java | 0 .../client/auth/HttpBasicAuthTest.java | 0 .../io/swagger/petstore/test/PetApiTest.java | 0 .../swagger/petstore/test/StoreApiTest.java | 0 .../io/swagger/petstore/test/UserApiTest.java | 0 .../client/petstore/java/jersey2/hello.txt | 1 + samples/client/petstore/java/jersey2/pom.xml | 171 ++++++ .../java/io/swagger/client/ApiClient.java | 532 ++++++++++++++++++ .../java/io/swagger/client/ApiException.java | 47 ++ .../java/io/swagger/client/Configuration.java | 21 + .../src/main/java/io/swagger/client/JSON.java | 51 ++ .../src/main/java/io/swagger/client/Pair.java | 38 ++ .../java/io/swagger/client/StringUtil.java | 41 ++ .../main/java/io/swagger/client/TypeRef.java | 25 + .../java/io/swagger/client/api/PetApi.java | 406 +++++++++++++ .../java/io/swagger/client/api/StoreApi.java | 214 +++++++ .../java/io/swagger/client/api/UserApi.java | 385 +++++++++++++ .../io/swagger/client/auth/ApiKeyAuth.java | 58 ++ .../swagger/client/auth/Authentication.java | 11 + .../io/swagger/client/auth/HttpBasicAuth.java | 40 ++ .../java/io/swagger/client/auth/OAuth.java | 13 + .../io/swagger/client/model/Category.java | 50 ++ .../java/io/swagger/client/model/Order.java | 111 ++++ .../java/io/swagger/client/model/Pet.java | 113 ++++ .../java/io/swagger/client/model/Tag.java | 50 ++ .../java/io/swagger/client/model/User.java | 135 +++++ .../java/io/swagger/client/ApiClientTest.java | 193 +++++++ .../io/swagger/client/ConfigurationTest.java | 15 + .../io/swagger/client/StringUtilTest.java | 33 ++ .../swagger/client/auth/ApiKeyAuthTest.java | 47 ++ .../client/auth/HttpBasicAuthTest.java | 52 ++ .../io/swagger/petstore/test/PetApiTest.java | 192 +++++++ .../swagger/petstore/test/StoreApiTest.java | 72 +++ .../io/swagger/petstore/test/UserApiTest.java | 86 +++ 63 files changed, 3255 insertions(+), 5 deletions(-) create mode 100644 bin/java-petstore-jersey2.json create mode 100755 bin/java-petstore-jersey2.sh create mode 100644 samples/client/petstore/java/default/hello.txt rename samples/client/petstore/java/{ => default}/pom.xml (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/ApiClient.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/ApiException.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/Configuration.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/JSON.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/Pair.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/StringUtil.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/TypeRef.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/api/PetApi.java (99%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/api/StoreApi.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/api/UserApi.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/auth/ApiKeyAuth.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/auth/Authentication.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/auth/HttpBasicAuth.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/auth/OAuth.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/model/Category.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/model/Order.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/model/Pet.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/model/Tag.java (100%) rename samples/client/petstore/java/{ => default}/src/main/java/io/swagger/client/model/User.java (100%) rename samples/client/petstore/java/{ => default}/src/test/java/io/swagger/client/ApiClientTest.java (100%) rename samples/client/petstore/java/{ => default}/src/test/java/io/swagger/client/ConfigurationTest.java (100%) rename samples/client/petstore/java/{ => default}/src/test/java/io/swagger/client/StringUtilTest.java (100%) rename samples/client/petstore/java/{ => default}/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java (100%) rename samples/client/petstore/java/{ => default}/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java (100%) rename samples/client/petstore/java/{ => default}/src/test/java/io/swagger/petstore/test/PetApiTest.java (100%) rename samples/client/petstore/java/{ => default}/src/test/java/io/swagger/petstore/test/StoreApiTest.java (100%) rename samples/client/petstore/java/{ => default}/src/test/java/io/swagger/petstore/test/UserApiTest.java (100%) create mode 100644 samples/client/petstore/java/jersey2/hello.txt create mode 100644 samples/client/petstore/java/jersey2/pom.xml create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/TypeRef.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/Authentication.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java create mode 100644 samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java create mode 100644 samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ConfigurationTest.java create mode 100644 samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/StringUtilTest.java create mode 100644 samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java create mode 100644 samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java create mode 100644 samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java create mode 100644 samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java create mode 100644 samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/UserApiTest.java diff --git a/bin/all-petstore.sh b/bin/all-petstore.sh index 7a47662a7c7c..23c2935ed2ae 100755 --- a/bin/all-petstore.sh +++ b/bin/all-petstore.sh @@ -24,6 +24,7 @@ cd $APP_DIR ./bin/dynamic-html.sh ./bin/html-petstore.sh ./bin/java-petstore.sh +./bin/java-petstore-jersey2.sh ./bin/jaxrs-petstore-server.sh ./bin/nodejs-petstore-server.sh ./bin/objc-petstore.sh diff --git a/bin/java-petstore-jersey2.json b/bin/java-petstore-jersey2.json new file mode 100644 index 000000000000..1ba121afe219 --- /dev/null +++ b/bin/java-petstore-jersey2.json @@ -0,0 +1 @@ +{"artifactId": "swagger-petstore-jersey2"} \ No newline at end of file diff --git a/bin/java-petstore-jersey2.sh b/bin/java-petstore-jersey2.sh new file mode 100755 index 000000000000..94f16422d1af --- /dev/null +++ b/bin/java-petstore-jersey2.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.json -l java --library jersey2 -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore.sh b/bin/java-petstore.sh index 3beff2f07cec..f842d9ca3b0e 100755 --- a/bin/java-petstore.sh +++ b/bin/java-petstore.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 -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java/default" java $JAVA_OPTS -jar $executable $ags diff --git a/pom.xml b/pom.xml index 45fba414722a..f476f7aae011 100644 --- a/pom.xml +++ b/pom.xml @@ -292,7 +292,19 @@ - samples/client/petstore/java + samples/client/petstore/java/default + + + + java-client-jersey2 + + + env + java + + + + samples/client/petstore/java/jersey2 @@ -377,7 +389,8 @@ samples/client/petstore/android-java - samples/client/petstore/java + samples/client/petstore/java/default + samples/client/petstore/java/jersey2 samples/client/petstore/scala samples/server/petstore/jaxrs samples/server/petstore/spring-mvc diff --git a/samples/client/petstore/java/default/hello.txt b/samples/client/petstore/java/default/hello.txt new file mode 100644 index 000000000000..6769dd60bdf5 --- /dev/null +++ b/samples/client/petstore/java/default/hello.txt @@ -0,0 +1 @@ +Hello world! \ No newline at end of file diff --git a/samples/client/petstore/java/pom.xml b/samples/client/petstore/java/default/pom.xml similarity index 100% rename from samples/client/petstore/java/pom.xml rename to samples/client/petstore/java/default/pom.xml diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/ApiException.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/Configuration.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/JSON.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/Pair.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/StringUtil.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/TypeRef.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/TypeRef.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java similarity index 99% rename from samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index c1657233fdc1..d1aee33af002 100644 --- a/samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -243,7 +243,7 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { "petstore_auth", "api_key" }; + String[] authNames = new String[] { "api_key", "petstore_auth" }; TypeRef returnType = new TypeRef() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/auth/ApiKeyAuth.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/auth/Authentication.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/auth/Authentication.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/auth/HttpBasicAuth.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/auth/OAuth.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/model/Category.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/model/Order.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/model/Pet.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java index f5cdc5fb71f0..d7c2038dead8 100644 --- a/samples/client/petstore/java/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java @@ -1,8 +1,8 @@ package io.swagger.client.model; import io.swagger.client.model.Category; -import java.util.*; import io.swagger.client.model.Tag; +import java.util.*; import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/model/Tag.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java diff --git a/samples/client/petstore/java/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java similarity index 100% rename from samples/client/petstore/java/src/main/java/io/swagger/client/model/User.java rename to samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java diff --git a/samples/client/petstore/java/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java similarity index 100% rename from samples/client/petstore/java/src/test/java/io/swagger/client/ApiClientTest.java rename to samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java diff --git a/samples/client/petstore/java/src/test/java/io/swagger/client/ConfigurationTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/client/ConfigurationTest.java similarity index 100% rename from samples/client/petstore/java/src/test/java/io/swagger/client/ConfigurationTest.java rename to samples/client/petstore/java/default/src/test/java/io/swagger/client/ConfigurationTest.java diff --git a/samples/client/petstore/java/src/test/java/io/swagger/client/StringUtilTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/client/StringUtilTest.java similarity index 100% rename from samples/client/petstore/java/src/test/java/io/swagger/client/StringUtilTest.java rename to samples/client/petstore/java/default/src/test/java/io/swagger/client/StringUtilTest.java diff --git a/samples/client/petstore/java/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java similarity index 100% rename from samples/client/petstore/java/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java rename to samples/client/petstore/java/default/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java diff --git a/samples/client/petstore/java/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java similarity index 100% rename from samples/client/petstore/java/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java rename to samples/client/petstore/java/default/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java diff --git a/samples/client/petstore/java/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java similarity index 100% rename from samples/client/petstore/java/src/test/java/io/swagger/petstore/test/PetApiTest.java rename to samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java diff --git a/samples/client/petstore/java/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java similarity index 100% rename from samples/client/petstore/java/src/test/java/io/swagger/petstore/test/StoreApiTest.java rename to samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java diff --git a/samples/client/petstore/java/src/test/java/io/swagger/petstore/test/UserApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/UserApiTest.java similarity index 100% rename from samples/client/petstore/java/src/test/java/io/swagger/petstore/test/UserApiTest.java rename to samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/UserApiTest.java diff --git a/samples/client/petstore/java/jersey2/hello.txt b/samples/client/petstore/java/jersey2/hello.txt new file mode 100644 index 000000000000..6769dd60bdf5 --- /dev/null +++ b/samples/client/petstore/java/jersey2/hello.txt @@ -0,0 +1 @@ +Hello world! \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2/pom.xml b/samples/client/petstore/java/jersey2/pom.xml new file mode 100644 index 000000000000..eee88cd24293 --- /dev/null +++ b/samples/client/petstore/java/jersey2/pom.xml @@ -0,0 +1,171 @@ + + 4.0.0 + io.swagger + swagger-petstore-jersey2 + jar + swagger-petstore-jersey2 + 1.0.0 + + scm:git:git@github.com:swagger-api/swagger-mustache.git + scm:git:git@github.com:swagger-api/swagger-codegen.git + https://github.com/swagger-api/swagger-codegen + + + 2.2.0 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + pertest + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add_sources + generate-sources + + add-source + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + + + + io.swagger + swagger-annotations + ${swagger-annotations-version} + + + + + org.glassfish.jersey.core + jersey-client + ${jersey-version} + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey-version} + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-version} + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + 2.1.5 + + + joda-time + joda-time + ${jodatime-version} + + + + + junit + junit + ${junit-version} + test + + + + 1.5.0 + 2.6 + 2.4.2 + 2.3 + 1.0.0 + 4.8.1 + + diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java new file mode 100644 index 000000000000..52ce291a7684 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java @@ -0,0 +1,532 @@ +package io.swagger.client; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.Form; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; + +import org.glassfish.jersey.client.ClientConfig; +import org.glassfish.jersey.filter.LoggingFilter; +import org.glassfish.jersey.media.multipart.FormDataBodyPart; +import org.glassfish.jersey.media.multipart.FormDataMultiPart; +import org.glassfish.jersey.media.multipart.MultiPart; +import org.glassfish.jersey.media.multipart.MultiPartFeature; +import org.glassfish.jersey.media.multipart.file.FileDataBodyPart; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.Map.Entry; +import java.util.HashMap; +import java.util.List; +import java.util.ArrayList; +import java.util.Date; +import java.util.TimeZone; + +import java.net.URLEncoder; + +import java.io.IOException; +import java.io.File; +import java.io.UnsupportedEncodingException; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.text.ParseException; + +import io.swagger.client.auth.Authentication; +import io.swagger.client.auth.HttpBasicAuth; +import io.swagger.client.auth.ApiKeyAuth; +import io.swagger.client.auth.OAuth; + +public class ApiClient { + private Map hostMap = new HashMap(); + private Map defaultHeaderMap = new HashMap(); + private boolean debugging = false; + private String basePath = "http://petstore.swagger.io/v2"; + private JSON json = new JSON(); + + private Map authentications; + + private DateFormat dateFormat; + + public ApiClient() { + // Use ISO 8601 format for date and datetime. + // See https://en.wikipedia.org/wiki/ISO_8601 + this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + + // Use UTC as the default time zone. + this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + + // Set default User-Agent. + setUserAgent("Java-Swagger"); + + // Setup authentications (key: authentication name, value: authentication). + authentications = new HashMap(); + authentications.put("api_key", new ApiKeyAuth("header", "api_key")); + authentications.put("petstore_auth", new OAuth()); + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + public String getBasePath() { + return basePath; + } + + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + /** + * Helper method to set username for the first HTTP basic authentication. + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + */ + public ApiClient setDebugging(boolean debugging) { + this.debugging = debugging; + return this; + } + + /** + * Get the date format used to parse/format date parameters. + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + * Set the date format used to parse/format date parameters. + */ + public ApiClient getDateFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + return this; + } + + /** + * Parse the given string into Date object. + */ + public Date parseDate(String str) { + try { + return dateFormat.parse(str); + } catch (java.text.ParseException e) { + throw new RuntimeException(e); + } + } + + /** + * Format the given Date object into string. + */ + public String formatDate(Date date) { + return dateFormat.format(date); + } + + /** + * Format the given parameter object into string. + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date) { + return formatDate((Date) param); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for(Object o : (Collection)param) { + if(b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /* + Format to {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Object value){ + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null) return params; + + Collection valueCollection = null; + if (value instanceof Collection) { + valueCollection = (Collection) value; + } else { + params.add(new Pair(name, parameterToString(value))); + return params; + } + + if (valueCollection.isEmpty()){ + return params; + } + + // get the collection format + collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv + + // create the params based on the collection format + if (collectionFormat.equals("multi")) { + for (Object item : valueCollection) { + params.add(new Pair(name, parameterToString(item))); + } + + return params; + } + + String delimiter = ","; + + if (collectionFormat.equals("csv")) { + delimiter = ","; + } else if (collectionFormat.equals("ssv")) { + delimiter = " "; + } else if (collectionFormat.equals("tsv")) { + delimiter = "\t"; + } else if (collectionFormat.equals("pipes")) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : valueCollection) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + params.add(new Pair(name, sb.substring(1))); + + return params; + } + + /** + * Select the Accept header's value from the given accepts array: + * if JSON exists in the given array, use it; + * otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, + * null will be returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) return null; + if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json"; + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: + * if JSON exists in the given array, use it; + * otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, + * JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) return "application/json"; + if (StringUtil.containsIgnoreCase(contentTypes, "application/json")) return "application/json"; + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Serialize the given Java object into string entity according the given + * Content-Type (only JSON is supported for now). + */ + public Entity serialize(Object obj, String contentType) throws ApiException { + if (contentType.startsWith("application/json")) { + return Entity.json(json.serialize(obj)); + } else { + throw new ApiException(400, "can not serialize object into Content-Type: " + contentType); + } + } + + /** + * Deserialize response body to Java object according to the Content-Type. + */ + public T deserialize(Response response, TypeRef returnType) throws ApiException { + String contentType = null; + List contentTypes = response.getHeaders().get("Content-Type"); + if (contentTypes != null && !contentTypes.isEmpty()) + contentType = String.valueOf(contentTypes.get(0)); + if (contentType == null) + throw new ApiException(500, "missing Content-Type in response"); + + String body; + if (response.hasEntity()) + body = (String) response.readEntity(String.class); + else + body = ""; + + if (contentType.startsWith("application/json")) { + return json.deserialize(body, returnType); + } else { + throw new ApiException(500, "can not deserialize Content-Type: " + contentType); + } + } + + /** + * Invoke API by sending HTTP request with the given options. + * + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "POST", "PUT", and "DELETE" + * @param queryParams The query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param formParams The form parameters + * @param accept The request's Accept header + * @param contentType The request's Content-Type header + * @param authNames The authentications to apply + * @param returnType The return type into which to deserialize the response + * @return The response body in type of string + */ + public T invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, TypeRef returnType) throws ApiException { + updateParamsForAuth(authNames, queryParams, headerParams); + + final ClientConfig clientConfig = new ClientConfig(); + clientConfig.register(MultiPartFeature.class); + if (debugging) { + clientConfig.register(LoggingFilter.class); + } + Client client = ClientBuilder.newClient(clientConfig); + + WebTarget target = client.target(this.basePath).path(path); + + if (queryParams != null) { + for (Pair queryParam : queryParams) { + if (queryParam.getValue() != null) { + target = target.queryParam(queryParam.getName(), queryParam.getValue()); + } + } + } + + Invocation.Builder invocationBuilder = target.request(contentType).accept(accept); + + for (String key : headerParams.keySet()) { + String value = headerParams.get(key); + if (value != null) { + invocationBuilder = invocationBuilder.header(key, value); + } + } + + for (String key : defaultHeaderMap.keySet()) { + if (!headerParams.containsKey(key)) { + String value = defaultHeaderMap.get(key); + if (value != null) { + invocationBuilder = invocationBuilder.header(key, value); + } + } + } + + Entity formEntity = null; + + if (contentType.startsWith("multipart/form-data")) { + MultiPart multipart = new MultiPart(); + for (Entry param: formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + + FormDataMultiPart mp = new FormDataMultiPart(); + mp.bodyPart(new FormDataBodyPart(param.getKey(), file.getName())); + multipart.bodyPart(mp, MediaType.MULTIPART_FORM_DATA_TYPE); + + multipart.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.APPLICATION_OCTET_STREAM_TYPE)); + } else { + FormDataMultiPart mp = new FormDataMultiPart(); + mp.bodyPart(new FormDataBodyPart(param.getKey(), parameterToString(param.getValue()))); + multipart.bodyPart(mp, MediaType.MULTIPART_FORM_DATA_TYPE); + } + } + formEntity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE); + } else if (contentType.startsWith("application/x-www-form-urlencoded")) { + Form form = new Form(); + for (Entry param: formParams.entrySet()) { + form.param(param.getKey(), parameterToString(param.getValue())); + } + formEntity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE); + } + + Response response = null; + + if ("GET".equals(method)) { + response = invocationBuilder.get(); + } else if ("POST".equals(method)) { + if (formEntity != null) { + response = invocationBuilder.post(formEntity); + } else if (body == null) { + response = invocationBuilder.post(null); + } else { + response = invocationBuilder.post(serialize(body, contentType)); + } + } else if ("PUT".equals(method)) { + if (formEntity != null) { + response = invocationBuilder.put(formEntity); + } else if (body == null) { + response = invocationBuilder.put(null); + } else { + response = invocationBuilder.put(serialize(body, contentType)); + } + } else if ("DELETE".equals(method)) { + response = invocationBuilder.delete(); + } else { + throw new ApiException(500, "unknown method type " + method); + } + + if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) { + return null; + } else if (response.getStatusInfo().getFamily().equals(Status.Family.SUCCESSFUL)) { + if (returnType == null) + return null; + else + return deserialize(response, returnType); + } else { + String message = "error"; + String respBody = null; + if (response.hasEntity()) { + try { + respBody = String.valueOf(response.readEntity(String.class)); + message = respBody; + } catch (RuntimeException e) { + // e.printStackTrace(); + } + } + Map> responseHeaders = new HashMap>(); + for (String key: response.getHeaders().keySet()) { + List values = response.getHeaders().get(key); + List headers = new ArrayList(); + for (Object o : values) { + headers.add(String.valueOf(o)); + } + responseHeaders.put(key, headers); + } + throw new ApiException( + response.getStatus(), + message, + responseHeaders, + respBody); + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + */ + private void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams) { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); + auth.applyToParams(queryParams, headerParams); + } + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java new file mode 100644 index 000000000000..a39785eb47ec --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java @@ -0,0 +1,47 @@ +package io.swagger.client; + +import java.util.Map; +import java.util.List; + +public class ApiException extends Exception { + private int code = 0; + private String message = null; + private Map> responseHeaders = null; + private String responseBody = null; + + public ApiException() {} + + public ApiException(int code, String message) { + this.code = code; + this.message = message; + } + + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this.code = code; + this.message = message; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public int getCode() { + return code; + } + + public String getMessage() { + return message; + } + + /** + * Get the HTTP response headers. + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + */ + public String getResponseBody() { + return responseBody; + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java new file mode 100644 index 000000000000..04899a110f63 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java @@ -0,0 +1,21 @@ +package io.swagger.client; + +public class Configuration { + private static ApiClient defaultApiClient = new ApiClient(); + + /** + * Get the default API client, which would be used when creating API + * instances without providing an API client. + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } + + /** + * Set the default API client, which would be used when creating API + * instances without providing an API client. + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java new file mode 100644 index 000000000000..4c1fa53430b2 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java @@ -0,0 +1,51 @@ +package io.swagger.client; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.datatype.joda.*; + +import java.io.IOException; + +public class JSON { + private ObjectMapper mapper; + + public JSON() { + mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.registerModule(new JodaModule()); + } + + /** + * Serialize the given Java object into JSON string. + */ + public String serialize(Object obj) throws ApiException { + try { + if (obj != null) + return mapper.writeValueAsString(obj); + else + return null; + } catch (Exception e) { + throw new ApiException(400, e.getMessage()); + } + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param body The JSON string + * @param returnType The type to deserialize inot + * @return The deserialized Java object + */ + public T deserialize(String body, TypeRef returnType) throws ApiException { + JavaType javaType = mapper.constructType(returnType.getType()); + try { + return mapper.readValue(body, javaType); + } catch (IOException e) { + if (returnType.getType().equals(String.class)) + return (T) body; + else + throw new ApiException(500, e.getMessage(), null, body); + } + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java new file mode 100644 index 000000000000..4b7112f6db65 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java @@ -0,0 +1,38 @@ +package io.swagger.client; + +public class Pair { + private String name = ""; + private String value = ""; + + public Pair (String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) return; + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) return; + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) return false; + if (arg.trim().isEmpty()) return false; + + return true; + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java new file mode 100644 index 000000000000..5b5af2d5ce03 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java @@ -0,0 +1,41 @@ +package io.swagger.client; + +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) return true; + if (value != null && value.equalsIgnoreCase(str)) return true; + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) return ""; + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/TypeRef.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/TypeRef.java new file mode 100644 index 000000000000..6081df1082fa --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/TypeRef.java @@ -0,0 +1,25 @@ +package io.swagger.client; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; + +public class TypeRef { + private final Type type; + + public TypeRef() { + this.type = getGenericType(getClass()); + } + + private static Type getGenericType(Class klass) { + Type superclass = klass.getGenericSuperclass(); + if (superclass instanceof Class) { + throw new RuntimeException("No type parameter provided"); + } + ParameterizedType parameterized = (ParameterizedType) superclass; + return parameterized.getActualTypeArguments()[0]; + } + + public Type getType() { + return type; + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java new file mode 100644 index 000000000000..d1aee33af002 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -0,0 +1,406 @@ +package io.swagger.client.api; + +import io.swagger.client.ApiException; +import io.swagger.client.ApiClient; +import io.swagger.client.Configuration; +import io.swagger.client.Pair; +import io.swagger.client.TypeRef; + +import io.swagger.client.model.*; + +import java.util.*; + +import io.swagger.client.model.Pet; +import java.io.File; + +import java.io.File; +import java.util.Map; +import java.util.HashMap; + +public class PetApi { + private ApiClient apiClient; + + public PetApi() { + this(Configuration.getDefaultApiClient()); + } + + public PetApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() { + return apiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + * @return void + */ + public void updatePet (Pet body) throws ApiException { + Object postBody = body; + + + // create path and map variables + String path = "/pet".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + "application/json", "application/xml" + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Add a new pet to the store + * + * @param body Pet object that needs to be added to the store + * @return void + */ + public void addPet (Pet body) throws ApiException { + Object postBody = body; + + + // create path and map variables + String path = "/pet".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + "application/json", "application/xml" + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma seperated strings + * @param status Status values that need to be considered for filter + * @return List + */ + public List findPetsByStatus (List status) throws ApiException { + Object postBody = null; + + + // create path and map variables + String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + queryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + TypeRef returnType = new TypeRef>() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Finds Pets by tags + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by + * @return List + */ + public List findPetsByTags (List tags) throws ApiException { + Object postBody = null; + + + // create path and map variables + String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + queryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + TypeRef returnType = new TypeRef>() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Find pet by ID + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return Pet + */ + public Pet getPetById (Long petId) throws ApiException { + Object postBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById"); + } + + + // create path and map variables + String path = "/pet/{petId}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "api_key", "petstore_auth" }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + * @return void + */ + public void updatePetWithForm (String petId, String name, String status) throws ApiException { + Object postBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm"); + } + + + // create path and map variables + String path = "/pet/{petId}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + if (name != null) + formParams.put("name", name); + if (status != null) + formParams.put("status", status); + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + "application/x-www-form-urlencoded" + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + * @return void + */ + public void deletePet (Long petId, String apiKey) throws ApiException { + Object postBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet"); + } + + + // create path and map variables + String path = "/pet/{petId}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + if (apiKey != null) + headerParams.put("api_key", apiClient.parameterToString(apiKey)); + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * uploads an image + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + * @return void + */ + public void uploadFile (Long petId, String additionalMetadata, File file) throws ApiException { + Object postBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile"); + } + + + // create path and map variables + String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + if (additionalMetadata != null) + formParams.put("additionalMetadata", additionalMetadata); + if (file != null) + formParams.put("file", file); + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + "multipart/form-data" + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java new file mode 100644 index 000000000000..6a0c014f266d --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java @@ -0,0 +1,214 @@ +package io.swagger.client.api; + +import io.swagger.client.ApiException; +import io.swagger.client.ApiClient; +import io.swagger.client.Configuration; +import io.swagger.client.Pair; +import io.swagger.client.TypeRef; + +import io.swagger.client.model.*; + +import java.util.*; + +import java.util.Map; +import io.swagger.client.model.Order; + +import java.io.File; +import java.util.Map; +import java.util.HashMap; + +public class StoreApi { + private ApiClient apiClient; + + public StoreApi() { + this(Configuration.getDefaultApiClient()); + } + + public StoreApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() { + return apiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return Map + */ + public Map getInventory () throws ApiException { + Object postBody = null; + + + // create path and map variables + String path = "/store/inventory".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "api_key" }; + + TypeRef returnType = new TypeRef>() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet + * @return Order + */ + public Order placeOrder (Order body) throws ApiException { + Object postBody = body; + + + // create path and map variables + String path = "/store/order".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param orderId ID of pet that needs to be fetched + * @return Order + */ + public Order getOrderById (String orderId) throws ApiException { + Object postBody = null; + + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById"); + } + + + // create path and map variables + String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted + * @return void + */ + public void deleteOrder (String orderId) throws ApiException { + Object postBody = null; + + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder"); + } + + + // create path and map variables + String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java new file mode 100644 index 000000000000..0d408637cea8 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java @@ -0,0 +1,385 @@ +package io.swagger.client.api; + +import io.swagger.client.ApiException; +import io.swagger.client.ApiClient; +import io.swagger.client.Configuration; +import io.swagger.client.Pair; +import io.swagger.client.TypeRef; + +import io.swagger.client.model.*; + +import java.util.*; + +import io.swagger.client.model.User; +import java.util.*; + +import java.io.File; +import java.util.Map; +import java.util.HashMap; + +public class UserApi { + private ApiClient apiClient; + + public UserApi() { + this(Configuration.getDefaultApiClient()); + } + + public UserApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() { + return apiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + + /** + * Create user + * This can only be done by the logged in user. + * @param body Created user object + * @return void + */ + public void createUser (User body) throws ApiException { + Object postBody = body; + + + // create path and map variables + String path = "/user".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + * @return void + */ + public void createUsersWithArrayInput (List body) throws ApiException { + Object postBody = body; + + + // create path and map variables + String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + * @return void + */ + public void createUsersWithListInput (List body) throws ApiException { + Object postBody = body; + + + // create path and map variables + String path = "/user/createWithList".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + * @return String + */ + public String loginUser (String username, String password) throws ApiException { + Object postBody = null; + + + // create path and map variables + String path = "/user/login".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + queryParams.addAll(apiClient.parameterToPairs("", "username", username)); + + queryParams.addAll(apiClient.parameterToPairs("", "password", password)); + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Logs out current logged in user session + * + * @return void + */ + public void logoutUser () throws ApiException { + Object postBody = null; + + + // create path and map variables + String path = "/user/logout".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + * @return User + */ + public User getUserByName (String username) throws ApiException { + Object postBody = null; + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName"); + } + + + // create path and map variables + String path = "/user/{username}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted + * @param body Updated user object + * @return void + */ + public void updateUser (String username, User body) throws ApiException { + Object postBody = body; + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); + } + + + // create path and map variables + String path = "/user/{username}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + * @return void + */ + public void deleteUser (String username) throws ApiException { + Object postBody = null; + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser"); + } + + + // create path and map variables + String path = "/user/{username}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java new file mode 100644 index 000000000000..0e5ca9c7c538 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -0,0 +1,58 @@ +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import java.util.Map; +import java.util.List; + +public class ApiKeyAuth implements Authentication { + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List queryParams, Map headerParams) { + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if (location == "query") { + queryParams.add(new Pair(paramName, value)); + } else if (location == "header") { + headerParams.put(paramName, value); + } + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/Authentication.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/Authentication.java new file mode 100644 index 000000000000..98b1a6900b93 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/Authentication.java @@ -0,0 +1,11 @@ +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import java.util.Map; +import java.util.List; + +public interface Authentication { + /** Apply authentication settings to header and query params. */ + void applyToParams(List queryParams, Map headerParams); +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java new file mode 100644 index 000000000000..980b24311bea --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -0,0 +1,40 @@ +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import java.util.Map; +import java.util.List; + +import java.io.UnsupportedEncodingException; +import javax.xml.bind.DatatypeConverter; + +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams) { + String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); + try { + headerParams.put("Authorization", "Basic " + DatatypeConverter.printBase64Binary(str.getBytes("UTF-8"))); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java new file mode 100644 index 000000000000..39fba5498c0e --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java @@ -0,0 +1,13 @@ +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import java.util.Map; +import java.util.List; + +public class OAuth implements Authentication { + @Override + public void applyToParams(List queryParams, Map headerParams) { + // TODO: support oauth + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java new file mode 100644 index 000000000000..d43f6a9758fb --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java @@ -0,0 +1,50 @@ +package io.swagger.client.model; + + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +public class Category { + + private Long id = null; + private String name = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java new file mode 100644 index 000000000000..25864d8c9cc8 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java @@ -0,0 +1,111 @@ +package io.swagger.client.model; + +import java.util.Date; + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +public class Order { + + private Long id = null; + private Long petId = null; + private Integer quantity = null; + private Date shipDate = null; + public enum StatusEnum { + placed, approved, delivered, + }; + private StatusEnum status = null; + private Boolean complete = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("petId") + public Long getPetId() { + return petId; + } + public void setPetId(Long petId) { + this.petId = petId; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("quantity") + public Integer getQuantity() { + return quantity; + } + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("shipDate") + public Date getShipDate() { + return shipDate; + } + public void setShipDate(Date shipDate) { + this.shipDate = shipDate; + } + + + /** + * Order Status + **/ + @ApiModelProperty(value = "Order Status") + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("complete") + public Boolean getComplete() { + return complete; + } + public void setComplete(Boolean complete) { + this.complete = complete; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" petId: ").append(petId).append("\n"); + sb.append(" quantity: ").append(quantity).append("\n"); + sb.append(" shipDate: ").append(shipDate).append("\n"); + sb.append(" status: ").append(status).append("\n"); + sb.append(" complete: ").append(complete).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java new file mode 100644 index 000000000000..d7c2038dead8 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java @@ -0,0 +1,113 @@ +package io.swagger.client.model; + +import io.swagger.client.model.Category; +import io.swagger.client.model.Tag; +import java.util.*; + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +public class Pet { + + private Long id = null; + private Category category = null; + private String name = null; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); + public enum StatusEnum { + available, pending, sold, + }; + private StatusEnum status = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("category") + public Category getCategory() { + return category; + } + public void setCategory(Category category) { + this.category = category; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty("photoUrls") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("tags") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" category: ").append(category).append("\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append(" photoUrls: ").append(photoUrls).append("\n"); + sb.append(" tags: ").append(tags).append("\n"); + sb.append(" status: ").append(status).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java new file mode 100644 index 000000000000..63a2ca3b7390 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java @@ -0,0 +1,50 @@ +package io.swagger.client.model; + + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +public class Tag { + + private Long id = null; + private String name = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java new file mode 100644 index 000000000000..0ace5b7e30a3 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java @@ -0,0 +1,135 @@ +package io.swagger.client.model; + + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +public class User { + + private Long id = null; + private String username = null; + private String firstName = null; + private String lastName = null; + private String email = null; + private String password = null; + private String phone = null; + private Integer userStatus = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("username") + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("firstName") + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("lastName") + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("email") + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("password") + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("phone") + public String getPhone() { + return phone; + } + public void setPhone(String phone) { + this.phone = phone; + } + + + /** + * User Status + **/ + @ApiModelProperty(value = "User Status") + @JsonProperty("userStatus") + public Integer getUserStatus() { + return userStatus; + } + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" username: ").append(username).append("\n"); + sb.append(" firstName: ").append(firstName).append("\n"); + sb.append(" lastName: ").append(lastName).append("\n"); + sb.append(" email: ").append(email).append("\n"); + sb.append(" password: ").append(password).append("\n"); + sb.append(" phone: ").append(phone).append("\n"); + sb.append(" userStatus: ").append(userStatus).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java new file mode 100644 index 000000000000..802c0cae3b97 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java @@ -0,0 +1,193 @@ +package io.swagger.client; + +import io.swagger.client.auth.*; + +import java.util.*; + +import org.junit.*; +import static org.junit.Assert.*; + + +public class ApiClientTest { + ApiClient apiClient = null; + + @Before + public void setup() { + apiClient = new ApiClient(); + } + + @Test + public void testSelectHeaderAccept() { + String[] accepts = {"APPLICATION/JSON", "APPLICATION/XML"}; + assertEquals("application/json", apiClient.selectHeaderAccept(accepts)); + + accepts = new String[]{"application/json", "application/xml"}; + assertEquals("application/json", apiClient.selectHeaderAccept(accepts)); + + accepts = new String[]{"application/xml", "application/json"}; + assertEquals("application/json", apiClient.selectHeaderAccept(accepts)); + + accepts = new String[]{"text/plain", "application/xml"}; + assertEquals("text/plain,application/xml", apiClient.selectHeaderAccept(accepts)); + + accepts = new String[]{}; + assertNull(apiClient.selectHeaderAccept(accepts)); + } + + @Test + public void testSelectHeaderContentType() { + String[] contentTypes = {"APPLICATION/JSON", "APPLICATION/XML"}; + assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes)); + + contentTypes = new String[]{"application/json", "application/xml"}; + assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes)); + + contentTypes = new String[]{"application/xml", "application/json"}; + assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes)); + + contentTypes = new String[]{"text/plain", "application/xml"}; + assertEquals("text/plain", apiClient.selectHeaderContentType(contentTypes)); + + contentTypes = new String[]{}; + assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes)); + } + + @Test + public void testGetAuthentications() { + Map auths = apiClient.getAuthentications(); + + Authentication auth = auths.get("api_key"); + assertNotNull(auth); + assertTrue(auth instanceof ApiKeyAuth); + ApiKeyAuth apiKeyAuth = (ApiKeyAuth) auth; + assertEquals("header", apiKeyAuth.getLocation()); + assertEquals("api_key", apiKeyAuth.getParamName()); + + auth = auths.get("petstore_auth"); + assertTrue(auth instanceof OAuth); + assertSame(auth, apiClient.getAuthentication("petstore_auth")); + + assertNull(auths.get("unknown")); + + try { + auths.put("my_auth", new HttpBasicAuth()); + fail("the authentications returned should not be modifiable"); + } catch (UnsupportedOperationException e) { + } + } + + @Test + public void testSetUsername() { + try { + apiClient.setUsername("my-username"); + fail("there should be no HTTP basic authentications"); + } catch (RuntimeException e) { + } + } + + @Test + public void testSetPassword() { + try { + apiClient.setPassword("my-password"); + fail("there should be no HTTP basic authentications"); + } catch (RuntimeException e) { + } + } + + @Test + public void testSetApiKeyAndPrefix() { + ApiKeyAuth auth = (ApiKeyAuth) apiClient.getAuthentications().get("api_key"); + auth.setApiKey(null); + auth.setApiKeyPrefix(null); + + apiClient.setApiKey("my-api-key"); + apiClient.setApiKeyPrefix("Token"); + assertEquals("my-api-key", auth.getApiKey()); + assertEquals("Token", auth.getApiKeyPrefix()); + + // reset values + auth.setApiKey(null); + auth.setApiKeyPrefix(null); + } + + @Test + public void testParameterToPairsWhenNameIsInvalid() throws Exception { + List pairs_a = apiClient.parameterToPairs("csv", null, new Integer(1)); + List pairs_b = apiClient.parameterToPairs("csv", "", new Integer(1)); + + assertTrue(pairs_a.isEmpty()); + assertTrue(pairs_b.isEmpty()); + } + + @Test + public void testParameterToPairsWhenValueIsNull() throws Exception { + List pairs = apiClient.parameterToPairs("csv", "param-a", null); + + assertTrue(pairs.isEmpty()); + } + + @Test + public void testParameterToPairsWhenValueIsEmptyStrings() throws Exception { + + // single empty string + List pairs = apiClient.parameterToPairs("csv", "param-a", " "); + assertEquals(1, pairs.size()); + + // list of empty strings + List strs = new ArrayList(); + strs.add(" "); + strs.add(" "); + strs.add(" "); + + List concatStrings = apiClient.parameterToPairs("csv", "param-a", strs); + + assertEquals(1, concatStrings.size()); + assertFalse(concatStrings.get(0).getValue().isEmpty()); // should contain some delimiters + } + + @Test + public void testParameterToPairsWhenValueIsNotCollection() throws Exception { + String name = "param-a"; + Integer value = 1; + + List pairs = apiClient.parameterToPairs("csv", name, value); + + assertEquals(1, pairs.size()); + assertEquals(value, Integer.valueOf(pairs.get(0).getValue())); + } + + @Test + public void testParameterToPairsWhenValueIsCollection() throws Exception { + Map collectionFormatMap = new HashMap(); + collectionFormatMap.put("csv", ","); + collectionFormatMap.put("tsv", "\t"); + collectionFormatMap.put("ssv", " "); + collectionFormatMap.put("pipes", "\\|"); + collectionFormatMap.put("", ","); // no format, must default to csv + collectionFormatMap.put("unknown", ","); // all other formats, must default to csv + + String name = "param-a"; + + List values = new ArrayList(); + values.add("value-a"); + values.add(123); + values.add(new Date()); + + // check for multi separately + List multiPairs = apiClient.parameterToPairs("multi", name, values); + assertEquals(values.size(), multiPairs.size()); + + // all other formats + for (String collectionFormat : collectionFormatMap.keySet()) { + List pairs = apiClient.parameterToPairs(collectionFormat, name, values); + + assertEquals(1, pairs.size()); + + String delimiter = collectionFormatMap.get(collectionFormat); + String[] pairValueSplit = pairs.get(0).getValue().split(delimiter); + + // must equal input values + assertEquals(values.size(), pairValueSplit.length); + } + } +} diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ConfigurationTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ConfigurationTest.java new file mode 100644 index 000000000000..b95eb74605ea --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ConfigurationTest.java @@ -0,0 +1,15 @@ +package io.swagger.client; + +import org.junit.*; +import static org.junit.Assert.*; + + +public class ConfigurationTest { + @Test + public void testDefaultApiClient() { + ApiClient apiClient = Configuration.getDefaultApiClient(); + assertNotNull(apiClient); + assertEquals("http://petstore.swagger.io/v2", apiClient.getBasePath()); + assertFalse(apiClient.isDebugging()); + } +} diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/StringUtilTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/StringUtilTest.java new file mode 100644 index 000000000000..4b03c7a98120 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/StringUtilTest.java @@ -0,0 +1,33 @@ +package io.swagger.client; + +import org.junit.*; +import static org.junit.Assert.*; + + +public class StringUtilTest { + @Test + public void testContainsIgnoreCase() { + assertTrue(StringUtil.containsIgnoreCase(new String[]{"abc"}, "abc")); + assertTrue(StringUtil.containsIgnoreCase(new String[]{"abc"}, "ABC")); + assertTrue(StringUtil.containsIgnoreCase(new String[]{"ABC"}, "abc")); + assertTrue(StringUtil.containsIgnoreCase(new String[]{null, "abc"}, "ABC")); + assertTrue(StringUtil.containsIgnoreCase(new String[]{null, "abc"}, null)); + + assertFalse(StringUtil.containsIgnoreCase(new String[]{"abc"}, "def")); + assertFalse(StringUtil.containsIgnoreCase(new String[]{}, "ABC")); + assertFalse(StringUtil.containsIgnoreCase(new String[]{}, null)); + } + + @Test + public void testJoin() { + String[] array = {"aa", "bb", "cc"}; + assertEquals("aa,bb,cc", StringUtil.join(array, ",")); + assertEquals("aa, bb, cc", StringUtil.join(array, ", ")); + assertEquals("aabbcc", StringUtil.join(array, "")); + assertEquals("aa bb cc", StringUtil.join(array, " ")); + assertEquals("aa\nbb\ncc", StringUtil.join(array, "\n")); + + assertEquals("", StringUtil.join(new String[]{}, ",")); + assertEquals("abc", StringUtil.join(new String[]{"abc"}, ",")); + } +} diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java new file mode 100644 index 000000000000..5bdb4fb78fba --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java @@ -0,0 +1,47 @@ +package io.swagger.client.auth; + +import java.util.HashMap; +import java.util.ArrayList; +import java.util.Map; +import java.util.List; + +import io.swagger.client.Pair; +import org.junit.*; +import static org.junit.Assert.*; + + +public class ApiKeyAuthTest { + @Test + public void testApplyToParamsInQuery() { + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + + ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); + auth.setApiKey("my-api-key"); + auth.applyToParams(queryParams, headerParams); + + assertEquals(1, queryParams.size()); + for (Pair queryParam : queryParams) { + assertEquals("my-api-key", queryParam.getValue()); + } + + // no changes to header parameters + assertEquals(0, headerParams.size()); + } + + @Test + public void testApplyToParamsInHeaderWithPrefix() { + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + + ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); + auth.setApiKey("my-api-token"); + auth.setApiKeyPrefix("Token"); + auth.applyToParams(queryParams, headerParams); + + // no changes to query parameters + assertEquals(0, queryParams.size()); + assertEquals(1, headerParams.size()); + assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN")); + } +} diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java new file mode 100644 index 000000000000..52c5497ba83e --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java @@ -0,0 +1,52 @@ +package io.swagger.client.auth; + +import java.util.HashMap; +import java.util.ArrayList; +import java.util.Map; +import java.util.List; + +import io.swagger.client.Pair; +import org.junit.*; +import static org.junit.Assert.*; + + +public class HttpBasicAuthTest { + HttpBasicAuth auth = null; + + @Before + public void setup() { + auth = new HttpBasicAuth(); + } + + @Test + public void testApplyToParams() { + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + + auth.setUsername("my-username"); + auth.setPassword("my-password"); + auth.applyToParams(queryParams, headerParams); + + // no changes to query parameters + assertEquals(0, queryParams.size()); + assertEquals(1, headerParams.size()); + // the string below is base64-encoded result of "my-username:my-password" with the "Basic " prefix + String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ="; + assertEquals(expected, headerParams.get("Authorization")); + + // null username should be treated as empty string + auth.setUsername(null); + auth.applyToParams(queryParams, headerParams); + // the string below is base64-encoded result of ":my-password" with the "Basic " prefix + expected = "Basic Om15LXBhc3N3b3Jk"; + assertEquals(expected, headerParams.get("Authorization")); + + // null password should be treated as empty string + auth.setUsername("my-username"); + auth.setPassword(null); + auth.applyToParams(queryParams, headerParams); + // the string below is base64-encoded result of "my-username:" with the "Basic " prefix + expected = "Basic bXktdXNlcm5hbWU6"; + assertEquals(expected, headerParams.get("Authorization")); + } +} diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java new file mode 100644 index 000000000000..b6ad5fb05275 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -0,0 +1,192 @@ +package io.swagger.petstore.test; + +import io.swagger.client.ApiClient; +import io.swagger.client.ApiException; +import io.swagger.client.Configuration; + +import io.swagger.client.api.*; +import io.swagger.client.auth.*; +import io.swagger.client.model.*; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.junit.*; +import static org.junit.Assert.*; + +public class PetApiTest { + PetApi api = null; + + @Before + public void setup() { + api = new PetApi(); + // setup authentication + ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key"); + apiKeyAuth.setApiKey("special-key"); + } + + @Test + public void testApiClient() { + // the default api client is used + assertEquals(Configuration.getDefaultApiClient(), api.getApiClient()); + assertNotNull(api.getApiClient()); + assertEquals("http://petstore.swagger.io/v2", api.getApiClient().getBasePath()); + assertFalse(api.getApiClient().isDebugging()); + + ApiClient oldClient = api.getApiClient(); + + ApiClient newClient = new ApiClient(); + newClient.setBasePath("http://example.com"); + newClient.setDebugging(true); + + // set api client via constructor + api = new PetApi(newClient); + assertNotNull(api.getApiClient()); + assertEquals("http://example.com", api.getApiClient().getBasePath()); + assertTrue(api.getApiClient().isDebugging()); + + // set api client via setter method + api.setApiClient(oldClient); + assertNotNull(api.getApiClient()); + assertEquals("http://petstore.swagger.io/v2", api.getApiClient().getBasePath()); + assertFalse(api.getApiClient().isDebugging()); + } + + @Test + public void testCreateAndGetPet() throws Exception { + Pet pet = createRandomPet(); + api.addPet(pet); + + Pet fetched = api.getPetById(pet.getId()); + assertNotNull(fetched); + assertEquals(pet.getId(), fetched.getId()); + assertNotNull(fetched.getCategory()); + assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); + } + + @Test + public void testUpdatePet() throws Exception { + Pet pet = createRandomPet(); + pet.setName("programmer"); + + api.updatePet(pet); + + Pet fetched = api.getPetById(pet.getId()); + assertNotNull(fetched); + assertEquals(pet.getId(), fetched.getId()); + assertNotNull(fetched.getCategory()); + assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); + } + + @Test + public void testFindPetsByStatus() throws Exception { + Pet pet = createRandomPet(); + pet.setName("programmer"); + pet.setStatus(Pet.StatusEnum.available); + + api.updatePet(pet); + + List pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"})); + assertNotNull(pets); + + boolean found = false; + for (Pet fetched : pets) { + if (fetched.getId().equals(pet.getId())) { + found = true; + break; + } + } + + assertTrue(found); + } + + @Test + public void testFindPetsByTags() throws Exception { + Pet pet = createRandomPet(); + pet.setName("monster"); + pet.setStatus(Pet.StatusEnum.available); + + List tags = new ArrayList(); + Tag tag1 = new Tag(); + tag1.setName("friendly"); + tags.add(tag1); + pet.setTags(tags); + + api.updatePet(pet); + + List pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"})); + assertNotNull(pets); + + boolean found = false; + for (Pet fetched : pets) { + if (fetched.getId().equals(pet.getId())) { + found = true; + break; + } + } + assertTrue(found); + } + + @Test + public void testUpdatePetWithForm() throws Exception { + Pet pet = createRandomPet(); + pet.setName("frank"); + api.addPet(pet); + + Pet fetched = api.getPetById(pet.getId()); + + api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null); + Pet updated = api.getPetById(fetched.getId()); + + assertEquals(updated.getName(), "furt"); + } + + @Test + public void testDeletePet() throws Exception { + Pet pet = createRandomPet(); + api.addPet(pet); + + Pet fetched = api.getPetById(pet.getId()); + api.deletePet(fetched.getId(), null); + + try { + fetched = api.getPetById(fetched.getId()); + fail("expected an error"); + } catch (ApiException e) { + assertEquals(404, e.getCode()); + } + } + + @Test + public void testUploadFile() throws Exception { + Pet pet = createRandomPet(); + api.addPet(pet); + + File file = new File("hello.txt"); + BufferedWriter writer = new BufferedWriter(new FileWriter(file)); + writer.write("Hello world!"); + writer.close(); + + api.uploadFile(pet.getId(), "a test file", new File(file.getAbsolutePath())); + } + + private Pet createRandomPet() { + Pet pet = new Pet(); + pet.setId(System.currentTimeMillis()); + pet.setName("gorilla"); + + Category category = new Category(); + category.setName("really-happy"); + + pet.setCategory(category); + pet.setStatus(Pet.StatusEnum.available); + List photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}); + pet.setPhotoUrls(photos); + + return pet; + } +} diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java new file mode 100644 index 000000000000..508764b8c2db --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -0,0 +1,72 @@ +package io.swagger.petstore.test; + +import io.swagger.client.ApiException; + +import io.swagger.client.*; +import io.swagger.client.api.*; +import io.swagger.client.auth.*; +import io.swagger.client.model.*; + +import java.util.Map; + +import org.junit.*; +import static org.junit.Assert.*; + +public class StoreApiTest { + StoreApi api = null; + + @Before + public void setup() { + api = new StoreApi(); + // setup authentication + ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key"); + apiKeyAuth.setApiKey("special-key"); + } + + @Test + public void testGetInventory() throws Exception { + Map inventory = api.getInventory(); + assertTrue(inventory.keySet().size() > 0); + } + + @Test + public void testPlaceOrder() throws Exception { + Order order = createOrder(); + api.placeOrder(order); + + Order fetched = api.getOrderById(String.valueOf(order.getId())); + assertEquals(order.getId(), fetched.getId()); + assertEquals(order.getPetId(), fetched.getPetId()); + assertEquals(order.getQuantity(), fetched.getQuantity()); + } + + @Test + public void testDeleteOrder() throws Exception { + Order order = createOrder(); + api.placeOrder(order); + + Order fetched = api.getOrderById(String.valueOf(order.getId())); + assertEquals(fetched.getId(), order.getId()); + + api.deleteOrder(String.valueOf(order.getId())); + + try { + api.getOrderById(String.valueOf(order.getId())); + // fail("expected an error"); + } catch (ApiException e) { + // ok + } + } + + private Order createOrder() { + Order order = new Order(); + order.setId(new Long(System.currentTimeMillis())); + order.setPetId(new Long(200)); + order.setQuantity(new Integer(13)); + order.setShipDate(new java.util.Date()); + order.setStatus(Order.StatusEnum.placed); + order.setComplete(true); + + return order; + } +} diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/UserApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/UserApiTest.java new file mode 100644 index 000000000000..26e46bfa6024 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/UserApiTest.java @@ -0,0 +1,86 @@ +package io.swagger.petstore.test; + +import io.swagger.client.api.*; +import io.swagger.client.auth.*; +import io.swagger.client.model.*; + +import java.util.Arrays; + +import org.junit.*; +import static org.junit.Assert.*; + +public class UserApiTest { + UserApi api = null; + + @Before + public void setup() { + api = new UserApi(); + // setup authentication + ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key"); + apiKeyAuth.setApiKey("special-key"); + } + + @Test + public void testCreateUser() throws Exception { + User user = createUser(); + + api.createUser(user); + + User fetched = api.getUserByName(user.getUsername()); + assertEquals(user.getId(), fetched.getId()); + } + + @Test + public void testCreateUsersWithArray() throws Exception { + User user1 = createUser(); + user1.setUsername("abc123"); + User user2 = createUser(); + user2.setUsername("123abc"); + + api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2})); + + User fetched = api.getUserByName(user1.getUsername()); + assertEquals(user1.getId(), fetched.getId()); + } + + @Test + public void testCreateUsersWithList() throws Exception { + User user1 = createUser(); + user1.setUsername("abc123"); + User user2 = createUser(); + user2.setUsername("123abc"); + + api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2})); + + User fetched = api.getUserByName(user1.getUsername()); + assertEquals(user1.getId(), fetched.getId()); + } + + @Test + public void testLoginUser() throws Exception { + User user = createUser(); + api.createUser(user); + + String token = api.loginUser(user.getUsername(), user.getPassword()); + assertTrue(token.startsWith("logged in user session:")); + } + + @Test + public void logoutUser() throws Exception { + api.logoutUser(); + } + + private User createUser() { + User user = new User(); + user.setId(System.currentTimeMillis()); + user.setUsername("fred"); + user.setFirstName("Fred"); + user.setLastName("Meyer"); + user.setEmail("fred@fredmeyer.com"); + user.setPassword("xxXXxx"); + user.setPhone("408-867-5309"); + user.setUserStatus(123); + + return user; + } +} From dc76887820a0e358cbbf65aa3f8e58664fe01510 Mon Sep 17 00:00:00 2001 From: Andrew B Date: Wed, 5 Aug 2015 15:50:34 -0700 Subject: [PATCH 022/109] Fixing subClassed types so that they can use enums --- .../io/swagger/codegen/CodegenProperty.java | 104 ++++++++++++++++++ .../codegen/languages/JavaClientCodegen.java | 64 +++++++++++ 2 files changed, 168 insertions(+) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java index 7872da2c707f..2f186816d1e8 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java @@ -34,4 +34,108 @@ public class CodegenProperty { public boolean isEnum; public List _enum; public Map allowableValues; + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CodegenProperty other = (CodegenProperty) obj; + if ((this.baseName == null) ? (other.baseName != null) : !this.baseName.equals(other.baseName)) { + return false; + } + if ((this.complexType == null) ? (other.complexType != null) : !this.complexType.equals(other.complexType)) { + return false; + } + if ((this.getter == null) ? (other.getter != null) : !this.getter.equals(other.getter)) { + return false; + } + if ((this.setter == null) ? (other.setter != null) : !this.setter.equals(other.setter)) { + return false; + } + if ((this.description == null) ? (other.description != null) : !this.description.equals(other.description)) { + return false; + } + if ((this.datatype == null) ? (other.datatype != null) : !this.datatype.equals(other.datatype)) { + return false; + } + if ((this.datatypeWithEnum == null) ? (other.datatypeWithEnum != null) : !this.datatypeWithEnum.equals(other.datatypeWithEnum)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if ((this.min == null) ? (other.min != null) : !this.min.equals(other.min)) { + return false; + } + if ((this.max == null) ? (other.max != null) : !this.max.equals(other.max)) { + return false; + } + if ((this.defaultValue == null) ? (other.defaultValue != null) : !this.defaultValue.equals(other.defaultValue)) { + return false; + } + if ((this.baseType == null) ? (other.baseType != null) : !this.baseType.equals(other.baseType)) { + return false; + } + if ((this.containerType == null) ? (other.containerType != null) : !this.containerType.equals(other.containerType)) { + return false; + } + if (this.maxLength != other.maxLength && (this.maxLength == null || !this.maxLength.equals(other.maxLength))) { + return false; + } + if (this.minLength != other.minLength && (this.minLength == null || !this.minLength.equals(other.minLength))) { + return false; + } + if ((this.pattern == null) ? (other.pattern != null) : !this.pattern.equals(other.pattern)) { + return false; + } + if ((this.example == null) ? (other.example != null) : !this.example.equals(other.example)) { + return false; + } + if ((this.jsonSchema == null) ? (other.jsonSchema != null) : !this.jsonSchema.equals(other.jsonSchema)) { + return false; + } + if (this.minimum != other.minimum && (this.minimum == null || !this.minimum.equals(other.minimum))) { + return false; + } + if (this.maximum != other.maximum && (this.maximum == null || !this.maximum.equals(other.maximum))) { + return false; + } + if (this.exclusiveMinimum != other.exclusiveMinimum && (this.exclusiveMinimum == null || !this.exclusiveMinimum.equals(other.exclusiveMinimum))) { + return false; + } + if (this.exclusiveMaximum != other.exclusiveMaximum && (this.exclusiveMaximum == null || !this.exclusiveMaximum.equals(other.exclusiveMaximum))) { + return false; + } + if (this.required != other.required && (this.required == null || !this.required.equals(other.required))) { + return false; + } + if (this.secondaryParam != other.secondaryParam && (this.secondaryParam == null || !this.secondaryParam.equals(other.secondaryParam))) { + return false; + } + if (this.isPrimitiveType != other.isPrimitiveType && (this.isPrimitiveType == null || !this.isPrimitiveType.equals(other.isPrimitiveType))) { + return false; + } + if (this.isContainer != other.isContainer && (this.isContainer == null || !this.isContainer.equals(other.isContainer))) { + return false; + } + if (this.isNotContainer != other.isNotContainer && (this.isNotContainer == null || !this.isNotContainer.equals(other.isNotContainer))) { + return false; + } + if (this.isEnum != other.isEnum) { + return false; + } + if (this._enum != other._enum && (this._enum == null || !this._enum.equals(other._enum))) { + return false; + } + if (this.allowableValues != other.allowableValues && (this.allowableValues == null || !this.allowableValues.equals(other.allowableValues))) { + return false; + } + return true; + } + + } 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 f272343a7955..2c71925098d6 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 @@ -1,17 +1,30 @@ package io.swagger.codegen.languages; +import com.google.common.base.Strings; import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenModel; +import io.swagger.codegen.CodegenProperty; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; +import io.swagger.models.ComposedModel; +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.RefModel; import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.MapProperty; import io.swagger.models.properties.Property; +import io.swagger.models.properties.StringProperty; import java.io.File; +import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import org.apache.commons.lang.StringUtils; @@ -249,6 +262,57 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { return camelize(operationId, true); } + @Override + public CodegenModel fromModel(String name, Model model, Map allDefinitions) { + CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); + + if (allDefinitions != null && codegenModel != null && codegenModel.parent != null && codegenModel.hasEnums) { + final Model parentModel = allDefinitions.get(toModelName(codegenModel.parent)); + final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel); + codegenModel = this.reconcileInlineEnums(codegenModel, parentCodegenModel); + } + + return codegenModel; + } + + private CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) { + // This generator uses inline classes to define enums, which breaks when + // dealing with models that have subTypes. To clean this up, we will analyze + // the parent and child models, look for enums that match, and remove + // them from the child models and leave them in the parent. + // Because the child models extend the parents, the enums will be available via the parent. + + // Only bother with reconciliation if the parent model has enums. + if (parentCodegenModel.hasEnums) { + + // Get the properties for the parent and child models + final List parentModelCodegenProperties = parentCodegenModel.vars; + List codegenProperties = codegenModel.vars; + + // Iterate over all of the parent model properties + for (CodegenProperty parentModelCodegenPropery : parentModelCodegenProperties) { + // Look for enums + if (parentModelCodegenPropery.isEnum) { + // Now that we have found an enum in the parent class, + // and search the child class for the same enum. + Iterator iterator = codegenProperties.iterator(); + while (iterator.hasNext()) { + CodegenProperty codegenProperty = iterator.next(); + if (codegenProperty.isEnum && codegenProperty.equals(parentModelCodegenPropery)) { + // We found an enum in the child class that is + // a duplicate of the one in the parent, so remove it. + iterator.remove(); + } + } + } + } + + codegenModel.vars = codegenProperties; + } + + return codegenModel; + } + public void setInvokerPackage(String invokerPackage) { this.invokerPackage = invokerPackage; } From c67a6582fcbc929f7bdd32fc23cc0c9564b88545 Mon Sep 17 00:00:00 2001 From: Andrew B Date: Wed, 5 Aug 2015 15:58:54 -0700 Subject: [PATCH 023/109] Bumping the version of swagger-parser to 1.0.9 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 45fba414722a..ce59ad54f41e 100644 --- a/pom.xml +++ b/pom.xml @@ -456,7 +456,7 @@ - 1.0.9-SNAPSHOT + 1.0.9 2.11.1 2.3.4 1.5.0 From 1b31a01b76605e55908c8850902eafb611205965 Mon Sep 17 00:00:00 2001 From: tiffanyperumpail Date: Wed, 5 Aug 2015 16:18:24 -0700 Subject: [PATCH 024/109] Added CodeGenStatus class with Status enum --- .../io/swagger/codegen/DefaultGenerator.java | 18 ++++++++++------ .../codegen/languages/CodeGenStatus.java | 21 +++++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CodeGenStatus.java diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 0b6f677857ac..91093a134981 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -1,8 +1,14 @@ package io.swagger.codegen; +import static io.swagger.codegen.languages.CodeGenStatus.Status.FAILED; +import static io.swagger.codegen.languages.CodeGenStatus.Status.SUCCESSFUL; +import static io.swagger.codegen.languages.CodeGenStatus.Status.UNRUN; +import static org.apache.commons.lang3.StringUtils.capitalize; +import static org.apache.commons.lang3.StringUtils.isNotEmpty; + import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Template; - +import io.swagger.codegen.languages.CodeGenStatus; import io.swagger.models.ComposedModel; import io.swagger.models.Contact; import io.swagger.models.Info; @@ -14,7 +20,6 @@ import io.swagger.models.Swagger; import io.swagger.models.auth.OAuth2Definition; import io.swagger.models.auth.SecuritySchemeDefinition; import io.swagger.util.Json; - import org.apache.commons.io.IOUtils; import java.io.File; @@ -34,14 +39,13 @@ import java.util.List; import java.util.Map; import java.util.Set; -import static org.apache.commons.lang3.StringUtils.capitalize; -import static org.apache.commons.lang3.StringUtils.isNotEmpty; - public class DefaultGenerator extends AbstractGenerator implements Generator { protected CodegenConfig config; protected ClientOptInput opts = null; protected Swagger swagger = null; + public CodeGenStatus status = new CodeGenStatus(UNRUN); + public Generator opts(ClientOptInput opts) { this.opts = opts; @@ -305,8 +309,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { } config.processSwagger(swagger); + + status.setStatus(SUCCESSFUL); } catch (Exception e) { - e.printStackTrace(); + status.setStatus(FAILED); } return files; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CodeGenStatus.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CodeGenStatus.java new file mode 100644 index 000000000000..80f5511825e1 --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CodeGenStatus.java @@ -0,0 +1,21 @@ +package io.swagger.codegen.languages; + +public class CodeGenStatus { + public enum Status { + UNRUN, SUCCESSFUL, FAILED + }; + + private Status status; + + public CodeGenStatus(Status status) { + this.status = status; + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } +} From 5328c00e8f48b4da0e4341a5356524868f9fceef Mon Sep 17 00:00:00 2001 From: tiffanyperumpail Date: Wed, 5 Aug 2015 16:53:39 -0700 Subject: [PATCH 025/109] Simplified enum by changing CodeGenStatus to an enum instead of a wrapper. Updated version of swagger-parser to 1.0.9. --- .../io/swagger/codegen/DefaultGenerator.java | 9 +++------ .../codegen/languages/CodeGenStatus.java | 18 +----------------- pom.xml | 2 +- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 91093a134981..1821d6b0e020 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -1,8 +1,5 @@ package io.swagger.codegen; -import static io.swagger.codegen.languages.CodeGenStatus.Status.FAILED; -import static io.swagger.codegen.languages.CodeGenStatus.Status.SUCCESSFUL; -import static io.swagger.codegen.languages.CodeGenStatus.Status.UNRUN; import static org.apache.commons.lang3.StringUtils.capitalize; import static org.apache.commons.lang3.StringUtils.isNotEmpty; @@ -44,7 +41,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { protected ClientOptInput opts = null; protected Swagger swagger = null; - public CodeGenStatus status = new CodeGenStatus(UNRUN); + public CodeGenStatus status = CodeGenStatus.UNRUN; public Generator opts(ClientOptInput opts) { this.opts = opts; @@ -310,9 +307,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { config.processSwagger(swagger); - status.setStatus(SUCCESSFUL); + status = CodeGenStatus.SUCCESSFUL; } catch (Exception e) { - status.setStatus(FAILED); + status = CodeGenStatus.FAILED; } return files; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CodeGenStatus.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CodeGenStatus.java index 80f5511825e1..aa22958517fd 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CodeGenStatus.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CodeGenStatus.java @@ -1,21 +1,5 @@ package io.swagger.codegen.languages; -public class CodeGenStatus { - public enum Status { +public enum CodeGenStatus { UNRUN, SUCCESSFUL, FAILED - }; - - private Status status; - - public CodeGenStatus(Status status) { - this.status = status; - } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } } diff --git a/pom.xml b/pom.xml index 45fba414722a..ce59ad54f41e 100644 --- a/pom.xml +++ b/pom.xml @@ -456,7 +456,7 @@ - 1.0.9-SNAPSHOT + 1.0.9 2.11.1 2.3.4 1.5.0 From 4ac8a93022d2f9e6ad9e1e98b107469971262dd6 Mon Sep 17 00:00:00 2001 From: tiffanyperumpail Date: Thu, 6 Aug 2015 11:29:59 -0700 Subject: [PATCH 026/109] Change swagger-parser-version to 1.0.9-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ce59ad54f41e..45fba414722a 100644 --- a/pom.xml +++ b/pom.xml @@ -456,7 +456,7 @@ - 1.0.9 + 1.0.9-SNAPSHOT 2.11.1 2.3.4 1.5.0 From 7a92f53b5538e065b51384bd24e5da44986afca4 Mon Sep 17 00:00:00 2001 From: Andrew B Date: Thu, 6 Aug 2015 15:22:18 -0700 Subject: [PATCH 027/109] Adding some tests for PR 1051 --- .../test/scala/Java/JavaModelEnumTest.scala | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/modules/swagger-codegen/src/test/scala/Java/JavaModelEnumTest.scala b/modules/swagger-codegen/src/test/scala/Java/JavaModelEnumTest.scala index e5191e1ae238..30a70ca6dfbc 100644 --- a/modules/swagger-codegen/src/test/scala/Java/JavaModelEnumTest.scala +++ b/modules/swagger-codegen/src/test/scala/Java/JavaModelEnumTest.scala @@ -31,4 +31,55 @@ class JavaModelEnumTest extends FlatSpec with Matchers { enumVar.baseType should be("String") enumVar.isEnum should equal(true) } + + it should "not override identical parent enums" in { + + val identicalEnumProperty = new StringProperty() + identicalEnumProperty.setEnum(List("VALUE1", "VALUE2", "VALUE3").asJava) + + val subEnumProperty = new StringProperty() + subEnumProperty.setEnum(List("SUB1", "SUB2", "SUB3").asJava) + + // Add one enum ptoperty to the parent + val parentProperties = new java.util.HashMap[String, Property]() + parentProperties.put("sharedThing", identicalEnumProperty) + + // Add TWO enums to the subType model; one of which is identical to the one in parent class + val subProperties = new java.util.HashMap[String, Property]() + subProperties.put("sharedThing", identicalEnumProperty) + subProperties.put("unsharedThing", identicalEnumProperty) + + val parentModel = new ModelImpl(); + parentModel.setProperties(parentProperties); + parentModel.name("parentModel"); + + val subModel = new ModelImpl(); + subModel.setProperties(subProperties); + subModel.name("subModel"); + + val model = new ComposedModel() + .parent(new RefModel(parentModel.getName())) + .child(subModel) + .interfaces(new java.util.ArrayList[RefModel]()) + + val codegen = new JavaClientCodegen() + val allModels = new java.util.HashMap[String, Model]() + allModels.put(codegen.toModelName(parentModel.getName()), parentModel) + allModels.put(codegen.toModelName(subModel.getName()), subModel) + + val cm = codegen.fromModel("sample", model, allModels) + + cm.name should be("sample") + cm.classname should be("Sample") + cm.parent should be("ParentModel") + cm.imports.asScala should be(Set("ParentModel")) + + // Assert that only the unshared/uninherited enum remains + cm.vars.size should be (1) + val enumVar = cm.vars.get(0) + enumVar.baseName should be("unsharedThing") + enumVar.datatype should be("String") + enumVar.datatypeWithEnum should be("UnsharedThingEnum") + enumVar.isEnum should equal(true) + } } \ No newline at end of file From a41361c959cd5b56f3b34d813c32a02952a224db Mon Sep 17 00:00:00 2001 From: xhh Date: Fri, 7 Aug 2015 22:16:32 +0800 Subject: [PATCH 028/109] Change the "--library" option into a config option --- README.md | 26 ++++--------------- bin/java-petstore-jersey2.json | 5 +++- bin/java-petstore-jersey2.sh | 2 +- .../io/swagger/codegen/cmd/ConfigHelp.java | 2 +- .../java/io/swagger/codegen/cmd/Generate.java | 15 +++++------ .../io/swagger/codegen/DefaultCodegen.java | 12 ++++++++- .../codegen/languages/JavaClientCodegen.java | 3 ++- 7 files changed, 31 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 72daf8612512..a7f7f4e45d9b 100644 --- a/README.md +++ b/README.md @@ -116,10 +116,6 @@ OPTIONS client language to generate (maybe class name in classpath, required) - -L , --library - Library template (sub-template) to use. Run library-help -l {lang} - command for a list of supported libraries. - -o , --output where to write the generated files (current dir by default) @@ -148,23 +144,6 @@ Other languages have petstore samples, too: ./bin/objc-petstore.sh ``` -Various library templates (sub-templates) might be available for a specific language. Running `library-help -l {lang}` will show all library templates supported. - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar library-help -l java -``` - -Output - -``` -LIBRARY OPTIONS - - HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2 - - jersey2 - HTTP client: Jersey client 2.6 -``` - ### Generating libraries from your server It's just as easy--just use the `-i` flag to point to either a server or file. @@ -270,6 +249,11 @@ CONFIG OPTIONS sourceFolder source folder for generated code + + library + library template (sub-template) to use: + - HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2 + jersey2 - HTTP client: Jersey client 2.6 ``` Your config file for java can look like diff --git a/bin/java-petstore-jersey2.json b/bin/java-petstore-jersey2.json index 1ba121afe219..af343e1d6b88 100644 --- a/bin/java-petstore-jersey2.json +++ b/bin/java-petstore-jersey2.json @@ -1 +1,4 @@ -{"artifactId": "swagger-petstore-jersey2"} \ No newline at end of file +{ + "library": "jersey2", + "artifactId": "swagger-petstore-jersey2" +} \ No newline at end of file diff --git a/bin/java-petstore-jersey2.sh b/bin/java-petstore-jersey2.sh index 94f16422d1af..cb51c1e1a8d4 100755 --- a/bin/java-petstore-jersey2.sh +++ b/bin/java-petstore-jersey2.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 -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java --library jersey2 -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2" java $JAVA_OPTS -jar $executable $ags diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/ConfigHelp.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/ConfigHelp.java index 6b34a4bf56df..78e4b9bd6baf 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/ConfigHelp.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/ConfigHelp.java @@ -45,7 +45,7 @@ public class ConfigHelp implements Runnable { System.out.println("CONFIG OPTIONS"); for (CliOption langCliOption : config.cliOptions()) { System.out.println("\t" + langCliOption.getOpt()); - System.out.println("\t " + langCliOption.getDescription()); + System.out.println("\t " + langCliOption.getDescription().replaceAll("\n", "\n\t ")); System.out.println(); } } diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java index 99f597740d9d..cf22ae91b629 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java @@ -40,11 +40,6 @@ public class Generate implements Runnable { description = "client language to generate (maybe class name in classpath, required)") private String lang; - @Option(name = {"-L", "--library"}, title = "library", - description = "Library template (sub-template) to use. Run library-help -l {lang} " + - "command for a list of supported libraries.") - private String library; - @Option(name = {"-o", "--output"}, title = "output directory", description = "where to write the generated files (current dir by default)") private String output = ""; @@ -110,7 +105,6 @@ public class Generate implements Runnable { } CodegenConfig config = forName(lang); - config.setLibrary(library); config.setOutputDir(new File(output).getAbsolutePath()); if (null != templateDir) { @@ -121,8 +115,13 @@ public class Generate implements Runnable { Config genConfig = ConfigParser.read(configFile); if (null != genConfig) { for (CliOption langCliOption : config.cliOptions()) { - if (genConfig.hasOption(langCliOption.getOpt())) { - config.additionalProperties().put(langCliOption.getOpt(), genConfig.getOption(langCliOption.getOpt())); + String opt = langCliOption.getOpt(); + if (genConfig.hasOption(opt)) { + config.additionalProperties().put(opt, genConfig.getOption(opt)); + // the "library" config option is for library template (sub-template) + if ("library".equals(opt)) { + config.setLibrary(genConfig.getOption(opt)); + } } } } 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 641fa43b6d4b..179387a0b370 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 @@ -55,6 +55,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -81,7 +82,7 @@ public class DefaultCodegen { protected List cliOptions = new ArrayList(); protected boolean skipOverwrite; protected boolean supportsInheritance = false; - protected Map supportedLibraries = new HashMap(); + protected Map supportedLibraries = new LinkedHashMap(); protected String library = null; public List cliOptions() { @@ -1392,6 +1393,7 @@ public class DefaultCodegen { /** * All library templates supported. + * (key: library name, value: library description) */ public Map supportedLibraries() { return supportedLibraries; @@ -1409,4 +1411,12 @@ public class DefaultCodegen { public String getLibrary() { return library; } + + protected CliOption buildLibraryCliOption(Map supportedLibraries) { + StringBuilder sb = new StringBuilder("library template (sub-template) to use:"); + for (String lib : supportedLibraries.keySet()) { + sb.append("\n").append(lib).append(" - ").append(supportedLibraries.get(lib)); + } + return new CliOption("library", sb.toString()); + } } 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 4df04fc9a1c8..e5437f2fcb82 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 @@ -62,8 +62,9 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { cliOptions.add(new CliOption("artifactVersion", "artifact version in generated pom.xml")); cliOptions.add(new CliOption("sourceFolder", "source folder for generated code")); - supportedLibraries.put("", "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2"); + supportedLibraries.put("", "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2"); supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6"); + cliOptions.add(buildLibraryCliOption(supportedLibraries)); } public CodegenType getTag() { From b686b532590bf04b1e15ea78fe834a6008af65d2 Mon Sep 17 00:00:00 2001 From: xhh Date: Sat, 8 Aug 2015 11:14:06 +0800 Subject: [PATCH 029/109] Support overriding API/model templates with library template --- .../io/swagger/codegen/AbstractGenerator.java | 17 ++++++++++++++++ .../io/swagger/codegen/DefaultGenerator.java | 20 +++++-------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java index 0d530e7c959a..2c90f4255ece 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/AbstractGenerator.java @@ -60,6 +60,23 @@ public abstract class AbstractGenerator { throw new RuntimeException("can't load template " + name); } + /** + * Get the template file path with template dir prepended, and use the + * library template if exists. + */ + public String getFullTemplateFile(CodegenConfig config, String templateFile) { + String library = config.getLibrary(); + if (library != null && !"".equals(library)) { + String libTemplateFile = config.templateDir() + File.separator + + "libraries" + File.separator + library + File.separator + + templateFile; + if (templateExists(libTemplateFile)) { + return libTemplateFile; + } + } + return config.templateDir() + File.separator + templateFile; + } + public boolean templateExists(String name) { return this.getClass().getClassLoader().getResource(getCPResourcePath(name)) != null; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 535c9baec72c..37d654734879 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -139,7 +139,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { if (!config.shouldOverwrite(filename)) { continue; } - String template = readTemplate(config.templateDir() + File.separator + templateName); + String templateFile = getFullTemplateFile(config, templateName); + String template = readTemplate(templateFile); Template tmpl = Mustache.compiler() .withLoader(new Mustache.TemplateLoader() { public Reader getTemplate(String name) { @@ -191,7 +192,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { continue; } - String template = readTemplate(config.templateDir() + File.separator + templateName); + String templateFile = getFullTemplateFile(config, templateName); + String template = readTemplate(templateFile); Template tmpl = Mustache.compiler() .withLoader(new Mustache.TemplateLoader() { public Reader getTemplate(String name) { @@ -262,19 +264,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { continue; } - String templateFile = null; - String library = config.getLibrary(); - if (library != null && !"".equals(library)) { - String libTemplateFile = config.templateDir() + File.separator + - "libraries" + File.separator + library + File.separator + - support.templateFile; - if (templateExists(libTemplateFile)) { - templateFile = libTemplateFile; - } - } - if (templateFile == null) { - templateFile = config.templateDir() + File.separator + support.templateFile; - } + String templateFile = getFullTemplateFile(config, support.templateFile); if (templateFile.endsWith("mustache")) { String template = readTemplate(templateFile); From 6fbb8ab1e00e837209f566081b04b8196b52c16b Mon Sep 17 00:00:00 2001 From: russellb337 Date: Tue, 11 Aug 2015 12:42:06 -0700 Subject: [PATCH 030/109] add @Generated annotation to all Java class templates --- .../src/main/java/io/swagger/codegen/DefaultGenerator.java | 5 +++++ .../src/main/resources/Java/ApiClient.mustache | 1 + .../src/main/resources/Java/Configuration.mustache | 1 + .../src/main/resources/Java/JsonUtil.mustache | 1 + .../swagger-codegen/src/main/resources/Java/Pair.mustache | 1 + .../src/main/resources/Java/StringUtil.mustache | 1 + modules/swagger-codegen/src/main/resources/Java/api.mustache | 1 + .../src/main/resources/Java/apiException.mustache | 1 + .../src/main/resources/Java/auth/ApiKeyAuth.mustache | 1 + .../src/main/resources/Java/auth/Authentication.mustache | 1 + .../src/main/resources/Java/auth/HttpBasicAuth.mustache | 1 + .../src/main/resources/Java/auth/OAuth.mustache | 1 + .../src/main/resources/Java/generatedAnnotation.mustache | 1 + .../swagger-codegen/src/main/resources/Java/model.mustache | 1 + .../src/main/resources/JavaInflector/api.mustache | 1 + .../resources/JavaInflector/generatedAnnotation.mustache | 1 + .../src/main/resources/JavaInflector/model.mustache | 1 + .../src/main/resources/JavaJaxRS/ApiException.mustache | 1 + .../src/main/resources/JavaJaxRS/ApiOriginFilter.mustache | 1 + .../src/main/resources/JavaJaxRS/ApiResponseMessage.mustache | 1 + .../src/main/resources/JavaJaxRS/NotFoundException.mustache | 1 + .../src/main/resources/JavaJaxRS/api.mustache | 1 + .../src/main/resources/JavaJaxRS/apiService.mustache | 1 + .../src/main/resources/JavaJaxRS/apiServiceFactory.mustache | 1 + .../src/main/resources/JavaJaxRS/apiServiceImpl.mustache | 1 + .../main/resources/JavaJaxRS/generatedAnnotation.mustache | 1 + .../src/main/resources/JavaJaxRS/model.mustache | 1 + .../resources/JavaSpringMVC/generatedAnnotation.mustache | 1 + 28 files changed, 32 insertions(+) create mode 100644 modules/swagger-codegen/src/main/resources/Java/generatedAnnotation.mustache create mode 100644 modules/swagger-codegen/src/main/resources/JavaInflector/generatedAnnotation.mustache create mode 100644 modules/swagger-codegen/src/main/resources/JavaJaxRS/generatedAnnotation.mustache create mode 100644 modules/swagger-codegen/src/main/resources/JavaSpringMVC/generatedAnnotation.mustache diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 0b6f677857ac..fb52d38739d5 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -16,6 +16,7 @@ import io.swagger.models.auth.SecuritySchemeDefinition; import io.swagger.util.Json; import org.apache.commons.io.IOUtils; +import org.joda.time.DateTime; import java.io.File; import java.io.FileInputStream; @@ -62,6 +63,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { List files = new ArrayList(); try { config.processOpts(); + + config.additionalProperties().put("generatedTime", DateTime.now().toString()); + config.additionalProperties().put("generatorClass", config.getClass().toString()); + if (swagger.getInfo() != null) { Info info = swagger.getInfo(); if (info.getTitle() != null) { diff --git a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache index 79b445948162..6930b548d42b 100644 --- a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache @@ -40,6 +40,7 @@ import {{invokerPackage}}.auth.HttpBasicAuth; import {{invokerPackage}}.auth.ApiKeyAuth; import {{invokerPackage}}.auth.OAuth; +{{>generatedAnnotation}} public class ApiClient { private Map hostMap = new HashMap(); private Map defaultHeaderMap = new HashMap(); diff --git a/modules/swagger-codegen/src/main/resources/Java/Configuration.mustache b/modules/swagger-codegen/src/main/resources/Java/Configuration.mustache index e936b423a91c..4629c4e17be4 100644 --- a/modules/swagger-codegen/src/main/resources/Java/Configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/Configuration.mustache @@ -1,5 +1,6 @@ package {{invokerPackage}}; +{{>generatedAnnotation}} public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/modules/swagger-codegen/src/main/resources/Java/JsonUtil.mustache b/modules/swagger-codegen/src/main/resources/Java/JsonUtil.mustache index 29d5f55eceea..4866f8c0fced 100644 --- a/modules/swagger-codegen/src/main/resources/Java/JsonUtil.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/JsonUtil.mustache @@ -7,6 +7,7 @@ import com.fasterxml.jackson.core.JsonGenerator.Feature; import com.fasterxml.jackson.datatype.joda.*; +{{>generatedAnnotation}} public class JsonUtil { public static ObjectMapper mapper; diff --git a/modules/swagger-codegen/src/main/resources/Java/Pair.mustache b/modules/swagger-codegen/src/main/resources/Java/Pair.mustache index 9805c74903b2..e2a47317afe4 100644 --- a/modules/swagger-codegen/src/main/resources/Java/Pair.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/Pair.mustache @@ -1,5 +1,6 @@ package {{invokerPackage}}; +{{>generatedAnnotation}} public class Pair { private String name = ""; private String value = ""; diff --git a/modules/swagger-codegen/src/main/resources/Java/StringUtil.mustache b/modules/swagger-codegen/src/main/resources/Java/StringUtil.mustache index 035d6739dce2..073966b0c217 100644 --- a/modules/swagger-codegen/src/main/resources/Java/StringUtil.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/StringUtil.mustache @@ -1,5 +1,6 @@ package {{invokerPackage}}; +{{>generatedAnnotation}} public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/modules/swagger-codegen/src/main/resources/Java/api.mustache b/modules/swagger-codegen/src/main/resources/Java/api.mustache index c48c0503f5c5..f8464e79fd2c 100644 --- a/modules/swagger-codegen/src/main/resources/Java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/api.mustache @@ -21,6 +21,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; +{{>generatedAnnotation}} {{#operations}} public class {{classname}} { private ApiClient {{localVariablePrefix}}apiClient; diff --git a/modules/swagger-codegen/src/main/resources/Java/apiException.mustache b/modules/swagger-codegen/src/main/resources/Java/apiException.mustache index 9afe96c6ffb4..bb3b53b0aeb2 100644 --- a/modules/swagger-codegen/src/main/resources/Java/apiException.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/apiException.mustache @@ -3,6 +3,7 @@ package {{invokerPackage}}; import java.util.Map; import java.util.List; +{{>generatedAnnotation}} public class ApiException extends Exception { private int code = 0; private String message = null; diff --git a/modules/swagger-codegen/src/main/resources/Java/auth/ApiKeyAuth.mustache b/modules/swagger-codegen/src/main/resources/Java/auth/ApiKeyAuth.mustache index a1824b551ca9..04be4812292c 100644 --- a/modules/swagger-codegen/src/main/resources/Java/auth/ApiKeyAuth.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/auth/ApiKeyAuth.mustache @@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair; import java.util.Map; import java.util.List; +{{>generatedAnnotation}} public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/modules/swagger-codegen/src/main/resources/Java/auth/Authentication.mustache b/modules/swagger-codegen/src/main/resources/Java/auth/Authentication.mustache index 265c74cb76f9..037ef58ab90e 100644 --- a/modules/swagger-codegen/src/main/resources/Java/auth/Authentication.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/auth/Authentication.mustache @@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair; import java.util.Map; import java.util.List; +{{>generatedAnnotation}} public interface Authentication { /** Apply authentication settings to header and query params. */ void applyToParams(List queryParams, Map headerParams); diff --git a/modules/swagger-codegen/src/main/resources/Java/auth/HttpBasicAuth.mustache b/modules/swagger-codegen/src/main/resources/Java/auth/HttpBasicAuth.mustache index 032ea57d4e89..63813e2504e1 100644 --- a/modules/swagger-codegen/src/main/resources/Java/auth/HttpBasicAuth.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/auth/HttpBasicAuth.mustache @@ -8,6 +8,7 @@ import java.util.List; import java.io.UnsupportedEncodingException; import javax.xml.bind.DatatypeConverter; +{{>generatedAnnotation}} public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/modules/swagger-codegen/src/main/resources/Java/auth/OAuth.mustache b/modules/swagger-codegen/src/main/resources/Java/auth/OAuth.mustache index 66cf2ac8f0f8..a1f1b6a827c2 100644 --- a/modules/swagger-codegen/src/main/resources/Java/auth/OAuth.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/auth/OAuth.mustache @@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair; import java.util.Map; import java.util.List; +{{>generatedAnnotation}} public class OAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { diff --git a/modules/swagger-codegen/src/main/resources/Java/generatedAnnotation.mustache b/modules/swagger-codegen/src/main/resources/Java/generatedAnnotation.mustache new file mode 100644 index 000000000000..49110fc1ad93 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/generatedAnnotation.mustache @@ -0,0 +1 @@ +@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Java/model.mustache b/modules/swagger-codegen/src/main/resources/Java/model.mustache index 0e12f514c488..39f0f0b6fa12 100644 --- a/modules/swagger-codegen/src/main/resources/Java/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/model.mustache @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * {{description}} **/{{/description}} @ApiModel(description = "{{{description}}}") +{{>generatedAnnotation}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{#vars}}{{#isEnum}} public enum {{datatypeWithEnum}} { diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache index 5f5b5b1df9a4..829a9daeabc4 100644 --- a/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache @@ -13,6 +13,7 @@ import {{modelPackage}}.*; {{#imports}}import {{import}}; {{/imports}} +{{>generatedAnnotation}} {{#operations}} public class {{classname}} { diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/generatedAnnotation.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/generatedAnnotation.mustache new file mode 100644 index 000000000000..49110fc1ad93 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/generatedAnnotation.mustache @@ -0,0 +1 @@ +@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/model.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/model.mustache index 300d5e61dd9d..db2480a85403 100644 --- a/modules/swagger-codegen/src/main/resources/JavaInflector/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/model.mustache @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * {{description}} **/{{/description}} @ApiModel(description = "{{{description}}}") +{{>generatedAnnotation}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{#vars}}{{#isEnum}} public enum {{datatypeWithEnum}} { diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiException.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiException.mustache index ffab3b1088e7..11b4036b8326 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiException.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiException.mustache @@ -1,5 +1,6 @@ package {{apiPackage}}; +{{>generatedAnnotation}} public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache index 68675432c648..5db3301b3d93 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache @@ -5,6 +5,7 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; +{{>generatedAnnotation}} public class ApiOriginFilter implements javax.servlet.Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiResponseMessage.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiResponseMessage.mustache index 94711b26efb2..2b9a2b1f8c5b 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiResponseMessage.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiResponseMessage.mustache @@ -3,6 +3,7 @@ package {{apiPackage}}; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement +{{>generatedAnnotation}} public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/NotFoundException.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/NotFoundException.mustache index 8ab2c99e4f84..1bd5e207d7be 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/NotFoundException.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/NotFoundException.mustache @@ -1,5 +1,6 @@ package {{apiPackage}}; +{{>generatedAnnotation}} public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache index 3216b60d5168..9e1f808806ea 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache @@ -26,6 +26,7 @@ import javax.ws.rs.*; {{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} {{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} @io.swagger.annotations.Api(value = "/{{baseName}}", description = "the {{baseName}} API") +{{>generatedAnnotation}} {{#operations}} public class {{classname}} { diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiService.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiService.mustache index 43e7cd8685ce..a731da6c11cc 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiService.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiService.mustache @@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; +{{>generatedAnnotation}} {{#operations}} public abstract class {{classname}}Service { {{#operation}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceFactory.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceFactory.mustache index a434311d285a..1bb63bc07751 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceFactory.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceFactory.mustache @@ -3,6 +3,7 @@ package {{package}}.factories; import {{package}}.{{classname}}Service; import {{package}}.impl.{{classname}}ServiceImpl; +{{>generatedAnnotation}} public class {{classname}}ServiceFactory { private final static {{classname}}Service service = new {{classname}}ServiceImpl(); diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceImpl.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceImpl.mustache index d49fa4952a2c..0acd755745ef 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceImpl.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/apiServiceImpl.mustache @@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; +{{>generatedAnnotation}} {{#operations}} public class {{classname}}ServiceImpl extends {{classname}}Service { {{#operation}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/generatedAnnotation.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/generatedAnnotation.mustache new file mode 100644 index 000000000000..49110fc1ad93 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/generatedAnnotation.mustache @@ -0,0 +1 @@ +@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/model.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/model.mustache index 300d5e61dd9d..db2480a85403 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/model.mustache @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * {{description}} **/{{/description}} @ApiModel(description = "{{{description}}}") +{{>generatedAnnotation}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{#vars}}{{#isEnum}} public enum {{datatypeWithEnum}} { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/generatedAnnotation.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/generatedAnnotation.mustache new file mode 100644 index 000000000000..49110fc1ad93 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/generatedAnnotation.mustache @@ -0,0 +1 @@ +@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") \ No newline at end of file From 38fccbd73d32effa6027259c110c3ea462a5386a Mon Sep 17 00:00:00 2001 From: russellb337 Date: Tue, 11 Aug 2015 12:42:18 -0700 Subject: [PATCH 031/109] add @Generated to all Java class templates --- .../src/main/resources/JavaSpringMVC/api.mustache | 1 + .../src/main/resources/JavaSpringMVC/apiException.mustache | 1 + .../src/main/resources/JavaSpringMVC/apiOriginFilter.mustache | 1 + .../src/main/resources/JavaSpringMVC/apiResponseMessage.mustache | 1 + .../src/main/resources/JavaSpringMVC/model.mustache | 1 + .../src/main/resources/JavaSpringMVC/notFoundException.mustache | 1 + .../src/main/resources/JavaSpringMVC/swaggerConfig.mustache | 1 + .../main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache | 1 + .../src/main/resources/JavaSpringMVC/webApplication.mustache | 1 + .../main/resources/JavaSpringMVC/webMvcConfiguration.mustache | 1 + 10 files changed, 10 insertions(+) diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache index d6a24b69311b..e6e8d6fc04ce 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache @@ -30,6 +30,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/{{baseName}}", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/{{baseName}}", description = "the {{baseName}} API") +{{>generatedAnnotation}} {{#operations}} public class {{classname}} { {{#operation}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiException.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiException.mustache index ffab3b1088e7..11b4036b8326 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiException.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiException.mustache @@ -1,5 +1,6 @@ package {{apiPackage}}; +{{>generatedAnnotation}} public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiOriginFilter.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiOriginFilter.mustache index 68675432c648..5db3301b3d93 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiOriginFilter.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiOriginFilter.mustache @@ -5,6 +5,7 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; +{{>generatedAnnotation}} public class ApiOriginFilter implements javax.servlet.Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiResponseMessage.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiResponseMessage.mustache index 94711b26efb2..2b9a2b1f8c5b 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiResponseMessage.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/apiResponseMessage.mustache @@ -3,6 +3,7 @@ package {{apiPackage}}; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement +{{>generatedAnnotation}} public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache index 300d5e61dd9d..db2480a85403 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * {{description}} **/{{/description}} @ApiModel(description = "{{{description}}}") +{{>generatedAnnotation}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { {{#vars}}{{#isEnum}} public enum {{datatypeWithEnum}} { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/notFoundException.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/notFoundException.mustache index 8ab2c99e4f84..1bd5e207d7be 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/notFoundException.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/notFoundException.mustache @@ -1,5 +1,6 @@ package {{apiPackage}}; +{{>generatedAnnotation}} public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerConfig.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerConfig.mustache index b33ee7fc994a..4a6e6879df32 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerConfig.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerConfig.mustache @@ -18,6 +18,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @EnableSwagger2 //Loads the spring beans required by the framework @PropertySource("classpath:swagger.properties") @Import(SwaggerUiConfiguration.class) +{{>generatedAnnotation}} public class SwaggerConfig { @Bean ApiInfo apiInfo() { diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache index 652dc3103582..0b515fe2cc8c 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/swaggerUiConfiguration.mustache @@ -8,6 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @Configuration @EnableWebMvc +{{>generatedAnnotation}} public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter { private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" }; diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webApplication.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webApplication.mustache index 6910ad11b765..426f831582eb 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webApplication.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webApplication.mustache @@ -2,6 +2,7 @@ package {{configPackage}}; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; +{{>generatedAnnotation}} public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer { @Override diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webMvcConfiguration.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webMvcConfiguration.mustache index 03904e51e794..d60c126316e0 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webMvcConfiguration.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/webMvcConfiguration.mustache @@ -3,6 +3,7 @@ package {{configPackage}}; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; +{{>generatedAnnotation}} public class WebMvcConfiguration extends WebMvcConfigurationSupport { @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { From a0eeb90a97b2a19ccc8555756cbf12af8ceea256 Mon Sep 17 00:00:00 2001 From: russellb337 Date: Tue, 11 Aug 2015 12:50:19 -0700 Subject: [PATCH 032/109] fixing bug --- .../src/main/java/io/swagger/codegen/DefaultGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index fb52d38739d5..a2f32706a0e3 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -64,7 +64,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { try { config.processOpts(); - config.additionalProperties().put("generatedTime", DateTime.now().toString()); + config.additionalProperties().put("generatedDate", DateTime.now().toString()); config.additionalProperties().put("generatorClass", config.getClass().toString()); if (swagger.getInfo() != null) { From b14edffc795083ea13ff35e733069989ac042744 Mon Sep 17 00:00:00 2001 From: David Biesack Date: Thu, 13 Aug 2015 13:46:32 -0400 Subject: [PATCH 033/109] improve static html; add template guards for collections. Update -core dependency --- .../io/swagger/codegen/CodegenOperation.java | 17 ++ .../main/resources/htmlDocs/index.mustache | 149 +++++++++++++++--- .../resources/htmlDocs/style.css.mustache | 8 + pom.xml | 2 +- 4 files changed, 152 insertions(+), 24 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java index b795f8e38e25..4f30cc01ccba 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java @@ -30,6 +30,23 @@ public class CodegenOperation { public List> examples; public ExternalDocs externalDocs; + private boolean nonempty(List params) + { + return params != null && params.size() > 0; + } + public boolean getHasBodyParam() { + return nonempty(bodyParams); + } + public boolean getHasQueryParams() { + return nonempty(bodyParams); + } + public boolean getHasHeaderParams() { + return nonempty(bodyParams); + } + public boolean getHasPathParams() { + return nonempty(bodyParams); + } + // legacy support public String nickname; } diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache index ce881084bc2f..584db3b7a855 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache @@ -1,52 +1,158 @@ - + + + - - API Reference + {{{appName}}} + +

{{{appName}}}

-
{{{appDescription}}} for {{partner}}
+
{{{appDescription}}}
{{#infoUrl}}
More information: {{{infoUrl}}}
{{/infoUrl}} {{#infoEmail}}
Contact Info: {{{infoEmail}}}
{{/infoEmail}} {{#version}}
Version: {{{version}}}
{{/version}}
{{{licenseInfo}}}
{{{licenseUrl}}}

Access

-
Customize this message as you see fit!
-

Methods

+ {{access}} + +

Methods

+ [ Jump to Models ] + + {{! for the tables of content, I cheat and don't use CSS styles.... }} +

Table of Contents

+
{{access}}
+ {{#apiInfo}} +
    + {{#apis}} + {{#operations}} + {{#operation}} +
  1. {{httpMethod}} {{path}}
  2. + {{/operation}} + {{/operations}} + {{/apis}} +
+ {{/apiInfo}} + {{#apiInfo}} {{#apis}} - {{#operations}}{{#operation}} -
-
{{httpMethod}}: {{path}}
-
{{#tags}}{{this}}{{/tags}}
-
{{nickname}} {{summary}}
+ {{#operations}} + {{#operation}} +
+
+ Up +
{{httpMethod}} {{path}}
+
{{summary}} ({{nickname}})
+ {{! notes is operation.description. So why rename it and make it super confusing???? }}
{{notes}}
-

Parameters

+ {{#hasPathParams}} +

Path parameters

- {{#allParams}}{{>queryParam}}{{>pathParam}}{{>bodyParam}}{{>headerParam}}{{>formParam}} - {{/allParams}} + {{#pathParams}}{{>pathParam}}{{/pathParams}}
+ {{/hasPathParams}} + + {{#hasConsumes}} +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    + {{#consumes}} +
  • {{mediaType}}
  • + {{/consumes}} +
+ {{/hasConsumes}} + + {{#hasBodyParam}} +

Request body

+
+ {{#bodyParams}}{{>bodyParam}}{{/bodyParams}} +
+ {{/hasBodyParam}} + + {{#hasHeaderParam}} +

Request headers

+
+ {{#headerParam}}{{>headerParam}}{{/headerParam}} +
+ {{/hasHeaderParam}} + + {{#hasQueryParams}} +

Query parameters

+
+ {{#queryParams}}{{>queryParam}}{{/queryParams}} +
+ {{/hasQueryParams}} + + + + {{#hasExamples}} + {{#examples}} +

Example data

+
Content-Type: {{{contentType}}}
+
{{{example}}}
+ {{/examples}} + {{/hasExamples}} + + {{#hasProduces}} +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + {{#produces}} +
  • {{mediaType}}
  • + {{/produces}} +
+ {{/hasProduces}} + +

Responses

+ {{#responses}} +

{{code}}

+ {{message}} {{#examples}}

Example data

Content-Type: {{{contentType}}}
{{example}}
{{/examples}} + {{/responses}}
-
- {{/operation}}{{/operations}} - {{/apis}}{{/apiInfo}} +
+ {{/operation}} + {{/operations}} + {{/apis}} + {{/apiInfo}} + + +

Models

+ [ Jump to Methods ] + +

Table of Contents

+
    + {{#models}} + {{#model}} +
  1. {{classname}}
  2. + {{/model}} + {{/models}} +
-

Models

{{#models}} {{#model}}
-

{{classname}}

+

{{classname}} Up

{{#vars}}
{{name}} {{#isNotRequired}}(optional){{/isNotRequired}}
{{datatype}} {{description}}
{{/vars}} @@ -54,8 +160,5 @@
{{/model}} {{/models}} - \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache index 14ab06a7f7e5..d69f0e7b1617 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache @@ -57,6 +57,10 @@ pre { margin-bottom: 2px; } +.http-method { + text-transform: uppercase; +} + pre.get { background-color: #0f6ab4; } @@ -96,6 +100,10 @@ code { background-color: #0f6ab4; } +.up { + float:right; +} + .parameter { width: 500px; } diff --git a/pom.xml b/pom.xml index a7e35de01c39..24d7de3b5a26 100644 --- a/pom.xml +++ b/pom.xml @@ -459,7 +459,7 @@ 1.0.10-SNAPSHOT 2.11.1 2.3.4 - 1.5.3-SNAPSHOT + 1.5.4-SNAPSHOT 2.1.4 2.3 1.2 From 894d571ea5b04a2b57fc4b404601abbb1565cc7f Mon Sep 17 00:00:00 2001 From: geekerzp Date: Wed, 19 Aug 2015 17:48:04 +0800 Subject: [PATCH 034/109] Change reserved word handling in python client. * First, remove the beginning underscores. * Then, append underscore if the var is reserved word or number. --- .../codegen/languages/PythonClientCodegen.java | 8 ++++---- .../main/resources/python/api_client.mustache | 8 +++----- .../resources/python/configuration.mustache | 4 ++-- .../src/main/resources/python/model.mustache | 17 ++++++++--------- .../python/swagger_client/api_client.py | 8 +++----- .../python/swagger_client/configuration.py | 4 ++-- .../python/swagger_client/models/category.py | 17 ++++++++--------- .../python/swagger_client/models/order.py | 17 ++++++++--------- .../python/swagger_client/models/pet.py | 17 ++++++++--------- .../python/swagger_client/models/tag.py | 17 ++++++++--------- .../python/swagger_client/models/user.py | 17 ++++++++--------- 11 files changed, 62 insertions(+), 72 deletions(-) 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 e0e1bdc07f8d..61dc431b8a7b 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 @@ -119,7 +119,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig @Override public String escapeReservedWord(String name) { - return name + "_"; + return "_" + name; } @Override @@ -179,14 +179,14 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig // petId => pet_id name = underscore(dropDots(name)); + // remove leading underscore + name = name.replaceAll("^_*", ""); + // for reserved word or word starting with number, append _ if (reservedWords.contains(name) || name.matches("^\\d.*")) { name = escapeReservedWord(name); } - // remove leading underscore - name = name.replaceAll("^_*", ""); - return name; } diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index ca9a3c051042..7493907d9e85 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -202,11 +202,9 @@ class ApiClient(object): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - obj_dict = {obj.attribute_map[key[1:]]: val - for key, val in iteritems(obj.__dict__) - if key != 'swagger_types' - and key != 'attribute_map' - and val is not None} + obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in iteritems(obj.swagger_types) + if getattr(obj, attr) is not None} return {key: self.sanitize_for_serialization(val) for key, val in iteritems(obj_dict)} diff --git a/modules/swagger-codegen/src/main/resources/python/configuration.mustache b/modules/swagger-codegen/src/main/resources/python/configuration.mustache index 62633cdc4a10..d6d94ff5a50f 100644 --- a/modules/swagger-codegen/src/main/resources/python/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/python/configuration.mustache @@ -23,9 +23,9 @@ import urllib3 try: import httplib except ImportError: - # python3 + # for python3 import http.client as httplib - + import sys import logging diff --git a/modules/swagger-codegen/src/main/resources/python/model.mustache b/modules/swagger-codegen/src/main/resources/python/model.mustache index c810655e3822..4a93aeaf29dd 100644 --- a/modules/swagger-codegen/src/main/resources/python/model.mustache +++ b/modules/swagger-codegen/src/main/resources/python/model.mustache @@ -86,18 +86,17 @@ class {{classname}}(object): """ result = {} - for name, prop in iteritems(self.__dict__): - if name == "attribute_map" or name == "swagger_types": - continue - if isinstance(prop, list): - result[name[1:]] = list(map( + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - prop + value )) - elif hasattr(prop, "to_dict"): - result[name[1:]] = prop.to_dict() + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() else: - result[name[1:]] = prop + result[attr] = value return result diff --git a/samples/client/petstore/python/swagger_client/api_client.py b/samples/client/petstore/python/swagger_client/api_client.py index ca9a3c051042..7493907d9e85 100644 --- a/samples/client/petstore/python/swagger_client/api_client.py +++ b/samples/client/petstore/python/swagger_client/api_client.py @@ -202,11 +202,9 @@ class ApiClient(object): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - obj_dict = {obj.attribute_map[key[1:]]: val - for key, val in iteritems(obj.__dict__) - if key != 'swagger_types' - and key != 'attribute_map' - and val is not None} + obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in iteritems(obj.swagger_types) + if getattr(obj, attr) is not None} return {key: self.sanitize_for_serialization(val) for key, val in iteritems(obj_dict)} diff --git a/samples/client/petstore/python/swagger_client/configuration.py b/samples/client/petstore/python/swagger_client/configuration.py index 8f469b726539..6bc58c90aea7 100644 --- a/samples/client/petstore/python/swagger_client/configuration.py +++ b/samples/client/petstore/python/swagger_client/configuration.py @@ -23,9 +23,9 @@ import urllib3 try: import httplib except ImportError: - # python3 + # for python3 import http.client as httplib - + import sys import logging diff --git a/samples/client/petstore/python/swagger_client/models/category.py b/samples/client/petstore/python/swagger_client/models/category.py index 615e65ea8399..bf70a7d10fd5 100644 --- a/samples/client/petstore/python/swagger_client/models/category.py +++ b/samples/client/petstore/python/swagger_client/models/category.py @@ -97,18 +97,17 @@ class Category(object): """ result = {} - for name, prop in iteritems(self.__dict__): - if name == "attribute_map" or name == "swagger_types": - continue - if isinstance(prop, list): - result[name[1:]] = list(map( + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - prop + value )) - elif hasattr(prop, "to_dict"): - result[name[1:]] = prop.to_dict() + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() else: - result[name[1:]] = prop + result[attr] = value return result diff --git a/samples/client/petstore/python/swagger_client/models/order.py b/samples/client/petstore/python/swagger_client/models/order.py index a381853b91f8..1a7612df190f 100644 --- a/samples/client/petstore/python/swagger_client/models/order.py +++ b/samples/client/petstore/python/swagger_client/models/order.py @@ -203,18 +203,17 @@ class Order(object): """ result = {} - for name, prop in iteritems(self.__dict__): - if name == "attribute_map" or name == "swagger_types": - continue - if isinstance(prop, list): - result[name[1:]] = list(map( + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - prop + value )) - elif hasattr(prop, "to_dict"): - result[name[1:]] = prop.to_dict() + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() else: - result[name[1:]] = prop + result[attr] = value return result diff --git a/samples/client/petstore/python/swagger_client/models/pet.py b/samples/client/petstore/python/swagger_client/models/pet.py index 57dc93387a90..cda4fa1e8cdd 100644 --- a/samples/client/petstore/python/swagger_client/models/pet.py +++ b/samples/client/petstore/python/swagger_client/models/pet.py @@ -203,18 +203,17 @@ class Pet(object): """ result = {} - for name, prop in iteritems(self.__dict__): - if name == "attribute_map" or name == "swagger_types": - continue - if isinstance(prop, list): - result[name[1:]] = list(map( + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - prop + value )) - elif hasattr(prop, "to_dict"): - result[name[1:]] = prop.to_dict() + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() else: - result[name[1:]] = prop + result[attr] = value return result diff --git a/samples/client/petstore/python/swagger_client/models/tag.py b/samples/client/petstore/python/swagger_client/models/tag.py index bfa389520a3c..8108052aae30 100644 --- a/samples/client/petstore/python/swagger_client/models/tag.py +++ b/samples/client/petstore/python/swagger_client/models/tag.py @@ -97,18 +97,17 @@ class Tag(object): """ result = {} - for name, prop in iteritems(self.__dict__): - if name == "attribute_map" or name == "swagger_types": - continue - if isinstance(prop, list): - result[name[1:]] = list(map( + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - prop + value )) - elif hasattr(prop, "to_dict"): - result[name[1:]] = prop.to_dict() + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() else: - result[name[1:]] = prop + result[attr] = value return result diff --git a/samples/client/petstore/python/swagger_client/models/user.py b/samples/client/petstore/python/swagger_client/models/user.py index 7380bc945821..576473adcfa5 100644 --- a/samples/client/petstore/python/swagger_client/models/user.py +++ b/samples/client/petstore/python/swagger_client/models/user.py @@ -247,18 +247,17 @@ class User(object): """ result = {} - for name, prop in iteritems(self.__dict__): - if name == "attribute_map" or name == "swagger_types": - continue - if isinstance(prop, list): - result[name[1:]] = list(map( + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - prop + value )) - elif hasattr(prop, "to_dict"): - result[name[1:]] = prop.to_dict() + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() else: - result[name[1:]] = prop + result[attr] = value return result From fb4c62cc28ed4c486feb40b4ca586e43c34bcfb8 Mon Sep 17 00:00:00 2001 From: Andrew B Date: Wed, 19 Aug 2015 23:08:49 -0700 Subject: [PATCH 035/109] Fixing merge conflict in pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ce59ad54f41e..45fba414722a 100644 --- a/pom.xml +++ b/pom.xml @@ -456,7 +456,7 @@ - 1.0.9 + 1.0.9-SNAPSHOT 2.11.1 2.3.4 1.5.0 From 2b613055822187b1fb3d21c4618d6c167c836fac Mon Sep 17 00:00:00 2001 From: Andrew B Date: Thu, 20 Aug 2015 14:16:10 -0700 Subject: [PATCH 036/109] Fixing issue #1089 --- .../codegen/languages/JavaClientCodegen.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) 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 678cce9263a7..b9e298b125c3 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 @@ -92,7 +92,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public void processOpts() { super.processOpts(); - + if (additionalProperties.containsKey("invokerPackage")) { this.setInvokerPackage((String) additionalProperties.get("invokerPackage")); } else { @@ -130,6 +130,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { this.setLocalVariablePrefix((String) additionalProperties.get("localVariablePrefix")); } + this.sanitizeConfig(); + final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("ApiClient.mustache", invokerFolder, "ApiClient.java")); @@ -146,7 +148,26 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java")); } - + private void sanitizeConfig() { + // Sanitize any config options here. We also have to update the additionalProperties because + // the whole additionalProperties object is injected into the main object passed to the mustache layer + + this.setApiPackage(sanitizePackageName(apiPackage)); + if (additionalProperties.containsKey("apiPackage")) { + this.additionalProperties.put("apiPackage", apiPackage); + } + + this.setModelPackage(sanitizePackageName(modelPackage)); + if (additionalProperties.containsKey("modelPackage")) { + this.additionalProperties.put("modelPackage", modelPackage); + } + + this.setInvokerPackage(sanitizePackageName(invokerPackage)); + if (additionalProperties.containsKey("invokerPackage")) { + this.additionalProperties.put("invokerPackage", invokerPackage); + } + } + @Override public String escapeReservedWord(String name) { return "_" + name; @@ -342,4 +363,14 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { public void setLocalVariablePrefix(String localVariablePrefix) { this.localVariablePrefix = localVariablePrefix; } + + private String sanitizePackageName(String packageName) { + packageName = packageName.trim(); + packageName = packageName.replaceAll("[^a-zA-Z0-9_\\.]", "_"); + if(Strings.isNullOrEmpty(packageName)) { + return "invalidPackageName"; + } + return packageName; + } + } From b7cd38d38b28f6be093596b199d5e0af8b15055e Mon Sep 17 00:00:00 2001 From: geekerzp Date: Fri, 21 Aug 2015 09:42:31 +0800 Subject: [PATCH 037/109] Update objc client. Sanitize request parameters (path, query, header, form, body). --- .../resources/objc/ApiClient-body.mustache | 63 +++++++++- .../resources/objc/ApiClient-header.mustache | 9 ++ .../src/main/resources/objc/api-body.mustache | 24 +--- .../objc/SwaggerClient/SWGApiClient.h | 9 ++ .../objc/SwaggerClient/SWGApiClient.m | 63 +++++++++- .../petstore/objc/SwaggerClient/SWGPet.h | 2 +- .../petstore/objc/SwaggerClient/SWGPetApi.m | 82 ++++++------- .../petstore/objc/SwaggerClient/SWGStoreApi.m | 40 +++---- .../petstore/objc/SwaggerClient/SWGUserApi.m | 108 ++++++------------ 9 files changed, 231 insertions(+), 169 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache index a7d290022f6d..b7643de6ddd6 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache @@ -467,6 +467,7 @@ static void (^reachabilityChangeBlock)(int); -(NSNumber*) requestWithCompletionBlock: (NSString*) path method: (NSString*) method + pathParams: (NSDictionary *) pathParams queryParams: (NSDictionary*) queryParams formParams: (NSDictionary *) formParams files: (NSDictionary *) files @@ -499,12 +500,25 @@ static void (^reachabilityChangeBlock)(int); self.responseSerializer = [AFHTTPResponseSerializer serializer]; } + // sanitize parameters + pathParams = [self sanitizeForSerialization:pathParams]; + queryParams = [self sanitizeForSerialization:queryParams]; + headerParams = [self sanitizeForSerialization:headerParams]; + formParams = [self sanitizeForSerialization:formParams]; + body = [self sanitizeForSerialization:body]; + // auth setting [self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings]; + NSMutableString *resourcePath = [NSMutableString stringWithString:path]; + [pathParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + [resourcePath replaceCharactersInRange:[resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", key, @"}"]] + withString:[SWGApiClient escape:obj]]; + }]; + NSMutableURLRequest * request = nil; - NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams]; + NSString* pathWithQueryParams = [self pathWithQueryParamsToString:resourcePath queryParams:queryParams]; if ([pathWithQueryParams hasPrefix:@"/"]) { pathWithQueryParams = [pathWithQueryParams substringFromIndex:1]; } @@ -540,20 +554,21 @@ static void (^reachabilityChangeBlock)(int); } } + // request cache BOOL hasHeaderParams = false; if(headerParams != nil && [headerParams count] > 0) { hasHeaderParams = true; } if(offlineState) { - NSLog(@"%@ cache forced", path); + NSLog(@"%@ cache forced", resourcePath); [request setCachePolicy:NSURLRequestReturnCacheDataDontLoad]; } else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) { - NSLog(@"%@ cache enabled", path); + NSLog(@"%@ cache enabled", resourcePath); [request setCachePolicy:NSURLRequestUseProtocolCachePolicy]; } else { - NSLog(@"%@ cache disabled", path); + NSLog(@"%@ cache disabled", resourcePath); [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; } @@ -671,4 +686,44 @@ static void (^reachabilityChangeBlock)(int); *querys = [NSDictionary dictionaryWithDictionary:querysWithAuth]; } +- (id) sanitizeForSerialization:(id) object { + if (object == nil) { + return nil; + } + else if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]] || [object isKindOfClass:[SWGQueryParamCollection class]]) { + return object; + } + else if ([object isKindOfClass:[NSDate class]]) { + return [object ISO8601String]; + } + else if ([object isKindOfClass:[NSArray class]]) { + NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[object count]]; + [object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + if (obj) { + [sanitizedObjs addObject:[self sanitizeForSerialization:obj]]; + } + }]; + return sanitizedObjs; + } + else if ([object isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[object count]]; + [object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + if (obj) { + [sanitizedObjs setValue:[self sanitizeForSerialization:obj] forKey:key]; + } + }]; + return sanitizedObjs; + } + else if ([object isKindOfClass:[SWGObject class]]) { + return [object toDictionary]; + } + else { + NSException *e = [NSException + exceptionWithName:@"InvalidObjectArgumentException" + reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", object] + userInfo:nil]; + @throw e; + } +} + @end diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache index 46d424d735f0..eba627058795 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache @@ -168,6 +168,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; * * @param path Request url. * @param method Request method. + * @param pathParams Request path parameters. * @param queryParams Request query parameters. * @param body Request body. * @param headerParams Request header parameters. @@ -180,6 +181,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; */ -(NSNumber*) requestWithCompletionBlock:(NSString*) path method:(NSString*) method + pathParams:(NSDictionary *) pathParams queryParams:(NSDictionary*) queryParams formParams:(NSDictionary *) formParams files:(NSDictionary *) files @@ -191,4 +193,11 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; responseType:(NSString *) responseType completionBlock:(void (^)(id, NSError *))completionBlock; +/** + * Sanitize object for request + * + * @param object The query/path/header/form/body param to be sanitized. + */ +- (id) sanitizeForSerialization:(id) object; + @end diff --git a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache index 198c5a89fdf3..a47b39c22cd1 100644 --- a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache @@ -88,8 +88,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - {{#pathParams}}[resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"{{baseName}}", @"}"]] withString: [{{classPrefix}}ApiClient escape:{{paramName}}]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + {{#pathParams}}if ({{paramName}} != nil) { + pathParams[@"{{baseName}}"] = {{paramName}}; + } {{/pathParams}} NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -132,22 +135,6 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; {{#bodyParam}} bodyParam = {{paramName}}; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[({{classPrefix}}Object*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [({{classPrefix}}Object*)bodyParam toDictionary]; - } {{/bodyParam}}{{^bodyParam}} {{#formParams}} {{#notFile}} @@ -167,6 +154,7 @@ {{/requiredParamCount}} return [self.apiClient requestWithCompletionBlock: resourcePath method: @"{{httpMethod}}" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h index 7802a5b46c0e..84f28faa8c6c 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h @@ -172,6 +172,7 @@ extern NSString *const SWGResponseObjectErrorKey; * * @param path Request url. * @param method Request method. + * @param pathParams Request path parameters. * @param queryParams Request query parameters. * @param body Request body. * @param headerParams Request header parameters. @@ -184,6 +185,7 @@ extern NSString *const SWGResponseObjectErrorKey; */ -(NSNumber*) requestWithCompletionBlock:(NSString*) path method:(NSString*) method + pathParams:(NSDictionary *) pathParams queryParams:(NSDictionary*) queryParams formParams:(NSDictionary *) formParams files:(NSDictionary *) files @@ -195,4 +197,11 @@ extern NSString *const SWGResponseObjectErrorKey; responseType:(NSString *) responseType completionBlock:(void (^)(id, NSError *))completionBlock; +/** + * Sanitize object for request + * + * @param object The query/path/header/form/body param to be sanitized. + */ +- (id) sanitizeForSerialization:(id) object; + @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m index 22b5c256402b..906169f4d129 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m @@ -467,6 +467,7 @@ static void (^reachabilityChangeBlock)(int); -(NSNumber*) requestWithCompletionBlock: (NSString*) path method: (NSString*) method + pathParams: (NSDictionary *) pathParams queryParams: (NSDictionary*) queryParams formParams: (NSDictionary *) formParams files: (NSDictionary *) files @@ -499,12 +500,25 @@ static void (^reachabilityChangeBlock)(int); self.responseSerializer = [AFHTTPResponseSerializer serializer]; } + // sanitize parameters + pathParams = [self sanitizeForSerialization:pathParams]; + queryParams = [self sanitizeForSerialization:queryParams]; + headerParams = [self sanitizeForSerialization:headerParams]; + formParams = [self sanitizeForSerialization:formParams]; + body = [self sanitizeForSerialization:body]; + // auth setting [self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings]; + NSMutableString *resourcePath = [NSMutableString stringWithString:path]; + [pathParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + [resourcePath replaceCharactersInRange:[resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", key, @"}"]] + withString:[SWGApiClient escape:obj]]; + }]; + NSMutableURLRequest * request = nil; - NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams]; + NSString* pathWithQueryParams = [self pathWithQueryParamsToString:resourcePath queryParams:queryParams]; if ([pathWithQueryParams hasPrefix:@"/"]) { pathWithQueryParams = [pathWithQueryParams substringFromIndex:1]; } @@ -540,20 +554,21 @@ static void (^reachabilityChangeBlock)(int); } } + // request cache BOOL hasHeaderParams = false; if(headerParams != nil && [headerParams count] > 0) { hasHeaderParams = true; } if(offlineState) { - NSLog(@"%@ cache forced", path); + NSLog(@"%@ cache forced", resourcePath); [request setCachePolicy:NSURLRequestReturnCacheDataDontLoad]; } else if(!hasHeaderParams && [method isEqualToString:@"GET"] && cacheEnabled) { - NSLog(@"%@ cache enabled", path); + NSLog(@"%@ cache enabled", resourcePath); [request setCachePolicy:NSURLRequestUseProtocolCachePolicy]; } else { - NSLog(@"%@ cache disabled", path); + NSLog(@"%@ cache disabled", resourcePath); [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; } @@ -671,4 +686,44 @@ static void (^reachabilityChangeBlock)(int); *querys = [NSDictionary dictionaryWithDictionary:querysWithAuth]; } +- (id) sanitizeForSerialization:(id) object { + if (object == nil) { + return nil; + } + else if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]] || [object isKindOfClass:[SWGQueryParamCollection class]]) { + return object; + } + else if ([object isKindOfClass:[NSDate class]]) { + return [object ISO8601String]; + } + else if ([object isKindOfClass:[NSArray class]]) { + NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[object count]]; + [object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + if (obj) { + [sanitizedObjs addObject:[self sanitizeForSerialization:obj]]; + } + }]; + return sanitizedObjs; + } + else if ([object isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[object count]]; + [object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + if (obj) { + [sanitizedObjs setValue:[self sanitizeForSerialization:obj] forKey:key]; + } + }]; + return sanitizedObjs; + } + else if ([object isKindOfClass:[SWGObject class]]) { + return [object toDictionary]; + } + else { + NSException *e = [NSException + exceptionWithName:@"InvalidObjectArgumentException" + reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", object] + userInfo:nil]; + @throw e; + } +} + @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.h b/samples/client/petstore/objc/SwaggerClient/SWGPet.h index e340e0e2b86a..84f10969e5be 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPet.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.h @@ -7,8 +7,8 @@ * Do not edit the class manually. */ -#import "SWGTag.h" #import "SWGCategory.h" +#import "SWGTag.h" @protocol SWGPet diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m index f2e7fb640307..4f30301c658d 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m @@ -80,7 +80,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -115,27 +116,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"PUT" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -172,7 +158,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -207,27 +194,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -264,7 +236,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -310,6 +283,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -346,7 +320,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -392,6 +367,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -433,8 +409,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -462,7 +441,7 @@ NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"api_key", @"petstore_auth"]; + NSArray *authSettings = @[@"petstore_auth", @"api_key"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -474,6 +453,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -521,8 +501,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -570,6 +553,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -614,8 +598,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -657,6 +644,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"DELETE" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -704,8 +692,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"petId", @"}"]] withString: [SWGApiClient escape:petId]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (petId != nil) { + pathParams[@"petId"] = petId; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -753,6 +744,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m index ed792988597f..792147ebed14 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m @@ -77,7 +77,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -117,6 +118,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -153,7 +155,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -188,27 +191,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -250,8 +238,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (orderId != nil) { + pathParams[@"orderId"] = orderId; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -291,6 +282,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -332,8 +324,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"orderId", @"}"]] withString: [SWGApiClient escape:orderId]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (orderId != nil) { + pathParams[@"orderId"] = orderId; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -373,6 +368,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"DELETE" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m index 46a76b35b577..92dd00fa28da 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m @@ -80,7 +80,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -115,27 +116,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -172,7 +158,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -207,27 +194,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -264,7 +236,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -299,27 +272,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"POST" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -359,7 +317,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -407,6 +366,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -440,7 +400,8 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -480,6 +441,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -521,8 +483,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (username != nil) { + pathParams[@"username"] = username; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -562,6 +527,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"GET" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -606,8 +572,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (username != nil) { + pathParams[@"username"] = username; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -642,27 +611,12 @@ NSMutableDictionary *files = [[NSMutableDictionary alloc] init]; bodyParam = body; - - if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){ - NSMutableArray *objs = [[NSMutableArray alloc] init]; - for (id dict in (NSArray*)bodyParam) { - if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; - } - else{ - [objs addObject:dict]; - } - } - bodyParam = objs; - } - else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; - } return [self.apiClient requestWithCompletionBlock: resourcePath method: @"PUT" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files @@ -704,8 +658,11 @@ if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; } - - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:[NSString stringWithFormat:@"%@%@%@", @"{", @"username", @"}"]] withString: [SWGApiClient escape:username]]; + + NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; + if (username != nil) { + pathParams[@"username"] = username; + } NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; @@ -745,6 +702,7 @@ return [self.apiClient requestWithCompletionBlock: resourcePath method: @"DELETE" + pathParams: pathParams queryParams: queryParams formParams: formParams files: files From 6218ad139ffddf17eaf09ecea700f3d3c6806155 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Fri, 21 Aug 2015 11:20:29 +0800 Subject: [PATCH 038/109] Fix issue that it will throw error if not pass optional form param in objc client. --- .../src/main/resources/objc/api-body.mustache | 4 +++- .../client/petstore/objc/SwaggerClient/SWGPetApi.m | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache index a47b39c22cd1..9c7d8388b231 100644 --- a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache @@ -138,7 +138,9 @@ {{/bodyParam}}{{^bodyParam}} {{#formParams}} {{#notFile}} - formParams[@"{{paramName}}"] = {{paramName}}; + if ({{paramName}}) { + formParams[@"{{paramName}}"] = {{paramName}}; + } {{/notFile}}{{#isFile}} files[@"{{paramName}}"] = {{paramName}}; {{/isFile}} diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m index 4f30301c658d..d79584f90bfe 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m @@ -541,11 +541,15 @@ - formParams[@"name"] = name; + if (name) { + formParams[@"name"] = name; + } - formParams[@"status"] = status; + if (status) { + formParams[@"status"] = status; + } @@ -732,7 +736,9 @@ - formParams[@"additionalMetadata"] = additionalMetadata; + if (additionalMetadata) { + formParams[@"additionalMetadata"] = additionalMetadata; + } From 4189d0765bbb6214f435b2c9211284ee5387dfd6 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Fri, 21 Aug 2015 11:40:59 +0800 Subject: [PATCH 039/109] Update api body template of objc client --- .../swagger-codegen/src/main/resources/objc/api-body.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache index 9c7d8388b231..534c887fe7b1 100644 --- a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache @@ -139,7 +139,7 @@ {{#formParams}} {{#notFile}} if ({{paramName}}) { - formParams[@"{{paramName}}"] = {{paramName}}; + formParams[@"{{baseName}}"] = {{paramName}}; } {{/notFile}}{{#isFile}} files[@"{{paramName}}"] = {{paramName}}; From 07162811a724337e832e27fc988e5c9793500f67 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Fri, 21 Aug 2015 08:56:22 -0700 Subject: [PATCH 040/109] fix for #1099, added file check --- .../src/main/java/io/swagger/codegen/DefaultGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 1e0ae01c1278..9f601930c04f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -193,7 +193,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { for (String templateName : config.apiTemplateFiles().keySet()) { String filename = config.apiFilename(templateName, tag); - if (!config.shouldOverwrite(filename)) { + if (!config.shouldOverwrite(filename) && new File(filename).exists()) { continue; } From 44b4af0374da2994dec4734c54c060a640ec2b5b Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Fri, 21 Aug 2015 15:02:56 -0700 Subject: [PATCH 041/109] added check, fix for #1103 --- .../java/io/swagger/codegen/DefaultCodegen.java | 4 +++- .../src/test/scala/Java/JavaModelTest.scala | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) 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 bf58bd1cc361..212358b96272 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 @@ -636,7 +636,9 @@ public class DefaultCodegen { if (np.getMaximum() != null) { allowableValues.put("max", np.getMaximum()); } - property.allowableValues = allowableValues; + if(allowableValues.size() > 0) { + property.allowableValues = allowableValues; + } } if (p instanceof StringProperty) { diff --git a/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala b/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala index 81e252aa117a..0043045a29db 100644 --- a/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala +++ b/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala @@ -2,6 +2,7 @@ package Java import io.swagger.codegen.languages.JavaClientCodegen import io.swagger.models._ +import io.swagger.models.parameters._ import io.swagger.models.properties._ import io.swagger.util.Json import org.junit.runner.RunWith @@ -382,7 +383,6 @@ class JavaModelTest2 extends FlatSpec with Matchers { cm.vars.size should be(1) val vars = cm.vars - Json.prettyPrint(vars.get(0)) vars.get(0).baseName should be("_") vars.get(0).getter should be("getU") vars.get(0).setter should be("setU") @@ -393,4 +393,17 @@ class JavaModelTest2 extends FlatSpec with Matchers { vars.get(0).hasMore should equal(null) vars.get(0).isNotContainer should equal(true) } + + it should "convert a parameter" in { + val parameter = new QueryParameter() + .property( + new IntegerProperty()) + .name("limit") + .required(true) + + val codegen = new JavaClientCodegen() + val cp = codegen.fromParameter(parameter, null) + + cp.allowableValues should be (null) + } } From 4f25a0e6c566f40b40eed9f5faf98fa4decbd453 Mon Sep 17 00:00:00 2001 From: Andrew B Date: Fri, 21 Aug 2015 18:36:03 -0700 Subject: [PATCH 042/109] adding an option so java models can implement Serializable --- .../codegen/languages/JavaClientCodegen.java | 17 +++++++++++++++++ .../src/main/resources/Java/model.mustache | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) 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 b9e298b125c3..be8d68507b54 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 @@ -35,6 +35,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { protected String artifactVersion = "1.0.0"; protected String sourceFolder = "src/main/java"; protected String localVariablePrefix = ""; + protected Boolean serializableModel = false; + public JavaClientCodegen() { super(); outputFolder = "generated-code/java"; @@ -75,6 +77,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { cliOptions.add(new CliOption("artifactVersion", "artifact version in generated pom.xml")); cliOptions.add(new CliOption("sourceFolder", "source folder for generated code")); cliOptions.add(new CliOption("localVariablePrefix", "prefix for generated code members and local variables")); + cliOptions.add(new CliOption("serializableModel", "boolean - toggle \"implements Serializable\" for generated models")); } public CodegenType getTag() { @@ -129,6 +132,12 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { if (additionalProperties.containsKey("localVariablePrefix")) { this.setLocalVariablePrefix((String) additionalProperties.get("localVariablePrefix")); } + + if (additionalProperties.containsKey("serializableModel")) { + this.setSerializableModel(Boolean.valueOf((String)additionalProperties.get("serializableModel"))); + } else { + additionalProperties.put("serializableModel", serializableModel); + } this.sanitizeConfig(); @@ -364,6 +373,14 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { this.localVariablePrefix = localVariablePrefix; } + public Boolean getSerializableModel() { + return serializableModel; + } + + public void setSerializableModel(Boolean serializableModel) { + this.serializableModel = serializableModel; + } + private String sanitizePackageName(String packageName) { packageName = packageName.trim(); packageName = packageName.replaceAll("[^a-zA-Z0-9_\\.]", "_"); diff --git a/modules/swagger-codegen/src/main/resources/Java/model.mustache b/modules/swagger-codegen/src/main/resources/Java/model.mustache index 39f0f0b6fa12..bc23f0187d50 100644 --- a/modules/swagger-codegen/src/main/resources/Java/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/model.mustache @@ -3,6 +3,9 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} +{{#serializableModel}} +import java.io.Serializable;{{/serializableModel}} + import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} @@ -13,7 +16,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; **/{{/description}} @ApiModel(description = "{{{description}}}") {{>generatedAnnotation}} -public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { +public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { {{#vars}}{{#isEnum}} public enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}} From dc423cc11de72e9147752d16386ed384dfecc152 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Sat, 22 Aug 2015 17:46:13 +0800 Subject: [PATCH 043/109] Fix issue that Mssing query parameters in python client. --- .../src/main/resources/python/api_client.mustache | 3 +++ .../src/main/resources/python/rest.mustache | 9 ++++++--- .../client/petstore/python/swagger_client/__init__.py | 2 +- .../client/petstore/python/swagger_client/api_client.py | 3 +++ .../petstore/python/swagger_client/apis/__init__.py | 2 +- .../petstore/python/swagger_client/apis/pet_api.py | 2 +- samples/client/petstore/python/swagger_client/rest.py | 9 ++++++--- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index ca9a3c051042..6acd4ca8e39e 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -338,16 +338,19 @@ class ApiClient(object): headers=headers) elif method == "POST": return RESTClient.POST(url, + query_params=query_params, headers=headers, post_params=post_params, body=body) elif method == "PUT": return RESTClient.PUT(url, + query_params=query_params, headers=headers, post_params=post_params, body=body) elif method == "PATCH": return RESTClient.PATCH(url, + query_params=query_params, headers=headers, post_params=post_params, body=body) diff --git a/modules/swagger-codegen/src/main/resources/python/rest.mustache b/modules/swagger-codegen/src/main/resources/python/rest.mustache index 8a8e55eb3d12..f9f85f294dc1 100644 --- a/modules/swagger-codegen/src/main/resources/python/rest.mustache +++ b/modules/swagger-codegen/src/main/resources/python/rest.mustache @@ -176,21 +176,24 @@ class RESTClientObject(object): headers=headers, query_params=query_params) - def POST(self, url, headers=None, post_params=None, body=None): + def POST(self, url, headers=None, query_params=None, post_params=None, body=None): return self.request("POST", url, headers=headers, + query_params=query_params, post_params=post_params, body=body) - def PUT(self, url, headers=None, post_params=None, body=None): + def PUT(self, url, headers=None, query_params=None, post_params=None, body=None): return self.request("PUT", url, headers=headers, + query_params=query_params, post_params=post_params, body=body) - def PATCH(self, url, headers=None, post_params=None, body=None): + def PATCH(self, url, headers=None, query_params=None, post_params=None, body=None): return self.request("PATCH", url, headers=headers, + query_params=query_params, post_params=post_params, body=body) diff --git a/samples/client/petstore/python/swagger_client/__init__.py b/samples/client/petstore/python/swagger_client/__init__.py index f61c5d55262a..6e7b59f36fde 100644 --- a/samples/client/petstore/python/swagger_client/__init__.py +++ b/samples/client/petstore/python/swagger_client/__init__.py @@ -9,8 +9,8 @@ from .models.order import Order # import apis into sdk package from .apis.user_api import UserApi -from .apis.pet_api import PetApi from .apis.store_api import StoreApi +from .apis.pet_api import PetApi # import ApiClient from .api_client import ApiClient diff --git a/samples/client/petstore/python/swagger_client/api_client.py b/samples/client/petstore/python/swagger_client/api_client.py index ca9a3c051042..6acd4ca8e39e 100644 --- a/samples/client/petstore/python/swagger_client/api_client.py +++ b/samples/client/petstore/python/swagger_client/api_client.py @@ -338,16 +338,19 @@ class ApiClient(object): headers=headers) elif method == "POST": return RESTClient.POST(url, + query_params=query_params, headers=headers, post_params=post_params, body=body) elif method == "PUT": return RESTClient.PUT(url, + query_params=query_params, headers=headers, post_params=post_params, body=body) elif method == "PATCH": return RESTClient.PATCH(url, + query_params=query_params, headers=headers, post_params=post_params, body=body) diff --git a/samples/client/petstore/python/swagger_client/apis/__init__.py b/samples/client/petstore/python/swagger_client/apis/__init__.py index 592a56e282d2..c0e09458f950 100644 --- a/samples/client/petstore/python/swagger_client/apis/__init__.py +++ b/samples/client/petstore/python/swagger_client/apis/__init__.py @@ -2,5 +2,5 @@ from __future__ import absolute_import # import apis into api package from .user_api import UserApi -from .pet_api import PetApi from .store_api import StoreApi +from .pet_api import PetApi diff --git a/samples/client/petstore/python/swagger_client/apis/pet_api.py b/samples/client/petstore/python/swagger_client/apis/pet_api.py index 1c34da118c14..fa1db5801b6a 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -408,7 +408,7 @@ class PetApi(object): select_header_content_type([]) # Authentication setting - auth_settings = ['api_key', 'petstore_auth'] + auth_settings = ['petstore_auth', 'api_key'] response = self.api_client.call_api(resource_path, method, path_params, diff --git a/samples/client/petstore/python/swagger_client/rest.py b/samples/client/petstore/python/swagger_client/rest.py index 8a8e55eb3d12..f9f85f294dc1 100644 --- a/samples/client/petstore/python/swagger_client/rest.py +++ b/samples/client/petstore/python/swagger_client/rest.py @@ -176,21 +176,24 @@ class RESTClientObject(object): headers=headers, query_params=query_params) - def POST(self, url, headers=None, post_params=None, body=None): + def POST(self, url, headers=None, query_params=None, post_params=None, body=None): return self.request("POST", url, headers=headers, + query_params=query_params, post_params=post_params, body=body) - def PUT(self, url, headers=None, post_params=None, body=None): + def PUT(self, url, headers=None, query_params=None, post_params=None, body=None): return self.request("PUT", url, headers=headers, + query_params=query_params, post_params=post_params, body=body) - def PATCH(self, url, headers=None, post_params=None, body=None): + def PATCH(self, url, headers=None, query_params=None, post_params=None, body=None): return self.request("PATCH", url, headers=headers, + query_params=query_params, post_params=post_params, body=body) From 569082743f126aaabfe0d6edd37183c03b9fd9f4 Mon Sep 17 00:00:00 2001 From: xhh Date: Sat, 22 Aug 2015 22:05:43 +0800 Subject: [PATCH 044/109] Remove the unused LibraryHelp command --- .../io/swagger/codegen/SwaggerCodegen.java | 4 +- .../io/swagger/codegen/cmd/LibraryHelp.java | 55 ------------------- 2 files changed, 1 insertion(+), 58 deletions(-) delete mode 100644 modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/LibraryHelp.java diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java index 2dec1fe26daa..3cdc01fe3f5a 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/SwaggerCodegen.java @@ -5,7 +5,6 @@ import io.airlift.airline.Help; import io.swagger.codegen.cmd.ConfigHelp; import io.swagger.codegen.cmd.Generate; import io.swagger.codegen.cmd.Langs; -import io.swagger.codegen.cmd.LibraryHelp; import io.swagger.codegen.cmd.Meta; /** @@ -30,8 +29,7 @@ public class SwaggerCodegen { Meta.class, Langs.class, Help.class, - ConfigHelp.class, - LibraryHelp.class + ConfigHelp.class ); builder.build().parse(args).run(); diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/LibraryHelp.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/LibraryHelp.java deleted file mode 100644 index 480286f90f7c..000000000000 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/LibraryHelp.java +++ /dev/null @@ -1,55 +0,0 @@ -package io.swagger.codegen.cmd; - -import io.airlift.airline.Command; -import io.airlift.airline.Option; -import io.swagger.codegen.CliOption; -import io.swagger.codegen.CodegenConfig; - -import java.util.ServiceLoader; - -import static java.util.ServiceLoader.load; - -@Command(name = "library-help", description = "Library help for chosen lang") -public class LibraryHelp implements Runnable { - - @Option(name = {"-l", "--lang"}, title = "language", required = true, - description = "language to get library help for") - private String lang; - - /** - * Tries to load config class with SPI first, then with class name directly from classpath - * - * @param name name of config, or full qualified class name in classpath - * @return config class - */ - private static CodegenConfig forName(String name) { - ServiceLoader loader = load(CodegenConfig.class); - for (CodegenConfig config : loader) { - if (config.getName().equals(name)) { - return config; - } - } - - // else try to load directly - try { - return (CodegenConfig) Class.forName(name).newInstance(); - } catch (Exception e) { - throw new RuntimeException("Can't load config class with name ".concat(name), e); - } - } - - @Override - public void run() { - System.out.println(); - CodegenConfig config = forName(lang); - System.out.println("LIBRARY OPTIONS"); - for (String library : config.supportedLibraries().keySet()) { - String description = config.supportedLibraries().get(library); - if ("".equals(library)) - library = ""; - System.out.println("\t" + library); - System.out.println("\t " + description); - System.out.println(); - } - } -} From f2df26f6e6504347a9c1270f39befb5ddce7c542 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 22 Aug 2015 23:09:12 +0800 Subject: [PATCH 045/109] fix deserializing datetime, add test case --- .../resources/php/ObjectSerializer.mustache | 2 +- .../lib/ObjectSerializer.php | 2 +- .../SwaggerClient-php/tests/OrderApiTest.php | 25 +++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache index 1d63440b66fd..2de1d556acb0 100644 --- a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache @@ -191,7 +191,7 @@ class ObjectSerializer $values[] = $this->deserialize($value, $subClass); } $deserialized = $values; - } elseif ($class === 'DateTime') { + } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); } elseif (in_array($class, array('string', 'int', 'float', 'double', 'bool', 'object'))) { settype($data, $class); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 535c623118ac..713f864a4a54 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -191,7 +191,7 @@ class ObjectSerializer $values[] = $this->deserialize($value, $subClass); } $deserialized = $values; - } elseif ($class === 'DateTime') { + } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); } elseif (in_array($class, array('string', 'int', 'float', 'double', 'bool', 'object'))) { settype($data, $class); diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/OrderApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/OrderApiTest.php index 7672667a2358..3eb0d11a9b2b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/OrderApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/OrderApiTest.php @@ -31,6 +31,31 @@ class OrderApiTest extends \PHPUnit_Framework_TestCase $order = new Swagger\Client\Model\Order(); $order->setStatus("invalid_value"); } + + // test deseralization of order + public function testDeserializationOfOrder() + { + $order_json = <<deserialize(json_decode($order_json), 'Swagger\Client\Model\Order'); + + $this->assertInstanceOf('Swagger\Client\Model\Order', $order); + $this->assertSame(10, $order->getId()); + $this->assertSame(20, $order->getPetId()); + $this->assertSame(30, $order->getQuantity()); + $this->assertTrue(new DateTime("2015-08-22T07:13:36.613Z") == $order->getShipDate()); + $this->assertSame("placed", $order->getStatus()); + $this->assertSame(false, $order->getComplete()); + } } From ac49d0dcdcefe940dd59907aa988f179294437d9 Mon Sep 17 00:00:00 2001 From: Ole Lensmar Date: Sun, 23 Aug 2015 09:37:28 -0400 Subject: [PATCH 046/109] post-merge fixes --- .../main/java/io/swagger/codegen/plugin/CodeGenMojo.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java index 4e0e1e23e5f8..41737ca0968e 100644 --- a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java +++ b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java @@ -93,10 +93,11 @@ public class CodeGenMojo extends AbstractMojo { private String language; /** - * Path to json configuration file. + * Path to separate json configuration file. */ @Parameter(name = "configurationFile", required = false) private String configurationFile; + /** * A map of language-specific parameters as passed with the -c option to the command line */ @@ -136,7 +137,6 @@ public class CodeGenMojo extends AbstractMojo { config.additionalProperties().put(INVOKER_PACKAGE_PARAM, invokerPackage); } - ClientOpts clientOpts = new ClientOpts(); if (configOptions != null) { for (CliOption langCliOption : config.cliOptions()) { if (configOptions.containsKey(langCliOption.getOpt())) { @@ -146,8 +146,6 @@ public class CodeGenMojo extends AbstractMojo { } } - ClientOptInput input = new ClientOptInput().opts(clientOpts).swagger(swagger); - if (null != configurationFile) { Config genConfig = ConfigParser.read(configurationFile); if (null != genConfig) { From 3160913433d80a6efb8c9e9668f8a1cc46f0ddde Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 23 Aug 2015 11:05:19 -0700 Subject: [PATCH 047/109] update files as rebase from #838 --- .../io/swagger/codegen/languages/PhpClientCodegen.java | 7 ++++++- .../src/main/resources/php/ObjectSerializer.mustache | 2 +- .../php/SwaggerClient-php/lib/ObjectSerializer.php | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index eaf758cf1c4b..cd88d916e03b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -15,7 +15,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { protected String invokerPackage = "Swagger\\Client"; @@ -61,6 +61,11 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { instantiationTypes.put("array", "array"); instantiationTypes.put("map", "map"); + + // provide primitives to mustache template + String primitives = "'" + StringUtils.join(languageSpecificPrimitives, "', '") + "'"; + additionalProperties.put("primitives", primitives); + // ref: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#data-types typeMapping = new HashMap(); typeMapping.put("integer", "int"); diff --git a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache index 2de1d556acb0..45b56aa9b97c 100644 --- a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache @@ -193,7 +193,7 @@ class ObjectSerializer $deserialized = $values; } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); - } elseif (in_array($class, array('string', 'int', 'float', 'double', 'bool', 'object'))) { + } elseif (in_array($class, array({{&primitives}}))) { settype($data, $class); $deserialized = $data; } elseif ($class === '\SplFileObject') { diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 713f864a4a54..0d281b9d1fa3 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -193,7 +193,7 @@ class ObjectSerializer $deserialized = $values; } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); - } elseif (in_array($class, array('string', 'int', 'float', 'double', 'bool', 'object'))) { + } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { settype($data, $class); $deserialized = $data; } elseif ($class === '\SplFileObject') { From 66e6d4fb8a13582a6d4857bc644d25f11324e04f Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 23 Aug 2015 11:10:04 -0700 Subject: [PATCH 048/109] rebuilt client --- .../src/main/java/io/swagger/client/ApiClient.java | 2 +- .../src/main/java/io/swagger/client/ApiException.java | 2 +- .../src/main/java/io/swagger/client/Configuration.java | 2 +- .../default/src/main/java/io/swagger/client/JSON.java | 2 +- .../default/src/main/java/io/swagger/client/Pair.java | 2 +- .../src/main/java/io/swagger/client/StringUtil.java | 2 +- .../default/src/main/java/io/swagger/client/TypeRef.java | 2 +- .../src/main/java/io/swagger/client/api/PetApi.java | 4 ++-- .../src/main/java/io/swagger/client/api/StoreApi.java | 2 +- .../src/main/java/io/swagger/client/api/UserApi.java | 2 +- .../src/main/java/io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../main/java/io/swagger/client/auth/Authentication.java | 2 +- .../main/java/io/swagger/client/auth/HttpBasicAuth.java | 2 +- .../src/main/java/io/swagger/client/auth/OAuth.java | 2 +- .../src/main/java/io/swagger/client/model/Category.java | 6 ++++-- .../src/main/java/io/swagger/client/model/Order.java | 6 ++++-- .../src/main/java/io/swagger/client/model/Pet.java | 8 +++++--- .../src/main/java/io/swagger/client/model/Tag.java | 6 ++++-- .../src/main/java/io/swagger/client/model/User.java | 6 ++++-- 19 files changed, 36 insertions(+), 26 deletions(-) diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java index 52c99a5fb600..9af0c10b5439 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java @@ -38,7 +38,7 @@ import io.swagger.client.auth.HttpBasicAuth; import io.swagger.client.auth.ApiKeyAuth; import io.swagger.client.auth.OAuth; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class ApiClient { private Map hostMap = new HashMap(); private Map defaultHeaderMap = new HashMap(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java index d42eb0dbf9d5..605f8c3769d7 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class ApiException extends Exception { private int code = 0; private String message = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java index f2b95e96c5a1..524006fd7bd3 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java index 0b9487b58584..3514e41778eb 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*; import java.io.IOException; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class JSON { private ObjectMapper mapper; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java index 4c9c4041834c..e7dd3350637d 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java index a27c220dbf30..c80bc8a1647c 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java index 3d68e7e51215..15eb3ea05bad 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class TypeRef { private final Type type; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index e6348cdc9e7f..5b71f7c199cb 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -17,7 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class PetApi { private ApiClient apiClient; @@ -244,7 +244,7 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { "petstore_auth", "api_key" }; + String[] authNames = new String[] { "api_key", "petstore_auth" }; TypeRef returnType = new TypeRef() {}; return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java index 12b2e69f82f8..7c0430b5f718 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java @@ -17,7 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class StoreApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java index b0e20a035bf3..a11ac7d16ed1 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java @@ -17,7 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class UserApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index 1ca97409c566..41094d084401 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java index 892bf1c60ffb..5585eecdf1e2 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public interface Authentication { /** Apply authentication settings to header and query params. */ void applyToParams(List queryParams, Map headerParams); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index d2161ee0ef1a..740d8993862d 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -8,7 +8,7 @@ import java.util.List; import java.io.UnsupportedEncodingException; import javax.xml.bind.DatatypeConverter; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java index 5c4242abcaf5..b592d67848f7 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") public class OAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java index 19e0076e3095..0d1945b5804f 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java @@ -1,13 +1,15 @@ package io.swagger.client.model; + + import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") -public class Category { +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class Category { private Long id = null; private String name = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java index 234b063eb279..2a3892f29181 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java @@ -2,13 +2,15 @@ package io.swagger.client.model; import java.util.Date; + + import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") -public class Order { +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class Order { private Long id = null; private Long petId = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java index b680a4f8a501..6cb7df1fde58 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java @@ -1,16 +1,18 @@ package io.swagger.client.model; import io.swagger.client.model.Category; -import java.util.*; import io.swagger.client.model.Tag; +import java.util.*; + + import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") -public class Pet { +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class Pet { private Long id = null; private Category category = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java index ce6d08092655..fe212ea8ab6f 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java @@ -1,13 +1,15 @@ package io.swagger.client.model; + + import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") -public class Tag { +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class Tag { private Long id = null; private String name = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java index 9a75d96d7611..5b9230b8e015 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java @@ -1,13 +1,15 @@ package io.swagger.client.model; + + import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:01.809+08:00") -public class User { +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class User { private Long id = null; private String username = null; From 414de008944112728283b1f4080070e8eb62c5d9 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 23 Aug 2015 14:23:00 -0700 Subject: [PATCH 049/109] fixed return type, rebuilt --- .../codegen/languages/SpringMVCServerCodegen.java | 9 ++++++--- .../src/main/resources/JavaSpringMVC/api.mustache | 4 ++-- .../src/main/resources/JavaSpringMVC/pom.mustache | 2 +- samples/server/petstore/spring-mvc/pom.xml | 2 +- .../src/main/java/io/swagger/api/ApiException.java | 1 + .../main/java/io/swagger/api/ApiOriginFilter.java | 1 + .../java/io/swagger/api/ApiResponseMessage.java | 1 + .../main/java/io/swagger/api/NotFoundException.java | 1 + .../src/main/java/io/swagger/api/PetApi.java | 13 +++++++------ .../src/main/java/io/swagger/api/StoreApi.java | 7 ++++--- .../src/main/java/io/swagger/api/UserApi.java | 1 + .../io/swagger/configuration/SwaggerConfig.java | 1 + .../configuration/SwaggerUiConfiguration.java | 1 + .../io/swagger/configuration/WebApplication.java | 1 + .../swagger/configuration/WebMvcConfiguration.java | 1 + .../src/main/java/io/swagger/model/Category.java | 1 + .../src/main/java/io/swagger/model/Order.java | 1 + .../src/main/java/io/swagger/model/Pet.java | 7 ++++--- .../src/main/java/io/swagger/model/Tag.java | 1 + .../src/main/java/io/swagger/model/User.java | 1 + 20 files changed, 38 insertions(+), 19 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java index 2962083495d1..edc424f125c6 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java @@ -143,27 +143,30 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen } } } + System.out.println(operation.operationId); + io.swagger.util.Json.prettyPrint(operation); + if (operation.returnType == null) { operation.returnType = "Void"; } else if (operation.returnType.startsWith("List")) { String rt = operation.returnType; int end = rt.lastIndexOf(">"); if (end > 0) { - operation.returnType = rt.substring("List<".length(), end); + operation.returnType = rt.substring("List<".length(), end).trim(); operation.returnContainer = "List"; } } else if (operation.returnType.startsWith("Map")) { String rt = operation.returnType; int end = rt.lastIndexOf(">"); if (end > 0) { - operation.returnType = rt.substring("Map<".length(), end); + operation.returnType = rt.substring("Map<".length(), end).split(",")[1].trim(); operation.returnContainer = "Map"; } } else if (operation.returnType.startsWith("Set")) { String rt = operation.returnType; int end = rt.lastIndexOf(">"); if (end > 0) { - operation.returnType = rt.substring("Set<".length(), end); + operation.returnType = rt.substring("Set<".length(), end).trim(); operation.returnContainer = "Set"; } } diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache index e6e8d6fc04ce..695d1c5525b6 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache @@ -42,11 +42,11 @@ public class {{classname}} { {{#hasProduces}}produces = { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}} {{#hasConsumes}}consumes = { {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}} method = RequestMethod.{{httpMethod}}) - public ResponseEntity<{{returnType}}> {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, + public ResponseEntity<{{>returnTypes}}> {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws NotFoundException { // do some magic! - return new ResponseEntity<{{returnType}}>(HttpStatus.OK); + return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); } {{/operation}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache index 9896c3ac6d83..ffbb0e435161 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache @@ -150,7 +150,7 @@ - 1.5.0 + 1.5.3 9.2.9.v20150224 1.13 1.6.3 diff --git a/samples/server/petstore/spring-mvc/pom.xml b/samples/server/petstore/spring-mvc/pom.xml index 1b49d0a46918..ad0b2c04acff 100644 --- a/samples/server/petstore/spring-mvc/pom.xml +++ b/samples/server/petstore/spring-mvc/pom.xml @@ -150,7 +150,7 @@ - 1.5.0 + 1.5.3 9.2.9.v20150224 1.13 1.6.3 diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java index cae767c0393f..d5cc468f9183 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java @@ -1,5 +1,6 @@ package io.swagger.api; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java index c2eeacf13d3f..4e9fe92b80ca 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java @@ -5,6 +5,7 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class ApiOriginFilter implements javax.servlet.Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java index 9e5b0ee44e2d..5b1085f05d46 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java @@ -3,6 +3,7 @@ package io.swagger.api; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java index 9c8410e47ab8..04c8e861b3af 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java @@ -1,5 +1,6 @@ package io.swagger.api; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java index 52ddc63c23cb..ae26430d13e8 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java @@ -30,6 +30,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/pet", description = "the pet API") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class PetApi { @@ -77,12 +78,12 @@ public class PetApi { produces = { "application/json", "application/xml" }, method = RequestMethod.GET) - public ResponseEntity findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue = "available") @RequestParam(value = "status", required = false, defaultValue="available") List status + public ResponseEntity> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue = "available") @RequestParam(value = "status", required = false, defaultValue="available") List status ) throws NotFoundException { // do some magic! - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.OK); } @@ -95,12 +96,12 @@ public class PetApi { produces = { "application/json", "application/xml" }, method = RequestMethod.GET) - public ResponseEntity findPetsByTags(@ApiParam(value = "Tags to filter by") @RequestParam(value = "tags", required = false) List tags + public ResponseEntity> findPetsByTags(@ApiParam(value = "Tags to filter by") @RequestParam(value = "tags", required = false) List tags ) throws NotFoundException { // do some magic! - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.OK); } @@ -157,10 +158,10 @@ public class PetApi { method = RequestMethod.DELETE) public ResponseEntity deletePet( -@ApiParam(value = "" ) @RequestHeader(value="apiKey", required=false) String apiKey +@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId , -@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId +@ApiParam(value = "" ) @RequestHeader(value="apiKey", required=false) String apiKey ) throws NotFoundException { // do some magic! diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java index c81693887db1..1da00f9bfa72 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java @@ -30,20 +30,21 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/store", description = "the store API") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class StoreApi { - @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map") + @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map") @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) @RequestMapping(value = "/inventory", produces = { "application/json", "application/xml" }, method = RequestMethod.GET) - public ResponseEntity getInventory() + public ResponseEntity> getInventory() throws NotFoundException { // do some magic! - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity>(HttpStatus.OK); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java index dd5fbc6c279e..13ef255488bb 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java @@ -30,6 +30,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/user", description = "the user API") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class UserApi { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java index 7b2de09cdd61..d15249c8d74f 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java @@ -18,6 +18,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @EnableSwagger2 //Loads the spring beans required by the framework @PropertySource("classpath:swagger.properties") @Import(SwaggerUiConfiguration.class) +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class SwaggerConfig { @Bean ApiInfo apiInfo() { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java index ff8f366a880d..2732a7c04917 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java @@ -8,6 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @Configuration @EnableWebMvc +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter { private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" }; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java index 05f7dae29ec2..1799d0da80aa 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java @@ -2,6 +2,7 @@ package io.swagger.configuration; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer { @Override diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java index 206e011dd487..629e5580e64b 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java @@ -3,6 +3,7 @@ package io.swagger.configuration; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class WebMvcConfiguration extends WebMvcConfigurationSupport { @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java index 56f86f70737c..734f3b75e79a 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class Category { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java index 4d0c133e9362..d58ff96620d1 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class Order { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java index 076a8cf8142f..a86d7296ec7d 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java @@ -1,21 +1,22 @@ package io.swagger.model; import io.swagger.model.Category; -import java.util.*; import io.swagger.model.Tag; +import java.util.*; import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class Pet { private Long id = null; private Category category = null; private String name = null; - private List photoUrls = new ArrayList() ; - private List tags = new ArrayList() ; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); public enum StatusEnum { available, pending, sold, }; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java index 99dd07c00f7a..d87fc671fbb7 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class Tag { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java index d5f43a4c25e8..1ef45c4bc669 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2015-08-23T14:20:14.172-07:00") public class User { private Long id = null; From a6a9d743be90517866c5668d3280c1d01910a79e Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 23 Aug 2015 14:23:20 -0700 Subject: [PATCH 050/109] added template --- .../src/main/resources/JavaSpringMVC/returnTypes.mustache | 1 + 1 file changed, 1 insertion(+) create mode 100644 modules/swagger-codegen/src/main/resources/JavaSpringMVC/returnTypes.mustache diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/returnTypes.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/returnTypes.mustache new file mode 100644 index 000000000000..c8f7a56938aa --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/returnTypes.mustache @@ -0,0 +1 @@ +{{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List<{{{returnType}}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file From d51fe801382a73b5764431e7956113e623f11e3e Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 23 Aug 2015 18:28:42 -0700 Subject: [PATCH 051/109] =?UTF-8?q?Revert=20"fixed=20generated=20code=20to?= =?UTF-8?q?=20go=20to=20target/generated-sources,=20added=20maven-c?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/swagger/codegen/DefaultGenerator.java | 6 +- .../codegen/languages/JaxRSServerCodegen.java | 35 +- .../main/resources/JavaJaxRS/README.mustache | 9 +- .../src/main/resources/JavaJaxRS/pom.mustache | 22 +- .../swagger/generator/online/Generator.java | 4 +- .../server/petstore/java-inflector/README.md | 8 - .../petstore/java-inflector/inflector.yaml | 10 - .../server/petstore/java-inflector/pom.xml | 174 ---- .../io/swagger/handler/PetController.java | 51 -- .../io/swagger/handler/StoreController.java | 35 - .../io/swagger/handler/UserController.java | 51 -- .../src/main/swagger/swagger.json | 762 ------------------ .../src/main/webapp/WEB-INF/web.xml | 24 - samples/server/petstore/jaxrs/README.md | 9 +- samples/server/petstore/jaxrs/pom.xml | 22 +- .../gen/java/io/swagger/api/ApiException.java | 9 + .../java/io/swagger/api/ApiOriginFilter.java | 26 + .../io/swagger/api/ApiResponseMessage.java | 68 ++ .../io/swagger/api/NotFoundException.java | 9 + .../src/gen/java/io/swagger/api/PetApi.java | 148 ++++ .../java/io/swagger/api/PetApiService.java | 47 ++ .../src/gen/java/io/swagger/api/StoreApi.java | 90 +++ .../java/io/swagger/api/StoreApiService.java | 35 + .../src/gen/java/io/swagger/api/UserApi.java | 142 ++++ .../java/io/swagger/api/UserApiService.java | 47 ++ .../gen}/java/io/swagger/model/Category.java | 0 .../src/gen}/java/io/swagger/model/Order.java | 0 .../src/gen}/java/io/swagger/model/Pet.java | 6 +- .../src/gen}/java/io/swagger/model/Tag.java | 0 .../src/gen}/java/io/swagger/model/User.java | 0 .../api/factories/PetApiServiceFactory.java | 9 +- .../api/factories/StoreApiServiceFactory.java | 9 +- .../api/factories/UserApiServiceFactory.java | 9 +- .../swagger/api/impl/PetApiServiceImpl.java | 132 ++- .../swagger/api/impl/StoreApiServiceImpl.java | 72 +- .../swagger/api/impl/UserApiServiceImpl.java | 129 ++- .../jaxrs/src/main/resources/swagger.json | 762 ------------------ 37 files changed, 816 insertions(+), 2155 deletions(-) delete mode 100644 samples/server/petstore/java-inflector/README.md delete mode 100644 samples/server/petstore/java-inflector/inflector.yaml delete mode 100644 samples/server/petstore/java-inflector/pom.xml delete mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java delete mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java delete mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java delete mode 100644 samples/server/petstore/java-inflector/src/main/swagger/swagger.json delete mode 100644 samples/server/petstore/java-inflector/src/main/webapp/WEB-INF/web.xml create mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java create mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java create mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java create mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java create mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java create mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java create mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java create mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java create mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java create mode 100644 samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java rename samples/server/petstore/{java-inflector/src/main => jaxrs/src/gen}/java/io/swagger/model/Category.java (100%) rename samples/server/petstore/{java-inflector/src/main => jaxrs/src/gen}/java/io/swagger/model/Order.java (100%) rename samples/server/petstore/{java-inflector/src/main => jaxrs/src/gen}/java/io/swagger/model/Pet.java (95%) rename samples/server/petstore/{java-inflector/src/main => jaxrs/src/gen}/java/io/swagger/model/Tag.java (100%) rename samples/server/petstore/{java-inflector/src/main => jaxrs/src/gen}/java/io/swagger/model/User.java (100%) delete mode 100644 samples/server/petstore/jaxrs/src/main/resources/swagger.json diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 0aa51ccb845e..40b676149a23 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -143,7 +143,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { for (String templateName : config.modelTemplateFiles().keySet()) { String suffix = config.modelTemplateFiles().get(templateName); String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix; - if ( new File(filename).exists() && !config.shouldOverwrite(filename)) { + if (!config.shouldOverwrite(filename)) { continue; } String templateFile = getFullTemplateFile(config, templateName); @@ -195,7 +195,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { for (String templateName : config.apiTemplateFiles().keySet()) { String filename = config.apiFilename(templateName, tag); - if( new File( filename ).exists() && !config.shouldOverwrite(filename)) { + if (!config.shouldOverwrite(filename) && new File(filename).exists()) { continue; } @@ -267,7 +267,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { of.mkdirs(); } String outputFilename = outputFolder + File.separator + support.destinationFilename; - if (new File( outputFilename ).exists() && !config.shouldOverwrite(outputFilename)) { + if (!config.shouldOverwrite(outputFilename)) { continue; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java index 6d83ff56a3cf..df3207975154 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java @@ -5,15 +5,11 @@ import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.CodegenType; import io.swagger.codegen.SupportingFile; import io.swagger.models.Operation; -import io.swagger.models.Swagger; import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.MapProperty; import io.swagger.models.properties.Property; -import io.swagger.util.Json; import java.io.File; -import java.io.FileWriter; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -21,7 +17,6 @@ import java.util.List; import java.util.Map; public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConfig { - public static final String DEFAULT_IMPL_SOURCE_FOLDER = "src/main/java"; protected String invokerPackage = "io.swagger.api"; protected String groupId = "io.swagger"; protected String artifactId = "swagger-jaxrs-server"; @@ -31,9 +26,9 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf public JaxRSServerCodegen() { super.processOpts(); - sourceFolder = "target/generated-sources"; + sourceFolder = "src/gen/java"; - outputFolder = System.getProperty("swagger.codegen.jaxrs.genfolder", "target/generated-sources"); + outputFolder = System.getProperty("swagger.codegen.jaxrs.genfolder", "generated-code/javaJaxRS"); modelTemplateFiles.put("model.mustache", ".java"); apiTemplateFiles.put("api.mustache", ".java"); apiTemplateFiles.put("apiService.mustache", ".java"); @@ -174,7 +169,7 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf int ix = result.lastIndexOf('/'); result = result.substring(0, ix) + "/impl" + result.substring(ix, result.length() - 5) + "ServiceImpl.java"; - String output = System.getProperty("swagger.codegen.jaxrs.impl.source", DEFAULT_IMPL_SOURCE_FOLDER); + String output = System.getProperty("swagger.codegen.jaxrs.impl.source"); if (output != null) { result = result.replace(apiFileFolder(), implFileFolder(output)); } @@ -182,7 +177,7 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf int ix = result.lastIndexOf('/'); result = result.substring(0, ix) + "/factories" + result.substring(ix, result.length() - 5) + "ServiceFactory.java"; - String output = System.getProperty("swagger.codegen.jaxrs.impl.source", DEFAULT_IMPL_SOURCE_FOLDER); + String output = System.getProperty("swagger.codegen.jaxrs.impl.source"); if (output != null) { result = result.replace(apiFileFolder(), implFileFolder(output)); } @@ -194,31 +189,11 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf return result; } - @Override - public void processSwagger(Swagger swagger) { - super.processSwagger(swagger); - - try { - File file = new File( outputFolder + "/src/main/resources/swagger.json" ); - file.getParentFile().mkdirs(); - - FileWriter swaggerFile = new FileWriter(file); - swaggerFile.write( Json.pretty(swagger)); - swaggerFile.flush(); - swaggerFile.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - private String implFileFolder(String output) { return outputFolder + "/" + output + "/" + apiPackage().replace('.', File.separatorChar); } public boolean shouldOverwrite(String filename) { - return filename.startsWith( outputFolder + File.separatorChar + sourceFolder); - -// return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") -// && !filename.endsWith("ServiceFactory.java"); + return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") && !filename.endsWith("ServiceFactory.java"); } } diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/README.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/README.mustache index a5281c3eac30..3ffa01fb2571 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/README.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/README.mustache @@ -1,5 +1,10 @@ # Swagger generated server ## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project using the -JAX-RS template. +This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the +[swagger-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 swagger-enabled scalatra server. + +This example uses the [scalatra](http://scalatra.org/) framework. To see how to make this your own, look here: + +[README](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/scalatra) \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache index c68c755a5716..708ca6cac4d0 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache @@ -50,6 +50,7 @@ 0 + true @@ -74,29 +75,12 @@ - target/generated-sources + src/gen/java - - io.swagger - swagger-codegen-maven-plugin - 2.1.3-SNAPSHOT - - - - generate - - - src/main/resources/swagger.json - jaxrs - . - - - - @@ -164,7 +148,7 @@ - 1.5.1-SNAPSHOT + 1.5.0 9.2.9.v20150224 1.13 1.6.3 diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java index d59060f39ef2..2faef30744ba 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java @@ -37,7 +37,7 @@ public class Generator { throw new BadRequestException(400, "No swagger specification was supplied"); } } else { - swagger = new SwaggerParser().read(node); + swagger = new SwaggerParser().read(node, true); } if (swagger == null) { throw new BadRequestException(400, "The swagger specification supplied was not valid"); @@ -97,7 +97,7 @@ public class Generator { throw new BadRequestException(400, "No swagger specification was supplied"); } } else { - swagger = new SwaggerParser().read(node); + swagger = new SwaggerParser().read(node, true); } if (swagger == null) { throw new BadRequestException(400, "The swagger specification supplied was not valid"); diff --git a/samples/server/petstore/java-inflector/README.md b/samples/server/petstore/java-inflector/README.md deleted file mode 100644 index c1309670c5ad..000000000000 --- a/samples/server/petstore/java-inflector/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Swagger Inflector - -Run with - -``` -mvn package jetty:run -`` - diff --git a/samples/server/petstore/java-inflector/inflector.yaml b/samples/server/petstore/java-inflector/inflector.yaml deleted file mode 100644 index 25ec6dde3f2e..000000000000 --- a/samples/server/petstore/java-inflector/inflector.yaml +++ /dev/null @@ -1,10 +0,0 @@ -controllerPackage: io.swagger.handler -modelPackage: io.swagger.model -swaggerUrl: ./src/main/swagger/swagger.json -modelMappings: - User : io.swagger.model.User - Category : io.swagger.model.Category - Pet : io.swagger.model.Pet - Tag : io.swagger.model.Tag - Order : io.swagger.model.Order - diff --git a/samples/server/petstore/java-inflector/pom.xml b/samples/server/petstore/java-inflector/pom.xml deleted file mode 100644 index 6d7dee18a58e..000000000000 --- a/samples/server/petstore/java-inflector/pom.xml +++ /dev/null @@ -1,174 +0,0 @@ - - - org.sonatype.oss - oss-parent - 5 - - 4.0.0 - io.swagger - swagger-inflector-server - jar - swagger-inflector-server - 1.0.0 - - 2.2.0 - - - - install - target - ${project.artifactId}-${project.version} - - - maven-dependency-plugin - - - package - - copy-dependencies - - - ${project.build.directory}/lib - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - **/logback.xml - - - - development - ${project.url} - ${project.version} - io.swagger - - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty-version} - - . - - inflector.yaml - src/main/swagger/swagger.yaml - - 1 - - / - - - 8080 - 60000 - - - - - - - - - com.fasterxml.jackson.core - jackson-core - ${jackson-version} - - - com.fasterxml.jackson.core - jackson-annotations - 2.4.0 - - - com.fasterxml.jackson.core - jackson-databind - ${jackson-version} - - - com.fasterxml.jackson.datatype - jackson-datatype-joda - ${jackson-version} - - - - org.glassfish.jersey.containers - jersey-container-servlet-core - ${jersey2-version} - - - org.glassfish.jersey.media - jersey-media-multipart - ${jersey2-version} - - - org.glassfish.jersey.core - jersey-client - ${jersey2-version} - - - javax.servlet - servlet-api - ${servlet-api-version} - provided - - - - ch.qos.logback - logback-classic - ${logback-version} - - - ch.qos.logback - logback-core - ${logback-version} - - - org.slf4j - slf4j-ext - ${slf4j-version} - - - org.slf4j - slf4j-api - ${slf4j-version} - - - - - commons-lang - commons-lang - ${commons-lang-version} - - - - - io.swagger - swagger-inflector - 1.0.0-SNAPSHOT - - - - - 1.0.0 - 1.5.0 - 1.0.8 - 2.4.2 - 2.2 - 1.2 - 9.2.9.v20150224 - 2.6 - 2.5 - 2.4 - 2.4 - 1.1 - 1.0.1 - 4.8.2 - 1.6.3 - - \ No newline at end of file diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java deleted file mode 100644 index 69325871d166..000000000000 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.swagger.handler; - -import io.swagger.inflector.models.RequestContext; -import io.swagger.inflector.models.ResponseContext; -import javax.ws.rs.core.Response.Status; - -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; -import java.io.File; -import java.util.List; - -import io.swagger.model.*; - -import io.swagger.model.Pet; -import java.io.File; - -public class PetController { - - public ResponseContext updatePet(RequestContext request ,Pet body) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext addPet(RequestContext request ,Pet body) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext findPetsByStatus(RequestContext request ,List status) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext findPetsByTags(RequestContext request ,List tags) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext getPetById(RequestContext request ,Long petId) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext updatePetWithForm(RequestContext request ,String petId,String name,String status) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext deletePet(RequestContext request ,Long petId,String apiKey) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext uploadFile(RequestContext request ,Long petId,String additionalMetadata,FormDataContentDisposition fileDetail) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } -} - diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java deleted file mode 100644 index 9afb704b726b..000000000000 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.swagger.handler; - -import io.swagger.inflector.models.RequestContext; -import io.swagger.inflector.models.ResponseContext; -import javax.ws.rs.core.Response.Status; - -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; -import java.io.File; -import java.util.List; - -import io.swagger.model.*; - -import java.util.Map; -import io.swagger.model.Order; - -public class StoreController { - - public ResponseContext getInventory(RequestContext request ) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext placeOrder(RequestContext request ,Order body) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext getOrderById(RequestContext request ,String orderId) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext deleteOrder(RequestContext request ,String orderId) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } -} - diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java deleted file mode 100644 index da907dc9fa35..000000000000 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.swagger.handler; - -import io.swagger.inflector.models.RequestContext; -import io.swagger.inflector.models.ResponseContext; -import javax.ws.rs.core.Response.Status; - -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; -import java.io.File; -import java.util.List; - -import io.swagger.model.*; - -import io.swagger.model.User; -import java.util.*; - -public class UserController { - - public ResponseContext createUser(RequestContext request ,User body) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext createUsersWithArrayInput(RequestContext request ,List body) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext createUsersWithListInput(RequestContext request ,List body) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext loginUser(RequestContext request ,String username,String password) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext logoutUser(RequestContext request ) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext getUserByName(RequestContext request ,String username) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext updateUser(RequestContext request ,String username,User body) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } - public ResponseContext deleteUser(RequestContext request ,String username) - { - return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); - } -} - diff --git a/samples/server/petstore/java-inflector/src/main/swagger/swagger.json b/samples/server/petstore/java-inflector/src/main/swagger/swagger.json deleted file mode 100644 index 5ca489f09296..000000000000 --- a/samples/server/petstore/java-inflector/src/main/swagger/swagger.json +++ /dev/null @@ -1,762 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "description" : "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", - "version" : "1.0.0", - "title" : "Swagger Petstore", - "termsOfService" : "http://swagger.io/terms/", - "contact" : { - "email" : "apiteam@swagger.io" - }, - "license" : { - "name" : "Apache 2.0", - "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" - } - }, - "host" : "petstore.swagger.io", - "basePath" : "/v2", - "schemes" : [ "http" ], - "paths" : { - "/pet" : { - "post" : { - "tags" : [ "pet" ], - "summary" : "Add a new pet to the store", - "description" : "", - "operationId" : "addPet", - "consumes" : [ "application/json", "application/xml" ], - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "in" : "body", - "name" : "body", - "description" : "Pet object that needs to be added to the store", - "required" : false, - "schema" : { - "$ref" : "#/definitions/Pet" - } - } ], - "responses" : { - "405" : { - "description" : "Invalid input" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - }, - "put" : { - "tags" : [ "pet" ], - "summary" : "Update an existing pet", - "description" : "", - "operationId" : "updatePet", - "consumes" : [ "application/json", "application/xml" ], - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "in" : "body", - "name" : "body", - "description" : "Pet object that needs to be added to the store", - "required" : false, - "schema" : { - "$ref" : "#/definitions/Pet" - } - } ], - "responses" : { - "405" : { - "description" : "Validation exception" - }, - "404" : { - "description" : "Pet not found" - }, - "400" : { - "description" : "Invalid ID supplied" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - } - }, - "/pet/findByStatus" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by status", - "description" : "Multiple status values can be provided with comma seperated strings", - "operationId" : "findPetsByStatus", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "status", - "in" : "query", - "description" : "Status values that need to be considered for filter", - "required" : false, - "type" : "array", - "items" : { - "type" : "string" - }, - "collectionFormat" : "multi", - "default" : "available" - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/Pet" - } - } - }, - "400" : { - "description" : "Invalid status value" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - } - }, - "/pet/findByTags" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by tags", - "description" : "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", - "operationId" : "findPetsByTags", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "tags", - "in" : "query", - "description" : "Tags to filter by", - "required" : false, - "type" : "array", - "items" : { - "type" : "string" - }, - "collectionFormat" : "multi" - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/Pet" - } - } - }, - "400" : { - "description" : "Invalid tag value" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - } - }, - "/pet/{petId}" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Find pet by ID", - "description" : "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", - "operationId" : "getPetById", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet that needs to be fetched", - "required" : true, - "type" : "integer", - "format" : "int64" - } ], - "responses" : { - "404" : { - "description" : "Pet not found" - }, - "200" : { - "description" : "successful operation", - "schema" : { - "$ref" : "#/definitions/Pet" - } - }, - "400" : { - "description" : "Invalid ID supplied" - } - }, - "security" : [ { - "api_key" : [ ] - }, { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - }, - "post" : { - "tags" : [ "pet" ], - "summary" : "Updates a pet in the store with form data", - "description" : "", - "operationId" : "updatePetWithForm", - "consumes" : [ "application/x-www-form-urlencoded" ], - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet that needs to be updated", - "required" : true, - "type" : "string" - }, { - "name" : "name", - "in" : "formData", - "description" : "Updated name of the pet", - "required" : false, - "type" : "string" - }, { - "name" : "status", - "in" : "formData", - "description" : "Updated status of the pet", - "required" : false, - "type" : "string" - } ], - "responses" : { - "405" : { - "description" : "Invalid input" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - }, - "delete" : { - "tags" : [ "pet" ], - "summary" : "Deletes a pet", - "description" : "", - "operationId" : "deletePet", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "api_key", - "in" : "header", - "description" : "", - "required" : false, - "type" : "string" - }, { - "name" : "petId", - "in" : "path", - "description" : "Pet id to delete", - "required" : true, - "type" : "integer", - "format" : "int64" - } ], - "responses" : { - "400" : { - "description" : "Invalid pet value" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - } - }, - "/pet/{petId}/uploadImage" : { - "post" : { - "tags" : [ "pet" ], - "summary" : "uploads an image", - "description" : "", - "operationId" : "uploadFile", - "consumes" : [ "multipart/form-data" ], - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet to update", - "required" : true, - "type" : "integer", - "format" : "int64" - }, { - "name" : "additionalMetadata", - "in" : "formData", - "description" : "Additional data to pass to server", - "required" : false, - "type" : "string" - }, { - "name" : "file", - "in" : "formData", - "description" : "file to upload", - "required" : false, - "type" : "file" - } ], - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - } - }, - "/store/inventory" : { - "get" : { - "tags" : [ "store" ], - "summary" : "Returns pet inventories by status", - "description" : "Returns a map of status codes to quantities", - "operationId" : "getInventory", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ ], - "responses" : { - "200" : { - "description" : "successful operation", - "schema" : { - "type" : "object", - "additionalProperties" : { - "type" : "integer", - "format" : "int32" - } - } - } - }, - "security" : [ { - "api_key" : [ ] - } ] - } - }, - "/store/order" : { - "post" : { - "tags" : [ "store" ], - "summary" : "Place an order for a pet", - "description" : "", - "operationId" : "placeOrder", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "in" : "body", - "name" : "body", - "description" : "order placed for purchasing the pet", - "required" : false, - "schema" : { - "$ref" : "#/definitions/Order" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "schema" : { - "$ref" : "#/definitions/Order" - } - }, - "400" : { - "description" : "Invalid Order" - } - } - } - }, - "/store/order/{orderId}" : { - "get" : { - "tags" : [ "store" ], - "summary" : "Find purchase order by ID", - "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", - "operationId" : "getOrderById", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of pet that needs to be fetched", - "required" : true, - "type" : "string" - } ], - "responses" : { - "404" : { - "description" : "Order not found" - }, - "200" : { - "description" : "successful operation", - "schema" : { - "$ref" : "#/definitions/Order" - } - }, - "400" : { - "description" : "Invalid ID supplied" - } - } - }, - "delete" : { - "tags" : [ "store" ], - "summary" : "Delete purchase order by ID", - "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - "operationId" : "deleteOrder", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of the order that needs to be deleted", - "required" : true, - "type" : "string" - } ], - "responses" : { - "404" : { - "description" : "Order not found" - }, - "400" : { - "description" : "Invalid ID supplied" - } - } - } - }, - "/user" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Create user", - "description" : "This can only be done by the logged in user.", - "operationId" : "createUser", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "in" : "body", - "name" : "body", - "description" : "Created user object", - "required" : false, - "schema" : { - "$ref" : "#/definitions/User" - } - } ], - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/createWithArray" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "description" : "", - "operationId" : "createUsersWithArrayInput", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "in" : "body", - "name" : "body", - "description" : "List of user object", - "required" : false, - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/User" - } - } - } ], - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/createWithList" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "description" : "", - "operationId" : "createUsersWithListInput", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "in" : "body", - "name" : "body", - "description" : "List of user object", - "required" : false, - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/User" - } - } - } ], - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/login" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs user into the system", - "description" : "", - "operationId" : "loginUser", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "username", - "in" : "query", - "description" : "The user name for login", - "required" : false, - "type" : "string" - }, { - "name" : "password", - "in" : "query", - "description" : "The password for login in clear text", - "required" : false, - "type" : "string" - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "schema" : { - "type" : "string" - } - }, - "400" : { - "description" : "Invalid username/password supplied" - } - } - } - }, - "/user/logout" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs out current logged in user session", - "description" : "", - "operationId" : "logoutUser", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ ], - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/{username}" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Get user by user name", - "description" : "", - "operationId" : "getUserByName", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be fetched. Use user1 for testing. ", - "required" : true, - "type" : "string" - } ], - "responses" : { - "404" : { - "description" : "User not found" - }, - "200" : { - "description" : "successful operation", - "schema" : { - "$ref" : "#/definitions/User" - }, - "examples" : { - "application/json" : { - "id" : 1, - "username" : "johnp", - "firstName" : "John", - "lastName" : "Public", - "email" : "johnp@swagger.io", - "password" : "-secret-", - "phone" : "0123456789", - "userStatus" : 0 - } - } - }, - "400" : { - "description" : "Invalid username supplied" - } - } - }, - "put" : { - "tags" : [ "user" ], - "summary" : "Updated user", - "description" : "This can only be done by the logged in user.", - "operationId" : "updateUser", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "name that need to be deleted", - "required" : true, - "type" : "string" - }, { - "in" : "body", - "name" : "body", - "description" : "Updated user object", - "required" : false, - "schema" : { - "$ref" : "#/definitions/User" - } - } ], - "responses" : { - "404" : { - "description" : "User not found" - }, - "400" : { - "description" : "Invalid user supplied" - } - } - }, - "delete" : { - "tags" : [ "user" ], - "summary" : "Delete user", - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be deleted", - "required" : true, - "type" : "string" - } ], - "responses" : { - "404" : { - "description" : "User not found" - }, - "400" : { - "description" : "Invalid username supplied" - } - } - } - } - }, - "securityDefinitions" : { - "api_key" : { - "type" : "apiKey", - "name" : "api_key", - "in" : "header" - }, - "petstore_auth" : { - "type" : "oauth2", - "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", - "flow" : "implicit", - "scopes" : { - "write:pets" : "modify pets in your account", - "read:pets" : "read your pets" - } - } - }, - "definitions" : { - "User" : { - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "username" : { - "type" : "string" - }, - "firstName" : { - "type" : "string" - }, - "lastName" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "phone" : { - "type" : "string" - }, - "userStatus" : { - "type" : "integer", - "format" : "int32", - "description" : "User Status" - } - }, - "xml" : { - "name" : "User" - } - }, - "Category" : { - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Category" - } - }, - "Pet" : { - "required" : [ "name", "photoUrls" ], - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "category" : { - "$ref" : "#/definitions/Category" - }, - "name" : { - "type" : "string", - "example" : "doggie" - }, - "photoUrls" : { - "type" : "array", - "items" : { - "type" : "string" - } - }, - "tags" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/Tag" - } - }, - "status" : { - "type" : "string", - "description" : "pet status in the store", - "enum" : [ "available", "pending", "sold" ] - } - }, - "xml" : { - "name" : "Pet" - } - }, - "Tag" : { - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Tag" - } - }, - "Order" : { - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "petId" : { - "type" : "integer", - "format" : "int64" - }, - "quantity" : { - "type" : "integer", - "format" : "int32" - }, - "shipDate" : { - "type" : "string", - "format" : "date-time" - }, - "status" : { - "type" : "string", - "description" : "Order Status", - "enum" : [ "placed", "approved", "delivered" ] - }, - "complete" : { - "type" : "boolean" - } - }, - "xml" : { - "name" : "Order" - } - } - } -} \ No newline at end of file diff --git a/samples/server/petstore/java-inflector/src/main/webapp/WEB-INF/web.xml b/samples/server/petstore/java-inflector/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 34a2eea6bcfa..000000000000 --- a/samples/server/petstore/java-inflector/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - swagger-inflector - org.glassfish.jersey.servlet.ServletContainer - - javax.ws.rs.Application - io.swagger.inflector.SwaggerInflector - - 1 - - - swagger-inflector - /* - - - CORSFilter - io.swagger.inflector.utils.CORSFilter - - - CORSFilter - /* - - \ No newline at end of file diff --git a/samples/server/petstore/jaxrs/README.md b/samples/server/petstore/jaxrs/README.md index a5281c3eac30..3ffa01fb2571 100644 --- a/samples/server/petstore/jaxrs/README.md +++ b/samples/server/petstore/jaxrs/README.md @@ -1,5 +1,10 @@ # Swagger generated server ## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project using the -JAX-RS template. +This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the +[swagger-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 swagger-enabled scalatra server. + +This example uses the [scalatra](http://scalatra.org/) framework. To see how to make this your own, look here: + +[README](https://github.com/swagger-api/swagger-codegen/tree/master/samples/server-generator/scalatra) \ No newline at end of file diff --git a/samples/server/petstore/jaxrs/pom.xml b/samples/server/petstore/jaxrs/pom.xml index 9a7e179cc721..cac2f6daf795 100644 --- a/samples/server/petstore/jaxrs/pom.xml +++ b/samples/server/petstore/jaxrs/pom.xml @@ -50,6 +50,7 @@ 0 + true @@ -74,29 +75,12 @@ - target/generated-sources + src/gen/java - - io.swagger - swagger-codegen-maven-plugin - 2.1.3-SNAPSHOT - - - - generate - - - src/main/resources/swagger.json - jaxrs - . - - - - @@ -164,7 +148,7 @@ - 1.5.1-SNAPSHOT + 1.5.0 9.2.9.v20150224 1.13 1.6.3 diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java new file mode 100644 index 000000000000..cae767c0393f --- /dev/null +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java @@ -0,0 +1,9 @@ +package io.swagger.api; + +public class ApiException extends Exception{ + private int code; + public ApiException (int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java new file mode 100644 index 000000000000..c2eeacf13d3f --- /dev/null +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java @@ -0,0 +1,26 @@ +package io.swagger.api; + +import java.io.IOException; + +import javax.servlet.*; +import javax.servlet.http.HttpServletResponse; + +public class ApiOriginFilter implements javax.servlet.Filter { + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } + + @Override + public void destroy() { + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } +} \ No newline at end of file diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java new file mode 100644 index 000000000000..9e5b0ee44e2d --- /dev/null +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java @@ -0,0 +1,68 @@ +package io.swagger.api; + +import javax.xml.bind.annotation.XmlTransient; + +@javax.xml.bind.annotation.XmlRootElement +public class ApiResponseMessage { + public static final int ERROR = 1; + public static final int WARNING = 2; + public static final int INFO = 3; + public static final int OK = 4; + public static final int TOO_BUSY = 5; + + int code; + String type; + String message; + + public ApiResponseMessage(){} + + public ApiResponseMessage(int code, String message){ + this.code = code; + switch(code){ + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } + + @XmlTransient + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java new file mode 100644 index 000000000000..9c8410e47ab8 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java @@ -0,0 +1,9 @@ +package io.swagger.api; + +public class NotFoundException extends ApiException { + private int code; + public NotFoundException (int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java new file mode 100644 index 000000000000..055fa75c80bc --- /dev/null +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java @@ -0,0 +1,148 @@ +package io.swagger.api; + +import io.swagger.model.*; +import io.swagger.api.PetApiService; +import io.swagger.api.factories.PetApiServiceFactory; + +import io.swagger.annotations.ApiParam; + +import com.sun.jersey.multipart.FormDataParam; + +import io.swagger.model.Pet; +import java.io.File; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; + +import javax.ws.rs.core.Response; +import javax.ws.rs.*; + +@Path("/pet") + + +@io.swagger.annotations.Api(value = "/pet", description = "the pet API") +public class PetApi { + + private final PetApiService delegate = PetApiServiceFactory.getPetApi(); + + @PUT + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception"), + + @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) + + public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body) + throws NotFoundException { + return delegate.updatePet(body); + } + @POST + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") }) + + public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body) + throws NotFoundException { + return delegate.addPet(body); + } + @GET + @Path("/findByStatus") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List") + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value") }) + + public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue="available") @QueryParam("status") List status) + throws NotFoundException { + return delegate.findPetsByStatus(status); + } + @GET + @Path("/findByTags") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List") + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value") }) + + public Response findPetsByTags(@ApiParam(value = "Tags to filter by") @QueryParam("tags") List tags) + throws NotFoundException { + return delegate.findPetsByTags(tags); + } + @GET + @Path("/{petId}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"), + + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) + + public Response getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("petId") Long petId) + throws NotFoundException { + return delegate.getPetById(petId); + } + @POST + @Path("/{petId}") + @Consumes({ "application/x-www-form-urlencoded" }) + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") }) + + public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathParam("petId") String petId, + @ApiParam(value = "Updated name of the pet" )@FormParam("name") String name, + @ApiParam(value = "Updated status of the pet" )@FormParam("status") String status) + throws NotFoundException { + return delegate.updatePetWithForm(petId,name,status); + } + @DELETE + @Path("/{petId}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value") }) + + public Response deletePet(@ApiParam(value = "" )@HeaderParam("api_key") String apiKey, + @ApiParam(value = "Pet id to delete",required=true ) @PathParam("petId") Long petId) + throws NotFoundException { + return delegate.deletePet(apiKey,petId); + } + @POST + @Path("/{petId}/uploadImage") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) + + public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathParam("petId") Long petId, + @ApiParam(value = "Additional data to pass to server" )@FormParam("additionalMetadata") String additionalMetadata, + @ApiParam(value = "file to upload") @FormDataParam("file") InputStream inputStream, + @ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail) + throws NotFoundException { + return delegate.uploadFile(petId,additionalMetadata,fileDetail); + } +} + diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java new file mode 100644 index 000000000000..6e8060269eb6 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java @@ -0,0 +1,47 @@ +package io.swagger.api; + +import io.swagger.api.*; +import io.swagger.model.*; + +import com.sun.jersey.multipart.FormDataParam; + +import io.swagger.model.Pet; +import java.io.File; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; + +import javax.ws.rs.core.Response; + +public abstract class PetApiService { + + public abstract Response updatePet(Pet body) + throws NotFoundException; + + public abstract Response addPet(Pet body) + throws NotFoundException; + + public abstract Response findPetsByStatus(List status) + throws NotFoundException; + + public abstract Response findPetsByTags(List tags) + throws NotFoundException; + + public abstract Response getPetById(Long petId) + throws NotFoundException; + + public abstract Response updatePetWithForm(String petId,String name,String status) + throws NotFoundException; + + public abstract Response deletePet(String apiKey,Long petId) + throws NotFoundException; + + public abstract Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail) + throws NotFoundException; + +} diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java new file mode 100644 index 000000000000..f5215862ba78 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java @@ -0,0 +1,90 @@ +package io.swagger.api; + +import io.swagger.model.*; +import io.swagger.api.StoreApiService; +import io.swagger.api.factories.StoreApiServiceFactory; + +import io.swagger.annotations.ApiParam; + +import com.sun.jersey.multipart.FormDataParam; + +import java.util.Map; +import io.swagger.model.Order; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; + +import javax.ws.rs.core.Response; +import javax.ws.rs.*; + +@Path("/store") + + +@io.swagger.annotations.Api(value = "/store", description = "the store API") +public class StoreApi { + + private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi(); + + @GET + @Path("/inventory") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map") + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation") }) + + public Response getInventory() + throws NotFoundException { + return delegate.getInventory(); + } + @POST + @Path("/order") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order") }) + + public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body) + throws NotFoundException { + return delegate.placeOrder(body); + } + @GET + @Path("/order/{orderId}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.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) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found"), + + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) + + public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("orderId") String orderId) + throws NotFoundException { + return delegate.getOrderById(orderId); + } + @DELETE + @Path("/order/{orderId}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.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) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) + + public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathParam("orderId") String orderId) + throws NotFoundException { + return delegate.deleteOrder(orderId); + } +} + diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java new file mode 100644 index 000000000000..5566e9c9b570 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java @@ -0,0 +1,35 @@ +package io.swagger.api; + +import io.swagger.api.*; +import io.swagger.model.*; + +import com.sun.jersey.multipart.FormDataParam; + +import java.util.Map; +import io.swagger.model.Order; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; + +import javax.ws.rs.core.Response; + +public abstract class StoreApiService { + + public abstract Response getInventory() + throws NotFoundException; + + public abstract Response placeOrder(Order body) + throws NotFoundException; + + public abstract Response getOrderById(String orderId) + throws NotFoundException; + + public abstract Response deleteOrder(String orderId) + throws NotFoundException; + +} diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java new file mode 100644 index 000000000000..f904b77746b4 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java @@ -0,0 +1,142 @@ +package io.swagger.api; + +import io.swagger.model.*; +import io.swagger.api.UserApiService; +import io.swagger.api.factories.UserApiServiceFactory; + +import io.swagger.annotations.ApiParam; + +import com.sun.jersey.multipart.FormDataParam; + +import io.swagger.model.User; +import java.util.*; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; + +import javax.ws.rs.core.Response; +import javax.ws.rs.*; + +@Path("/user") + + +@io.swagger.annotations.Api(value = "/user", description = "the user API") +public class UserApi { + + private final UserApiService delegate = UserApiServiceFactory.getUserApi(); + + @POST + + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) + + public Response createUser(@ApiParam(value = "Created user object" ) User body) + throws NotFoundException { + return delegate.createUser(body); + } + @POST + @Path("/createWithArray") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) + + public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ) List body) + throws NotFoundException { + return delegate.createUsersWithArrayInput(body); + } + @POST + @Path("/createWithList") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) + + public Response createUsersWithListInput(@ApiParam(value = "List of user object" ) List body) + throws NotFoundException { + return delegate.createUsersWithListInput(body); + } + @GET + @Path("/login") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied") }) + + public Response loginUser(@ApiParam(value = "The user name for login") @QueryParam("username") String username, + @ApiParam(value = "The password for login in clear text") @QueryParam("password") String password) + throws NotFoundException { + return delegate.loginUser(username,password); + } + @GET + @Path("/logout") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) + + public Response logoutUser() + throws NotFoundException { + return delegate.logoutUser(); + } + @GET + @Path("/{username}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 404, message = "User not found"), + + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") }) + + public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathParam("username") String username) + throws NotFoundException { + return delegate.getUserByName(username); + } + @PUT + @Path("/{username}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 404, message = "User not found"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied") }) + + public Response updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathParam("username") String username, + @ApiParam(value = "Updated user object" ) User body) + throws NotFoundException { + return delegate.updateUser(username,body); + } + @DELETE + @Path("/{username}") + + @Produces({ "application/json", "application/xml" }) + @io.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 404, message = "User not found"), + + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") }) + + public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathParam("username") String username) + throws NotFoundException { + return delegate.deleteUser(username); + } +} + diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java new file mode 100644 index 000000000000..6a09fcd0feb5 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java @@ -0,0 +1,47 @@ +package io.swagger.api; + +import io.swagger.api.*; +import io.swagger.model.*; + +import com.sun.jersey.multipart.FormDataParam; + +import io.swagger.model.User; +import java.util.*; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; + +import javax.ws.rs.core.Response; + +public abstract class UserApiService { + + public abstract Response createUser(User body) + throws NotFoundException; + + public abstract Response createUsersWithArrayInput(List body) + throws NotFoundException; + + public abstract Response createUsersWithListInput(List body) + throws NotFoundException; + + public abstract Response loginUser(String username,String password) + throws NotFoundException; + + public abstract Response logoutUser() + throws NotFoundException; + + public abstract Response getUserByName(String username) + throws NotFoundException; + + public abstract Response updateUser(String username,User body) + throws NotFoundException; + + public abstract Response deleteUser(String username) + throws NotFoundException; + +} diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java similarity index 100% rename from samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java rename to samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java similarity index 100% rename from samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java rename to samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java similarity index 95% rename from samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java rename to samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java index 9c233d082898..076a8cf8142f 100644 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java @@ -1,8 +1,8 @@ package io.swagger.model; import io.swagger.model.Category; -import io.swagger.model.Tag; import java.util.*; +import io.swagger.model.Tag; import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; @@ -14,8 +14,8 @@ public class Pet { private Long id = null; private Category category = null; private String name = null; - private List photoUrls = new ArrayList(); - private List tags = new ArrayList(); + private List photoUrls = new ArrayList() ; + private List tags = new ArrayList() ; public enum StatusEnum { available, pending, sold, }; diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java similarity index 100% rename from samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java rename to samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java similarity index 100% rename from samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java rename to samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java index 56ad64c3212a..fb0bb2bc3ded 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java @@ -5,10 +5,9 @@ import io.swagger.api.impl.PetApiServiceImpl; public class PetApiServiceFactory { - private final static PetApiService service = new PetApiServiceImpl(); + private final static PetApiService service = new PetApiServiceImpl(); - public static PetApiService getPetApi() - { - return service; - } + public static PetApiService getPetApi() { + return service; + } } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java index d60aa7d8660d..325f5ba7ae0c 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java @@ -5,10 +5,9 @@ import io.swagger.api.impl.StoreApiServiceImpl; public class StoreApiServiceFactory { - private final static StoreApiService service = new StoreApiServiceImpl(); + private final static StoreApiService service = new StoreApiServiceImpl(); - public static StoreApiService getStoreApi() - { - return service; - } + public static StoreApiService getStoreApi() { + return service; + } } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java index 5db4914a878d..9a802740e2ca 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java @@ -5,10 +5,9 @@ import io.swagger.api.impl.UserApiServiceImpl; public class UserApiServiceFactory { - private final static UserApiService service = new UserApiServiceImpl(); + private final static UserApiService service = new UserApiServiceImpl(); - public static UserApiService getUserApi() - { - return service; - } + public static UserApiService getUserApi() { + return service; + } } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java index a330f65530c3..3af5a9cd420e 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java @@ -1,79 +1,69 @@ package io.swagger.api.impl; -import io.swagger.api.*; -import io.swagger.model.*; - -import com.sun.jersey.multipart.FormDataParam; - -import io.swagger.model.Pet; -import java.io.File; - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - import com.sun.jersey.core.header.FormDataContentDisposition; -import com.sun.jersey.multipart.FormDataParam; +import io.swagger.api.*; +import io.swagger.api.NotFoundException; +import io.swagger.model.Pet; import javax.ws.rs.core.Response; +import java.util.List; public class PetApiServiceImpl extends PetApiService { - - @Override - public Response updatePet(Pet body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response addPet(Pet body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response findPetsByStatus(List status) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response findPetsByTags(List tags) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response getPetById(Long petId) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response updatePetWithForm(String petId,String name,String status) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response deletePet(Long petId,String apiKey) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - + + @Override + public Response updatePet(Pet body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response addPet(Pet body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response findPetsByStatus(List status) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response findPetsByTags(List tags) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getPetById(Long petId) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response updatePetWithForm(String petId, String name, String status) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response deletePet(String apiKey, Long petId) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response uploadFile(Long petId, String additionalMetadata, FormDataContentDisposition fileDetail) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java index 84e8938f2f9e..9494c3adc89f 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java @@ -1,51 +1,39 @@ package io.swagger.api.impl; import io.swagger.api.*; -import io.swagger.model.*; - -import com.sun.jersey.multipart.FormDataParam; - -import java.util.Map; -import io.swagger.model.Order; - -import java.util.List; import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import com.sun.jersey.core.header.FormDataContentDisposition; -import com.sun.jersey.multipart.FormDataParam; +import io.swagger.model.Order; import javax.ws.rs.core.Response; public class StoreApiServiceImpl extends StoreApiService { - - @Override - public Response getInventory() - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response placeOrder(Order body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response getOrderById(String orderId) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response deleteOrder(String orderId) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - + + @Override + public Response getInventory() + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response placeOrder(Order body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getOrderById(String orderId) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response deleteOrder(String orderId) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java index b7735c7ac9ea..5a8e7a976c4b 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java @@ -1,79 +1,68 @@ package io.swagger.api.impl; import io.swagger.api.*; -import io.swagger.model.*; - -import com.sun.jersey.multipart.FormDataParam; - -import io.swagger.model.User; -import java.util.*; - -import java.util.List; import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import com.sun.jersey.core.header.FormDataContentDisposition; -import com.sun.jersey.multipart.FormDataParam; +import io.swagger.model.User; import javax.ws.rs.core.Response; +import java.util.List; public class UserApiServiceImpl extends UserApiService { - - @Override - public Response createUser(User body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response createUsersWithArrayInput(List body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response createUsersWithListInput(List body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response loginUser(String username,String password) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response logoutUser() - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response getUserByName(String username) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response updateUser(String username,User body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response deleteUser(String username) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - + + @Override + public Response createUser(User body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response createUsersWithArrayInput(List body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response createUsersWithListInput(List body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response loginUser(String username, String password) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response logoutUser() + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getUserByName(String username) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response updateUser(String username, User body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response deleteUser(String username) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + } diff --git a/samples/server/petstore/jaxrs/src/main/resources/swagger.json b/samples/server/petstore/jaxrs/src/main/resources/swagger.json deleted file mode 100644 index 5ca489f09296..000000000000 --- a/samples/server/petstore/jaxrs/src/main/resources/swagger.json +++ /dev/null @@ -1,762 +0,0 @@ -{ - "swagger" : "2.0", - "info" : { - "description" : "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", - "version" : "1.0.0", - "title" : "Swagger Petstore", - "termsOfService" : "http://swagger.io/terms/", - "contact" : { - "email" : "apiteam@swagger.io" - }, - "license" : { - "name" : "Apache 2.0", - "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" - } - }, - "host" : "petstore.swagger.io", - "basePath" : "/v2", - "schemes" : [ "http" ], - "paths" : { - "/pet" : { - "post" : { - "tags" : [ "pet" ], - "summary" : "Add a new pet to the store", - "description" : "", - "operationId" : "addPet", - "consumes" : [ "application/json", "application/xml" ], - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "in" : "body", - "name" : "body", - "description" : "Pet object that needs to be added to the store", - "required" : false, - "schema" : { - "$ref" : "#/definitions/Pet" - } - } ], - "responses" : { - "405" : { - "description" : "Invalid input" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - }, - "put" : { - "tags" : [ "pet" ], - "summary" : "Update an existing pet", - "description" : "", - "operationId" : "updatePet", - "consumes" : [ "application/json", "application/xml" ], - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "in" : "body", - "name" : "body", - "description" : "Pet object that needs to be added to the store", - "required" : false, - "schema" : { - "$ref" : "#/definitions/Pet" - } - } ], - "responses" : { - "405" : { - "description" : "Validation exception" - }, - "404" : { - "description" : "Pet not found" - }, - "400" : { - "description" : "Invalid ID supplied" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - } - }, - "/pet/findByStatus" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by status", - "description" : "Multiple status values can be provided with comma seperated strings", - "operationId" : "findPetsByStatus", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "status", - "in" : "query", - "description" : "Status values that need to be considered for filter", - "required" : false, - "type" : "array", - "items" : { - "type" : "string" - }, - "collectionFormat" : "multi", - "default" : "available" - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/Pet" - } - } - }, - "400" : { - "description" : "Invalid status value" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - } - }, - "/pet/findByTags" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by tags", - "description" : "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", - "operationId" : "findPetsByTags", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "tags", - "in" : "query", - "description" : "Tags to filter by", - "required" : false, - "type" : "array", - "items" : { - "type" : "string" - }, - "collectionFormat" : "multi" - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/Pet" - } - } - }, - "400" : { - "description" : "Invalid tag value" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - } - }, - "/pet/{petId}" : { - "get" : { - "tags" : [ "pet" ], - "summary" : "Find pet by ID", - "description" : "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", - "operationId" : "getPetById", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet that needs to be fetched", - "required" : true, - "type" : "integer", - "format" : "int64" - } ], - "responses" : { - "404" : { - "description" : "Pet not found" - }, - "200" : { - "description" : "successful operation", - "schema" : { - "$ref" : "#/definitions/Pet" - } - }, - "400" : { - "description" : "Invalid ID supplied" - } - }, - "security" : [ { - "api_key" : [ ] - }, { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - }, - "post" : { - "tags" : [ "pet" ], - "summary" : "Updates a pet in the store with form data", - "description" : "", - "operationId" : "updatePetWithForm", - "consumes" : [ "application/x-www-form-urlencoded" ], - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet that needs to be updated", - "required" : true, - "type" : "string" - }, { - "name" : "name", - "in" : "formData", - "description" : "Updated name of the pet", - "required" : false, - "type" : "string" - }, { - "name" : "status", - "in" : "formData", - "description" : "Updated status of the pet", - "required" : false, - "type" : "string" - } ], - "responses" : { - "405" : { - "description" : "Invalid input" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - }, - "delete" : { - "tags" : [ "pet" ], - "summary" : "Deletes a pet", - "description" : "", - "operationId" : "deletePet", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "api_key", - "in" : "header", - "description" : "", - "required" : false, - "type" : "string" - }, { - "name" : "petId", - "in" : "path", - "description" : "Pet id to delete", - "required" : true, - "type" : "integer", - "format" : "int64" - } ], - "responses" : { - "400" : { - "description" : "Invalid pet value" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - } - }, - "/pet/{petId}/uploadImage" : { - "post" : { - "tags" : [ "pet" ], - "summary" : "uploads an image", - "description" : "", - "operationId" : "uploadFile", - "consumes" : [ "multipart/form-data" ], - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "petId", - "in" : "path", - "description" : "ID of pet to update", - "required" : true, - "type" : "integer", - "format" : "int64" - }, { - "name" : "additionalMetadata", - "in" : "formData", - "description" : "Additional data to pass to server", - "required" : false, - "type" : "string" - }, { - "name" : "file", - "in" : "formData", - "description" : "file to upload", - "required" : false, - "type" : "file" - } ], - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - } - }, - "/store/inventory" : { - "get" : { - "tags" : [ "store" ], - "summary" : "Returns pet inventories by status", - "description" : "Returns a map of status codes to quantities", - "operationId" : "getInventory", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ ], - "responses" : { - "200" : { - "description" : "successful operation", - "schema" : { - "type" : "object", - "additionalProperties" : { - "type" : "integer", - "format" : "int32" - } - } - } - }, - "security" : [ { - "api_key" : [ ] - } ] - } - }, - "/store/order" : { - "post" : { - "tags" : [ "store" ], - "summary" : "Place an order for a pet", - "description" : "", - "operationId" : "placeOrder", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "in" : "body", - "name" : "body", - "description" : "order placed for purchasing the pet", - "required" : false, - "schema" : { - "$ref" : "#/definitions/Order" - } - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "schema" : { - "$ref" : "#/definitions/Order" - } - }, - "400" : { - "description" : "Invalid Order" - } - } - } - }, - "/store/order/{orderId}" : { - "get" : { - "tags" : [ "store" ], - "summary" : "Find purchase order by ID", - "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", - "operationId" : "getOrderById", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of pet that needs to be fetched", - "required" : true, - "type" : "string" - } ], - "responses" : { - "404" : { - "description" : "Order not found" - }, - "200" : { - "description" : "successful operation", - "schema" : { - "$ref" : "#/definitions/Order" - } - }, - "400" : { - "description" : "Invalid ID supplied" - } - } - }, - "delete" : { - "tags" : [ "store" ], - "summary" : "Delete purchase order by ID", - "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - "operationId" : "deleteOrder", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of the order that needs to be deleted", - "required" : true, - "type" : "string" - } ], - "responses" : { - "404" : { - "description" : "Order not found" - }, - "400" : { - "description" : "Invalid ID supplied" - } - } - } - }, - "/user" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Create user", - "description" : "This can only be done by the logged in user.", - "operationId" : "createUser", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "in" : "body", - "name" : "body", - "description" : "Created user object", - "required" : false, - "schema" : { - "$ref" : "#/definitions/User" - } - } ], - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/createWithArray" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "description" : "", - "operationId" : "createUsersWithArrayInput", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "in" : "body", - "name" : "body", - "description" : "List of user object", - "required" : false, - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/User" - } - } - } ], - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/createWithList" : { - "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", - "description" : "", - "operationId" : "createUsersWithListInput", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "in" : "body", - "name" : "body", - "description" : "List of user object", - "required" : false, - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/User" - } - } - } ], - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/login" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs user into the system", - "description" : "", - "operationId" : "loginUser", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "username", - "in" : "query", - "description" : "The user name for login", - "required" : false, - "type" : "string" - }, { - "name" : "password", - "in" : "query", - "description" : "The password for login in clear text", - "required" : false, - "type" : "string" - } ], - "responses" : { - "200" : { - "description" : "successful operation", - "schema" : { - "type" : "string" - } - }, - "400" : { - "description" : "Invalid username/password supplied" - } - } - } - }, - "/user/logout" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Logs out current logged in user session", - "description" : "", - "operationId" : "logoutUser", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ ], - "responses" : { - "default" : { - "description" : "successful operation" - } - } - } - }, - "/user/{username}" : { - "get" : { - "tags" : [ "user" ], - "summary" : "Get user by user name", - "description" : "", - "operationId" : "getUserByName", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be fetched. Use user1 for testing. ", - "required" : true, - "type" : "string" - } ], - "responses" : { - "404" : { - "description" : "User not found" - }, - "200" : { - "description" : "successful operation", - "schema" : { - "$ref" : "#/definitions/User" - }, - "examples" : { - "application/json" : { - "id" : 1, - "username" : "johnp", - "firstName" : "John", - "lastName" : "Public", - "email" : "johnp@swagger.io", - "password" : "-secret-", - "phone" : "0123456789", - "userStatus" : 0 - } - } - }, - "400" : { - "description" : "Invalid username supplied" - } - } - }, - "put" : { - "tags" : [ "user" ], - "summary" : "Updated user", - "description" : "This can only be done by the logged in user.", - "operationId" : "updateUser", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "name that need to be deleted", - "required" : true, - "type" : "string" - }, { - "in" : "body", - "name" : "body", - "description" : "Updated user object", - "required" : false, - "schema" : { - "$ref" : "#/definitions/User" - } - } ], - "responses" : { - "404" : { - "description" : "User not found" - }, - "400" : { - "description" : "Invalid user supplied" - } - } - }, - "delete" : { - "tags" : [ "user" ], - "summary" : "Delete user", - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "produces" : [ "application/json", "application/xml" ], - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be deleted", - "required" : true, - "type" : "string" - } ], - "responses" : { - "404" : { - "description" : "User not found" - }, - "400" : { - "description" : "Invalid username supplied" - } - } - } - } - }, - "securityDefinitions" : { - "api_key" : { - "type" : "apiKey", - "name" : "api_key", - "in" : "header" - }, - "petstore_auth" : { - "type" : "oauth2", - "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", - "flow" : "implicit", - "scopes" : { - "write:pets" : "modify pets in your account", - "read:pets" : "read your pets" - } - } - }, - "definitions" : { - "User" : { - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "username" : { - "type" : "string" - }, - "firstName" : { - "type" : "string" - }, - "lastName" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "phone" : { - "type" : "string" - }, - "userStatus" : { - "type" : "integer", - "format" : "int32", - "description" : "User Status" - } - }, - "xml" : { - "name" : "User" - } - }, - "Category" : { - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Category" - } - }, - "Pet" : { - "required" : [ "name", "photoUrls" ], - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "category" : { - "$ref" : "#/definitions/Category" - }, - "name" : { - "type" : "string", - "example" : "doggie" - }, - "photoUrls" : { - "type" : "array", - "items" : { - "type" : "string" - } - }, - "tags" : { - "type" : "array", - "items" : { - "$ref" : "#/definitions/Tag" - } - }, - "status" : { - "type" : "string", - "description" : "pet status in the store", - "enum" : [ "available", "pending", "sold" ] - } - }, - "xml" : { - "name" : "Pet" - } - }, - "Tag" : { - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "name" : { - "type" : "string" - } - }, - "xml" : { - "name" : "Tag" - } - }, - "Order" : { - "properties" : { - "id" : { - "type" : "integer", - "format" : "int64" - }, - "petId" : { - "type" : "integer", - "format" : "int64" - }, - "quantity" : { - "type" : "integer", - "format" : "int32" - }, - "shipDate" : { - "type" : "string", - "format" : "date-time" - }, - "status" : { - "type" : "string", - "description" : "Order Status", - "enum" : [ "placed", "approved", "delivered" ] - }, - "complete" : { - "type" : "boolean" - } - }, - "xml" : { - "name" : "Order" - } - } - } -} \ No newline at end of file From 35ed412d1e0425e9a45c0717b4b816ed6d1f5364 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 23 Aug 2015 18:58:46 -0700 Subject: [PATCH 052/109] moved file --- .../{io.swagger.codegen => io/swagger/codegen}/GenerateTest.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename modules/swagger-codegen-cli/src/test/java/{io.swagger.codegen => io/swagger/codegen}/GenerateTest.java (100%) diff --git a/modules/swagger-codegen-cli/src/test/java/io.swagger.codegen/GenerateTest.java b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/GenerateTest.java similarity index 100% rename from modules/swagger-codegen-cli/src/test/java/io.swagger.codegen/GenerateTest.java rename to modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/GenerateTest.java From 164ed998129ad485cc49851255034314735e2310 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 24 Aug 2015 11:50:21 +0800 Subject: [PATCH 053/109] fix serializableModel (boolean) --- .../io/swagger/codegen/languages/JavaClientCodegen.java | 6 +++--- .../default/src/main/java/io/swagger/client/ApiClient.java | 2 +- .../src/main/java/io/swagger/client/ApiException.java | 2 +- .../src/main/java/io/swagger/client/Configuration.java | 2 +- .../java/default/src/main/java/io/swagger/client/JSON.java | 2 +- .../java/default/src/main/java/io/swagger/client/Pair.java | 2 +- .../default/src/main/java/io/swagger/client/StringUtil.java | 2 +- .../default/src/main/java/io/swagger/client/TypeRef.java | 2 +- .../default/src/main/java/io/swagger/client/api/PetApi.java | 2 +- .../src/main/java/io/swagger/client/api/StoreApi.java | 2 +- .../src/main/java/io/swagger/client/api/UserApi.java | 2 +- .../src/main/java/io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../main/java/io/swagger/client/auth/Authentication.java | 2 +- .../src/main/java/io/swagger/client/auth/HttpBasicAuth.java | 2 +- .../default/src/main/java/io/swagger/client/auth/OAuth.java | 2 +- .../src/main/java/io/swagger/client/model/Category.java | 2 +- .../src/main/java/io/swagger/client/model/Order.java | 2 +- .../default/src/main/java/io/swagger/client/model/Pet.java | 2 +- .../default/src/main/java/io/swagger/client/model/Tag.java | 2 +- .../default/src/main/java/io/swagger/client/model/User.java | 2 +- 20 files changed, 22 insertions(+), 22 deletions(-) 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 a0e31a19061a..a405bfc60971 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 @@ -139,10 +139,10 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } if (additionalProperties.containsKey("serializableModel")) { - this.setSerializableModel(Boolean.valueOf((String)additionalProperties.get("serializableModel"))); - } else { - additionalProperties.put("serializableModel", serializableModel); + this.setSerializableModel(Boolean.valueOf((String)additionalProperties.get("serializableModel").toString())); } + // need to put back serializableModel (boolean) into additionalProperties as value in additionalProperties is string + additionalProperties.put("serializableModel", serializableModel); this.sanitizeConfig(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java index 9af0c10b5439..bc2dab2e8a8d 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java @@ -38,7 +38,7 @@ import io.swagger.client.auth.HttpBasicAuth; import io.swagger.client.auth.ApiKeyAuth; import io.swagger.client.auth.OAuth; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class ApiClient { private Map hostMap = new HashMap(); private Map defaultHeaderMap = new HashMap(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java index 605f8c3769d7..679786deb107 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class ApiException extends Exception { private int code = 0; private String message = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java index 524006fd7bd3..0a674b8d52ae 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java index 3514e41778eb..030152a99742 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*; import java.io.IOException; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class JSON { private ObjectMapper mapper; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java index e7dd3350637d..9f9e2c96b4cc 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java index c80bc8a1647c..de5e940ba55d 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java index 15eb3ea05bad..cd69bd71e7c6 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class TypeRef { private final Type type; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index 5b71f7c199cb..75dfc35beb1c 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -17,7 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class PetApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java index 7c0430b5f718..a488fb374450 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java @@ -17,7 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class StoreApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java index a11ac7d16ed1..3dee565a271b 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java @@ -17,7 +17,7 @@ import java.io.File; import java.util.Map; import java.util.HashMap; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class UserApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index 41094d084401..dccddad00886 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java index 5585eecdf1e2..7efcc795425a 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public interface Authentication { /** Apply authentication settings to header and query params. */ void applyToParams(List queryParams, Map headerParams); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index 740d8993862d..41d7988af0d6 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -8,7 +8,7 @@ import java.util.List; import java.io.UnsupportedEncodingException; import javax.xml.bind.DatatypeConverter; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java index b592d67848f7..20520b968133 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class OAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java index 0d1945b5804f..b7ccc46204c0 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class Category { private Long id = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java index 2a3892f29181..df7ad48b6e11 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class Order { private Long id = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java index 6cb7df1fde58..68799092a32e 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java index fe212ea8ab6f..2550d7c76364 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java index 5b9230b8e015..d27f1c2658d8 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") public class User { private Long id = null; From 6c1f7243bf298cfa5ecf22258e1b35523795d9b7 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 23 Aug 2015 23:29:53 -0700 Subject: [PATCH 054/109] rebuilt --- samples/server/petstore/jaxrs/pom.xml | 41 +- .../gen/java/io/swagger/api/ApiException.java | 1 + .../java/io/swagger/api/ApiOriginFilter.java | 10 +- .../io/swagger/api/ApiResponseMessage.java | 1 + .../io/swagger/api/NotFoundException.java | 1 + .../src/gen/java/io/swagger/api/PetApi.java | 39 +- .../java/io/swagger/api/PetApiService.java | 3 +- .../src/gen/java/io/swagger/api/StoreApi.java | 19 +- .../java/io/swagger/api/StoreApiService.java | 1 + .../src/gen/java/io/swagger/api/UserApi.java | 27 +- .../java/io/swagger/api/UserApiService.java | 1 + .../gen/java/io/swagger/model/Category.java | 1 + .../src/gen/java/io/swagger/model/Order.java | 1 + .../src/gen/java/io/swagger/model/Pet.java | 7 +- .../src/gen/java/io/swagger/model/Tag.java | 1 + .../src/gen/java/io/swagger/model/User.java | 1 + .../api/factories/PetApiServiceFactory.java | 10 +- .../api/factories/StoreApiServiceFactory.java | 10 +- .../api/factories/UserApiServiceFactory.java | 10 +- .../swagger/api/impl/PetApiServiceImpl.java | 131 +++-- .../swagger/api/impl/StoreApiServiceImpl.java | 73 ++- .../swagger/api/impl/UserApiServiceImpl.java | 130 ++-- .../java/io/swagger/client/ApiClient.java | 553 ++++++++++++++++++ .../java/io/swagger/client/ApiException.java | 48 ++ .../java/io/swagger/client/Configuration.java | 22 + .../src/test/java/io/swagger/client/JSON.java | 52 ++ .../src/test/java/io/swagger/client/Pair.java | 39 ++ .../java/io/swagger/client/StringUtil.java | 42 ++ .../test/java/io/swagger/client/TypeRef.java | 26 + .../java/io/swagger/client/api/PetApi.java | 407 +++++++++++++ .../java/io/swagger/client/api/StoreApi.java | 215 +++++++ .../java/io/swagger/client/api/UserApi.java | 386 ++++++++++++ .../io/swagger/client/auth/ApiKeyAuth.java | 59 ++ .../swagger/client/auth/Authentication.java | 12 + .../io/swagger/client/auth/HttpBasicAuth.java | 41 ++ .../java/io/swagger/client/auth/OAuth.java | 14 + .../io/swagger/client/model/Category.java | 53 ++ .../java/io/swagger/client/model/Order.java | 114 ++++ .../java/io/swagger/client/model/Pet.java | 116 ++++ .../java/io/swagger/client/model/Tag.java | 53 ++ .../java/io/swagger/client/model/User.java | 138 +++++ .../integration/ResourceListingTestIT.java | 85 +++ 42 files changed, 2770 insertions(+), 224 deletions(-) create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/ApiClient.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/ApiException.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/Configuration.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/JSON.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/Pair.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/StringUtil.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/TypeRef.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/api/PetApi.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/api/StoreApi.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/api/UserApi.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/ApiKeyAuth.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/Authentication.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/HttpBasicAuth.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/OAuth.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Category.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Order.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Pet.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Tag.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/User.java create mode 100644 samples/server/petstore/jaxrs/src/test/java/io/swagger/test/integration/ResourceListingTestIT.java diff --git a/samples/server/petstore/jaxrs/pom.xml b/samples/server/petstore/jaxrs/pom.xml index cac2f6daf795..ae9f3e06162f 100644 --- a/samples/server/petstore/jaxrs/pom.xml +++ b/samples/server/petstore/jaxrs/pom.xml @@ -119,13 +119,12 @@ jersey-server ${jersey-version} - - org.scalatest - scalatest_2.9.1 - ${scala-test-version} - test + javax.servlet + servlet-api + ${servlet-api-version} + junit junit @@ -133,9 +132,30 @@ test - javax.servlet - servlet-api - ${servlet-api-version} + com.sun.jersey + jersey-client + ${jersey-version} + test + + + org.testng + testng + 6.8.8 + test + + + junit + junit + + + snakeyaml + org.yaml + + + bsh + org.beanshell + + @@ -148,11 +168,10 @@ - 1.5.0 + 1.5.3 9.2.9.v20150224 - 1.13 + 1.18.1 1.6.3 - 1.6.1 4.8.1 2.5 diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java index cae767c0393f..300636842ba1 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java @@ -1,5 +1,6 @@ package io.swagger.api; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java index c2eeacf13d3f..e7ad9b521ac4 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiOriginFilter.java @@ -5,8 +5,8 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public class ApiOriginFilter implements javax.servlet.Filter { - @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse res = (HttpServletResponse) response; @@ -16,11 +16,7 @@ public class ApiOriginFilter implements javax.servlet.Filter { chain.doFilter(request, response); } - @Override - public void destroy() { - } + public void destroy() {} - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } + public void init(FilterConfig filterConfig) throws ServletException {} } \ No newline at end of file diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java index 9e5b0ee44e2d..6d6958c1c907 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiResponseMessage.java @@ -3,6 +3,7 @@ package io.swagger.api; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java index 9c8410e47ab8..c3eab326e644 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/NotFoundException.java @@ -1,5 +1,6 @@ package io.swagger.api; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java index 055fa75c80bc..f583f1e64cfc 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java @@ -26,6 +26,7 @@ import javax.ws.rs.*; @io.swagger.annotations.Api(value = "/pet", description = "the pet API") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public class PetApi { private final PetApiService delegate = PetApiServiceFactory.getPetApi(); @@ -36,11 +37,11 @@ public class PetApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception"), + @io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception", response = Void.class), - @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"), + @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Void.class), - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class) }) public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body) throws NotFoundException { @@ -52,7 +53,7 @@ public class PetApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") }) + @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body) throws NotFoundException { @@ -64,9 +65,9 @@ public class PetApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List") @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value") }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value", response = Pet.class, responseContainer = "List") }) public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue="available") @QueryParam("status") List status) throws NotFoundException { @@ -78,9 +79,9 @@ public class PetApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List") @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value") }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class, responseContainer = "List") }) public Response findPetsByTags(@ApiParam(value = "Tags to filter by") @QueryParam("tags") List tags) throws NotFoundException { @@ -92,11 +93,11 @@ public class PetApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"), + @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Pet.class), - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class), - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class) }) public Response getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("petId") Long petId) throws NotFoundException { @@ -108,7 +109,7 @@ public class PetApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") }) + @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathParam("petId") String petId, @ApiParam(value = "Updated name of the pet" )@FormParam("name") String name, @@ -122,12 +123,12 @@ public class PetApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value") }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) }) - public Response deletePet(@ApiParam(value = "" )@HeaderParam("api_key") String apiKey, - @ApiParam(value = "Pet id to delete",required=true ) @PathParam("petId") Long petId) + public Response deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathParam("petId") Long petId, + @ApiParam(value = "" )@HeaderParam("api_key") String apiKey) throws NotFoundException { - return delegate.deletePet(apiKey,petId); + return delegate.deletePet(petId,apiKey); } @POST @Path("/{petId}/uploadImage") @@ -135,12 +136,12 @@ public class PetApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = Void.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) }) public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathParam("petId") Long petId, @ApiParam(value = "Additional data to pass to server" )@FormParam("additionalMetadata") String additionalMetadata, - @ApiParam(value = "file to upload") @FormDataParam("file") InputStream inputStream, - @ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail) + @FormDataParam("file") InputStream inputStream, + @FormDataParam("file") FormDataContentDisposition fileDetail) throws NotFoundException { return delegate.uploadFile(petId,additionalMetadata,fileDetail); } diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java index 6e8060269eb6..708dc647f911 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java @@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public abstract class PetApiService { public abstract Response updatePet(Pet body) @@ -38,7 +39,7 @@ public abstract class PetApiService { public abstract Response updatePetWithForm(String petId,String name,String status) throws NotFoundException; - public abstract Response deletePet(String apiKey,Long petId) + public abstract Response deletePet(Long petId,String apiKey) throws NotFoundException; public abstract Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail) diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java index f5215862ba78..a487439cb3f9 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApi.java @@ -26,6 +26,7 @@ import javax.ws.rs.*; @io.swagger.annotations.Api(value = "/store", description = "the store API") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public class StoreApi { private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi(); @@ -34,9 +35,9 @@ public class StoreApi { @Path("/inventory") @Produces({ "application/json", "application/xml" }) - @io.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map") + @io.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map") @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation") }) + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Integer.class, responseContainer = "Map") }) public Response getInventory() throws NotFoundException { @@ -48,9 +49,9 @@ public class StoreApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class), - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order") }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body) throws NotFoundException { @@ -62,11 +63,11 @@ public class StoreApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.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) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found"), + @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Order.class), - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class), - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class) }) public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("orderId") String orderId) throws NotFoundException { @@ -78,9 +79,9 @@ public class StoreApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.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) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found"), + @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Void.class), - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class) }) public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathParam("orderId") String orderId) throws NotFoundException { diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java index 5566e9c9b570..955d640d1b5f 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/StoreApiService.java @@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public abstract class StoreApiService { public abstract Response getInventory() diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java index f904b77746b4..d7bde1b17534 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApi.java @@ -26,6 +26,7 @@ import javax.ws.rs.*; @io.swagger.annotations.Api(value = "/user", description = "the user API") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public class UserApi { private final UserApiService delegate = UserApiServiceFactory.getUserApi(); @@ -36,7 +37,7 @@ public class UserApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) }) public Response createUser(@ApiParam(value = "Created user object" ) User body) throws NotFoundException { @@ -48,7 +49,7 @@ public class UserApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) }) public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ) List body) throws NotFoundException { @@ -60,7 +61,7 @@ public class UserApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) }) public Response createUsersWithListInput(@ApiParam(value = "List of user object" ) List body) throws NotFoundException { @@ -72,9 +73,9 @@ public class UserApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = String.class), - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied") }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) public Response loginUser(@ApiParam(value = "The user name for login") @QueryParam("username") String username, @ApiParam(value = "The password for login in clear text") @QueryParam("password") String password) @@ -87,7 +88,7 @@ public class UserApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 0, message = "successful operation") }) + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) }) public Response logoutUser() throws NotFoundException { @@ -99,11 +100,11 @@ public class UserApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 404, message = "User not found"), + @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = User.class), - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation"), + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = User.class), - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = User.class) }) public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathParam("username") String username) throws NotFoundException { @@ -115,9 +116,9 @@ public class UserApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 404, message = "User not found"), + @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class), - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied") }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class) }) public Response updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathParam("username") String username, @ApiParam(value = "Updated user object" ) User body) @@ -130,9 +131,9 @@ public class UserApi { @Produces({ "application/json", "application/xml" }) @io.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 404, message = "User not found"), + @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class), - @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied") }) + @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class) }) public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathParam("username") String username) throws NotFoundException { diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java index 6a09fcd0feb5..e838a00e2829 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/UserApiService.java @@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public abstract class UserApiService { public abstract Response createUser(User body) diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java index 56f86f70737c..57666c8444b8 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Category.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public class Category { private Long id = null; diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java index 4d0c133e9362..99b3c758473e 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Order.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public class Order { private Long id = null; diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java index 076a8cf8142f..0b01a065022e 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Pet.java @@ -1,21 +1,22 @@ package io.swagger.model; import io.swagger.model.Category; -import java.util.*; import io.swagger.model.Tag; +import java.util.*; import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public class Pet { private Long id = null; private Category category = null; private String name = null; - private List photoUrls = new ArrayList() ; - private List tags = new ArrayList() ; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); public enum StatusEnum { available, pending, sold, }; diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java index 99dd07c00f7a..935e04025c87 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/Tag.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public class Tag { private Long id = null; diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java index d5f43a4c25e8..6d6fb0c1d94e 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/User.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T23:29:16.812-07:00") public class User { private Long id = null; diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java index fb0bb2bc3ded..c3a7cbf8bf77 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/PetApiServiceFactory.java @@ -3,11 +3,13 @@ package io.swagger.api.factories; import io.swagger.api.PetApiService; import io.swagger.api.impl.PetApiServiceImpl; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T22:18:00.553-07:00") public class PetApiServiceFactory { - private final static PetApiService service = new PetApiServiceImpl(); + private final static PetApiService service = new PetApiServiceImpl(); - public static PetApiService getPetApi() { - return service; - } + public static PetApiService getPetApi() + { + return service; + } } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java index 325f5ba7ae0c..9eb7af458dd9 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/StoreApiServiceFactory.java @@ -3,11 +3,13 @@ package io.swagger.api.factories; import io.swagger.api.StoreApiService; import io.swagger.api.impl.StoreApiServiceImpl; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T22:18:00.553-07:00") public class StoreApiServiceFactory { - private final static StoreApiService service = new StoreApiServiceImpl(); + private final static StoreApiService service = new StoreApiServiceImpl(); - public static StoreApiService getStoreApi() { - return service; - } + public static StoreApiService getStoreApi() + { + return service; + } } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java index 9a802740e2ca..2f381c6b4591 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/factories/UserApiServiceFactory.java @@ -3,11 +3,13 @@ package io.swagger.api.factories; import io.swagger.api.UserApiService; import io.swagger.api.impl.UserApiServiceImpl; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T22:18:00.553-07:00") public class UserApiServiceFactory { - private final static UserApiService service = new UserApiServiceImpl(); + private final static UserApiService service = new UserApiServiceImpl(); - public static UserApiService getUserApi() { - return service; - } + public static UserApiService getUserApi() + { + return service; + } } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java index 3af5a9cd420e..c7ee88aaf638 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java @@ -1,69 +1,80 @@ package io.swagger.api.impl; -import com.sun.jersey.core.header.FormDataContentDisposition; import io.swagger.api.*; -import io.swagger.api.NotFoundException; +import io.swagger.model.*; + +import com.sun.jersey.multipart.FormDataParam; + import io.swagger.model.Pet; +import java.io.File; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; -import java.util.List; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T22:18:00.553-07:00") public class PetApiServiceImpl extends PetApiService { - - @Override - public Response updatePet(Pet body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response addPet(Pet body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response findPetsByStatus(List status) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response findPetsByTags(List tags) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response getPetById(Long petId) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response updatePetWithForm(String petId, String name, String status) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response deletePet(String apiKey, Long petId) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response uploadFile(Long petId, String additionalMetadata, FormDataContentDisposition fileDetail) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - + + @Override + public Response updatePet(Pet body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response addPet(Pet body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response findPetsByStatus(List status) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response findPetsByTags(List tags) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getPetById(Long petId) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response updatePetWithForm(String petId,String name,String status) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response deletePet(Long petId,String apiKey) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java index 9494c3adc89f..7dbf5e75dd27 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java @@ -1,39 +1,52 @@ package io.swagger.api.impl; import io.swagger.api.*; -import io.swagger.api.NotFoundException; +import io.swagger.model.*; + +import com.sun.jersey.multipart.FormDataParam; + +import java.util.Map; import io.swagger.model.Order; +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; + import javax.ws.rs.core.Response; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T22:18:00.553-07:00") public class StoreApiServiceImpl extends StoreApiService { - - @Override - public Response getInventory() - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response placeOrder(Order body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response getOrderById(String orderId) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response deleteOrder(String orderId) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - + + @Override + public Response getInventory() + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response placeOrder(Order body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getOrderById(String orderId) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response deleteOrder(String orderId) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + } diff --git a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java index 5a8e7a976c4b..cdbc9afed191 100644 --- a/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java +++ b/samples/server/petstore/jaxrs/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java @@ -1,68 +1,80 @@ package io.swagger.api.impl; import io.swagger.api.*; -import io.swagger.api.NotFoundException; +import io.swagger.model.*; + +import com.sun.jersey.multipart.FormDataParam; + import io.swagger.model.User; +import java.util.*; + +import java.util.List; +import io.swagger.api.NotFoundException; + +import java.io.InputStream; + +import com.sun.jersey.core.header.FormDataContentDisposition; +import com.sun.jersey.multipart.FormDataParam; import javax.ws.rs.core.Response; -import java.util.List; +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2015-08-23T22:18:00.553-07:00") public class UserApiServiceImpl extends UserApiService { - - @Override - public Response createUser(User body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response createUsersWithArrayInput(List body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response createUsersWithListInput(List body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response loginUser(String username, String password) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response logoutUser() - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response getUserByName(String username) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response updateUser(String username, User body) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - - @Override - public Response deleteUser(String username) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - + + @Override + public Response createUser(User body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response createUsersWithArrayInput(List body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response createUsersWithListInput(List body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response loginUser(String username,String password) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response logoutUser() + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response getUserByName(String username) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response updateUser(String username,User body) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + + @Override + public Response deleteUser(String username) + throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + } diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/ApiClient.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/ApiClient.java new file mode 100644 index 000000000000..9af0c10b5439 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/ApiClient.java @@ -0,0 +1,553 @@ +package io.swagger.client; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.client.filter.LoggingFilter; +import com.sun.jersey.api.client.WebResource.Builder; + +import com.sun.jersey.multipart.FormDataMultiPart; +import com.sun.jersey.multipart.file.FileDataBodyPart; + +import javax.ws.rs.core.Response.Status.Family; +import javax.ws.rs.core.MediaType; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.Map.Entry; +import java.util.HashMap; +import java.util.List; +import java.util.ArrayList; +import java.util.Date; +import java.util.TimeZone; + +import java.net.URLEncoder; + +import java.io.IOException; +import java.io.File; +import java.io.UnsupportedEncodingException; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.text.ParseException; + +import io.swagger.client.auth.Authentication; +import io.swagger.client.auth.HttpBasicAuth; +import io.swagger.client.auth.ApiKeyAuth; +import io.swagger.client.auth.OAuth; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class ApiClient { + private Map hostMap = new HashMap(); + private Map defaultHeaderMap = new HashMap(); + private boolean debugging = false; + private String basePath = "http://petstore.swagger.io/v2"; + private JSON json = new JSON(); + + private Map authentications; + + private DateFormat dateFormat; + + public ApiClient() { + // Use ISO 8601 format for date and datetime. + // See https://en.wikipedia.org/wiki/ISO_8601 + this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + + // Use UTC as the default time zone. + this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + + // Set default User-Agent. + setUserAgent("Java-Swagger"); + + // Setup authentications (key: authentication name, value: authentication). + authentications = new HashMap(); + authentications.put("api_key", new ApiKeyAuth("header", "api_key")); + authentications.put("petstore_auth", new OAuth()); + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + public String getBasePath() { + return basePath; + } + + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + /** + * Helper method to set username for the first HTTP basic authentication. + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + */ + public ApiClient setDebugging(boolean debugging) { + this.debugging = debugging; + return this; + } + + /** + * Get the date format used to parse/format date parameters. + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + * Set the date format used to parse/format date parameters. + */ + public ApiClient getDateFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + return this; + } + + /** + * Parse the given string into Date object. + */ + public Date parseDate(String str) { + try { + return dateFormat.parse(str); + } catch (java.text.ParseException e) { + throw new RuntimeException(e); + } + } + + /** + * Format the given Date object into string. + */ + public String formatDate(Date date) { + return dateFormat.format(date); + } + + /** + * Format the given parameter object into string. + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date) { + return formatDate((Date) param); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for(Object o : (Collection)param) { + if(b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /* + Format to {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Object value){ + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null) return params; + + Collection valueCollection = null; + if (value instanceof Collection) { + valueCollection = (Collection) value; + } else { + params.add(new Pair(name, parameterToString(value))); + return params; + } + + if (valueCollection.isEmpty()){ + return params; + } + + // get the collection format + collectionFormat = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); // default: csv + + // create the params based on the collection format + if (collectionFormat.equals("multi")) { + for (Object item : valueCollection) { + params.add(new Pair(name, parameterToString(item))); + } + + return params; + } + + String delimiter = ","; + + if (collectionFormat.equals("csv")) { + delimiter = ","; + } else if (collectionFormat.equals("ssv")) { + delimiter = " "; + } else if (collectionFormat.equals("tsv")) { + delimiter = "\t"; + } else if (collectionFormat.equals("pipes")) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : valueCollection) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + params.add(new Pair(name, sb.substring(1))); + + return params; + } + + /** + * Select the Accept header's value from the given accepts array: + * if JSON exists in the given array, use it; + * otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, + * null will be returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) return null; + if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json"; + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: + * if JSON exists in the given array, use it; + * otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, + * JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) return "application/json"; + if (StringUtil.containsIgnoreCase(contentTypes, "application/json")) return "application/json"; + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Serialize the given Java object into string according the given + * Content-Type (only JSON is supported for now). + */ + public String serialize(Object obj, String contentType) throws ApiException { + if (contentType.startsWith("application/json")) { + return json.serialize(obj); + } else { + throw new ApiException(400, "can not serialize object into Content-Type: " + contentType); + } + } + + /** + * Deserialize response body to Java object according to the Content-Type. + */ + public T deserialize(ClientResponse response, TypeRef returnType) throws ApiException { + String contentType = null; + List contentTypes = response.getHeaders().get("Content-Type"); + if (contentTypes != null && !contentTypes.isEmpty()) + contentType = contentTypes.get(0); + if (contentType == null) + throw new ApiException(500, "missing Content-Type in response"); + + String body; + if (response.hasEntity()) + body = (String) response.getEntity(String.class); + else + body = ""; + + if (contentType.startsWith("application/json")) { + return json.deserialize(body, returnType); + } else { + throw new ApiException(500, "can not deserialize Content-Type: " + contentType); + } + } + + /** + * Invoke API by sending HTTP request with the given options. + * + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "POST", "PUT", and "DELETE" + * @param queryParams The query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param formParams The form parameters + * @param accept The request's Accept header + * @param contentType The request's Content-Type header + * @param authNames The authentications to apply + * @param returnType The return type into which to deserialize the response + * @return The response body in type of string + */ + public T invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, TypeRef returnType) throws ApiException { + updateParamsForAuth(authNames, queryParams, headerParams); + + Client client = getClient(); + + StringBuilder b = new StringBuilder(); + b.append("?"); + if (queryParams != null){ + for (Pair queryParam : queryParams){ + if (!queryParam.getName().isEmpty()) { + b.append(escapeString(queryParam.getName())); + b.append("="); + b.append(escapeString(queryParam.getValue())); + b.append("&"); + } + } + } + + String querystring = b.substring(0, b.length() - 1); + + Builder builder; + if (accept == null) + builder = client.resource(basePath + path + querystring).getRequestBuilder(); + else + builder = client.resource(basePath + path + querystring).accept(accept); + + for (String key : headerParams.keySet()) { + builder = builder.header(key, headerParams.get(key)); + } + for (String key : defaultHeaderMap.keySet()) { + if (!headerParams.containsKey(key)) { + builder = builder.header(key, defaultHeaderMap.get(key)); + } + } + + String encodedFormParams = null; + if (contentType.startsWith("multipart/form-data")) { + FormDataMultiPart mp = new FormDataMultiPart(); + for (Entry param: formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + mp.field(param.getKey(), file.getName()); + mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE)); + } else { + mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE); + } + } + body = mp; + } else if (contentType.startsWith("application/x-www-form-urlencoded")) { + encodedFormParams = this.getXWWWFormUrlencodedParams(formParams); + } + + ClientResponse response = null; + + if ("GET".equals(method)) { + response = (ClientResponse) builder.get(ClientResponse.class); + } else if ("POST".equals(method)) { + if (encodedFormParams != null) { + response = builder.type(contentType).post(ClientResponse.class, encodedFormParams); + } else if (body == null) { + response = builder.post(ClientResponse.class, null); + } else if (body instanceof FormDataMultiPart) { + response = builder.type(contentType).post(ClientResponse.class, body); + } else { + response = builder.type(contentType).post(ClientResponse.class, serialize(body, contentType)); + } + } else if ("PUT".equals(method)) { + if (encodedFormParams != null) { + response = builder.type(contentType).put(ClientResponse.class, encodedFormParams); + } else if(body == null) { + response = builder.put(ClientResponse.class, serialize(body, contentType)); + } else { + response = builder.type(contentType).put(ClientResponse.class, serialize(body, contentType)); + } + } else if ("DELETE".equals(method)) { + if (encodedFormParams != null) { + response = builder.type(contentType).delete(ClientResponse.class, encodedFormParams); + } else if(body == null) { + response = builder.delete(ClientResponse.class); + } else { + response = builder.type(contentType).delete(ClientResponse.class, serialize(body, contentType)); + } + } else { + throw new ApiException(500, "unknown method type " + method); + } + + if (response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) { + return null; + } else if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) { + if (returnType == null) + return null; + else + return deserialize(response, returnType); + } else { + String message = "error"; + String respBody = null; + if (response.hasEntity()) { + try { + respBody = String.valueOf(response.getEntity(String.class)); + message = respBody; + } catch (RuntimeException e) { + // e.printStackTrace(); + } + } + throw new ApiException( + response.getStatusInfo().getStatusCode(), + message, + response.getHeaders(), + respBody); + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + */ + private void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams) { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); + auth.applyToParams(queryParams, headerParams); + } + } + + /** + * Encode the given form parameters as request body. + */ + private String getXWWWFormUrlencodedParams(Map formParams) { + StringBuilder formParamBuilder = new StringBuilder(); + + for (Entry param : formParams.entrySet()) { + String keyStr = param.getKey(); + String valueStr = parameterToString(param.getValue()); + try { + formParamBuilder.append(URLEncoder.encode(param.getKey(), "utf8")) + .append("=") + .append(URLEncoder.encode(valueStr, "utf8")); + formParamBuilder.append("&"); + } catch (UnsupportedEncodingException e) { + // move on to next + } + } + + String encodedFormParams = formParamBuilder.toString(); + if (encodedFormParams.endsWith("&")) { + encodedFormParams = encodedFormParams.substring(0, encodedFormParams.length() - 1); + } + + return encodedFormParams; + } + + /** + * Get an existing client or create a new client to handle HTTP request. + */ + private Client getClient() { + if(!hostMap.containsKey(basePath)) { + Client client = Client.create(); + if (debugging) + client.addFilter(new LoggingFilter()); + hostMap.put(basePath, client); + } + return hostMap.get(basePath); + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/ApiException.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/ApiException.java new file mode 100644 index 000000000000..605f8c3769d7 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/ApiException.java @@ -0,0 +1,48 @@ +package io.swagger.client; + +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class ApiException extends Exception { + private int code = 0; + private String message = null; + private Map> responseHeaders = null; + private String responseBody = null; + + public ApiException() {} + + public ApiException(int code, String message) { + this.code = code; + this.message = message; + } + + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this.code = code; + this.message = message; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public int getCode() { + return code; + } + + public String getMessage() { + return message; + } + + /** + * Get the HTTP response headers. + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + */ + public String getResponseBody() { + return responseBody; + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/Configuration.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/Configuration.java new file mode 100644 index 000000000000..524006fd7bd3 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/Configuration.java @@ -0,0 +1,22 @@ +package io.swagger.client; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class Configuration { + private static ApiClient defaultApiClient = new ApiClient(); + + /** + * Get the default API client, which would be used when creating API + * instances without providing an API client. + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } + + /** + * Set the default API client, which would be used when creating API + * instances without providing an API client. + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/JSON.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/JSON.java new file mode 100644 index 000000000000..3514e41778eb --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/JSON.java @@ -0,0 +1,52 @@ +package io.swagger.client; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.datatype.joda.*; + +import java.io.IOException; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class JSON { + private ObjectMapper mapper; + + public JSON() { + mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.registerModule(new JodaModule()); + } + + /** + * Serialize the given Java object into JSON string. + */ + public String serialize(Object obj) throws ApiException { + try { + if (obj != null) + return mapper.writeValueAsString(obj); + else + return null; + } catch (Exception e) { + throw new ApiException(400, e.getMessage()); + } + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param body The JSON string + * @param returnType The type to deserialize inot + * @return The deserialized Java object + */ + public T deserialize(String body, TypeRef returnType) throws ApiException { + JavaType javaType = mapper.constructType(returnType.getType()); + try { + return mapper.readValue(body, javaType); + } catch (IOException e) { + if (returnType.getType().equals(String.class)) + return (T) body; + else + throw new ApiException(500, e.getMessage(), null, body); + } + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/Pair.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/Pair.java new file mode 100644 index 000000000000..e7dd3350637d --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/Pair.java @@ -0,0 +1,39 @@ +package io.swagger.client; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class Pair { + private String name = ""; + private String value = ""; + + public Pair (String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) return; + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) return; + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) return false; + if (arg.trim().isEmpty()) return false; + + return true; + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/StringUtil.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/StringUtil.java new file mode 100644 index 000000000000..c80bc8a1647c --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/StringUtil.java @@ -0,0 +1,42 @@ +package io.swagger.client; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) return true; + if (value != null && value.equalsIgnoreCase(str)) return true; + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) return ""; + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/TypeRef.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/TypeRef.java new file mode 100644 index 000000000000..15eb3ea05bad --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/TypeRef.java @@ -0,0 +1,26 @@ +package io.swagger.client; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class TypeRef { + private final Type type; + + public TypeRef() { + this.type = getGenericType(getClass()); + } + + private static Type getGenericType(Class klass) { + Type superclass = klass.getGenericSuperclass(); + if (superclass instanceof Class) { + throw new RuntimeException("No type parameter provided"); + } + ParameterizedType parameterized = (ParameterizedType) superclass; + return parameterized.getActualTypeArguments()[0]; + } + + public Type getType() { + return type; + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/api/PetApi.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/api/PetApi.java new file mode 100644 index 000000000000..5b71f7c199cb --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/api/PetApi.java @@ -0,0 +1,407 @@ +package io.swagger.client.api; + +import io.swagger.client.ApiException; +import io.swagger.client.ApiClient; +import io.swagger.client.Configuration; +import io.swagger.client.Pair; +import io.swagger.client.TypeRef; + +import io.swagger.client.model.*; + +import java.util.*; + +import io.swagger.client.model.Pet; +import java.io.File; + +import java.io.File; +import java.util.Map; +import java.util.HashMap; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class PetApi { + private ApiClient apiClient; + + public PetApi() { + this(Configuration.getDefaultApiClient()); + } + + public PetApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() { + return apiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + * @return void + */ + public void updatePet (Pet body) throws ApiException { + Object postBody = body; + + + // create path and map variables + String path = "/pet".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + "application/json", "application/xml" + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Add a new pet to the store + * + * @param body Pet object that needs to be added to the store + * @return void + */ + public void addPet (Pet body) throws ApiException { + Object postBody = body; + + + // create path and map variables + String path = "/pet".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + "application/json", "application/xml" + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma seperated strings + * @param status Status values that need to be considered for filter + * @return List + */ + public List findPetsByStatus (List status) throws ApiException { + Object postBody = null; + + + // create path and map variables + String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + queryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + TypeRef returnType = new TypeRef>() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Finds Pets by tags + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by + * @return List + */ + public List findPetsByTags (List tags) throws ApiException { + Object postBody = null; + + + // create path and map variables + String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + queryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + TypeRef returnType = new TypeRef>() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Find pet by ID + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return Pet + */ + public Pet getPetById (Long petId) throws ApiException { + Object postBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById"); + } + + + // create path and map variables + String path = "/pet/{petId}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "api_key", "petstore_auth" }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + * @return void + */ + public void updatePetWithForm (String petId, String name, String status) throws ApiException { + Object postBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm"); + } + + + // create path and map variables + String path = "/pet/{petId}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + if (name != null) + formParams.put("name", name); + if (status != null) + formParams.put("status", status); + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + "application/x-www-form-urlencoded" + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + * @return void + */ + public void deletePet (Long petId, String apiKey) throws ApiException { + Object postBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet"); + } + + + // create path and map variables + String path = "/pet/{petId}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + if (apiKey != null) + headerParams.put("api_key", apiClient.parameterToString(apiKey)); + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * uploads an image + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + * @return void + */ + public void uploadFile (Long petId, String additionalMetadata, File file) throws ApiException { + Object postBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile"); + } + + + // create path and map variables + String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + if (additionalMetadata != null) + formParams.put("additionalMetadata", additionalMetadata); + if (file != null) + formParams.put("file", file); + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + "multipart/form-data" + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "petstore_auth" }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/api/StoreApi.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/api/StoreApi.java new file mode 100644 index 000000000000..7c0430b5f718 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/api/StoreApi.java @@ -0,0 +1,215 @@ +package io.swagger.client.api; + +import io.swagger.client.ApiException; +import io.swagger.client.ApiClient; +import io.swagger.client.Configuration; +import io.swagger.client.Pair; +import io.swagger.client.TypeRef; + +import io.swagger.client.model.*; + +import java.util.*; + +import java.util.Map; +import io.swagger.client.model.Order; + +import java.io.File; +import java.util.Map; +import java.util.HashMap; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class StoreApi { + private ApiClient apiClient; + + public StoreApi() { + this(Configuration.getDefaultApiClient()); + } + + public StoreApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() { + return apiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return Map + */ + public Map getInventory () throws ApiException { + Object postBody = null; + + + // create path and map variables + String path = "/store/inventory".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { "api_key" }; + + TypeRef returnType = new TypeRef>() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet + * @return Order + */ + public Order placeOrder (Order body) throws ApiException { + Object postBody = body; + + + // create path and map variables + String path = "/store/order".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param orderId ID of pet that needs to be fetched + * @return Order + */ + public Order getOrderById (String orderId) throws ApiException { + Object postBody = null; + + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById"); + } + + + // create path and map variables + String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted + * @return void + */ + public void deleteOrder (String orderId) throws ApiException { + Object postBody = null; + + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder"); + } + + + // create path and map variables + String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/api/UserApi.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/api/UserApi.java new file mode 100644 index 000000000000..a11ac7d16ed1 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/api/UserApi.java @@ -0,0 +1,386 @@ +package io.swagger.client.api; + +import io.swagger.client.ApiException; +import io.swagger.client.ApiClient; +import io.swagger.client.Configuration; +import io.swagger.client.Pair; +import io.swagger.client.TypeRef; + +import io.swagger.client.model.*; + +import java.util.*; + +import io.swagger.client.model.User; +import java.util.*; + +import java.io.File; +import java.util.Map; +import java.util.HashMap; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class UserApi { + private ApiClient apiClient; + + public UserApi() { + this(Configuration.getDefaultApiClient()); + } + + public UserApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() { + return apiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + + /** + * Create user + * This can only be done by the logged in user. + * @param body Created user object + * @return void + */ + public void createUser (User body) throws ApiException { + Object postBody = body; + + + // create path and map variables + String path = "/user".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + * @return void + */ + public void createUsersWithArrayInput (List body) throws ApiException { + Object postBody = body; + + + // create path and map variables + String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + * @return void + */ + public void createUsersWithListInput (List body) throws ApiException { + Object postBody = body; + + + // create path and map variables + String path = "/user/createWithList".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + * @return String + */ + public String loginUser (String username, String password) throws ApiException { + Object postBody = null; + + + // create path and map variables + String path = "/user/login".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + queryParams.addAll(apiClient.parameterToPairs("", "username", username)); + + queryParams.addAll(apiClient.parameterToPairs("", "password", password)); + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Logs out current logged in user session + * + * @return void + */ + public void logoutUser () throws ApiException { + Object postBody = null; + + + // create path and map variables + String path = "/user/logout".replaceAll("\\{format\\}","json"); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + * @return User + */ + public User getUserByName (String username) throws ApiException { + Object postBody = null; + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling getUserByName"); + } + + + // create path and map variables + String path = "/user/{username}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + TypeRef returnType = new TypeRef() {}; + return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted + * @param body Updated user object + * @return void + */ + public void updateUser (String username, User body) throws ApiException { + Object postBody = body; + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); + } + + + // create path and map variables + String path = "/user/{username}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + * @return void + */ + public void deleteUser (String username) throws ApiException { + Object postBody = null; + + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling deleteUser"); + } + + + // create path and map variables + String path = "/user/{username}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); + + // query params + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + + + + + + + final String[] accepts = { + "application/json", "application/xml" + }; + final String accept = apiClient.selectHeaderAccept(accepts); + + final String[] contentTypes = { + + }; + final String contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + apiClient.invokeAPI(path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, null); + + } + +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/ApiKeyAuth.java new file mode 100644 index 000000000000..41094d084401 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/ApiKeyAuth.java @@ -0,0 +1,59 @@ +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class ApiKeyAuth implements Authentication { + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List queryParams, Map headerParams) { + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if (location == "query") { + queryParams.add(new Pair(paramName, value)); + } else if (location == "header") { + headerParams.put(paramName, value); + } + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/Authentication.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/Authentication.java new file mode 100644 index 000000000000..5585eecdf1e2 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/Authentication.java @@ -0,0 +1,12 @@ +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public interface Authentication { + /** Apply authentication settings to header and query params. */ + void applyToParams(List queryParams, Map headerParams); +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/HttpBasicAuth.java new file mode 100644 index 000000000000..740d8993862d --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/HttpBasicAuth.java @@ -0,0 +1,41 @@ +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import java.util.Map; +import java.util.List; + +import java.io.UnsupportedEncodingException; +import javax.xml.bind.DatatypeConverter; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams) { + String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); + try { + headerParams.put("Authorization", "Basic " + DatatypeConverter.printBase64Binary(str.getBytes("UTF-8"))); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/OAuth.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/OAuth.java new file mode 100644 index 000000000000..b592d67848f7 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/auth/OAuth.java @@ -0,0 +1,14 @@ +package io.swagger.client.auth; + +import io.swagger.client.Pair; + +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class OAuth implements Authentication { + @Override + public void applyToParams(List queryParams, Map headerParams) { + // TODO: support oauth + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Category.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Category.java new file mode 100644 index 000000000000..0d1945b5804f --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Category.java @@ -0,0 +1,53 @@ +package io.swagger.client.model; + + + + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class Category { + + private Long id = null; + private String name = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Order.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Order.java new file mode 100644 index 000000000000..2a3892f29181 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Order.java @@ -0,0 +1,114 @@ +package io.swagger.client.model; + +import java.util.Date; + + + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class Order { + + private Long id = null; + private Long petId = null; + private Integer quantity = null; + private Date shipDate = null; + public enum StatusEnum { + placed, approved, delivered, + }; + private StatusEnum status = null; + private Boolean complete = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("petId") + public Long getPetId() { + return petId; + } + public void setPetId(Long petId) { + this.petId = petId; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("quantity") + public Integer getQuantity() { + return quantity; + } + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("shipDate") + public Date getShipDate() { + return shipDate; + } + public void setShipDate(Date shipDate) { + this.shipDate = shipDate; + } + + + /** + * Order Status + **/ + @ApiModelProperty(value = "Order Status") + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("complete") + public Boolean getComplete() { + return complete; + } + public void setComplete(Boolean complete) { + this.complete = complete; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" petId: ").append(petId).append("\n"); + sb.append(" quantity: ").append(quantity).append("\n"); + sb.append(" shipDate: ").append(shipDate).append("\n"); + sb.append(" status: ").append(status).append("\n"); + sb.append(" complete: ").append(complete).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Pet.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Pet.java new file mode 100644 index 000000000000..6cb7df1fde58 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Pet.java @@ -0,0 +1,116 @@ +package io.swagger.client.model; + +import io.swagger.client.model.Category; +import io.swagger.client.model.Tag; +import java.util.*; + + + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class Pet { + + private Long id = null; + private Category category = null; + private String name = null; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); + public enum StatusEnum { + available, pending, sold, + }; + private StatusEnum status = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("category") + public Category getCategory() { + return category; + } + public void setCategory(Category category) { + this.category = category; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty("photoUrls") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("tags") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" category: ").append(category).append("\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append(" photoUrls: ").append(photoUrls).append("\n"); + sb.append(" tags: ").append(tags).append("\n"); + sb.append(" status: ").append(status).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Tag.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Tag.java new file mode 100644 index 000000000000..fe212ea8ab6f --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/Tag.java @@ -0,0 +1,53 @@ +package io.swagger.client.model; + + + + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class Tag { + + private Long id = null; + private String name = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/User.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/User.java new file mode 100644 index 000000000000..5b9230b8e015 --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/client/model/User.java @@ -0,0 +1,138 @@ +package io.swagger.client.model; + + + + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-23T11:08:48.917-07:00") +public class User { + + private Long id = null; + private String username = null; + private String firstName = null; + private String lastName = null; + private String email = null; + private String password = null; + private String phone = null; + private Integer userStatus = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("username") + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("firstName") + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("lastName") + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("email") + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("password") + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("phone") + public String getPhone() { + return phone; + } + public void setPhone(String phone) { + this.phone = phone; + } + + + /** + * User Status + **/ + @ApiModelProperty(value = "User Status") + @JsonProperty("userStatus") + public Integer getUserStatus() { + return userStatus; + } + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" username: ").append(username).append("\n"); + sb.append(" firstName: ").append(firstName).append("\n"); + sb.append(" lastName: ").append(lastName).append("\n"); + sb.append(" email: ").append(email).append("\n"); + sb.append(" password: ").append(password).append("\n"); + sb.append(" phone: ").append(phone).append("\n"); + sb.append(" userStatus: ").append(userStatus).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/server/petstore/jaxrs/src/test/java/io/swagger/test/integration/ResourceListingTestIT.java b/samples/server/petstore/jaxrs/src/test/java/io/swagger/test/integration/ResourceListingTestIT.java new file mode 100644 index 000000000000..f2b6ffffa68e --- /dev/null +++ b/samples/server/petstore/jaxrs/src/test/java/io/swagger/test/integration/ResourceListingTestIT.java @@ -0,0 +1,85 @@ +/* + * Copyright 2015 SmartBear Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.swagger.test.integration; + +import io.swagger.client.ApiClient; +import io.swagger.client.Pair; +import io.swagger.client.TypeRef; +import io.swagger.models.Operation; +import io.swagger.models.Response; +import io.swagger.models.Swagger; +import io.swagger.models.parameters.Parameter; +import io.swagger.models.properties.IntegerProperty; +import io.swagger.models.properties.MapProperty; +import io.swagger.models.properties.Property; +import io.swagger.util.Json; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + +public class ResourceListingTestIT { + ApiClient client = new ApiClient(); + Swagger swagger = null; + + @BeforeClass + public void setup() throws Exception { + TypeRef ref = new TypeRef(){}; + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + Map formParams = new HashMap(); + + String str = client.invokeAPI("/swagger.json", "GET", queryParams, null, headerParams, formParams, "application/json", "", new String[0], ref); + swagger = Json.mapper().readValue(str, Swagger.class); + assertNotNull(swagger); + } + + @Test + public void verifyFileInput() throws Exception { + Operation op = swagger.getPath("/pet/{petId}/uploadImage").getPost(); + List parameters = op.getParameters(); + Parameter petId = parameters.get(0); + assertEquals(petId.getName(), "petId"); + assertEquals(petId.getIn(), "path"); + + Parameter additionalMetadata = parameters.get(1); + assertEquals(additionalMetadata.getName(), "additionalMetadata"); + assertEquals(additionalMetadata.getIn(), "formData"); + + Parameter file = parameters.get(2); + assertEquals(file.getName(), "file"); + assertEquals(file.getIn(), "formData"); + } + + @Test + public void verifyMapResponse() throws Exception { + Operation op = swagger.getPath("/store/inventory").getGet(); + Response response = op.getResponses().get("200"); + + Property property = response.getSchema(); + assertTrue(property instanceof MapProperty); + + MapProperty mp = (MapProperty) property; + assertTrue(mp.getAdditionalProperties() instanceof IntegerProperty); + } +} \ No newline at end of file From a83f01ad601651786488dee8ebf07f2866e6bc73 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 23 Aug 2015 23:33:27 -0700 Subject: [PATCH 055/109] made string safe --- .../java/io/swagger/codegen/languages/JavaClientCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a0e31a19061a..5cd5cc214961 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 @@ -139,7 +139,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } if (additionalProperties.containsKey("serializableModel")) { - this.setSerializableModel(Boolean.valueOf((String)additionalProperties.get("serializableModel"))); + this.setSerializableModel(Boolean.valueOf(additionalProperties.get("serializableModel").toString())); } else { additionalProperties.put("serializableModel", serializableModel); } From 6dcb8da2d8f5a4175b72135d4bed00e0cf221e71 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 23 Aug 2015 23:33:55 -0700 Subject: [PATCH 056/109] altered to return inner type only --- .../codegen/languages/JaxRSServerCodegen.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java index df3207975154..01261799556c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenResponse; import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.CodegenType; import io.swagger.codegen.SupportingFile; @@ -122,27 +123,35 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf if (operations != null) { List ops = (List) operations.get("operation"); for (CodegenOperation operation : ops) { + List responses = operation.responses; + if (responses != null) { + for (CodegenResponse resp : responses) { + if ("0".equals(resp.code)) { + resp.code = "200"; + } + } + } if (operation.returnType == null) { operation.returnType = "Void"; } else if (operation.returnType.startsWith("List")) { String rt = operation.returnType; int end = rt.lastIndexOf(">"); if (end > 0) { - operation.returnType = rt.substring("List<".length(), end); + operation.returnType = rt.substring("List<".length(), end).trim(); operation.returnContainer = "List"; } } else if (operation.returnType.startsWith("Map")) { String rt = operation.returnType; int end = rt.lastIndexOf(">"); if (end > 0) { - operation.returnType = rt.substring("Map<".length(), end); + operation.returnType = rt.substring("Map<".length(), end).split(",")[1].trim(); operation.returnContainer = "Map"; } } else if (operation.returnType.startsWith("Set")) { String rt = operation.returnType; int end = rt.lastIndexOf(">"); if (end > 0) { - operation.returnType = rt.substring("Set<".length(), end); + operation.returnType = rt.substring("Set<".length(), end).trim(); operation.returnContainer = "Set"; } } From 7c2310a13f4e6fd9ca4366884c21b37c7aff1004 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 23 Aug 2015 23:34:35 -0700 Subject: [PATCH 057/109] updated to jersey 1.18.1, fixes for #1115 --- .../JavaJaxRS/ApiOriginFilter.mustache | 9 +--- .../src/main/resources/JavaJaxRS/api.mustache | 2 +- .../resources/JavaJaxRS/formParams.mustache | 4 +- .../src/main/resources/JavaJaxRS/pom.mustache | 41 ++++++++++++++----- .../resources/JavaJaxRS/returnTypes.mustache | 1 + 5 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/JavaJaxRS/returnTypes.mustache diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache index 5db3301b3d93..a1e5a678fe17 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/ApiOriginFilter.mustache @@ -7,7 +7,6 @@ import javax.servlet.http.HttpServletResponse; {{>generatedAnnotation}} public class ApiOriginFilter implements javax.servlet.Filter { - @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse res = (HttpServletResponse) response; @@ -17,11 +16,7 @@ public class ApiOriginFilter implements javax.servlet.Filter { chain.doFilter(request, response); } - @Override - public void destroy() { - } + public void destroy() {} - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } + public void init(FilterConfig filterConfig) throws ServletException {} } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache index 9e1f808806ea..a2213ea60860 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache @@ -39,7 +39,7 @@ public class {{classname}} { {{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} @io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}) @io.swagger.annotations.ApiResponses(value = { {{#responses}} - @io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}"){{#hasMore}}, + @io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}}, {{/hasMore}}{{/responses}} }) public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/formParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/formParams.mustache index ba842165f3d3..1bae4717f4dc 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/formParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/formParams.mustache @@ -1,2 +1,2 @@ -{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") @FormDataParam("file") InputStream inputStream, - @ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}} \ No newline at end of file +{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}} @FormDataParam("file") InputStream inputStream, + @FormDataParam("file") FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache index 708ca6cac4d0..ba58d23ca7f0 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache @@ -119,13 +119,12 @@ jersey-server ${jersey-version} - - org.scalatest - scalatest_2.9.1 - ${scala-test-version} - test + javax.servlet + servlet-api + ${servlet-api-version} + junit junit @@ -133,9 +132,30 @@ test - javax.servlet - servlet-api - ${servlet-api-version} + com.sun.jersey + jersey-client + ${jersey-version} + test + + + org.testng + testng + 6.8.8 + test + + + junit + junit + + + snakeyaml + org.yaml + + + bsh + org.beanshell + +
@@ -148,11 +168,10 @@ - 1.5.0 + 1.5.3 9.2.9.v20150224 - 1.13 + 1.18.1 1.6.3 - 1.6.1 4.8.1 2.5 diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/returnTypes.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/returnTypes.mustache new file mode 100644 index 000000000000..c8f7a56938aa --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/returnTypes.mustache @@ -0,0 +1 @@ +{{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List<{{{returnType}}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file From 87f1ef4dc26f1b3694ae89ba3d31aacc90e5385c Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 23 Aug 2015 23:46:54 -0700 Subject: [PATCH 058/109] re-ordered --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1d79e4936fd8..569799439dac 100644 --- a/pom.xml +++ b/pom.xml @@ -392,10 +392,10 @@ samples/client/petstore/java/default samples/client/petstore/java/jersey2 samples/client/petstore/scala - samples/server/petstore/jaxrs samples/server/petstore/spring-mvc samples/client/petstore/ruby + samples/server/petstore/jaxrs From d8ceb8c64800fac40492ba9b6b795d50494c4e8e Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 23 Aug 2015 23:47:01 -0700 Subject: [PATCH 059/109] enabled samples --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 73c80821ba56..73dc7fdd26df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ sudo: false language: java -script: mvn verify +script: mvn verify -Psamples jdk: - oraclejdk7 From 715c0af41f76da3ee63c4b81e7e0b0a439a40caf Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Mon, 24 Aug 2015 00:03:20 -0700 Subject: [PATCH 060/109] merged & rebuilt --- .../java/io/swagger/codegen/languages/JavaClientCodegen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 8c9d2242539b..379a2db2eb1b 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 @@ -141,9 +141,9 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { if (additionalProperties.containsKey("serializableModel")) { this.setSerializableModel(Boolean.valueOf((String)additionalProperties.get("serializableModel").toString())); } + // need to put back serializableModel (boolean) into additionalProperties as value in additionalProperties is string - additionalProperties.put("serializableModel", serializableModel); - } + additionalProperties.put("serializableModel", serializableModel); this.sanitizeConfig(); From 9cc7615b71f4e2a044d6a0943f2676240f26ca6c Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Mon, 24 Aug 2015 00:32:58 -0700 Subject: [PATCH 061/109] rebuilt, updated versions --- modules/swagger-codegen-cli/pom.xml | 2 +- modules/swagger-codegen-maven-plugin/pom.xml | 2 +- modules/swagger-codegen/pom.xml | 2 +- .../main/resources/JavaInflector/api.mustache | 5 +- .../main/resources/JavaInflector/pom.mustache | 86 +------------------ .../main/resources/akka-scala/pom.mustache | 2 +- .../src/main/resources/scala/pom.mustache | 2 +- modules/swagger-generator/pom.xml | 2 +- pom.xml | 2 +- 9 files changed, 11 insertions(+), 94 deletions(-) diff --git a/modules/swagger-codegen-cli/pom.xml b/modules/swagger-codegen-cli/pom.xml index 6a6d05270df4..3416cab850cd 100644 --- a/modules/swagger-codegen-cli/pom.xml +++ b/modules/swagger-codegen-cli/pom.xml @@ -3,7 +3,7 @@ io.swagger swagger-codegen-project - 2.1.3-SNAPSHOT + 2.1.3 ../.. 4.0.0 diff --git a/modules/swagger-codegen-maven-plugin/pom.xml b/modules/swagger-codegen-maven-plugin/pom.xml index 08c1ffef2ad5..dba8b73c49f7 100644 --- a/modules/swagger-codegen-maven-plugin/pom.xml +++ b/modules/swagger-codegen-maven-plugin/pom.xml @@ -6,7 +6,7 @@ io.swagger swagger-codegen-project - 2.1.3-SNAPSHOT + 2.1.3 ../.. swagger-codegen-maven-plugin diff --git a/modules/swagger-codegen/pom.xml b/modules/swagger-codegen/pom.xml index 762aa3a72f29..29cbf7a6fed6 100644 --- a/modules/swagger-codegen/pom.xml +++ b/modules/swagger-codegen/pom.xml @@ -3,7 +3,7 @@ io.swagger swagger-codegen-project - 2.1.3-SNAPSHOT + 2.1.3 ../.. 4.0.0 diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache index 829a9daeabc4..fb80b011e547 100644 --- a/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache @@ -16,12 +16,11 @@ import {{modelPackage}}.*; {{>generatedAnnotation}} {{#operations}} public class {{classname}} { - {{#operation}} - public ResponseContext {{nickname}}(RequestContext request {{#allParams}},{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{/allParams}}) - { + public ResponseContext {{nickname}}(RequestContext request {{#allParams}}, {{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{/allParams}}) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + {{/operation}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache index 09477f950523..20d5aaf30c64 100644 --- a/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache @@ -74,99 +74,17 @@ - - - com.fasterxml.jackson.core - jackson-core - ${jackson-version} - - - com.fasterxml.jackson.core - jackson-annotations - 2.4.0 - - - com.fasterxml.jackson.core - jackson-databind - ${jackson-version} - - - com.fasterxml.jackson.datatype - jackson-datatype-joda - ${jackson-version} - - - - org.glassfish.jersey.containers - jersey-container-servlet-core - ${jersey2-version} - - - org.glassfish.jersey.media - jersey-media-multipart - ${jersey2-version} - - - org.glassfish.jersey.core - jersey-client - ${jersey2-version} - - - javax.servlet - servlet-api - ${servlet-api-version} - provided - - - - ch.qos.logback - logback-classic - ${logback-version} - - - ch.qos.logback - logback-core - ${logback-version} - - - org.slf4j - slf4j-ext - ${slf4j-version} - - - org.slf4j - slf4j-api - ${slf4j-version} - - - - - commons-lang - commons-lang - ${commons-lang-version} - - - + io.swagger swagger-inflector 1.0.0-SNAPSHOT - 1.0.0 - 1.5.0 - 1.0.8 - 2.4.2 - 2.2 - 1.2 + 1.5.3 9.2.9.v20150224 - 2.6 - 2.5 - 2.4 - 2.4 - 1.1 1.0.1 4.8.2 1.6.3 diff --git a/modules/swagger-codegen/src/main/resources/akka-scala/pom.mustache b/modules/swagger-codegen/src/main/resources/akka-scala/pom.mustache index eb24f77c0720..b9fd8603baaa 100644 --- a/modules/swagger-codegen/src/main/resources/akka-scala/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/akka-scala/pom.mustache @@ -217,7 +217,7 @@ 2.3.9 1.2 2.2 - 1.5.0 + 1.5.3 1.0.0 4.8.1 diff --git a/modules/swagger-codegen/src/main/resources/scala/pom.mustache b/modules/swagger-codegen/src/main/resources/scala/pom.mustache index c6fe4a1f3561..5fc849ea87df 100644 --- a/modules/swagger-codegen/src/main/resources/scala/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/scala/pom.mustache @@ -210,7 +210,7 @@ 1.2 2.2 1.19 - 1.5.0 + 1.5.3 1.0.5 1.0.0 2.4.2 diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml index 69e7802c487f..696bd6c4a8ef 100644 --- a/modules/swagger-generator/pom.xml +++ b/modules/swagger-generator/pom.xml @@ -4,7 +4,7 @@ io.swagger swagger-codegen-project - 2.1.3-SNAPSHOT + 2.1.3 ../.. swagger-generator diff --git a/pom.xml b/pom.xml index e9f0096a7ef0..6fd9bdc2cb26 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ swagger-codegen-project pom swagger-codegen-project - 2.1.3-SNAPSHOT + 2.1.3 https://github.com/swagger-api/swagger-codegen scm:git:git@github.com:swagger-api/swagger-codegen.git From d048a684388015df0c7e66ce3c5ab0b6fa862963 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Mon, 24 Aug 2015 00:33:26 -0700 Subject: [PATCH 062/109] added sample --- .../server/petstore/java-inflector/README.md | 8 + .../petstore/java-inflector/inflector.yaml | 10 + .../server/petstore/java-inflector/pom.xml | 92 +++ .../io/swagger/handler/PetController.java | 51 ++ .../io/swagger/handler/StoreController.java | 35 + .../io/swagger/handler/UserController.java | 51 ++ .../main/java/io/swagger/model/Category.java | 51 ++ .../src/main/java/io/swagger/model/Order.java | 112 +++ .../src/main/java/io/swagger/model/Pet.java | 114 +++ .../src/main/java/io/swagger/model/Tag.java | 51 ++ .../src/main/java/io/swagger/model/User.java | 136 ++++ .../src/main/swagger/swagger.json | 770 ++++++++++++++++++ .../src/main/webapp/WEB-INF/web.xml | 24 + 13 files changed, 1505 insertions(+) create mode 100644 samples/server/petstore/java-inflector/README.md create mode 100644 samples/server/petstore/java-inflector/inflector.yaml create mode 100644 samples/server/petstore/java-inflector/pom.xml create mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java create mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java create mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java create mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java create mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java create mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java create mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java create mode 100644 samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java create mode 100644 samples/server/petstore/java-inflector/src/main/swagger/swagger.json create mode 100644 samples/server/petstore/java-inflector/src/main/webapp/WEB-INF/web.xml diff --git a/samples/server/petstore/java-inflector/README.md b/samples/server/petstore/java-inflector/README.md new file mode 100644 index 000000000000..c1309670c5ad --- /dev/null +++ b/samples/server/petstore/java-inflector/README.md @@ -0,0 +1,8 @@ +# Swagger Inflector + +Run with + +``` +mvn package jetty:run +`` + diff --git a/samples/server/petstore/java-inflector/inflector.yaml b/samples/server/petstore/java-inflector/inflector.yaml new file mode 100644 index 000000000000..25ec6dde3f2e --- /dev/null +++ b/samples/server/petstore/java-inflector/inflector.yaml @@ -0,0 +1,10 @@ +controllerPackage: io.swagger.handler +modelPackage: io.swagger.model +swaggerUrl: ./src/main/swagger/swagger.json +modelMappings: + User : io.swagger.model.User + Category : io.swagger.model.Category + Pet : io.swagger.model.Pet + Tag : io.swagger.model.Tag + Order : io.swagger.model.Order + diff --git a/samples/server/petstore/java-inflector/pom.xml b/samples/server/petstore/java-inflector/pom.xml new file mode 100644 index 000000000000..7b7ec1d8b3d6 --- /dev/null +++ b/samples/server/petstore/java-inflector/pom.xml @@ -0,0 +1,92 @@ + + + org.sonatype.oss + oss-parent + 5 + + 4.0.0 + io.swagger + swagger-inflector-server + jar + swagger-inflector-server + 1.0.0 + + 2.2.0 + + + + install + target + ${project.artifactId}-${project.version} + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + **/logback.xml + + + + development + ${project.url} + ${project.version} + io.swagger + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty-version} + + . + + inflector.yaml + src/main/swagger/swagger.yaml + + 1 + + / + + + 8080 + 60000 + + + + + + + + + io.swagger + swagger-inflector + 1.0.0-SNAPSHOT + + + + 1.0.0 + 1.5.3 + 9.2.9.v20150224 + 1.0.1 + 4.8.2 + 1.6.3 + + \ No newline at end of file diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java new file mode 100644 index 000000000000..5535d2cc8f04 --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java @@ -0,0 +1,51 @@ +package io.swagger.handler; + +import io.swagger.inflector.models.RequestContext; +import io.swagger.inflector.models.ResponseContext; +import javax.ws.rs.core.Response.Status; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import java.io.File; +import java.util.List; + +import io.swagger.model.*; + +import io.swagger.model.Pet; +import java.io.File; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +public class PetController { + public ResponseContext updatePet(RequestContext request , Pet body) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext addPet(RequestContext request , Pet body) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext findPetsByStatus(RequestContext request , List status) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext findPetsByTags(RequestContext request , List tags) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext getPetById(RequestContext request , Long petId) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext updatePetWithForm(RequestContext request , String petId, String name, String status) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext deletePet(RequestContext request , Long petId, String apiKey) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext uploadFile(RequestContext request , Long petId, String additionalMetadata, FormDataContentDisposition fileDetail) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + +} + diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java new file mode 100644 index 000000000000..140864aa9270 --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java @@ -0,0 +1,35 @@ +package io.swagger.handler; + +import io.swagger.inflector.models.RequestContext; +import io.swagger.inflector.models.ResponseContext; +import javax.ws.rs.core.Response.Status; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import java.io.File; +import java.util.List; + +import io.swagger.model.*; + +import java.util.Map; +import io.swagger.model.Order; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +public class StoreController { + public ResponseContext getInventory(RequestContext request ) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext placeOrder(RequestContext request , Order body) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext getOrderById(RequestContext request , String orderId) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext deleteOrder(RequestContext request , String orderId) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + +} + diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java new file mode 100644 index 000000000000..9cb041fcaa8c --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java @@ -0,0 +1,51 @@ +package io.swagger.handler; + +import io.swagger.inflector.models.RequestContext; +import io.swagger.inflector.models.ResponseContext; +import javax.ws.rs.core.Response.Status; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import java.io.File; +import java.util.List; + +import io.swagger.model.*; + +import io.swagger.model.User; +import java.util.*; + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +public class UserController { + public ResponseContext createUser(RequestContext request , User body) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext createUsersWithArrayInput(RequestContext request , List body) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext createUsersWithListInput(RequestContext request , List body) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext loginUser(RequestContext request , String username, String password) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext logoutUser(RequestContext request ) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext getUserByName(RequestContext request , String username) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext updateUser(RequestContext request , String username, User body) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + + public ResponseContext deleteUser(RequestContext request , String username) { + return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); + } + +} + diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java new file mode 100644 index 000000000000..1ae10af53312 --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java @@ -0,0 +1,51 @@ +package io.swagger.model; + + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +public class Category { + + private Long id = null; + private String name = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java new file mode 100644 index 000000000000..d063c3117925 --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java @@ -0,0 +1,112 @@ +package io.swagger.model; + +import java.util.Date; + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +public class Order { + + private Long id = null; + private Long petId = null; + private Integer quantity = null; + private Date shipDate = null; + public enum StatusEnum { + placed, approved, delivered, + }; + private StatusEnum status = null; + private Boolean complete = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("petId") + public Long getPetId() { + return petId; + } + public void setPetId(Long petId) { + this.petId = petId; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("quantity") + public Integer getQuantity() { + return quantity; + } + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("shipDate") + public Date getShipDate() { + return shipDate; + } + public void setShipDate(Date shipDate) { + this.shipDate = shipDate; + } + + + /** + * Order Status + **/ + @ApiModelProperty(value = "Order Status") + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("complete") + public Boolean getComplete() { + return complete; + } + public void setComplete(Boolean complete) { + this.complete = complete; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" petId: ").append(petId).append("\n"); + sb.append(" quantity: ").append(quantity).append("\n"); + sb.append(" shipDate: ").append(shipDate).append("\n"); + sb.append(" status: ").append(status).append("\n"); + sb.append(" complete: ").append(complete).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java new file mode 100644 index 000000000000..669f258f1c7b --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java @@ -0,0 +1,114 @@ +package io.swagger.model; + +import io.swagger.model.Category; +import io.swagger.model.Tag; +import java.util.*; + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +public class Pet { + + private Long id = null; + private Category category = null; + private String name = null; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); + public enum StatusEnum { + available, pending, sold, + }; + private StatusEnum status = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("category") + public Category getCategory() { + return category; + } + public void setCategory(Category category) { + this.category = category; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + @JsonProperty("photoUrls") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("tags") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" category: ").append(category).append("\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append(" photoUrls: ").append(photoUrls).append("\n"); + sb.append(" tags: ").append(tags).append("\n"); + sb.append(" status: ").append(status).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java new file mode 100644 index 000000000000..8d56f9938ae4 --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java @@ -0,0 +1,51 @@ +package io.swagger.model; + + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +public class Tag { + + private Long id = null; + private String name = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java new file mode 100644 index 000000000000..ec9a66770306 --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java @@ -0,0 +1,136 @@ +package io.swagger.model; + + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +public class User { + + private Long id = null; + private String username = null; + private String firstName = null; + private String lastName = null; + private String email = null; + private String password = null; + private String phone = null; + private Integer userStatus = null; + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("username") + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("firstName") + public String getFirstName() { + return firstName; + } + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("lastName") + public String getLastName() { + return lastName; + } + public void setLastName(String lastName) { + this.lastName = lastName; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("email") + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("password") + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("phone") + public String getPhone() { + return phone; + } + public void setPhone(String phone) { + this.phone = phone; + } + + + /** + * User Status + **/ + @ApiModelProperty(value = "User Status") + @JsonProperty("userStatus") + public Integer getUserStatus() { + return userStatus; + } + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(id).append("\n"); + sb.append(" username: ").append(username).append("\n"); + sb.append(" firstName: ").append(firstName).append("\n"); + sb.append(" lastName: ").append(lastName).append("\n"); + sb.append(" email: ").append(email).append("\n"); + sb.append(" password: ").append(password).append("\n"); + sb.append(" phone: ").append(phone).append("\n"); + sb.append(" userStatus: ").append(userStatus).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/samples/server/petstore/java-inflector/src/main/swagger/swagger.json b/samples/server/petstore/java-inflector/src/main/swagger/swagger.json new file mode 100644 index 000000000000..36ecd60503e0 --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/swagger/swagger.json @@ -0,0 +1,770 @@ +{ + "swagger" : "2.0", + "info" : { + "description" : "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", + "version" : "1.0.0", + "title" : "Swagger Petstore", + "termsOfService" : "http://swagger.io/terms/", + "contact" : { + "email" : "apiteam@swagger.io" + }, + "license" : { + "name" : "Apache 2.0", + "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "host" : "petstore.swagger.io", + "basePath" : "/v2", + "schemes" : [ "http" ], + "paths" : { + "/pet" : { + "post" : { + "tags" : [ "pet" ], + "summary" : "Add a new pet to the store", + "description" : "", + "operationId" : "addPet", + "consumes" : [ "application/json", "application/xml" ], + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "Pet object that needs to be added to the store", + "required" : false, + "schema" : { + "$ref" : "#/definitions/Pet" + } + } ], + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + }, + "put" : { + "tags" : [ "pet" ], + "summary" : "Update an existing pet", + "description" : "", + "operationId" : "updatePet", + "consumes" : [ "application/json", "application/xml" ], + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "Pet object that needs to be added to the store", + "required" : false, + "schema" : { + "$ref" : "#/definitions/Pet" + } + } ], + "responses" : { + "405" : { + "description" : "Validation exception" + }, + "404" : { + "description" : "Pet not found" + }, + "400" : { + "description" : "Invalid ID supplied" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/pet/findByStatus" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by status", + "description" : "Multiple status values can be provided with comma seperated strings", + "operationId" : "findPetsByStatus", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "status", + "in" : "query", + "description" : "Status values that need to be considered for filter", + "required" : false, + "type" : "array", + "items" : { + "type" : "string" + }, + "collectionFormat" : "multi", + "default" : "available" + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/Pet" + } + } + }, + "400" : { + "description" : "Invalid status value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/pet/findByTags" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Finds Pets by tags", + "description" : "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "tags", + "in" : "query", + "description" : "Tags to filter by", + "required" : false, + "type" : "array", + "items" : { + "type" : "string" + }, + "collectionFormat" : "multi" + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/Pet" + } + } + }, + "400" : { + "description" : "Invalid tag value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/pet/{petId}" : { + "get" : { + "tags" : [ "pet" ], + "summary" : "Find pet by ID", + "description" : "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", + "operationId" : "getPetById", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet that needs to be fetched", + "required" : true, + "type" : "integer", + "format" : "int64" + } ], + "responses" : { + "404" : { + "description" : "Pet not found" + }, + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/Pet" + } + }, + "400" : { + "description" : "Invalid ID supplied" + } + }, + "security" : [ { + "api_key" : [ ] + }, { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + }, + "post" : { + "tags" : [ "pet" ], + "summary" : "Updates a pet in the store with form data", + "description" : "", + "operationId" : "updatePetWithForm", + "consumes" : [ "application/x-www-form-urlencoded" ], + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet that needs to be updated", + "required" : true, + "type" : "string" + }, { + "name" : "name", + "in" : "formData", + "description" : "Updated name of the pet", + "required" : false, + "type" : "string" + }, { + "name" : "status", + "in" : "formData", + "description" : "Updated status of the pet", + "required" : false, + "type" : "string" + } ], + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + }, + "delete" : { + "tags" : [ "pet" ], + "summary" : "Deletes a pet", + "description" : "", + "operationId" : "deletePet", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "api_key", + "in" : "header", + "description" : "", + "required" : false, + "type" : "string" + }, { + "name" : "petId", + "in" : "path", + "description" : "Pet id to delete", + "required" : true, + "type" : "integer", + "format" : "int64" + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "tags" : [ "pet" ], + "summary" : "uploads an image", + "description" : "", + "operationId" : "uploadFile", + "consumes" : [ "multipart/form-data" ], + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "petId", + "in" : "path", + "description" : "ID of pet to update", + "required" : true, + "type" : "integer", + "format" : "int64" + }, { + "name" : "additionalMetadata", + "in" : "formData", + "description" : "Additional data to pass to server", + "required" : false, + "type" : "string" + }, { + "name" : "file", + "in" : "formData", + "description" : "file to upload", + "required" : false, + "type" : "file" + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ] + } + }, + "/store/inventory" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Returns pet inventories by status", + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "type" : "object", + "additionalProperties" : { + "type" : "integer", + "format" : "int32" + } + } + } + }, + "security" : [ { + "api_key" : [ ] + } ] + } + }, + "/store/order" : { + "post" : { + "tags" : [ "store" ], + "summary" : "Place an order for a pet", + "description" : "", + "operationId" : "placeOrder", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "order placed for purchasing the pet", + "required" : false, + "schema" : { + "$ref" : "#/definitions/Order" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/Order" + } + }, + "400" : { + "description" : "Invalid Order" + } + } + } + }, + "/store/order/{orderId}" : { + "get" : { + "tags" : [ "store" ], + "summary" : "Find purchase order by ID", + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", + "operationId" : "getOrderById", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of pet that needs to be fetched", + "required" : true, + "type" : "string" + } ], + "responses" : { + "404" : { + "description" : "Order not found" + }, + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/Order" + } + }, + "400" : { + "description" : "Invalid ID supplied" + } + } + }, + "delete" : { + "tags" : [ "store" ], + "summary" : "Delete purchase order by ID", + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "orderId", + "in" : "path", + "description" : "ID of the order that needs to be deleted", + "required" : true, + "type" : "string" + } ], + "responses" : { + "404" : { + "description" : "Order not found" + }, + "400" : { + "description" : "Invalid ID supplied" + } + } + } + }, + "/user" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Create user", + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "Created user object", + "required" : false, + "schema" : { + "$ref" : "#/definitions/User" + } + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + } + } + }, + "/user/createWithArray" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "description" : "", + "operationId" : "createUsersWithArrayInput", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "List of user object", + "required" : false, + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/User" + } + } + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + } + } + }, + "/user/createWithList" : { + "post" : { + "tags" : [ "user" ], + "summary" : "Creates list of users with given input array", + "description" : "", + "operationId" : "createUsersWithListInput", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "List of user object", + "required" : false, + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/User" + } + } + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + } + } + }, + "/user/login" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs user into the system", + "description" : "", + "operationId" : "loginUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "username", + "in" : "query", + "description" : "The user name for login", + "required" : false, + "type" : "string" + }, { + "name" : "password", + "in" : "query", + "description" : "The password for login in clear text", + "required" : false, + "type" : "string" + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "type" : "string" + } + }, + "400" : { + "description" : "Invalid username/password supplied" + } + } + } + }, + "/user/logout" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Logs out current logged in user session", + "description" : "", + "operationId" : "logoutUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ ], + "responses" : { + "default" : { + "description" : "successful operation" + } + } + } + }, + "/user/{username}" : { + "get" : { + "tags" : [ "user" ], + "summary" : "Get user by user name", + "description" : "", + "operationId" : "getUserByName", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be fetched. Use user1 for testing. ", + "required" : true, + "type" : "string" + } ], + "responses" : { + "404" : { + "description" : "User not found" + }, + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/User" + }, + "examples" : { + "application/json" : { + "id" : 1, + "username" : "johnp", + "firstName" : "John", + "lastName" : "Public", + "email" : "johnp@swagger.io", + "password" : "-secret-", + "phone" : "0123456789", + "userStatus" : 0 + } + } + }, + "400" : { + "description" : "Invalid username supplied" + } + } + }, + "put" : { + "tags" : [ "user" ], + "summary" : "Updated user", + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "name that need to be deleted", + "required" : true, + "type" : "string" + }, { + "in" : "body", + "name" : "body", + "description" : "Updated user object", + "required" : false, + "schema" : { + "$ref" : "#/definitions/User" + } + } ], + "responses" : { + "404" : { + "description" : "User not found" + }, + "400" : { + "description" : "Invalid user supplied" + } + } + }, + "delete" : { + "tags" : [ "user" ], + "summary" : "Delete user", + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "produces" : [ "application/json", "application/xml" ], + "parameters" : [ { + "name" : "username", + "in" : "path", + "description" : "The name that needs to be deleted", + "required" : true, + "type" : "string" + } ], + "responses" : { + "404" : { + "description" : "User not found" + }, + "400" : { + "description" : "Invalid username supplied" + } + } + } + } + }, + "securityDefinitions" : { + "api_key" : { + "type" : "apiKey", + "name" : "api_key", + "in" : "header" + }, + "petstore_auth" : { + "type" : "oauth2", + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "flow" : "implicit", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, + "definitions" : { + "User" : { + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "type" : "integer", + "format" : "int32", + "description" : "User Status" + } + }, + "xml" : { + "name" : "User" + } + }, + "Category" : { + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "xml" : { + "name" : "Category" + } + }, + "Pet" : { + "required" : [ "name", "photoUrls" ], + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "category" : { + "$ref" : "#/definitions/Category" + }, + "name" : { + "type" : "string", + "example" : "doggie" + }, + "photoUrls" : { + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + }, + "items" : { + "type" : "string" + } + }, + "tags" : { + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + }, + "items" : { + "$ref" : "#/definitions/Tag" + } + }, + "status" : { + "type" : "string", + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ] + } + }, + "xml" : { + "name" : "Pet" + } + }, + "Tag" : { + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "xml" : { + "name" : "Tag" + } + }, + "Order" : { + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "petId" : { + "type" : "integer", + "format" : "int64" + }, + "quantity" : { + "type" : "integer", + "format" : "int32" + }, + "shipDate" : { + "type" : "string", + "format" : "date-time" + }, + "status" : { + "type" : "string", + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ] + }, + "complete" : { + "type" : "boolean" + } + }, + "xml" : { + "name" : "Order" + } + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-inflector/src/main/webapp/WEB-INF/web.xml b/samples/server/petstore/java-inflector/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..34a2eea6bcfa --- /dev/null +++ b/samples/server/petstore/java-inflector/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + swagger-inflector + org.glassfish.jersey.servlet.ServletContainer + + javax.ws.rs.Application + io.swagger.inflector.SwaggerInflector + + 1 + + + swagger-inflector + /* + + + CORSFilter + io.swagger.inflector.utils.CORSFilter + + + CORSFilter + /* + + \ No newline at end of file From ee05366d0bdff06b75a5cca3ea22d15e1e2e8d3e Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Mon, 24 Aug 2015 00:37:23 -0700 Subject: [PATCH 063/109] updated README for release --- README.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b8fd40914b0f..c63d39047987 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,12 @@ Build a nodejs server stub: ## Compatibility The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-codegen project has the following compatibilies with the swagger specification: -Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes ------------------------ | ------------ | -------------------------- | ----- -2.1.0 | 2015-06-09 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen) -2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17) -1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1) +Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes +-------------------------- | ------------ | -------------------------- | ----- +2.1.3 | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen) +2.1.3 (**current stable**) | 2015-08-24 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen/tree/v2.1.3) +2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17) +1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1) ### Prerequisites @@ -184,12 +185,16 @@ There are different aspects of customizing the code generator beyond just creati ``` $ ls -1 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ +AbstractTypeScriptClientCodegen.java AkkaScalaClientCodegen.java AndroidClientCodegen.java AsyncScalaClientCodegen.java CSharpClientCodegen.java +CodeGenStatus.java +CsharpDotNet2ClientCodegen.java FlashClientCodegen.java JavaClientCodegen.java +JavaInflectorServerCodegen.java JaxRSServerCodegen.java NodeJSServerCodegen.java ObjcClientCodegen.java @@ -202,6 +207,8 @@ RetrofitClientCodegen.java RubyClientCodegen.java ScalaClientCodegen.java ScalatraServerCodegen.java +SilexServerCodegen.java +SinatraServerCodegen.java SpringMVCServerCodegen.java StaticDocCodegen.java StaticHtmlGenerator.java @@ -209,6 +216,8 @@ SwaggerGenerator.java SwaggerYamlGenerator.java SwiftCodegen.java TizenClientCodegen.java +TypeScriptAngularClientCodegen.java +TypeScriptNodeClientCodegen.java ``` Each of these files creates reasonable defaults so you can get running quickly. But if you want to configure package names, prefixes, model folders, etc. you can use a json config file to pass the values. From dd67287d6384fc77b8e63c9616e20a7eae120717 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Mon, 24 Aug 2015 00:51:18 -0700 Subject: [PATCH 064/109] updated development version --- modules/swagger-codegen-cli/pom.xml | 2 +- modules/swagger-codegen-maven-plugin/pom.xml | 2 +- modules/swagger-codegen/pom.xml | 2 +- modules/swagger-generator/pom.xml | 2 +- pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen-cli/pom.xml b/modules/swagger-codegen-cli/pom.xml index 3416cab850cd..8c86a4700293 100644 --- a/modules/swagger-codegen-cli/pom.xml +++ b/modules/swagger-codegen-cli/pom.xml @@ -3,7 +3,7 @@ io.swagger swagger-codegen-project - 2.1.3 + 2.1.4 ../.. 4.0.0 diff --git a/modules/swagger-codegen-maven-plugin/pom.xml b/modules/swagger-codegen-maven-plugin/pom.xml index dba8b73c49f7..ca386fba4db8 100644 --- a/modules/swagger-codegen-maven-plugin/pom.xml +++ b/modules/swagger-codegen-maven-plugin/pom.xml @@ -6,7 +6,7 @@ io.swagger swagger-codegen-project - 2.1.3 + 2.1.4 ../.. swagger-codegen-maven-plugin diff --git a/modules/swagger-codegen/pom.xml b/modules/swagger-codegen/pom.xml index 29cbf7a6fed6..51d491e1287a 100644 --- a/modules/swagger-codegen/pom.xml +++ b/modules/swagger-codegen/pom.xml @@ -3,7 +3,7 @@ io.swagger swagger-codegen-project - 2.1.3 + 2.1.4 ../.. 4.0.0 diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml index 696bd6c4a8ef..11f159bab46e 100644 --- a/modules/swagger-generator/pom.xml +++ b/modules/swagger-generator/pom.xml @@ -4,7 +4,7 @@ io.swagger swagger-codegen-project - 2.1.3 + 2.1.4 ../.. swagger-generator diff --git a/pom.xml b/pom.xml index 6fd9bdc2cb26..cd8e088946ff 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ swagger-codegen-project pom swagger-codegen-project - 2.1.3 + 2.1.4 https://github.com/swagger-api/swagger-codegen scm:git:git@github.com:swagger-api/swagger-codegen.git From 617fa43a8933b293695dc174ab5d917fc76dd645 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Mon, 24 Aug 2015 00:52:35 -0700 Subject: [PATCH 065/109] updated development version --- modules/swagger-codegen-cli/pom.xml | 2 +- modules/swagger-codegen-maven-plugin/pom.xml | 2 +- modules/swagger-codegen/pom.xml | 2 +- modules/swagger-generator/pom.xml | 2 +- pom.xml | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/swagger-codegen-cli/pom.xml b/modules/swagger-codegen-cli/pom.xml index 8c86a4700293..13f7f5c01525 100644 --- a/modules/swagger-codegen-cli/pom.xml +++ b/modules/swagger-codegen-cli/pom.xml @@ -3,7 +3,7 @@ io.swagger swagger-codegen-project - 2.1.4 + 2.1.4-SNAPSHOT ../.. 4.0.0 diff --git a/modules/swagger-codegen-maven-plugin/pom.xml b/modules/swagger-codegen-maven-plugin/pom.xml index ca386fba4db8..4d7107dba7e1 100644 --- a/modules/swagger-codegen-maven-plugin/pom.xml +++ b/modules/swagger-codegen-maven-plugin/pom.xml @@ -6,7 +6,7 @@ io.swagger swagger-codegen-project - 2.1.4 + 2.1.4-SNAPSHOT ../.. swagger-codegen-maven-plugin diff --git a/modules/swagger-codegen/pom.xml b/modules/swagger-codegen/pom.xml index 51d491e1287a..a392e98bda43 100644 --- a/modules/swagger-codegen/pom.xml +++ b/modules/swagger-codegen/pom.xml @@ -3,7 +3,7 @@ io.swagger swagger-codegen-project - 2.1.4 + 2.1.4-SNAPSHOT ../.. 4.0.0 diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml index 11f159bab46e..dbb092e98163 100644 --- a/modules/swagger-generator/pom.xml +++ b/modules/swagger-generator/pom.xml @@ -4,7 +4,7 @@ io.swagger swagger-codegen-project - 2.1.4 + 2.1.4-SNAPSHOT ../.. swagger-generator diff --git a/pom.xml b/pom.xml index cd8e088946ff..f2bcf50cd6e5 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ swagger-codegen-project pom swagger-codegen-project - 2.1.4 + 2.1.4-SNAPSHOT https://github.com/swagger-api/swagger-codegen scm:git:git@github.com:swagger-api/swagger-codegen.git @@ -473,7 +473,7 @@ 2.11.1 2.3.4 1.5.3 - 2.1.4 + 2.1.4-SNAPSHOT 2.3 1.2 4.8.1 From 6820179903fa69b484fe46a354f08f0b8fef65c6 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Mon, 24 Aug 2015 01:04:24 -0700 Subject: [PATCH 066/109] fixed scalatest version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f2bcf50cd6e5..4baa768bd763 100644 --- a/pom.xml +++ b/pom.xml @@ -473,7 +473,7 @@ 2.11.1 2.3.4 1.5.3 - 2.1.4-SNAPSHOT + 2.1.4 2.3 1.2 4.8.1 From 0d5c06660526a595264b33afef077d3cd1e2dbe2 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Mon, 24 Aug 2015 01:04:28 -0700 Subject: [PATCH 067/109] fixed scalatest version --- samples/client/wordnik/android-java/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/client/wordnik/android-java/pom.xml b/samples/client/wordnik/android-java/pom.xml index 0be5e486152a..f2a84451d837 100644 --- a/samples/client/wordnik/android-java/pom.xml +++ b/samples/client/wordnik/android-java/pom.xml @@ -152,7 +152,7 @@ - 1.5.1-M1 + 1.5.3 2.1.4 4.8.1 1.0.0 From 29a2eedc1e87b951ca28b5943e260f9815e9785f Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Mon, 24 Aug 2015 01:04:33 -0700 Subject: [PATCH 068/109] java8 tag fixes --- .../src/main/java/io/swagger/generator/Bootstrap.java | 6 +++--- .../java/io/swagger/generator/exception/ApiException.java | 6 +++--- .../io/swagger/generator/exception/BadRequestException.java | 6 +++--- .../io/swagger/generator/exception/NotFoundException.java | 6 +++--- .../main/java/io/swagger/generator/model/ApiResponse.java | 6 +++--- .../src/main/java/io/swagger/generator/model/Generated.java | 6 +++--- .../main/java/io/swagger/generator/model/InputOption.java | 6 +++--- .../java/io/swagger/generator/util/ApiOriginFilter.java | 6 +++--- .../src/main/java/io/swagger/generator/util/ZipUtil.java | 6 +++--- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java b/modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java index f6d924c00ad5..0e71119e67a1 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/Bootstrap.java @@ -1,12 +1,12 @@ /** * Copyright 2015 SmartBear Software - *

+ *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

+ *

* http://www.apache.org/licenses/LICENSE-2.0 - *

+ *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/exception/ApiException.java b/modules/swagger-generator/src/main/java/io/swagger/generator/exception/ApiException.java index ac28d1cc5f43..50019486ec38 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/exception/ApiException.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/exception/ApiException.java @@ -1,12 +1,12 @@ /** * Copyright 2015 SmartBear Software - *

+ *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

+ *

* http://www.apache.org/licenses/LICENSE-2.0 - *

+ *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/exception/BadRequestException.java b/modules/swagger-generator/src/main/java/io/swagger/generator/exception/BadRequestException.java index 7a15e82073a7..b90c6ee319d6 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/exception/BadRequestException.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/exception/BadRequestException.java @@ -1,12 +1,12 @@ /** * Copyright 2015 SmartBear Software - *

+ *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

+ *

* http://www.apache.org/licenses/LICENSE-2.0 - *

+ *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/exception/NotFoundException.java b/modules/swagger-generator/src/main/java/io/swagger/generator/exception/NotFoundException.java index dbd6a1463ee6..339cac259c1f 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/exception/NotFoundException.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/exception/NotFoundException.java @@ -1,12 +1,12 @@ /** * Copyright 2015 SmartBear Software - *

+ *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

+ *

* http://www.apache.org/licenses/LICENSE-2.0 - *

+ *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/model/ApiResponse.java b/modules/swagger-generator/src/main/java/io/swagger/generator/model/ApiResponse.java index 0f3ce2e8cc99..8fe9d41fb7ec 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/model/ApiResponse.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/model/ApiResponse.java @@ -1,12 +1,12 @@ /** * Copyright 2015 SmartBear Software - *

+ *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

+ *

* http://www.apache.org/licenses/LICENSE-2.0 - *

+ *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/model/Generated.java b/modules/swagger-generator/src/main/java/io/swagger/generator/model/Generated.java index 501cd2ddd826..614adcc61bc7 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/model/Generated.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/model/Generated.java @@ -1,12 +1,12 @@ /** * Copyright 2015 SmartBear Software - *

+ *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

+ *

* http://www.apache.org/licenses/LICENSE-2.0 - *

+ *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/model/InputOption.java b/modules/swagger-generator/src/main/java/io/swagger/generator/model/InputOption.java index dc55ad00582d..45b3b7b7bbff 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/model/InputOption.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/model/InputOption.java @@ -1,12 +1,12 @@ /** * Copyright 2015 SmartBear Software - *

+ *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

+ *

* http://www.apache.org/licenses/LICENSE-2.0 - *

+ *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/util/ApiOriginFilter.java b/modules/swagger-generator/src/main/java/io/swagger/generator/util/ApiOriginFilter.java index 6daf764a45db..07ee795f5884 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/util/ApiOriginFilter.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/util/ApiOriginFilter.java @@ -1,12 +1,12 @@ /** * Copyright 2015 SmartBear Software - *

+ *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

+ *

* http://www.apache.org/licenses/LICENSE-2.0 - *

+ *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/util/ZipUtil.java b/modules/swagger-generator/src/main/java/io/swagger/generator/util/ZipUtil.java index 11e63d5cbcb5..ca0a0e620182 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/util/ZipUtil.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/util/ZipUtil.java @@ -1,12 +1,12 @@ /** * Copyright 2015 SmartBear Software - *

+ *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

+ *

* http://www.apache.org/licenses/LICENSE-2.0 - *

+ *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. From 0e0bfde3a8684e75f2dcc3d0c9e015b6e4c5e973 Mon Sep 17 00:00:00 2001 From: Ron Date: Mon, 24 Aug 2015 11:20:30 +0300 Subject: [PATCH 069/109] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c63d39047987..5fbd2a852245 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ The Swagger Specification has undergone 3 revisions since initial creation in 20 Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes -------------------------- | ------------ | -------------------------- | ----- -2.1.3 | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen) -2.1.3 (**current stable**) | 2015-08-24 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen/tree/v2.1.3) +2.1.4-SNAPSHOT | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen) +2.1.3 (**current stable**) | 2015-08-24 | 1.0, 1.1, 1.2, 2.0 | [v2.1.3](https://github.com/swagger-api/swagger-codegen/tree/v2.1.3) 2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17) 1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1) From 3f8dbf416d091b45eb088b620512e62c1d76e9df Mon Sep 17 00:00:00 2001 From: Ron Date: Mon, 24 Aug 2015 11:20:51 +0300 Subject: [PATCH 070/109] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5fbd2a852245..b43351aa6197 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ The Swagger Specification has undergone 3 revisions since initial creation in 20 Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes -------------------------- | ------------ | -------------------------- | ----- 2.1.4-SNAPSHOT | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen) -2.1.3 (**current stable**) | 2015-08-24 | 1.0, 1.1, 1.2, 2.0 | [v2.1.3](https://github.com/swagger-api/swagger-codegen/tree/v2.1.3) +2.1.3 (**current stable**) | 2015-08-24 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.3](https://github.com/swagger-api/swagger-codegen/tree/v2.1.3) 2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17) 1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1) From 85aabbe8102847939948c995318eae4a7301f01b Mon Sep 17 00:00:00 2001 From: Robin Eggenkamp Date: Fri, 21 Aug 2015 12:24:37 +0200 Subject: [PATCH 071/109] Fix possible NullPointerException getWrapped() returns a Boolean which can be null --- .../java/io/swagger/codegen/examples/XmlExampleGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/examples/XmlExampleGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/examples/XmlExampleGenerator.java index 73294268f39d..a6bfc7d5ddd6 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/examples/XmlExampleGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/examples/XmlExampleGenerator.java @@ -128,7 +128,7 @@ public class XmlExampleGenerator { ArrayProperty p = (ArrayProperty) property; Property inner = p.getItems(); boolean wrapped = false; - if (property.getXml() != null && property.getXml().getWrapped()) { + if (property.getXml() != null && property.getXml().getWrapped() != null && property.getXml().getWrapped()) { wrapped = true; } if (wrapped) { From 8408a97aef841228bb4e8211653b4b2cec5c9c92 Mon Sep 17 00:00:00 2001 From: xhh Date: Mon, 24 Aug 2015 16:50:57 +0800 Subject: [PATCH 072/109] Java: Support special characters in enum values and use upper case for enum names Conflicts: samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java --- .../codegen/languages/JavaClientCodegen.java | 25 +++++++++++++++++++ .../src/main/resources/Java/JSON.mustache | 2 ++ .../main/resources/Java/enumClass.mustache | 14 +++++++++++ .../src/main/resources/Java/model.mustache | 11 +++----- .../src/main/java/io/swagger/client/JSON.java | 4 ++- .../java/io/swagger/client/model/Order.java | 21 +++++++++++++--- .../java/io/swagger/client/model/Pet.java | 23 +++++++++++++---- .../io/swagger/petstore/test/PetApiTest.java | 6 ++--- .../swagger/petstore/test/StoreApiTest.java | 2 +- .../client/petstore/java/jersey2/hello.txt | 1 - .../src/main/java/io/swagger/client/JSON.java | 4 ++- .../java/io/swagger/client/model/Order.java | 25 +++++++++++++++---- .../java/io/swagger/client/model/Pet.java | 25 +++++++++++++++---- .../io/swagger/petstore/test/PetApiTest.java | 6 ++--- .../swagger/petstore/test/StoreApiTest.java | 2 +- 15 files changed, 134 insertions(+), 37 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/Java/enumClass.mustache delete mode 100644 samples/client/petstore/java/jersey2/hello.txt 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 379a2db2eb1b..3b35e85d954d 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 @@ -318,6 +318,31 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { return codegenModel; } + @Override + public Map postProcessModels(Map objs) { + List models = (List) objs.get("models"); + for (Object _mo : models) { + Map mo = (Map) _mo; + CodegenModel cm = (CodegenModel) mo.get("model"); + for (CodegenProperty var : cm.vars) { + Map allowableValues = var.allowableValues; + if (allowableValues == null) + continue; + List values = (List) allowableValues.get("values"); + // put "enumVars" map into `allowableValues", including `name` and `value` + List> enumVars = new ArrayList>(); + for (String value : values) { + Map enumVar = new HashMap(); + enumVar.put("name", toVarName(value.toUpperCase())); + enumVar.put("value", value); + enumVars.add(enumVar); + } + allowableValues.put("enumVars", enumVars); + } + } + return objs; + } + private CodegenModel reconcileInlineEnums(CodegenModel codegenModel, CodegenModel parentCodegenModel) { // This generator uses inline classes to define enums, which breaks when // dealing with models that have subTypes. To clean this up, we will analyze diff --git a/modules/swagger-codegen/src/main/resources/Java/JSON.mustache b/modules/swagger-codegen/src/main/resources/Java/JSON.mustache index 4f90c6190b2f..7689856f5de5 100644 --- a/modules/swagger-codegen/src/main/resources/Java/JSON.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/JSON.mustache @@ -14,6 +14,8 @@ public class JSON { mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); mapper.registerModule(new JodaModule()); } diff --git a/modules/swagger-codegen/src/main/resources/Java/enumClass.mustache b/modules/swagger-codegen/src/main/resources/Java/enumClass.mustache new file mode 100644 index 000000000000..1cef90b75a4a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/enumClass.mustache @@ -0,0 +1,14 @@ +public enum {{datatypeWithEnum}} { + {{#allowableValues}}{{#enumVars}}{{name}}("{{value}}"){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} diff --git a/modules/swagger-codegen/src/main/resources/Java/model.mustache b/modules/swagger-codegen/src/main/resources/Java/model.mustache index 13c0c15c9a5a..bfb65a3d4195 100644 --- a/modules/swagger-codegen/src/main/resources/Java/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/model.mustache @@ -18,13 +18,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; {{>generatedAnnotation}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { {{#vars}}{{#isEnum}} - public enum {{datatypeWithEnum}} { - {{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}} - };{{/isEnum}}{{#items.isEnum}}{{#items}} - public enum {{datatypeWithEnum}} { - {{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}} - }; -{{/items}}{{/items.isEnum}} + +{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}} + +{{>enumClass}}{{/items}}{{/items.isEnum}} private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}} {{#vars}} diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java index 030152a99742..5523b921e45c 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*; import java.io.IOException; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T18:19:30.060+08:00") public class JSON { private ObjectMapper mapper; @@ -14,6 +14,8 @@ public class JSON { mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); mapper.registerModule(new JodaModule()); } diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java index df7ad48b6e11..e89c1f3fb408 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java @@ -9,16 +9,29 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T18:19:30.060+08:00") public class Order { private Long id = null; private Long petId = null; private Integer quantity = null; private Date shipDate = null; - public enum StatusEnum { - placed, approved, delivered, - }; + +public enum StatusEnum { + PLACED("placed"), APPROVED("approved"), DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} + private StatusEnum status = null; private Boolean complete = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java index 68799092a32e..b3b0e1b5347f 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java @@ -1,8 +1,8 @@ package io.swagger.client.model; import io.swagger.client.model.Category; -import io.swagger.client.model.Tag; import java.util.*; +import io.swagger.client.model.Tag; @@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T11:46:58.447+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T18:19:30.060+08:00") public class Pet { private Long id = null; @@ -19,9 +19,22 @@ public class Pet { private String name = null; private List photoUrls = new ArrayList(); private List tags = new ArrayList(); - public enum StatusEnum { - available, pending, sold, - }; + +public enum StatusEnum { + AVAILABLE("available"), PENDING("pending"), SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} + private StatusEnum status = null; diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java index b6ad5fb05275..0a8f8a1665d2 100644 --- a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -86,7 +86,7 @@ public class PetApiTest { public void testFindPetsByStatus() throws Exception { Pet pet = createRandomPet(); pet.setName("programmer"); - pet.setStatus(Pet.StatusEnum.available); + pet.setStatus(Pet.StatusEnum.AVAILABLE); api.updatePet(pet); @@ -108,7 +108,7 @@ public class PetApiTest { public void testFindPetsByTags() throws Exception { Pet pet = createRandomPet(); pet.setName("monster"); - pet.setStatus(Pet.StatusEnum.available); + pet.setStatus(Pet.StatusEnum.AVAILABLE); List tags = new ArrayList(); Tag tag1 = new Tag(); @@ -183,7 +183,7 @@ public class PetApiTest { category.setName("really-happy"); pet.setCategory(category); - pet.setStatus(Pet.StatusEnum.available); + pet.setStatus(Pet.StatusEnum.AVAILABLE); List photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}); pet.setPhotoUrls(photos); diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 508764b8c2db..a1fd7e345a81 100644 --- a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -64,7 +64,7 @@ public class StoreApiTest { order.setPetId(new Long(200)); order.setQuantity(new Integer(13)); order.setShipDate(new java.util.Date()); - order.setStatus(Order.StatusEnum.placed); + order.setStatus(Order.StatusEnum.PLACED); order.setComplete(true); return order; diff --git a/samples/client/petstore/java/jersey2/hello.txt b/samples/client/petstore/java/jersey2/hello.txt deleted file mode 100644 index 6769dd60bdf5..000000000000 --- a/samples/client/petstore/java/jersey2/hello.txt +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java index 0baddcd02c0d..3095c7bacead 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*; import java.io.IOException; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T16:42:49.539+08:00") public class JSON { private ObjectMapper mapper; @@ -14,6 +14,8 @@ public class JSON { mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); mapper.registerModule(new JodaModule()); } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java index 671d8366be0d..2477288848da 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java @@ -2,21 +2,36 @@ package io.swagger.client.model; import java.util.Date; + + import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") -public class Order { +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T16:42:49.539+08:00") +public class Order { private Long id = null; private Long petId = null; private Integer quantity = null; private Date shipDate = null; - public enum StatusEnum { - placed, approved, delivered, - }; + +public enum StatusEnum { + PLACED("placed"), APPROVED("approved"), DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} + private StatusEnum status = null; private Boolean complete = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java index 036f694ffddd..1ed729475562 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java @@ -4,22 +4,37 @@ import io.swagger.client.model.Category; import java.util.*; import io.swagger.client.model.Tag; + + import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-22T21:47:05.989+08:00") -public class Pet { +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-08-24T16:42:49.539+08:00") +public class Pet { private Long id = null; private Category category = null; private String name = null; private List photoUrls = new ArrayList(); private List tags = new ArrayList(); - public enum StatusEnum { - available, pending, sold, - }; + +public enum StatusEnum { + AVAILABLE("available"), PENDING("pending"), SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} + private StatusEnum status = null; diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java index b6ad5fb05275..0a8f8a1665d2 100644 --- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -86,7 +86,7 @@ public class PetApiTest { public void testFindPetsByStatus() throws Exception { Pet pet = createRandomPet(); pet.setName("programmer"); - pet.setStatus(Pet.StatusEnum.available); + pet.setStatus(Pet.StatusEnum.AVAILABLE); api.updatePet(pet); @@ -108,7 +108,7 @@ public class PetApiTest { public void testFindPetsByTags() throws Exception { Pet pet = createRandomPet(); pet.setName("monster"); - pet.setStatus(Pet.StatusEnum.available); + pet.setStatus(Pet.StatusEnum.AVAILABLE); List tags = new ArrayList(); Tag tag1 = new Tag(); @@ -183,7 +183,7 @@ public class PetApiTest { category.setName("really-happy"); pet.setCategory(category); - pet.setStatus(Pet.StatusEnum.available); + pet.setStatus(Pet.StatusEnum.AVAILABLE); List photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}); pet.setPhotoUrls(photos); diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 508764b8c2db..a1fd7e345a81 100644 --- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -64,7 +64,7 @@ public class StoreApiTest { order.setPetId(new Long(200)); order.setQuantity(new Integer(13)); order.setShipDate(new java.util.Date()); - order.setStatus(Order.StatusEnum.placed); + order.setStatus(Order.StatusEnum.PLACED); order.setComplete(true); return order; From d4b4fe4b47517147bcb2610722ebd5abae4ceae4 Mon Sep 17 00:00:00 2001 From: b_sapir Date: Mon, 24 Aug 2015 14:33:15 +0300 Subject: [PATCH 073/109] Support binary input and output (for body parameters or responses with type "string" and format "binary". Implemented for Java. --- .../io/swagger/codegen/CodegenParameter.java | 2 +- .../io/swagger/codegen/CodegenResponse.java | 1 + .../io/swagger/codegen/DefaultCodegen.java | 15 ++- .../codegen/languages/JavaClientCodegen.java | 9 +- .../main/resources/Java/ApiClient.mustache | 110 +++++++++++++++--- .../src/main/resources/Java/api.mustache | 45 ++++--- .../test/resources/2_0/binaryDataTest.json | 51 ++++++++ .../src/test/scala/CodegenTest.scala | 15 +++ .../src/test/scala/Java/JavaModelTest.scala | 22 ++++ 9 files changed, 230 insertions(+), 40 deletions(-) create mode 100644 modules/swagger-codegen/src/test/resources/2_0/binaryDataTest.json diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java index c5aeaab124cc..4447915de4da 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java @@ -7,7 +7,7 @@ import java.util.List; public class CodegenParameter { public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam, - isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam; + isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam, isBinary; public String baseName, paramName, dataType, collectionFormat, description, baseType, defaultValue; public String jsonSchema; public boolean isEnum; diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java index 6d90152f5149..1929bcf52dc3 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java @@ -15,6 +15,7 @@ public class CodegenResponse { public Boolean primitiveType; public Boolean isMapContainer; public Boolean isListContainer; + public Boolean isBinary; public Object schema; public String jsonSchema; 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 212358b96272..394de531bb47 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 @@ -27,6 +27,7 @@ import io.swagger.models.parameters.SerializableParameter; import io.swagger.models.properties.AbstractNumericProperty; import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.BooleanProperty; +import io.swagger.models.properties.ByteArrayProperty; import io.swagger.models.properties.DateProperty; import io.swagger.models.properties.DateTimeProperty; import io.swagger.models.properties.DecimalProperty; @@ -308,6 +309,8 @@ public class DefaultCodegen { typeMapping.put("double", "Double"); typeMapping.put("object", "Object"); typeMapping.put("integer", "Integer"); + typeMapping.put("ByteArray", "byte[]"); + instantiationTypes = new HashMap(); @@ -444,6 +447,8 @@ public class DefaultCodegen { String datatype = null; if (p instanceof StringProperty) { datatype = "string"; + } else if (p instanceof ByteArrayProperty) { + datatype = "ByteArray"; } else if (p instanceof BooleanProperty) { datatype = "boolean"; } else if (p instanceof DateProperty) { @@ -965,6 +970,7 @@ public class DefaultCodegen { } } r.dataType = cm.datatype; + r.isBinary = cm.datatype.equals("byte[]"); if (cm.isContainer != null) { r.simpleType = false; r.containerType = cm.containerType; @@ -1061,12 +1067,17 @@ public class DefaultCodegen { p.dataType = getTypeDeclaration(cm.classname); imports.add(p.dataType); } else { - // TODO: missing format, so this will not always work - Property prop = PropertyBuilder.build(impl.getType(), null, null); + Property prop = PropertyBuilder.build(impl.getType(), impl.getFormat(), null); prop.setRequired(bp.getRequired()); CodegenProperty cp = fromProperty("property", prop); if (cp != null) { p.dataType = cp.datatype; + if (p.dataType.equals("byte[]")) { + p.isBinary = true; + } + else { + p.isBinary = false; + } } } } else if (model instanceof ArrayModel) { 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 b9e298b125c3..89dceef8d1a8 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 @@ -64,7 +64,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { "Integer", "Long", "Float", - "Object") + "Object", + "byte[]") ); instantiationTypes.put("array", "ArrayList"); instantiationTypes.put("map", "HashMap"); @@ -129,7 +130,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { if (additionalProperties.containsKey("localVariablePrefix")) { this.setLocalVariablePrefix((String) additionalProperties.get("localVariablePrefix")); } - + this.sanitizeConfig(); final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator); @@ -266,7 +267,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { if (typeMapping.containsKey(swaggerType)) { type = typeMapping.get(swaggerType); if (languageSpecificPrimitives.contains(type)) { - return toModelName(type); + return type; } } else { type = swaggerType; @@ -363,7 +364,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { public void setLocalVariablePrefix(String localVariablePrefix) { this.localVariablePrefix = localVariablePrefix; } - + private String sanitizePackageName(String packageName) { packageName = packageName.trim(); packageName = packageName.replaceAll("[^a-zA-Z0-9_\\.]", "_"); diff --git a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache index 6930b548d42b..df43687f0a9f 100644 --- a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache @@ -30,6 +30,7 @@ import java.net.URLEncoder; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.io.DataInputStream; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -385,21 +386,12 @@ public class ApiClient { } } - /** - * Invoke API by sending HTTP request with the given options. - * - * @param path The sub-path of the HTTP URL - * @param method The request method, one of "GET", "POST", "PUT", and "DELETE" - * @param queryParams The query parameters - * @param body The request body object - * @param headerParams The header parameters - * @param formParams The form parameters - * @param accept The request's Accept header - * @param contentType The request's Content-Type header - * @param authNames The authentications to apply - * @return The response body in type of string - */ - public String invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException { + private ClientResponse getAPIResponse(String path, String method, List queryParams, Object body, byte[] binaryBody, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException { + + if (body != null && binaryBody != null){ + throw new ApiException(500, "either body or binaryBody must be null"); + } + updateParamsForAuth(authNames, queryParams, headerParams); Client client = getClient(); @@ -446,7 +438,10 @@ public class ApiClient { response = builder.type(contentType).post(ClientResponse.class, encodedFormParams); } else if (body == null) { - response = builder.post(ClientResponse.class, null); + if(binaryBody == null) + response = builder.post(ClientResponse.class, null); + else + response = builder.type(contentType).post(ClientResponse.class, binaryBody); } else if(body instanceof FormDataMultiPart) { response = builder.type(contentType).post(ClientResponse.class, body); } @@ -460,7 +455,10 @@ public class ApiClient { response = builder.type(contentType).put(ClientResponse.class, encodedFormParams); } else if(body == null) { - response = builder.put(ClientResponse.class, serialize(body)); + if(binaryBody == null) + response = builder.put(ClientResponse.class, null); + else + response = builder.type(contentType).put(ClientResponse.class, binaryBody); } else { response = builder.type(contentType).put(ClientResponse.class, serialize(body)); } @@ -472,7 +470,10 @@ public class ApiClient { response = builder.type(contentType).delete(ClientResponse.class, encodedFormParams); } else if(body == null) { - response = builder.delete(ClientResponse.class); + if(binaryBody == null) + response = builder.delete(ClientResponse.class); + else + response = builder.type(contentType).delete(ClientResponse.class, binaryBody); } else { response = builder.type(contentType).delete(ClientResponse.class, serialize(body)); } @@ -480,6 +481,27 @@ public class ApiClient { else { throw new ApiException(500, "unknown method type " + method); } + return response; + } + + /** + * Invoke API by sending HTTP request with the given options. + * + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "POST", "PUT", and "DELETE" + * @param queryParams The query parameters + * @param body The request body object - if it is not binary, otherwise null + * @param binaryBody The request body object - if it is binary, otherwise null + * @param headerParams The header parameters + * @param formParams The form parameters + * @param accept The request's Accept header + * @param contentType The request's Content-Type header + * @param authNames The authentications to apply + * @return The response body in type of string + */ + public String invokeAPI(String path, String method, List queryParams, Object body, byte[] binaryBody, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException { + + ClientResponse response = getAPIResponse(path, method, queryParams, body, binaryBody, headerParams, formParams, accept, contentType, authNames); if(response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) { return null; @@ -511,6 +533,58 @@ public class ApiClient { respBody); } } + /** + * Invoke API by sending HTTP request with the given options - return binary result + * + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "POST", "PUT", and "DELETE" + * @param queryParams The query parameters + * @param body The request body object - if it is not binary, otherwise null + * @param binaryBody The request body object - if it is binary, otherwise null + * @param headerParams The header parameters + * @param formParams The form parameters + * @param accept The request's Accept header + * @param contentType The request's Content-Type header + * @param authNames The authentications to apply + * @return The response body in type of string + */ + public byte[] invokeBinaryAPI(String path, String method, List queryParams, Object body, byte[] binaryBody, Map headerParams, Map formParams, String accept, String contentType, String[]authNames) throws ApiException { + + ClientResponse response = getAPIResponse(path, method, queryParams, body, binaryBody, headerParams, formParams, accept, contentType, authNames); + + if(response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) { + return null; + } + else if(response.getStatusInfo().getFamily() == Family.SUCCESSFUL) { + if(response.hasEntity()) { + DataInputStream stream = new DataInputStream(response.getEntityInputStream()); + byte[] data = new byte[response.getLength()]; + try { + stream.readFully(data); + } catch (IOException ex) { + throw new ApiException(500, "Error obtaining binary response data"); + } + return data; + } + else { + return new byte[0]; + } + } + else { + String message = "error"; + if(response.hasEntity()) { + try{ + message = String.valueOf(response.getEntity(String.class)); + } + catch (RuntimeException e) { + // e.printStackTrace(); + } + } + throw new ApiException( + response.getStatusInfo().getStatusCode(), + message); + } + } /** * Update query and header parameters based on authentication settings. diff --git a/modules/swagger-codegen/src/main/resources/Java/api.mustache b/modules/swagger-codegen/src/main/resources/Java/api.mustache index f8464e79fd2c..ac4b3a306b8c 100644 --- a/modules/swagger-codegen/src/main/resources/Java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/api.mustache @@ -50,16 +50,16 @@ public class {{classname}} { {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { - Object {{localVariablePrefix}}postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; + Object {{localVariablePrefix}}postBody = {{#bodyParam}}{{^isBinary}}{{paramName}}{{/isBinary}}{{#isBinary}}null{{/isBinary}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; + byte[] {{localVariablePrefix}}postBinaryBody = {{#bodyParam}}{{#isBinary}}{{paramName}}{{/isBinary}}{{^isBinary}}null{{/isBinary}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; {{#allParams}}{{#required}} - // verify the required parameter '{{paramName}}' is set - if ({{paramName}} == null) { - throw new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{nickname}}"); - } - {{/required}}{{/allParams}} - + // verify the required parameter '{{paramName}}' is set + if ({{paramName}} == null) { + throw new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{nickname}}"); + } + {{/required}}{{/allParams}} // create path and map variables - String {{localVariablePrefix}}path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}} + String {{localVariablePrefix}}path = "{{{path}}}".replaceAll("\\{format\\}","json"){{#pathParams}} .replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; // query params @@ -110,14 +110,29 @@ public class {{classname}} { } try { + String[] {{localVariablePrefix}}authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; - String {{localVariablePrefix}}response = {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames); - if({{localVariablePrefix}}response != null){ - return {{#returnType}}({{{returnType}}}) {{localVariablePrefix}}apiClient.deserialize({{localVariablePrefix}}response, "{{returnContainer}}", {{returnBaseType}}.class){{/returnType}}; - } - else { - return {{#returnType}}null{{/returnType}}; - } + + {{#responses}}{{#isDefault}} + {{#isBinary}} + byte[] {{localVariablePrefix}}response = null; + {{localVariablePrefix}}response = {{localVariablePrefix}}apiClient.invokeBinaryAPI({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams,{{localVariablePrefix}} postBody, {{localVariablePrefix}}postBinaryBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames); + return {{localVariablePrefix}}response; + + {{/isBinary}} + {{^isBinary}} + + String {{localVariablePrefix}}response = {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}postBinaryBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames); + if({{localVariablePrefix}}response != null){ + return {{#returnType}}({{{returnType}}}) {{localVariablePrefix}}apiClient.deserialize({{localVariablePrefix}}response, "{{returnContainer}}", {{returnBaseType}}.class){{/returnType}}; + } + else { + return {{#returnType}}null{{/returnType}}; + } + {{/isBinary}} + {{/isDefault}} + {{/responses}} + } catch (ApiException ex) { throw ex; } diff --git a/modules/swagger-codegen/src/test/resources/2_0/binaryDataTest.json b/modules/swagger-codegen/src/test/resources/2_0/binaryDataTest.json new file mode 100644 index 000000000000..5ae05f9ae83f --- /dev/null +++ b/modules/swagger-codegen/src/test/resources/2_0/binaryDataTest.json @@ -0,0 +1,51 @@ +{ + "swagger": "2.0", + "info": { + "description": "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", + "version": "1.0.0", + "title": "Swagger Petstore", + "termsOfService": "http://helloreverb.com/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "basePath": "/v2", + "schemes": [ + "http" + ], + "paths": { + "/tests/binaryResponse": { + "post": { + "summary": "Echo test", + "operationId": "echotest", + "consumes": [ + "application/octet-stream" + ], + "produces": [ + "application/octet-stream" + ], + "parameters": [ + { + "name": "InputBinaryData", + "in": "body", + "required": true, + "schema": { + "type": "string", + "format": "binary" + } + } + ], + "responses": { + "200": { + "description": "OutputBinaryData", + "schema": { + "type": "string", + "format": "binary" + } + } + } + } + } + } +} diff --git a/modules/swagger-codegen/src/test/scala/CodegenTest.scala b/modules/swagger-codegen/src/test/scala/CodegenTest.scala index 0e76f5088dff..015932948de6 100644 --- a/modules/swagger-codegen/src/test/scala/CodegenTest.scala +++ b/modules/swagger-codegen/src/test/scala/CodegenTest.scala @@ -139,4 +139,19 @@ class CodegenTest extends FlatSpec with Matchers { val op = codegen.fromOperation(path, "get", p, model.getDefinitions()) op.returnType should be("String") } + + it should "return byte array when response format is byte" in { + val model = new SwaggerParser() + .read("src/test/resources/2_0/binaryDataTest.json") + System.err.println("model is " + model); + val codegen = new DefaultCodegen() + + val path = "/tests/binaryResponse" + val p = model.getPaths().get(path).getPost() + val op = codegen.fromOperation(path, "post", p, model.getDefinitions()) + op.returnType should be("byte[]") + op.bodyParam.dataType should be ("byte[]") + op.bodyParam.isBinary should equal (true); + op.responses.get(0).isBinary should equal(true); + } } \ No newline at end of file diff --git a/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala b/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala index 0043045a29db..2df8db477de4 100644 --- a/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala +++ b/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala @@ -365,6 +365,28 @@ class JavaModelTest extends FlatSpec with Matchers { val vars = cm.vars cm.classname should be("WithDots") } + + it should "convert a modelwith binary data" in { + val model = new ModelImpl() + .description("model with binary") + .property("inputBinaryData", new ByteArrayProperty()); + + val codegen = new JavaClientCodegen() + val cm = codegen.fromModel("sample", model) + val vars = cm.vars + + vars.get(0).baseName should be ("inputBinaryData") + vars.get(0).getter should be ("getInputBinaryData") + vars.get(0).setter should be ("setInputBinaryData") + vars.get(0).datatype should be ("byte[]") + vars.get(0).name should be ("inputBinaryData") + vars.get(0).defaultValue should be ("null") + vars.get(0).baseType should be ("byte[]") + vars.get(0).hasMore should equal (null) + vars.get(0).required should equal (null) + vars.get(0).isNotContainer should equal (true) + + } } From c177cf75d2978bfdd079abb88d272b0afaf76a20 Mon Sep 17 00:00:00 2001 From: b_sapir Date: Mon, 24 Aug 2015 14:33:15 +0300 Subject: [PATCH 074/109] Support binary input and output (for body parameters or responses with type "string" and format "binary". Implemented for Java. --- .../io/swagger/codegen/CodegenParameter.java | 2 +- .../io/swagger/codegen/CodegenResponse.java | 1 + .../io/swagger/codegen/DefaultCodegen.java | 15 ++- .../codegen/languages/JavaClientCodegen.java | 6 +- .../main/resources/Java/ApiClient.mustache | 113 ++++++++++++++---- .../src/main/resources/Java/api.mustache | 32 +++-- .../test/resources/2_0/binaryDataTest.json | 51 ++++++++ .../src/test/scala/CodegenTest.scala | 15 +++ .../src/test/scala/Java/JavaModelTest.scala | 22 ++++ 9 files changed, 223 insertions(+), 34 deletions(-) create mode 100644 modules/swagger-codegen/src/test/resources/2_0/binaryDataTest.json diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java index c5aeaab124cc..4447915de4da 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java @@ -7,7 +7,7 @@ import java.util.List; public class CodegenParameter { public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam, - isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam; + isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam, isBinary; public String baseName, paramName, dataType, collectionFormat, description, baseType, defaultValue; public String jsonSchema; public boolean isEnum; diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java index 6d90152f5149..1929bcf52dc3 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java @@ -15,6 +15,7 @@ public class CodegenResponse { public Boolean primitiveType; public Boolean isMapContainer; public Boolean isListContainer; + public Boolean isBinary; public Object schema; public String jsonSchema; 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 8a75eac30d61..4fe5da20b194 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 @@ -27,6 +27,7 @@ import io.swagger.models.parameters.SerializableParameter; import io.swagger.models.properties.AbstractNumericProperty; import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.BooleanProperty; +import io.swagger.models.properties.ByteArrayProperty; import io.swagger.models.properties.DateProperty; import io.swagger.models.properties.DateTimeProperty; import io.swagger.models.properties.DecimalProperty; @@ -311,6 +312,8 @@ public class DefaultCodegen { typeMapping.put("double", "Double"); typeMapping.put("object", "Object"); typeMapping.put("integer", "Integer"); + typeMapping.put("ByteArray", "byte[]"); + instantiationTypes = new HashMap(); @@ -447,6 +450,8 @@ public class DefaultCodegen { String datatype = null; if (p instanceof StringProperty) { datatype = "string"; + } else if (p instanceof ByteArrayProperty) { + datatype = "ByteArray"; } else if (p instanceof BooleanProperty) { datatype = "boolean"; } else if (p instanceof DateProperty) { @@ -974,6 +979,7 @@ public class DefaultCodegen { } } r.dataType = cm.datatype; + r.isBinary = cm.datatype.equals("byte[]"); if (cm.isContainer != null) { r.simpleType = false; r.containerType = cm.containerType; @@ -1070,12 +1076,17 @@ public class DefaultCodegen { p.dataType = getTypeDeclaration(cm.classname); imports.add(p.dataType); } else { - // TODO: missing format, so this will not always work - Property prop = PropertyBuilder.build(impl.getType(), null, null); + Property prop = PropertyBuilder.build(impl.getType(), impl.getFormat(), null); prop.setRequired(bp.getRequired()); CodegenProperty cp = fromProperty("property", prop); if (cp != null) { p.dataType = cp.datatype; + if (p.dataType.equals("byte[]")) { + p.isBinary = true; + } + else { + p.isBinary = false; + } } } } else if (model instanceof ArrayModel) { 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 379a2db2eb1b..f0a64b98fb4c 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 @@ -66,7 +66,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { "Integer", "Long", "Float", - "Object") + "Object", + "byte[]") ); instantiationTypes.put("array", "ArrayList"); instantiationTypes.put("map", "HashMap"); @@ -282,7 +283,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { if (typeMapping.containsKey(swaggerType)) { type = typeMapping.get(swaggerType); if (languageSpecificPrimitives.contains(type)) { - return toModelName(type); + return type; } } else { type = swaggerType; @@ -379,6 +380,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { public void setLocalVariablePrefix(String localVariablePrefix) { this.localVariablePrefix = localVariablePrefix; } + public Boolean getSerializableModel() { return serializableModel; diff --git a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache index 4e691c27493c..2846c409c605 100644 --- a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache @@ -28,6 +28,7 @@ import java.net.URLEncoder; import java.io.IOException; import java.io.File; import java.io.UnsupportedEncodingException; +import java.io.DataInputStream; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -372,22 +373,12 @@ public class ApiClient { } } - /** - * Invoke API by sending HTTP request with the given options. - * - * @param path The sub-path of the HTTP URL - * @param method The request method, one of "GET", "POST", "PUT", and "DELETE" - * @param queryParams The query parameters - * @param body The request body object - * @param headerParams The header parameters - * @param formParams The form parameters - * @param accept The request's Accept header - * @param contentType The request's Content-Type header - * @param authNames The authentications to apply - * @param returnType The return type into which to deserialize the response - * @return The response body in type of string - */ - public T invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, TypeRef returnType) throws ApiException { + private ClientResponse getAPIResponse(String path, String method, List queryParams, Object body, byte[] binaryBody, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException { + + if (body != null && binaryBody != null){ + throw new ApiException(500, "either body or binaryBody must be null"); + } + updateParamsForAuth(authNames, queryParams, headerParams); Client client = getClient(); @@ -447,7 +438,10 @@ public class ApiClient { if (encodedFormParams != null) { response = builder.type(contentType).post(ClientResponse.class, encodedFormParams); } else if (body == null) { - response = builder.post(ClientResponse.class, null); + if(binaryBody == null) + response = builder.post(ClientResponse.class, null); + else + response = builder.type(contentType).post(ClientResponse.class, binaryBody); } else if (body instanceof FormDataMultiPart) { response = builder.type(contentType).post(ClientResponse.class, body); } else { @@ -457,7 +451,10 @@ public class ApiClient { if (encodedFormParams != null) { response = builder.type(contentType).put(ClientResponse.class, encodedFormParams); } else if(body == null) { - response = builder.put(ClientResponse.class, serialize(body, contentType)); + if(binaryBody == null) + response = builder.put(ClientResponse.class, null); + else + response = builder.type(contentType).put(ClientResponse.class, binaryBody); } else { response = builder.type(contentType).put(ClientResponse.class, serialize(body, contentType)); } @@ -465,15 +462,39 @@ public class ApiClient { if (encodedFormParams != null) { response = builder.type(contentType).delete(ClientResponse.class, encodedFormParams); } else if(body == null) { - response = builder.delete(ClientResponse.class); + if(binaryBody == null) + response = builder.delete(ClientResponse.class); + else + response = builder.type(contentType).delete(ClientResponse.class, binaryBody); } else { response = builder.type(contentType).delete(ClientResponse.class, serialize(body, contentType)); } } else { throw new ApiException(500, "unknown method type " + method); } + return response; + } - if (response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) { + /** + * Invoke API by sending HTTP request with the given options. + * + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "POST", "PUT", and "DELETE" + * @param queryParams The query parameters + * @param body The request body object - if it is not binary, otherwise null + * @param binaryBody The request body object - if it is binary, otherwise null + * @param headerParams The header parameters + * @param formParams The form parameters + * @param accept The request's Accept header + * @param contentType The request's Content-Type header + * @param authNames The authentications to apply + * @return The response body in type of string + */ + public T invokeAPI(String path, String method, List queryParams, Object body, byte[] binaryBody, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException { + + ClientResponse response = getAPIResponse(path, method, queryParams, body, binaryBody, headerParams, formParams, accept, contentType, authNames); + + if(response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) { return null; } else if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) { if (returnType == null) @@ -498,6 +519,58 @@ public class ApiClient { respBody); } } + /** + * Invoke API by sending HTTP request with the given options - return binary result + * + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "POST", "PUT", and "DELETE" + * @param queryParams The query parameters + * @param body The request body object - if it is not binary, otherwise null + * @param binaryBody The request body object - if it is binary, otherwise null + * @param headerParams The header parameters + * @param formParams The form parameters + * @param accept The request's Accept header + * @param contentType The request's Content-Type header + * @param authNames The authentications to apply + * @return The response body in type of string + */ + public byte[] invokeBinaryAPI(String path, String method, List queryParams, Object body, byte[] binaryBody, Map headerParams, Map formParams, String accept, String contentType, String[]authNames) throws ApiException { + + ClientResponse response = getAPIResponse(path, method, queryParams, body, binaryBody, headerParams, formParams, accept, contentType, authNames); + + if(response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) { + return null; + } + else if(response.getStatusInfo().getFamily() == Family.SUCCESSFUL) { + if(response.hasEntity()) { + DataInputStream stream = new DataInputStream(response.getEntityInputStream()); + byte[] data = new byte[response.getLength()]; + try { + stream.readFully(data); + } catch (IOException ex) { + throw new ApiException(500, "Error obtaining binary response data"); + } + return data; + } + else { + return new byte[0]; + } + } + else { + String message = "error"; + if(response.hasEntity()) { + try{ + message = String.valueOf(response.getEntity(String.class)); + } + catch (RuntimeException e) { + // e.printStackTrace(); + } + } + throw new ApiException( + response.getStatusInfo().getStatusCode(), + message); + } + } /** * Update query and header parameters based on authentication settings. diff --git a/modules/swagger-codegen/src/main/resources/Java/api.mustache b/modules/swagger-codegen/src/main/resources/Java/api.mustache index a4dc5e6f9035..7d6ccc4c6c5c 100644 --- a/modules/swagger-codegen/src/main/resources/Java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/api.mustache @@ -46,16 +46,16 @@ public class {{classname}} { {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { - Object {{localVariablePrefix}}postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; + Object {{localVariablePrefix}}postBody = {{#bodyParam}}{{^isBinary}}{{paramName}}{{/isBinary}}{{#isBinary}}null{{/isBinary}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; + byte[] {{localVariablePrefix}}postBinaryBody = {{#bodyParam}}{{#isBinary}}{{paramName}}{{/isBinary}}{{^isBinary}}null{{/isBinary}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; {{#allParams}}{{#required}} - // verify the required parameter '{{paramName}}' is set - if ({{paramName}} == null) { - throw new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{nickname}}"); - } - {{/required}}{{/allParams}} - + // verify the required parameter '{{paramName}}' is set + if ({{paramName}} == null) { + throw new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{nickname}}"); + } + {{/required}}{{/allParams}} // create path and map variables - String {{localVariablePrefix}}path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}} + String {{localVariablePrefix}}path = "{{{path}}}".replaceAll("\\{format\\}","json"){{#pathParams}} .replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; // query params @@ -84,14 +84,28 @@ public class {{classname}} { {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }; final String {{localVariablePrefix}}contentType = {{localVariablePrefix}}apiClient.selectHeaderContentType({{localVariablePrefix}}contentTypes); - + String[] {{localVariablePrefix}}authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; + {{#responses}} + {{#isDefault}} + + {{#isBinary}} + byte[] {{localVariablePrefix}}response = null; + {{localVariablePrefix}}response = {{localVariablePrefix}}apiClient.invokeBinaryAPI({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams,{{localVariablePrefix}} postBody, {{localVariablePrefix}}postBinaryBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames); + return {{localVariablePrefix}}response; + {{/isBinary}} + + {{^isBinary}} {{#returnType}} TypeRef {{localVariablePrefix}}returnType = new TypeRef<{{{returnType}}}>() {}; return {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames, {{localVariablePrefix}}returnType); {{/returnType}}{{^returnType}} {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames, null); {{/returnType}} + {{/isBinary}} + + {{/isDefault}} + {{/responses}} } {{/operation}} } diff --git a/modules/swagger-codegen/src/test/resources/2_0/binaryDataTest.json b/modules/swagger-codegen/src/test/resources/2_0/binaryDataTest.json new file mode 100644 index 000000000000..5ae05f9ae83f --- /dev/null +++ b/modules/swagger-codegen/src/test/resources/2_0/binaryDataTest.json @@ -0,0 +1,51 @@ +{ + "swagger": "2.0", + "info": { + "description": "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", + "version": "1.0.0", + "title": "Swagger Petstore", + "termsOfService": "http://helloreverb.com/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "basePath": "/v2", + "schemes": [ + "http" + ], + "paths": { + "/tests/binaryResponse": { + "post": { + "summary": "Echo test", + "operationId": "echotest", + "consumes": [ + "application/octet-stream" + ], + "produces": [ + "application/octet-stream" + ], + "parameters": [ + { + "name": "InputBinaryData", + "in": "body", + "required": true, + "schema": { + "type": "string", + "format": "binary" + } + } + ], + "responses": { + "200": { + "description": "OutputBinaryData", + "schema": { + "type": "string", + "format": "binary" + } + } + } + } + } + } +} diff --git a/modules/swagger-codegen/src/test/scala/CodegenTest.scala b/modules/swagger-codegen/src/test/scala/CodegenTest.scala index 0e76f5088dff..015932948de6 100644 --- a/modules/swagger-codegen/src/test/scala/CodegenTest.scala +++ b/modules/swagger-codegen/src/test/scala/CodegenTest.scala @@ -139,4 +139,19 @@ class CodegenTest extends FlatSpec with Matchers { val op = codegen.fromOperation(path, "get", p, model.getDefinitions()) op.returnType should be("String") } + + it should "return byte array when response format is byte" in { + val model = new SwaggerParser() + .read("src/test/resources/2_0/binaryDataTest.json") + System.err.println("model is " + model); + val codegen = new DefaultCodegen() + + val path = "/tests/binaryResponse" + val p = model.getPaths().get(path).getPost() + val op = codegen.fromOperation(path, "post", p, model.getDefinitions()) + op.returnType should be("byte[]") + op.bodyParam.dataType should be ("byte[]") + op.bodyParam.isBinary should equal (true); + op.responses.get(0).isBinary should equal(true); + } } \ No newline at end of file diff --git a/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala b/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala index 0043045a29db..2df8db477de4 100644 --- a/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala +++ b/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala @@ -365,6 +365,28 @@ class JavaModelTest extends FlatSpec with Matchers { val vars = cm.vars cm.classname should be("WithDots") } + + it should "convert a modelwith binary data" in { + val model = new ModelImpl() + .description("model with binary") + .property("inputBinaryData", new ByteArrayProperty()); + + val codegen = new JavaClientCodegen() + val cm = codegen.fromModel("sample", model) + val vars = cm.vars + + vars.get(0).baseName should be ("inputBinaryData") + vars.get(0).getter should be ("getInputBinaryData") + vars.get(0).setter should be ("setInputBinaryData") + vars.get(0).datatype should be ("byte[]") + vars.get(0).name should be ("inputBinaryData") + vars.get(0).defaultValue should be ("null") + vars.get(0).baseType should be ("byte[]") + vars.get(0).hasMore should equal (null) + vars.get(0).required should equal (null) + vars.get(0).isNotContainer should equal (true) + + } } From 0261121d780efff40de24d18c0f7630825b581fd Mon Sep 17 00:00:00 2001 From: F481 Date: Mon, 24 Aug 2015 14:04:50 +0200 Subject: [PATCH 075/109] added some useful log/output messages and exception handling --- .../java/io/swagger/codegen/cmd/Generate.java | 4 +- .../io/swagger/codegen/DefaultCodegen.java | 33 +++++-- .../io/swagger/codegen/DefaultGenerator.java | 88 ++++++++++++------- .../codegen/languages/JavaClientCodegen.java | 11 +++ 4 files changed, 94 insertions(+), 42 deletions(-) diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java index cf22ae91b629..74b445c57ff6 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java @@ -78,17 +78,19 @@ public class Generate implements Runnable { */ private static CodegenConfig forName(String name) { ServiceLoader loader = load(CodegenConfig.class); + String available = ""; for (CodegenConfig config : loader) { if (config.getName().equals(name)) { return config; } + available = available + config.getName() + "\n"; } // else try to load directly try { return (CodegenConfig) Class.forName(name).newInstance(); } catch (Exception e) { - throw new RuntimeException("Can't load config class with name ".concat(name), e); + throw new RuntimeException("Can't load config class with name ".concat(name) + "Available: "+available, e); } } 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 8a75eac30d61..298d57ff177b 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 @@ -391,7 +391,13 @@ public class DefaultCodegen { public String toInstantiationType(Property p) { if (p instanceof MapProperty) { MapProperty ap = (MapProperty) p; - String inner = getSwaggerType(ap.getAdditionalProperties()); + Property additionalProperties2 = ap.getAdditionalProperties(); + String type = additionalProperties2.getType(); + if (null == type) { + LOGGER.error("No Type defined for Additional Property " + additionalProperties2 + "\n" // + + "\tIn Property: " + p); + } + String inner = getSwaggerType(additionalProperties2); return instantiationTypes.get("map") + ""; } else if (p instanceof ArrayProperty) { ArrayProperty ap = (ArrayProperty) p; @@ -763,7 +769,7 @@ public class DefaultCodegen { } } operationId = builder.toString(); - LOGGER.warn("generated operationId " + operationId); + LOGGER.info("generated operationId " + operationId + "\tfor Path: " + httpMethod + " " + path); } operationId = removeNonNameElementToCamelCase(operationId); op.path = path; @@ -1002,6 +1008,10 @@ public class DefaultCodegen { } p.jsonSchema = Json.pretty(param); + if (System.getProperty("debugParser") != null) { + LOGGER.info("working on Parameter " + param); + } + // move the defaultValue for headers, forms and params if (param instanceof QueryParameter) { p.defaultValue = ((QueryParameter) param).getDefaultValue(); @@ -1015,7 +1025,11 @@ public class DefaultCodegen { SerializableParameter qp = (SerializableParameter) param; Property property = null; String collectionFormat = null; - if ("array".equals(qp.getType())) { + String type = qp.getType(); + if (null == type) { + LOGGER.warn("Type is NULL for Serializable Parameter: " + param); + } + if ("array".equals(type)) { Property inner = qp.getItems(); if (inner == null) { LOGGER.warn("warning! No inner type supplied for array parameter \"" + qp.getName() + "\", using String"); @@ -1027,7 +1041,7 @@ public class DefaultCodegen { p.baseType = pr.datatype; p.isContainer = true; imports.add(pr.baseType); - } else if ("object".equals(qp.getType())) { + } else if ("object".equals(type)) { Property inner = qp.getItems(); if (inner == null) { LOGGER.warn("warning! No inner type supplied for map parameter \"" + qp.getName() + "\", using String"); @@ -1040,12 +1054,13 @@ public class DefaultCodegen { imports.add(pr.baseType); } else { Map args = new HashMap(); + String format = qp.getFormat(); args.put(PropertyId.ENUM, qp.getEnum()); - property = PropertyBuilder.build(qp.getType(), qp.getFormat(), args); + property = PropertyBuilder.build(type, format, args); } if (property == null) { - LOGGER.warn("warning! Property type \"" + qp.getType() + "\" not found for parameter \"" + param.getName() + "\", using String"); - property = new StringProperty().description("//TODO automatically added by swagger-codegen. Type was " + qp.getType() + " but not supported"); + LOGGER.warn("warning! Property type \"" + type + "\" not found for parameter \"" + param.getName() + "\", using String"); + property = new StringProperty().description("//TODO automatically added by swagger-codegen. Type was " + type + " but not supported"); } property.setRequired(param.getRequired()); CodegenProperty model = fromProperty(qp.getName(), property); @@ -1060,6 +1075,10 @@ public class DefaultCodegen { imports.add(model.complexType); } } else { + if (!(param instanceof BodyParameter)) { + LOGGER.error("Cannot use Parameter " + param + " as Body Parameter"); + } + BodyParameter bp = (BodyParameter) param; Model model = bp.getSchema(); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 40b676149a23..378a874d3e07 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -20,6 +20,8 @@ import io.swagger.models.parameters.Parameter; import io.swagger.util.Json; import org.apache.commons.io.IOUtils; import org.joda.time.DateTime; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.FileInputStream; @@ -39,12 +41,15 @@ import java.util.Map; import java.util.Set; public class DefaultGenerator extends AbstractGenerator implements Generator { + Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class); + protected CodegenConfig config; protected ClientOptInput opts = null; protected Swagger swagger = null; public CodeGenStatus status = CodeGenStatus.UNRUN; + @Override public Generator opts(ClientOptInput opts) { this.opts = opts; @@ -55,6 +60,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { return this; } + @Override public List generate() { if (swagger == null || config == null) { throw new RuntimeException("missing swagger input or config!"); @@ -150,6 +156,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { String template = readTemplate(templateFile); Template tmpl = Mustache.compiler() .withLoader(new Mustache.TemplateLoader() { + @Override public Reader getTemplate(String name) { return getTemplateReader(config.templateDir() + File.separator + name + ".mustache"); } @@ -203,6 +210,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { String template = readTemplate(templateFile); Template tmpl = Mustache.compiler() .withLoader(new Mustache.TemplateLoader() { + @Override public Reader getTemplate(String name) { return getTemplateReader(config.templateDir() + File.separator + name + ".mustache"); } @@ -277,6 +285,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { String template = readTemplate(templateFile); Template tmpl = Mustache.compiler() .withLoader(new Mustache.TemplateLoader() { + @Override public Reader getTemplate(String name) { return getTemplateReader(config.templateDir() + File.separator + name + ".mustache"); } @@ -416,6 +425,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { public void processOperation(String resourcePath, String httpMethod, Operation operation, Map> operations, Path path) { if (operation != null) { + LOGGER.info("processOperation: resourcePath= " + resourcePath + "\t;" + httpMethod + " " + operation + "\n"); List tags = operation.getTags(); if (tags == null) { tags = new ArrayList(); @@ -445,44 +455,54 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { } for (String tag : tags) { - CodegenOperation co = config.fromOperation(resourcePath, httpMethod, operation, swagger.getDefinitions()); - co.tags = new ArrayList(); - co.tags.add(sanitizeTag(tag)); - config.addOperationToGroup(sanitizeTag(tag), resourcePath, operation, co, operations); + CodegenOperation co = null; + try { + co = config.fromOperation(resourcePath, httpMethod, operation, swagger.getDefinitions()); + co.tags = new ArrayList(); + co.tags.add(sanitizeTag(tag)); + config.addOperationToGroup(sanitizeTag(tag), resourcePath, operation, co, operations); - List>> securities = operation.getSecurity(); - if (securities == null) { - continue; - } - Map authMethods = new HashMap(); - for (Map> security : securities) { - if (security.size() != 1) { - //Not sure what to do + List>> securities = operation.getSecurity(); + if (securities == null) { continue; } - String securityName = security.keySet().iterator().next(); - SecuritySchemeDefinition securityDefinition = fromSecurity(securityName); - if (securityDefinition != null) { - if(securityDefinition instanceof OAuth2Definition) { - OAuth2Definition oauth2Definition = (OAuth2Definition) securityDefinition; - OAuth2Definition oauth2Operation = new OAuth2Definition(); - oauth2Operation.setType(oauth2Definition.getType()); - oauth2Operation.setAuthorizationUrl(oauth2Definition.getAuthorizationUrl()); - oauth2Operation.setFlow(oauth2Definition.getFlow()); - oauth2Operation.setTokenUrl(oauth2Definition.getTokenUrl()); - for (String scope : security.values().iterator().next()) { - if (oauth2Definition.getScopes().containsKey(scope)) { - oauth2Operation.addScope(scope, oauth2Definition.getScopes().get(scope)); - } - } - authMethods.put(securityName, oauth2Operation); - } else { - authMethods.put(securityName, securityDefinition); - } + Map authMethods = new HashMap(); + for (Map> security : securities) { + if (security.size() != 1) { + //Not sure what to do + continue; + } + String securityName = security.keySet().iterator().next(); + SecuritySchemeDefinition securityDefinition = fromSecurity(securityName); + if (securityDefinition != null) { + if(securityDefinition instanceof OAuth2Definition) { + OAuth2Definition oauth2Definition = (OAuth2Definition) securityDefinition; + OAuth2Definition oauth2Operation = new OAuth2Definition(); + oauth2Operation.setType(oauth2Definition.getType()); + oauth2Operation.setAuthorizationUrl(oauth2Definition.getAuthorizationUrl()); + oauth2Operation.setFlow(oauth2Definition.getFlow()); + oauth2Operation.setTokenUrl(oauth2Definition.getTokenUrl()); + for (String scope : security.values().iterator().next()) { + if (oauth2Definition.getScopes().containsKey(scope)) { + oauth2Operation.addScope(scope, oauth2Definition.getScopes().get(scope)); + } + } + authMethods.put(securityName, oauth2Operation); + } else { + authMethods.put(securityName, securityDefinition); + } + } + } + if (!authMethods.isEmpty()) { + co.authMethods = config.fromSecurity(authMethods); + } + catch (Exception ex) { + LOGGER.error("Error while trying to get Config from Operation for tag(" + tag + ")\n" // + + "\tResource: " + httpMethod + " " + resourcePath + "\n"// + + "\tOperation:" + operation + "\n" // + + "\tDefinitions: " + swagger.getDefinitions() + "\n"); + ex.printStackTrace(); } - } - if (!authMethods.isEmpty()) { - co.authMethods = config.fromSecurity(authMethods); } } } 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 379a2db2eb1b..0e9b189d77a0 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 @@ -27,8 +27,12 @@ import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { + private static final Logger LOGGER = LoggerFactory.getLogger(JavaClientCodegen.class); + protected String invokerPackage = "io.swagger.client"; protected String groupId = "io.swagger"; protected String artifactId = "swagger-java-client"; @@ -85,14 +89,17 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { cliOptions.add(buildLibraryCliOption(supportedLibraries)); } + @Override public CodegenType getTag() { return CodegenType.CLIENT; } + @Override public String getName() { return "java"; } + @Override public String getHelp() { return "Generates a Java client library."; } @@ -194,6 +201,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar); } + @Override public String modelFileFolder() { return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar); } @@ -287,6 +295,9 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } else { type = swaggerType; } + if (null == type) { + LOGGER.error("No Type defined for Property " + p); + } return toModelName(type); } From 3d89399b58eb60ae448e97308c1c09278121fce1 Mon Sep 17 00:00:00 2001 From: F481 Date: Mon, 24 Aug 2015 14:28:13 +0200 Subject: [PATCH 076/109] fixed syntax error --- .../java/io/swagger/codegen/DefaultGenerator.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 378a874d3e07..bcc86be0558f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -496,13 +496,13 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { if (!authMethods.isEmpty()) { co.authMethods = config.fromSecurity(authMethods); } - catch (Exception ex) { - LOGGER.error("Error while trying to get Config from Operation for tag(" + tag + ")\n" // - + "\tResource: " + httpMethod + " " + resourcePath + "\n"// - + "\tOperation:" + operation + "\n" // - + "\tDefinitions: " + swagger.getDefinitions() + "\n"); - ex.printStackTrace(); - } + } + catch (Exception ex) { + LOGGER.error("Error while trying to get Config from Operation for tag(" + tag + ")\n" // + + "\tResource: " + httpMethod + " " + resourcePath + "\n"// + + "\tOperation:" + operation + "\n" // + + "\tDefinitions: " + swagger.getDefinitions() + "\n"); + ex.printStackTrace(); } } } From b0c776bbea54d2a5550c50e00c67646c9e618ae9 Mon Sep 17 00:00:00 2001 From: b_sapir Date: Mon, 24 Aug 2015 15:59:58 +0300 Subject: [PATCH 077/109] Support binary input and output - fix some merge problems --- .../src/main/java/io/swagger/codegen/DefaultCodegen.java | 1 + .../src/main/resources/Java/ApiClient.mustache | 6 +++--- .../swagger-codegen/src/main/resources/Java/api.mustache | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) 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 4fe5da20b194..1422b1c36a0c 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 @@ -534,6 +534,7 @@ public class DefaultCodegen { if (model instanceof ArrayModel) { ArrayModel am = (ArrayModel) model; ArrayProperty arrayProperty = new ArrayProperty(am.getItems()); + m.hasEnums = false; // Otherwise there will be a NullPointerException in JavaClientCodegen.fromModel addParentContainer(m, name, arrayProperty); } else if (model instanceof RefModel) { // TODO diff --git a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache index 2846c409c605..1a0dc5bc3a73 100644 --- a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache @@ -373,7 +373,7 @@ public class ApiClient { } } - private ClientResponse getAPIResponse(String path, String method, List queryParams, Object body, byte[] binaryBody, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException { + private ClientResponse getAPIResponse(String path, String method, List queryParams, Object body, byte[] binaryBody, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException { if (body != null && binaryBody != null){ throw new ApiException(500, "either body or binaryBody must be null"); @@ -490,7 +490,7 @@ public class ApiClient { * @param authNames The authentications to apply * @return The response body in type of string */ - public T invokeAPI(String path, String method, List queryParams, Object body, byte[] binaryBody, Map headerParams, Map formParams, String accept, String contentType, String[] authNames) throws ApiException { + public T invokeAPI(String path, String method, List queryParams, Object body, byte[] binaryBody, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, TypeRef returnType) throws ApiException { ClientResponse response = getAPIResponse(path, method, queryParams, body, binaryBody, headerParams, formParams, accept, contentType, authNames); @@ -534,7 +534,7 @@ public class ApiClient { * @param authNames The authentications to apply * @return The response body in type of string */ - public byte[] invokeBinaryAPI(String path, String method, List queryParams, Object body, byte[] binaryBody, Map headerParams, Map formParams, String accept, String contentType, String[]authNames) throws ApiException { + public byte[] invokeBinaryAPI(String path, String method, List queryParams, Object body, byte[] binaryBody, Map headerParams, Map formParams, String accept, String contentType, String[]authNames) throws ApiException { ClientResponse response = getAPIResponse(path, method, queryParams, body, binaryBody, headerParams, formParams, accept, contentType, authNames); diff --git a/modules/swagger-codegen/src/main/resources/Java/api.mustache b/modules/swagger-codegen/src/main/resources/Java/api.mustache index 7d6ccc4c6c5c..53aa42ec37c3 100644 --- a/modules/swagger-codegen/src/main/resources/Java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/api.mustache @@ -98,9 +98,9 @@ public class {{classname}} { {{^isBinary}} {{#returnType}} TypeRef {{localVariablePrefix}}returnType = new TypeRef<{{{returnType}}}>() {}; - return {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames, {{localVariablePrefix}}returnType); + return {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}postBinaryBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames, {{localVariablePrefix}}returnType); {{/returnType}}{{^returnType}} - {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames, null); + {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}path, "{{httpMethod}}", {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}postBinaryBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames, null); {{/returnType}} {{/isBinary}} From 2251a2f8927d7ec795b5d930e6a0bae55767f834 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 23 Aug 2015 16:49:36 +0800 Subject: [PATCH 078/109] fix typo, update documentation for python lib --- .../codegen/languages/PythonClientCodegen.java | 2 +- .../src/main/resources/python/api.mustache | 3 ++- .../src/main/resources/python/api_client.mustache | 14 ++++++++------ .../main/resources/python/configuration.mustache | 8 +++++--- .../src/main/resources/python/model.mustache | 8 +++++--- .../src/main/resources/python/setup.mustache | 6 ++---- 6 files changed, 23 insertions(+), 18 deletions(-) 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 61dc431b8a7b..179299f9c2e2 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 @@ -61,7 +61,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig "return", "def", "for", "lambda", "try")); cliOptions.clear(); - cliOptions.add(new CliOption("packageName", "python package name (convension: under_score), default: swagger_client")); + cliOptions.add(new CliOption("packageName", "python package name (convention: under_score), default: swagger_client")); cliOptions.add(new CliOption("packageVersion", "python package version, default: 1.0.0")); } diff --git a/modules/swagger-codegen/src/main/resources/python/api.mustache b/modules/swagger-codegen/src/main/resources/python/api.mustache index 3620e9fb9eee..f85d5962c974 100644 --- a/modules/swagger-codegen/src/main/resources/python/api.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api.mustache @@ -34,6 +34,7 @@ class {{classname}}(object): """ NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. + Ref: https://github.com/swagger-api/swagger-codegen """ def __init__(self, api_client=None): @@ -51,7 +52,7 @@ class {{classname}}(object): {{{summary}}} {{{notes}}} - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index 02099f0ceb1e..72b2f049854f 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + ref: https://github.com/swagger-api/swagger-codegen """ from __future__ import absolute_import @@ -56,7 +58,7 @@ class ApiClient(object): templates. NOTE: This class is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen + Ref: https://github.com/swagger-api/swagger-codegen Do not edit the class manually. :param host: The base path for the server to call. @@ -75,7 +77,7 @@ class ApiClient(object): self.host = host self.cookie = cookie # Set default User-Agent. - self.user_agent = 'Python-Swagger' + self.user_agent = 'Python-Swagger/{{packageVersion}}' @property def user_agent(self): @@ -280,7 +282,8 @@ class ApiClient(object): body=None, post_params=None, files=None, response_type=None, auth_settings=None, callback=None): """ - Makes the HTTP request and return the deserialized data. + Makes the HTTP request (synchronous) and return the deserialized data. + To make an async request, define a function for callback. :param resource_path: Path to method endpoint. :param method: Method to call. @@ -450,9 +453,8 @@ class ApiClient(object): def __deserialize_file(self, response): """ - Saves response body into a file in (the defined) temporary folder, - using the filename from the `Content-Disposition` header if provided, - otherwise a random filename. + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. :param response: RESTResponse. :return: file path. diff --git a/modules/swagger-codegen/src/main/resources/python/configuration.mustache b/modules/swagger-codegen/src/main/resources/python/configuration.mustache index d6d94ff5a50f..b8ec002c44d2 100644 --- a/modules/swagger-codegen/src/main/resources/python/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/python/configuration.mustache @@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + ref: https://github.com/swagger-api/swagger-codegen """ from __future__ import absolute_import @@ -44,7 +46,7 @@ def singleton(cls, *args, **kw): class Configuration(object): """ NOTE: This class is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen + Ref: https://github.com/swagger-api/swagger-codegen Do not edit the class manually. """ @@ -56,7 +58,7 @@ class Configuration(object): self.host = "{{basePath}}" # Default api client self.api_client = None - # Temp file folder for download + # Temp file folder for downloading files self.temp_folder_path = None # Authentication Settings @@ -139,7 +141,7 @@ class Configuration(object): def get_basic_auth_token(self): """ - Gets basic auth header string. + Gets HTTP basic authentication header (string). :return: The token for basic HTTP authentication. """ diff --git a/modules/swagger-codegen/src/main/resources/python/model.mustache b/modules/swagger-codegen/src/main/resources/python/model.mustache index 4a93aeaf29dd..81e0b05849ab 100644 --- a/modules/swagger-codegen/src/main/resources/python/model.mustache +++ b/modules/swagger-codegen/src/main/resources/python/model.mustache @@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen """ {{#models}} @@ -29,7 +31,7 @@ class {{classname}}(object): """ def __init__(self): """ - Swagger model + {{classname}} - a model defined in Swagger :param dict swaggerTypes: The key is attribute name and the value is attribute type. @@ -82,7 +84,7 @@ class {{classname}}(object): {{/vars}} def to_dict(self): """ - Return model properties dict + Returns the model properties as a dict """ result = {} @@ -102,7 +104,7 @@ class {{classname}}(object): def to_str(self): """ - Return model properties str + Returns the string representation of the model """ return pformat(self.to_dict()) diff --git a/modules/swagger-codegen/src/main/resources/python/setup.mustache b/modules/swagger-codegen/src/main/resources/python/setup.mustache index a939ce019587..08e110e35cce 100644 --- a/modules/swagger-codegen/src/main/resources/python/setup.mustache +++ b/modules/swagger-codegen/src/main/resources/python/setup.mustache @@ -8,13 +8,11 @@ VERSION = "{{packageVersion}}" {{#apiInfo}}{{#apis}}{{^hasMore}} -# To install the library, open a Terminal shell, then run this -# file by typing: +# To install the library, run the following # # python setup.py install # -# You need to have the setuptools module installed. -# Try reading the setuptools documentation: +# prerequisite: setuptools # http://pypi.python.org/pypi/setuptools REQUIRES = ["urllib3 >= 1.10", "six >= 1.9", "certifi", "python-dateutil"] From a7c08e680cc244436a007f28e9db068fe887e185 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 23 Aug 2015 17:20:30 +0800 Subject: [PATCH 079/109] update python samples --- samples/client/petstore/python/.coverage | Bin 0 -> 3918 bytes .../petstore/python/dev-requirements.txt.log | 15 +++++++++ samples/client/petstore/python/setup.py | 6 ++-- .../python/swagger_client.egg-info/PKG-INFO | 12 ++++++++ .../swagger_client.egg-info/SOURCES.txt | 29 ++++++++++++++++++ .../dependency_links.txt | 1 + .../swagger_client.egg-info/requires.txt | 4 +++ .../swagger_client.egg-info/top_level.txt | 2 ++ .../python/swagger_client/api_client.py | 14 +++++---- .../python/swagger_client/apis/pet_api.py | 17 +++++----- .../python/swagger_client/apis/store_api.py | 9 +++--- .../python/swagger_client/apis/user_api.py | 17 +++++----- .../python/swagger_client/configuration.py | 8 +++-- .../python/swagger_client/models/category.py | 8 +++-- .../python/swagger_client/models/order.py | 8 +++-- .../python/swagger_client/models/pet.py | 8 +++-- .../python/swagger_client/models/tag.py | 8 +++-- .../python/swagger_client/models/user.py | 8 +++-- 18 files changed, 126 insertions(+), 48 deletions(-) create mode 100644 samples/client/petstore/python/.coverage create mode 100644 samples/client/petstore/python/dev-requirements.txt.log create mode 100644 samples/client/petstore/python/swagger_client.egg-info/PKG-INFO create mode 100644 samples/client/petstore/python/swagger_client.egg-info/SOURCES.txt create mode 100644 samples/client/petstore/python/swagger_client.egg-info/dependency_links.txt create mode 100644 samples/client/petstore/python/swagger_client.egg-info/requires.txt create mode 100644 samples/client/petstore/python/swagger_client.egg-info/top_level.txt diff --git a/samples/client/petstore/python/.coverage b/samples/client/petstore/python/.coverage new file mode 100644 index 0000000000000000000000000000000000000000..d58a8fe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mu3StL#2GK;Grpv;+sxlMA zlc{DmUqLK9E;rx*A;CTJY~{!SuXil$^ZCFl&K6IpA+y15J~K@M*W^xuD^O)J z1RfD}|AoCKYxib@L@N+ngWqOA*zAGeI=r>Pcj4<<`nv{y;Bb5Y$eQ3YRP43Ze!+U- zCF|`!`riJN2gTd?tM&Igc-N583Jed6qlE3-z@oG8XpfApzT6K}V~B95aG0=II9ymN z94Q(f!Jx1_ z$A#;JtA%SkAdC(-dq8aPbl4=^BHWt8#2ua#cjjQRGslZZg^vk;DtuhHPxyrJN#Rq% zr-jc5pB3&GJ|}!$ctH4q=g2|fOTw3hzZbrm!^#_;EN=<_Cj5u+9pSsee|pfoCwyP{ zf$&4&N5YRicZ@ZClzo+j%Kpj$%E8JnDo<3Nq#T-KkO9c(Q{n)`k;+q)qm^TnW0m8S zaiDVHl(C|4?1DOW4kC~s1(RjyO6S8h;lRNkh%UAalQS-C~IRk=;M zJ&(}zA#JqhL@uR$V`0A|r?k{kwb#{Nh0t_2QOfLKd0tkH9}abev9SM=1.11.2 (from tox->-r dev-requirements.txt (line 2)) + Using cached virtualenv-13.1.2-py2.py3-none-any.whl +Collecting py>=1.4.17 (from tox->-r dev-requirements.txt (line 2)) + Using cached py-1.4.30-py2.py3-none-any.whl +Collecting pluggy<0.4.0,>=0.3.0 (from tox->-r dev-requirements.txt (line 2)) + Using cached pluggy-0.3.0-py2.py3-none-any.whl +Installing collected packages: nose, virtualenv, py, pluggy, tox, coverage, randomize +Successfully installed coverage-3.7.1 nose-1.3.7 pluggy-0.3.0 py-1.4.30 randomize-0.13 tox-2.1.1 virtualenv-13.1.2 diff --git a/samples/client/petstore/python/setup.py b/samples/client/petstore/python/setup.py index e66e9689343e..8564466b0dda 100644 --- a/samples/client/petstore/python/setup.py +++ b/samples/client/petstore/python/setup.py @@ -8,13 +8,11 @@ VERSION = "1.0.0" -# To install the library, open a Terminal shell, then run this -# file by typing: +# To install the library, run the following # # python setup.py install # -# You need to have the setuptools module installed. -# Try reading the setuptools documentation: +# prerequisite: setuptools # http://pypi.python.org/pypi/setuptools REQUIRES = ["urllib3 >= 1.10", "six >= 1.9", "certifi", "python-dateutil"] diff --git a/samples/client/petstore/python/swagger_client.egg-info/PKG-INFO b/samples/client/petstore/python/swagger_client.egg-info/PKG-INFO new file mode 100644 index 000000000000..d4fe6f978b3f --- /dev/null +++ b/samples/client/petstore/python/swagger_client.egg-info/PKG-INFO @@ -0,0 +1,12 @@ +Metadata-Version: 1.0 +Name: swagger-client +Version: 1.0.0 +Summary: Swagger Petstore +Home-page: UNKNOWN +Author: UNKNOWN +Author-email: apiteam@swagger.io +License: UNKNOWN +Description: This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + +Keywords: Swagger,Swagger Petstore +Platform: UNKNOWN diff --git a/samples/client/petstore/python/swagger_client.egg-info/SOURCES.txt b/samples/client/petstore/python/swagger_client.egg-info/SOURCES.txt new file mode 100644 index 000000000000..a7d91c0b8ce2 --- /dev/null +++ b/samples/client/petstore/python/swagger_client.egg-info/SOURCES.txt @@ -0,0 +1,29 @@ +setup.cfg +setup.py +swagger_client/__init__.py +swagger_client/api_client.py +swagger_client/configuration.py +swagger_client/rest.py +swagger_client.egg-info/PKG-INFO +swagger_client.egg-info/SOURCES.txt +swagger_client.egg-info/dependency_links.txt +swagger_client.egg-info/requires.txt +swagger_client.egg-info/top_level.txt +swagger_client/apis/__init__.py +swagger_client/apis/pet_api.py +swagger_client/apis/store_api.py +swagger_client/apis/user_api.py +swagger_client/models/__init__.py +swagger_client/models/category.py +swagger_client/models/order.py +swagger_client/models/pet.py +swagger_client/models/tag.py +swagger_client/models/user.py +tests/__init__.py +tests/test_api_client.py +tests/test_api_exception.py +tests/test_deserialization.py +tests/test_order_model.py +tests/test_pet_api.py +tests/test_pet_model.py +tests/test_store_api.py \ No newline at end of file diff --git a/samples/client/petstore/python/swagger_client.egg-info/dependency_links.txt b/samples/client/petstore/python/swagger_client.egg-info/dependency_links.txt new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/samples/client/petstore/python/swagger_client.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/samples/client/petstore/python/swagger_client.egg-info/requires.txt b/samples/client/petstore/python/swagger_client.egg-info/requires.txt new file mode 100644 index 000000000000..367a059209fe --- /dev/null +++ b/samples/client/petstore/python/swagger_client.egg-info/requires.txt @@ -0,0 +1,4 @@ +urllib3 >= 1.10 +six >= 1.9 +certifi +python-dateutil diff --git a/samples/client/petstore/python/swagger_client.egg-info/top_level.txt b/samples/client/petstore/python/swagger_client.egg-info/top_level.txt new file mode 100644 index 000000000000..9a02a75c0585 --- /dev/null +++ b/samples/client/petstore/python/swagger_client.egg-info/top_level.txt @@ -0,0 +1,2 @@ +swagger_client +tests diff --git a/samples/client/petstore/python/swagger_client/api_client.py b/samples/client/petstore/python/swagger_client/api_client.py index 02099f0ceb1e..33e8acb8ba16 100644 --- a/samples/client/petstore/python/swagger_client/api_client.py +++ b/samples/client/petstore/python/swagger_client/api_client.py @@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + ref: https://github.com/swagger-api/swagger-codegen """ from __future__ import absolute_import @@ -56,7 +58,7 @@ class ApiClient(object): templates. NOTE: This class is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen + Ref: https://github.com/swagger-api/swagger-codegen Do not edit the class manually. :param host: The base path for the server to call. @@ -75,7 +77,7 @@ class ApiClient(object): self.host = host self.cookie = cookie # Set default User-Agent. - self.user_agent = 'Python-Swagger' + self.user_agent = 'Python-Swagger/1.0.0' @property def user_agent(self): @@ -280,7 +282,8 @@ class ApiClient(object): body=None, post_params=None, files=None, response_type=None, auth_settings=None, callback=None): """ - Makes the HTTP request and return the deserialized data. + Makes the HTTP request (synchronous) and return the deserialized data. + To make an async request, define a function for callback. :param resource_path: Path to method endpoint. :param method: Method to call. @@ -450,9 +453,8 @@ class ApiClient(object): def __deserialize_file(self, response): """ - Saves response body into a file in (the defined) temporary folder, - using the filename from the `Content-Disposition` header if provided, - otherwise a random filename. + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. :param response: RESTResponse. :return: file path. diff --git a/samples/client/petstore/python/swagger_client/apis/pet_api.py b/samples/client/petstore/python/swagger_client/apis/pet_api.py index fa1db5801b6a..0dcdbc9ddae9 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -33,6 +33,7 @@ class PetApi(object): """ NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. + Ref: https://github.com/swagger-api/swagger-codegen """ def __init__(self, api_client=None): @@ -49,7 +50,7 @@ class PetApi(object): Update an existing pet - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -124,7 +125,7 @@ class PetApi(object): Add a new pet to the store - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -199,7 +200,7 @@ class PetApi(object): Finds Pets by status Multiple status values can be provided with comma seperated strings - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -274,7 +275,7 @@ class PetApi(object): Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -349,7 +350,7 @@ class PetApi(object): Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -427,7 +428,7 @@ class PetApi(object): Updates a pet in the store with form data - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -511,7 +512,7 @@ class PetApi(object): Deletes a pet - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -592,7 +593,7 @@ class PetApi(object): uploads an image - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): diff --git a/samples/client/petstore/python/swagger_client/apis/store_api.py b/samples/client/petstore/python/swagger_client/apis/store_api.py index 4dca0af85e2c..affb76f6c8b1 100644 --- a/samples/client/petstore/python/swagger_client/apis/store_api.py +++ b/samples/client/petstore/python/swagger_client/apis/store_api.py @@ -33,6 +33,7 @@ class StoreApi(object): """ NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. + Ref: https://github.com/swagger-api/swagger-codegen """ def __init__(self, api_client=None): @@ -49,7 +50,7 @@ class StoreApi(object): Returns pet inventories by status Returns a map of status codes to quantities - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -121,7 +122,7 @@ class StoreApi(object): Place an order for a pet - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -196,7 +197,7 @@ class StoreApi(object): Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -274,7 +275,7 @@ class StoreApi(object): Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): diff --git a/samples/client/petstore/python/swagger_client/apis/user_api.py b/samples/client/petstore/python/swagger_client/apis/user_api.py index 4897abe8801e..574379491ec0 100644 --- a/samples/client/petstore/python/swagger_client/apis/user_api.py +++ b/samples/client/petstore/python/swagger_client/apis/user_api.py @@ -33,6 +33,7 @@ class UserApi(object): """ NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. + Ref: https://github.com/swagger-api/swagger-codegen """ def __init__(self, api_client=None): @@ -49,7 +50,7 @@ class UserApi(object): Create user This can only be done by the logged in user. - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -124,7 +125,7 @@ class UserApi(object): Creates list of users with given input array - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -199,7 +200,7 @@ class UserApi(object): Creates list of users with given input array - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -274,7 +275,7 @@ class UserApi(object): Logs user into the system - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -352,7 +353,7 @@ class UserApi(object): Logs out current logged in user session - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -424,7 +425,7 @@ class UserApi(object): Get user by user name - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -502,7 +503,7 @@ class UserApi(object): Updated user This can only be done by the logged in user. - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): @@ -583,7 +584,7 @@ class UserApi(object): Delete user This can only be done by the logged in user. - This method makes a synchronous HTTP request by default.To make an + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): diff --git a/samples/client/petstore/python/swagger_client/configuration.py b/samples/client/petstore/python/swagger_client/configuration.py index 6bc58c90aea7..b253f561abe4 100644 --- a/samples/client/petstore/python/swagger_client/configuration.py +++ b/samples/client/petstore/python/swagger_client/configuration.py @@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + ref: https://github.com/swagger-api/swagger-codegen """ from __future__ import absolute_import @@ -44,7 +46,7 @@ def singleton(cls, *args, **kw): class Configuration(object): """ NOTE: This class is auto generated by the swagger code generator program. - https://github.com/swagger-api/swagger-codegen + Ref: https://github.com/swagger-api/swagger-codegen Do not edit the class manually. """ @@ -56,7 +58,7 @@ class Configuration(object): self.host = "http://petstore.swagger.io/v2" # Default api client self.api_client = None - # Temp file folder for download + # Temp file folder for downloading files self.temp_folder_path = None # Authentication Settings @@ -139,7 +141,7 @@ class Configuration(object): def get_basic_auth_token(self): """ - Gets basic auth header string. + Gets HTTP basic authentication header (string). :return: The token for basic HTTP authentication. """ diff --git a/samples/client/petstore/python/swagger_client/models/category.py b/samples/client/petstore/python/swagger_client/models/category.py index bf70a7d10fd5..06ad3b8421f2 100644 --- a/samples/client/petstore/python/swagger_client/models/category.py +++ b/samples/client/petstore/python/swagger_client/models/category.py @@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen """ from pprint import pformat @@ -27,7 +29,7 @@ class Category(object): """ def __init__(self): """ - Swagger model + Category - a model defined in Swagger :param dict swaggerTypes: The key is attribute name and the value is attribute type. @@ -93,7 +95,7 @@ class Category(object): def to_dict(self): """ - Return model properties dict + Returns the model properties as a dict """ result = {} @@ -113,7 +115,7 @@ class Category(object): def to_str(self): """ - Return model properties str + Returns the string representation of the model """ return pformat(self.to_dict()) diff --git a/samples/client/petstore/python/swagger_client/models/order.py b/samples/client/petstore/python/swagger_client/models/order.py index 1a7612df190f..40e4504de87b 100644 --- a/samples/client/petstore/python/swagger_client/models/order.py +++ b/samples/client/petstore/python/swagger_client/models/order.py @@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen """ from pprint import pformat @@ -27,7 +29,7 @@ class Order(object): """ def __init__(self): """ - Swagger model + Order - a model defined in Swagger :param dict swaggerTypes: The key is attribute name and the value is attribute type. @@ -199,7 +201,7 @@ class Order(object): def to_dict(self): """ - Return model properties dict + Returns the model properties as a dict """ result = {} @@ -219,7 +221,7 @@ class Order(object): def to_str(self): """ - Return model properties str + Returns the string representation of the model """ return pformat(self.to_dict()) diff --git a/samples/client/petstore/python/swagger_client/models/pet.py b/samples/client/petstore/python/swagger_client/models/pet.py index cda4fa1e8cdd..d8700908eb78 100644 --- a/samples/client/petstore/python/swagger_client/models/pet.py +++ b/samples/client/petstore/python/swagger_client/models/pet.py @@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen """ from pprint import pformat @@ -27,7 +29,7 @@ class Pet(object): """ def __init__(self): """ - Swagger model + Pet - a model defined in Swagger :param dict swaggerTypes: The key is attribute name and the value is attribute type. @@ -199,7 +201,7 @@ class Pet(object): def to_dict(self): """ - Return model properties dict + Returns the model properties as a dict """ result = {} @@ -219,7 +221,7 @@ class Pet(object): def to_str(self): """ - Return model properties str + Returns the string representation of the model """ return pformat(self.to_dict()) diff --git a/samples/client/petstore/python/swagger_client/models/tag.py b/samples/client/petstore/python/swagger_client/models/tag.py index 8108052aae30..262fc10f338c 100644 --- a/samples/client/petstore/python/swagger_client/models/tag.py +++ b/samples/client/petstore/python/swagger_client/models/tag.py @@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen """ from pprint import pformat @@ -27,7 +29,7 @@ class Tag(object): """ def __init__(self): """ - Swagger model + Tag - a model defined in Swagger :param dict swaggerTypes: The key is attribute name and the value is attribute type. @@ -93,7 +95,7 @@ class Tag(object): def to_dict(self): """ - Return model properties dict + Returns the model properties as a dict """ result = {} @@ -113,7 +115,7 @@ class Tag(object): def to_str(self): """ - Return model properties str + Returns the string representation of the model """ return pformat(self.to_dict()) diff --git a/samples/client/petstore/python/swagger_client/models/user.py b/samples/client/petstore/python/swagger_client/models/user.py index 576473adcfa5..7f74d20f3d37 100644 --- a/samples/client/petstore/python/swagger_client/models/user.py +++ b/samples/client/petstore/python/swagger_client/models/user.py @@ -14,6 +14,8 @@ Copyright 2015 SmartBear Software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen """ from pprint import pformat @@ -27,7 +29,7 @@ class User(object): """ def __init__(self): """ - Swagger model + User - a model defined in Swagger :param dict swaggerTypes: The key is attribute name and the value is attribute type. @@ -243,7 +245,7 @@ class User(object): def to_dict(self): """ - Return model properties dict + Returns the model properties as a dict """ result = {} @@ -263,7 +265,7 @@ class User(object): def to_str(self): """ - Return model properties str + Returns the string representation of the model """ return pformat(self.to_dict()) From 68f61d9a378b0ab99ba85adb682fe5e3ed7a803d Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 24 Aug 2015 21:11:52 +0800 Subject: [PATCH 080/109] use snake_case instead of under_score --- .../java/io/swagger/codegen/languages/PythonClientCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 179299f9c2e2..9b685d1e2070 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 @@ -61,7 +61,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig "return", "def", "for", "lambda", "try")); cliOptions.clear(); - cliOptions.add(new CliOption("packageName", "python package name (convention: under_score), default: swagger_client")); + cliOptions.add(new CliOption("packageName", "python package name (convention: snake_case), default: swagger_client")); cliOptions.add(new CliOption("packageVersion", "python package version, default: 1.0.0")); } From a43d2163a06b42f4dce4b505ba85a05e1259b52d Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 24 Aug 2015 21:53:28 +0800 Subject: [PATCH 081/109] add camelCase support for php variable naming --- .../codegen/languages/PhpClientCodegen.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index cd88d916e03b..5f6c48120cb8 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -24,6 +24,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { protected String packagePath = "SwaggerClient-php"; protected String artifactVersion = "1.0.0"; protected String srcBasePath = "lib"; + protected String variableNamingConvention= "snake_case"; public PhpClientCodegen() { super(); @@ -84,6 +85,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("object", "object"); typeMapping.put("DateTime", "\\DateTime"); + cliOptions.add(new CliOption("variableNamingConvention", "naming convention of variable name, e.g. camelCase. Default: snake_case")); cliOptions.add(new CliOption("invokerPackage", "The main namespace to use for all classes. e.g. Yay\\Pets")); cliOptions.add(new CliOption("packagePath", "The main package name for classes. e.g. GeneratedPetstore")); cliOptions.add(new CliOption("srcBasePath", "The directory under packagePath to serve as source root.")); @@ -279,6 +281,10 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { this.srcBasePath = srcBasePath; } + public void setParameterNamingConvention(String variableNamingConvention) { + this.variableNamingConvention = variableNamingConvention; + } + private void setComposerVendorName(String composerVendorName) { this.composerVendorName = composerVendorName; } @@ -289,9 +295,19 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public String toVarName(String name) { - // return the name in underscore style - // PhoneNumber => phone_number - name = underscore(name); + if (additionalProperties.containsKey("variableNamingConvention")) { + this.setParameterNamingConvention((String) additionalProperties.get("variableNamingConvention")); + } + + if ("camelCase".equals(variableNamingConvention)) { + // return the name in camelCase style + // phone_number => phoneNumber + name = camelize(name, true); + } else { // default to snake case + // return the name in underscore style + // PhoneNumber => phone_number + name = underscore(name); + } // parameter name starting with number won't compile // need to escape it by appending _ at the beginning From 52dc7e210c9b08033cc92b580ba74b32ff56ad2d Mon Sep 17 00:00:00 2001 From: ivanmartinvalle Date: Mon, 24 Aug 2015 18:29:01 -0500 Subject: [PATCH 082/109] Add status code and response headers of the last request to java and csharp templates per #990 --- .../main/resources/Java/ApiClient.mustache | 20 +++++++++++++++++++ .../main/resources/csharp/ApiClient.mustache | 20 +++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache index 1a0dc5bc3a73..5e18c854cba4 100644 --- a/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache @@ -49,6 +49,9 @@ public class ApiClient { private Map authentications; + private int statusCode; + private Map> responseHeaders; + private DateFormat dateFormat; public ApiClient() { @@ -80,6 +83,20 @@ public class ApiClient { return this; } + /** + * Gets the status code of the previous request + */ + public int getStatusCode() { + return statusCode; + } + + /** + * Gets the response headers of the previous request + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + /** * Get authentications (key: authentication name, value: authentication). */ @@ -494,6 +511,9 @@ public class ApiClient { ClientResponse response = getAPIResponse(path, method, queryParams, body, binaryBody, headerParams, formParams, accept, contentType, authNames); + statusCode = response.getStatusInfo().getStatusCode(); + responseHeaders = response.getHeaders(); + if(response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) { return null; } else if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) { diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache index c93537a740dc..b74ab56ea107 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache @@ -49,6 +49,16 @@ namespace {{packageName}}.Client { get { return _defaultHeaderMap; } } + + /// + /// Gets the status code of the previous request + /// + public int StatusCode { get; private set; } + + /// + /// Gets the response headers of the previous request + /// + public Dictionary ResponseHeaders { get; private set; } // Creates and sets up a RestRequest prior to a call. private RestRequest PrepareRequest( @@ -110,7 +120,10 @@ namespace {{packageName}}.Client { var request = PrepareRequest( path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - return (Object)RestClient.Execute(request); + var response = RestClient.Execute(request); + StatusCode = (int) response.StatusCode; + ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()); + return (Object) response; } /// @@ -133,7 +146,10 @@ namespace {{packageName}}.Client { var request = PrepareRequest( path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - return (Object) await RestClient.ExecuteTaskAsync(request); + var response = await RestClient.ExecuteTaskAsync(request); + StatusCode = (int)response.StatusCode; + ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()); + return (Object)response; } /// From 392e5172b53e6d3a0d5708d236ab2ddf5c7d1e8e Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Mon, 24 Aug 2015 17:26:26 -0700 Subject: [PATCH 083/109] changed default behavior for inflector to have unimplemented handlers --- .../main/resources/JavaInflector/api.mustache | 8 +++++++ .../io/swagger/handler/PetController.java | 24 ++++++++++++++++++- .../io/swagger/handler/StoreController.java | 16 ++++++++++++- .../io/swagger/handler/UserController.java | 24 ++++++++++++++++++- .../main/java/io/swagger/model/Category.java | 2 +- .../src/main/java/io/swagger/model/Order.java | 2 +- .../src/main/java/io/swagger/model/Pet.java | 2 +- .../src/main/java/io/swagger/model/Tag.java | 2 +- .../src/main/java/io/swagger/model/User.java | 2 +- 9 files changed, 74 insertions(+), 8 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache index fb80b011e547..74e688ee23e0 100644 --- a/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/api.mustache @@ -16,10 +16,18 @@ import {{modelPackage}}.*; {{>generatedAnnotation}} {{#operations}} public class {{classname}} { + /** + * Uncomment and implement as you see fit. These operations will map + * Direclty to operation calls from the routing logic. Because the inflector + * Code allows you to implement logic incrementally, they are disabled. + **/ + {{#operation}} + /* public ResponseContext {{nickname}}(RequestContext request {{#allParams}}, {{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{/allParams}}) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ {{/operation}} } diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java index 5535d2cc8f04..9f31acf53da9 100644 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/PetController.java @@ -13,39 +13,61 @@ import io.swagger.model.*; import io.swagger.model.Pet; import java.io.File; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T17:25:49.737-07:00") public class PetController { + /** + * Uncomment and implement as you see fit. These operations will map + * Direclty to operation calls from the routing logic. Because the inflector + * Code allows you to implement logic incrementally, they are disabled. + **/ + + /* public ResponseContext updatePet(RequestContext request , Pet body) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext addPet(RequestContext request , Pet body) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext findPetsByStatus(RequestContext request , List status) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext findPetsByTags(RequestContext request , List tags) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext getPetById(RequestContext request , Long petId) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext updatePetWithForm(RequestContext request , String petId, String name, String status) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext deletePet(RequestContext request , Long petId, String apiKey) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext uploadFile(RequestContext request , Long petId, String additionalMetadata, FormDataContentDisposition fileDetail) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ } diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java index 140864aa9270..3506b6b920c6 100644 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/StoreController.java @@ -13,23 +13,37 @@ import io.swagger.model.*; import java.util.Map; import io.swagger.model.Order; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T17:25:49.737-07:00") public class StoreController { + /** + * Uncomment and implement as you see fit. These operations will map + * Direclty to operation calls from the routing logic. Because the inflector + * Code allows you to implement logic incrementally, they are disabled. + **/ + + /* public ResponseContext getInventory(RequestContext request ) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext placeOrder(RequestContext request , Order body) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext getOrderById(RequestContext request , String orderId) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext deleteOrder(RequestContext request , String orderId) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ } diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java index 9cb041fcaa8c..3ca4fa0e3941 100644 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/handler/UserController.java @@ -13,39 +13,61 @@ import io.swagger.model.*; import io.swagger.model.User; import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T17:25:49.737-07:00") public class UserController { + /** + * Uncomment and implement as you see fit. These operations will map + * Direclty to operation calls from the routing logic. Because the inflector + * Code allows you to implement logic incrementally, they are disabled. + **/ + + /* public ResponseContext createUser(RequestContext request , User body) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext createUsersWithArrayInput(RequestContext request , List body) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext createUsersWithListInput(RequestContext request , List body) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext loginUser(RequestContext request , String username, String password) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext logoutUser(RequestContext request ) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext getUserByName(RequestContext request , String username) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext updateUser(RequestContext request , String username, User body) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ + /* public ResponseContext deleteUser(RequestContext request , String username) { return new ResponseContext().status(Status.INTERNAL_SERVER_ERROR).entity( "Not implemented" ); } + */ } diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java index 1ae10af53312..03a37fef5b09 100644 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Category.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T17:25:49.737-07:00") public class Category { private Long id = null; diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java index d063c3117925..de3a2f8b9eb7 100644 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Order.java @@ -7,7 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T17:25:49.737-07:00") public class Order { private Long id = null; diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java index 669f258f1c7b..eb81026f6012 100644 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Pet.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T17:25:49.737-07:00") public class Pet { private Long id = null; diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java index 8d56f9938ae4..8c8f2597461d 100644 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/Tag.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T17:25:49.737-07:00") public class Tag { private Long id = null; diff --git a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java index ec9a66770306..be5261cdb70e 100644 --- a/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java +++ b/samples/server/petstore/java-inflector/src/main/java/io/swagger/model/User.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T00:32:07.279-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaInflectorServerCodegen", date = "2015-08-24T17:25:49.737-07:00") public class User { private Long id = null; From ab5483cd0478f77b7654e77dc0621edc613b4c42 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Tue, 25 Aug 2015 09:40:53 +0800 Subject: [PATCH 084/109] Add test cases for sanitizeForSerialization method in objc client. --- .../Tests/SWGApiClientTest.m | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m index d19180dc008e..547aff2fe1d9 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m +++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m @@ -1,7 +1,12 @@ #import #import +#import #import #import +#import +#import +#import +#import @interface SWGApiClientTest : XCTestCase @@ -98,4 +103,74 @@ XCTAssertEqualObjects(basicAuthCredentials, [config getBasicAuthToken]); } +- (void)testSanitizeForDeserialization { + id result; + id data; + + // nil + data = nil; + result = [self.apiClient sanitizeForSerialization:data]; + XCTAssertEqualObjects(result, data); + + // NSString + data = @"test string"; + result = [self.apiClient sanitizeForSerialization:data]; + XCTAssertEqualObjects(result, data); + + // NSNumber + data = @1; + result = [self.apiClient sanitizeForSerialization:data]; + XCTAssertEqualObjects(result, data); + + // SWGQueryParamCollection + data = [[SWGQueryParamCollection alloc] init]; + result = [self.apiClient sanitizeForSerialization:data]; + XCTAssertEqualObjects(result, data); + + // NSDate + data = [NSDate dateWithISO8601String:@"1997-07-16T19:20:30.45+01:0"]; + result = [self.apiClient sanitizeForSerialization:data]; + XCTAssertEqualObjects(result, [data ISO8601String]); + + // model + data = [self createPet]; + result = [self.apiClient sanitizeForSerialization:data]; + XCTAssertEqualObjects(result, [data toDictionary]); + + // NSArray + data = @[@1]; + result = [self.apiClient sanitizeForSerialization:data]; + XCTAssertEqualObjects(result, data); + + // NSDictionary + data = @{@"test key": @"test value"}; + result = [self.apiClient sanitizeForSerialization:data]; + XCTAssertEqualObjects(result, data); +} + +- (SWGPet*) createPet { + SWGPet * pet = [[SWGPet alloc] init]; + pet._id = [[NSNumber alloc] initWithLong:[[NSDate date] timeIntervalSince1970]]; + pet.name = @"monkey"; + + SWGCategory * category = [[SWGCategory alloc] init]; + category._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; + category.name = @"super-happy"; + pet.category = category; + + SWGTag *tag1 = [[SWGTag alloc] init]; + tag1._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; + tag1.name = @"test tag 1"; + SWGTag *tag2 = [[SWGTag alloc] init]; + tag2._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; + tag2.name = @"test tag 2"; + pet.tags = (NSArray *)[[NSArray alloc] initWithObjects:tag1, tag2, nil]; + + pet.status = @"available"; + + NSArray * photos = [[NSArray alloc] initWithObjects:@"http://foo.bar.com/3", @"http://foo.bar.com/4", nil]; + pet.photoUrls = photos; + return pet; +} + @end From eb21963fa5bdb0afb1f3281776fc74e0e9fe20d0 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Tue, 25 Aug 2015 10:51:03 +0800 Subject: [PATCH 085/109] Update test case testSanitizeForSerialization in objc client. --- .../Tests/SWGApiClientTest.m | 43 ++++++------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m index 547aff2fe1d9..3e13f618c29c 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m +++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m @@ -103,7 +103,7 @@ XCTAssertEqualObjects(basicAuthCredentials, [config getBasicAuthToken]); } -- (void)testSanitizeForDeserialization { +- (void)testSanitizeForSerialization { id result; id data; @@ -128,14 +128,24 @@ XCTAssertEqualObjects(result, data); // NSDate - data = [NSDate dateWithISO8601String:@"1997-07-16T19:20:30.45+01:0"]; + data = [NSDate dateWithISO8601String:@"1997-07-16T19:20:30.45+01:00"]; + result = [self.apiClient sanitizeForSerialization:data]; + XCTAssertEqualObjects(result, [data ISO8601String]); + + data = [NSDate dateWithISO8601String:@"1997-07-16"]; result = [self.apiClient sanitizeForSerialization:data]; XCTAssertEqualObjects(result, [data ISO8601String]); // model - data = [self createPet]; + NSDictionary *petDict = @{@"id": @1, @"name": @"monkey", + @"category": @{@"id": @1, @"name": @"test category"}, + @"tags": @[@{@"id": @1, @"name": @"test tag1"}, + @{@"id": @2, @"name": @"test tag2"}], + @"status": @"available", + @"photoUrls": @[@"http://foo.bar.com/3", @"http://foo.bar.com/4"]}; + data = [[SWGPet alloc] initWithDictionary:petDict error:nil]; result = [self.apiClient sanitizeForSerialization:data]; - XCTAssertEqualObjects(result, [data toDictionary]); + XCTAssertEqualObjects(result, petDict); // NSArray data = @[@1]; @@ -148,29 +158,4 @@ XCTAssertEqualObjects(result, data); } -- (SWGPet*) createPet { - SWGPet * pet = [[SWGPet alloc] init]; - pet._id = [[NSNumber alloc] initWithLong:[[NSDate date] timeIntervalSince1970]]; - pet.name = @"monkey"; - - SWGCategory * category = [[SWGCategory alloc] init]; - category._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; - category.name = @"super-happy"; - pet.category = category; - - SWGTag *tag1 = [[SWGTag alloc] init]; - tag1._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; - tag1.name = @"test tag 1"; - SWGTag *tag2 = [[SWGTag alloc] init]; - tag2._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; - tag2.name = @"test tag 2"; - pet.tags = (NSArray *)[[NSArray alloc] initWithObjects:tag1, tag2, nil]; - - pet.status = @"available"; - - NSArray * photos = [[NSArray alloc] initWithObjects:@"http://foo.bar.com/3", @"http://foo.bar.com/4", nil]; - pet.photoUrls = photos; - return pet; -} - @end From 1b2f491b0ea61ec9aca327dcbe5a4d0758569459 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Tue, 25 Aug 2015 11:16:19 +0800 Subject: [PATCH 086/109] Add tese case for sanitizing array of models in objc client. --- .../objc/SwaggerClientTests/Tests/SWGApiClientTest.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m index 3e13f618c29c..e9f1a46af3ba 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m +++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m @@ -152,6 +152,12 @@ result = [self.apiClient sanitizeForSerialization:data]; XCTAssertEqualObjects(result, data); + // NSArray of models + NSArray *arrayOfPetDict = @[petDict]; + data = [NSArray arrayWithObject:[[SWGPet alloc] initWithDictionary:petDict error:nil]]; + result = [self.apiClient sanitizeForSerialization:data]; + XCTAssertEqualObjects(result, arrayOfPetDict); + // NSDictionary data = @{@"test key": @"test value"}; result = [self.apiClient sanitizeForSerialization:data]; From 568b7a4fcddfffd8d863b031b6a5b0ad831108ab Mon Sep 17 00:00:00 2001 From: geekerzp Date: Tue, 25 Aug 2015 15:04:46 +0800 Subject: [PATCH 087/109] Add test cases for sanitize_for_serialization method in python client. --- .../petstore/python/tests/test_api_client.py | 87 +++++++++++++++++-- 1 file changed, 82 insertions(+), 5 deletions(-) diff --git a/samples/client/petstore/python/tests/test_api_client.py b/samples/client/petstore/python/tests/test_api_client.py index 903fde458152..61c57cb7e460 100644 --- a/samples/client/petstore/python/tests/test_api_client.py +++ b/samples/client/petstore/python/tests/test_api_client.py @@ -10,6 +10,7 @@ $ nosetests -v import os import time import unittest +from dateutil.parser import parse import swagger_client import swagger_client.configuration @@ -51,7 +52,7 @@ class ApiClientTests(unittest.TestCase): accepts = ['APPLICATION/JSON', 'APPLICATION/XML'] accept = self.api_client.select_header_accept(accepts) self.assertEqual(accept, 'application/json') - + accepts = ['application/json', 'application/xml'] accept = self.api_client.select_header_accept(accepts) self.assertEqual(accept, 'application/json') @@ -72,19 +73,95 @@ class ApiClientTests(unittest.TestCase): content_types = ['APPLICATION/JSON', 'APPLICATION/XML'] content_type = self.api_client.select_header_content_type(content_types) self.assertEqual(content_type, 'application/json') - + content_types = ['application/json', 'application/xml'] content_type = self.api_client.select_header_content_type(content_types) self.assertEqual(content_type, 'application/json') - + content_types = ['application/xml', 'application/json'] content_type = self.api_client.select_header_content_type(content_types) self.assertEqual(content_type, 'application/json') - + content_types = ['text/plain', 'application/xml'] content_type = self.api_client.select_header_content_type(content_types) self.assertEqual(content_type, 'text/plain') - + content_types = [] content_type = self.api_client.select_header_content_type(content_types) self.assertEqual(content_type, 'application/json') + + def test_sanitize_for_serialization(self): + # None + data = None + result = self.api_client.sanitize_for_serialization(None) + self.assertEqual(result, data) + + # str + data = "test string" + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # int + data = 1 + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # bool + data = True + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # date + data = parse("1997-07-16").date() # date + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, "1997-07-16") + + # datetime + data = parse("1997-07-16T19:20:30.45+01:00") # datetime + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, "1997-07-16T19:20:30.450000+01:00") + + # list + data = [1] + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # dict + data = {"test key": "test value"} + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, data) + + # model + pet_dict = {"id": 1, "name": "monkey", + "category": {"id": 1, "name": "test category"}, + "tags": [{"id": 1, "name": "test tag1"}, + {"id": 2, "name": "test tag2"}], + "status": "available", + "photoUrls": ["http://foo.bar.com/3", + "http://foo.bar.com/4"]} + pet = swagger_client.Pet() + pet.id = pet_dict["id"] + pet.name = pet_dict["name"] + cate = swagger_client.Category() + cate.id = pet_dict["category"]["id"] + cate.name = pet_dict["category"]["name"] + pet.category = cate + tag1 = swagger_client.Tag() + tag1.id = pet_dict["tags"][0]["id"] + tag1.name = pet_dict["tags"][0]["name"] + tag2 = swagger_client.Tag() + tag2.id = pet_dict["tags"][1]["id"] + tag2.name = pet_dict["tags"][1]["name"] + pet.tags = [tag1, tag2] + pet.status = pet_dict["status"] + pet.photo_urls = pet_dict["photoUrls"] + + data = pet + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, pet_dict) + + # list of models + list_of_pet_dict = [pet_dict] + data = [pet] + result = self.api_client.sanitize_for_serialization(data) + self.assertEqual(result, list_of_pet_dict) From 570a595ffbd3f3c23cc274a3ac36327270c394c3 Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 25 Aug 2015 15:35:22 +0800 Subject: [PATCH 088/109] fix invokerPackage with packageName in compile.mustache --- .../swagger-codegen/src/main/resources/csharp/compile.mustache | 2 +- .../csharp/SwaggerClientTest/Lib/SwaggerClient/compile.bat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/csharp/compile.mustache b/modules/swagger-codegen/src/main/resources/csharp/compile.mustache index ed4481bb4bbe..e35879e0efa1 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/compile.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/compile.mustache @@ -1,3 +1,3 @@ SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319 -%CSCPATH%\csc /reference:bin/Newtonsoft.Json.dll;bin/RestSharp.dll /target:library /out:bin/{{invokerPackage}}.dll /recurse:src\*.cs /doc:bin/{{invokerPackage}}.xml +%CSCPATH%\csc /reference:bin/Newtonsoft.Json.dll;bin/RestSharp.dll /target:library /out:bin/{{packageName}}.dll /recurse:src\*.cs /doc:bin/{{packageName}}.xml diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile.bat b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile.bat index bb6ae8097eac..909633566901 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile.bat +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile.bat @@ -1,3 +1,3 @@ SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319 -%CSCPATH%\csc /reference:bin/Newtonsoft.Json.dll;bin/RestSharp.dll /target:library /out:bin/.dll /recurse:src\*.cs /doc:bin/.xml +%CSCPATH%\csc /reference:bin/Newtonsoft.Json.dll;bin/RestSharp.dll /target:library /out:bin/IO.Swagger.dll /recurse:src\*.cs /doc:bin/IO.Swagger.xml From b3d28f07f1ed6fe4f879ed78a9207272513ddbe7 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Tue, 25 Aug 2015 17:58:14 +0800 Subject: [PATCH 089/109] Add option `verify_ssl` to switch SSL/TLS verification. --- .../src/main/resources/python/api.mustache | 2 +- .../main/resources/python/api_client.mustache | 51 +++--- .../resources/python/configuration.mustache | 6 + .../src/main/resources/python/rest.mustache | 149 +++++++----------- .../python/swagger_client/api_client.py | 51 +++--- .../python/swagger_client/apis/pet_api.py | 2 +- .../python/swagger_client/apis/store_api.py | 2 +- .../python/swagger_client/apis/user_api.py | 2 +- .../python/swagger_client/configuration.py | 6 + .../petstore/python/swagger_client/rest.py | 149 +++++++----------- 10 files changed, 180 insertions(+), 240 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/python/api.mustache b/modules/swagger-codegen/src/main/resources/python/api.mustache index f85d5962c974..b076fa5d3ea3 100644 --- a/modules/swagger-codegen/src/main/resources/python/api.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api.mustache @@ -43,7 +43,7 @@ class {{classname}}(object): self.api_client = api_client else: if not config.api_client: - config.api_client = ApiClient('{{basePath}}') + config.api_client = ApiClient() self.api_client = config.api_client {{#operation}} diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index 72b2f049854f..1becd5547dd5 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -20,7 +20,7 @@ Copyright 2015 SmartBear Software from __future__ import absolute_import from . import models -from .rest import RESTClient +from .rest import RESTClientObject from .rest import ApiException import os @@ -71,6 +71,7 @@ class ApiClient(object): """ Constructor of the class. """ + self.rest_client = RESTClientObject() self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value @@ -330,35 +331,35 @@ class ApiClient(object): Makes the HTTP request using RESTClient. """ if method == "GET": - return RESTClient.GET(url, - query_params=query_params, - headers=headers) + return self.rest_client.GET(url, + query_params=query_params, + headers=headers) elif method == "HEAD": - return RESTClient.HEAD(url, - query_params=query_params, - headers=headers) + return self.rest_client.HEAD(url, + query_params=query_params, + headers=headers) elif method == "POST": - return RESTClient.POST(url, - query_params=query_params, - headers=headers, - post_params=post_params, - body=body) + return self.rest_client.POST(url, + query_params=query_params, + headers=headers, + post_params=post_params, + body=body) elif method == "PUT": - return RESTClient.PUT(url, - query_params=query_params, - headers=headers, - post_params=post_params, - body=body) + return self.rest_client.PUT(url, + query_params=query_params, + headers=headers, + post_params=post_params, + body=body) elif method == "PATCH": - return RESTClient.PATCH(url, - query_params=query_params, - headers=headers, - post_params=post_params, - body=body) + return self.rest_client.PATCH(url, + query_params=query_params, + headers=headers, + post_params=post_params, + body=body) elif method == "DELETE": - return RESTClient.DELETE(url, - query_params=query_params, - headers=headers) + return self.rest_client.DELETE(url, + query_params=query_params, + headers=headers) else: raise ValueError( "http method must be `GET`, `HEAD`," diff --git a/modules/swagger-codegen/src/main/resources/python/configuration.mustache b/modules/swagger-codegen/src/main/resources/python/configuration.mustache index b8ec002c44d2..07625c67e484 100644 --- a/modules/swagger-codegen/src/main/resources/python/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/python/configuration.mustache @@ -79,6 +79,12 @@ class Configuration(object): self.__debug = False self.init_logger() + # SSL/TLS verification + # Set this to false to skip verifying SSL certificate when calling API from https server. + self.verify_ssl = True + # Set this to customize the certificate file to verify the peer. + self.ssl_ca_cert = None + def init_logger(self): """ Initializes logger settings. diff --git a/modules/swagger-codegen/src/main/resources/python/rest.mustache b/modules/swagger-codegen/src/main/resources/python/rest.mustache index f9f85f294dc1..1481cbff3d52 100644 --- a/modules/swagger-codegen/src/main/resources/python/rest.mustache +++ b/modules/swagger-codegen/src/main/resources/python/rest.mustache @@ -18,6 +18,7 @@ Copyright 2015 SmartBear Software Credit: this file (rest.py) is modified based on rest.py in Dropbox Python SDK: https://www.dropbox.com/developers/core/sdks/python """ +from __future__ import absolute_import import sys import io @@ -29,6 +30,8 @@ import logging # python 2 and python 3 compatibility library from six import iteritems +from .configuration import Configuration + try: import urllib3 except ImportError: @@ -69,31 +72,24 @@ class RESTResponse(io.IOBase): class RESTClientObject(object): def __init__(self, pools_size=4): - # http pool manager - self.pool_manager = urllib3.PoolManager( - num_pools=pools_size - ) + if Configuration().verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + if Configuration().ssl_ca_cert: + ca_certs = Configuration().ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() # https pool manager - # certificates validated using Mozilla’s root certificates - self.ssl_pool_manager = urllib3.PoolManager( + self.pool_manager = urllib3.PoolManager( num_pools=pools_size, - cert_reqs=ssl.CERT_REQUIRED, - ca_certs=certifi.where() + cert_reqs=cert_reqs, + ca_certs=ca_certs ) - def agent(self, url): - """ - Use `urllib3.util.parse_url` for backward compatibility. - Return proper pool manager for the http/https schemes. - """ - url = urllib3.util.parse_url(url) - scheme = url.scheme - if scheme == 'https': - return self.ssl_pool_manager - else: - return self.pool_manager - def request(self, method, url, query_params=None, headers=None, body=None, post_params=None): """ @@ -120,32 +116,37 @@ class RESTClientObject(object): if 'Content-Type' not in headers: headers['Content-Type'] = 'application/json' - # For `POST`, `PUT`, `PATCH` - if method in ['POST', 'PUT', 'PATCH']: - if query_params: - url += '?' + urlencode(query_params) - if headers['Content-Type'] == 'application/json': - r = self.agent(url).request(method, url, - body=json.dumps(body), - headers=headers) - if headers['Content-Type'] == 'application/x-www-form-urlencoded': - r = self.agent(url).request(method, url, - fields=post_params, - encode_multipart=False, - headers=headers) - if headers['Content-Type'] == 'multipart/form-data': - # must del headers['Content-Type'], or the correct Content-Type - # which generated by urllib3 will be overwritten. - del headers['Content-Type'] - r = self.agent(url).request(method, url, - fields=post_params, - encode_multipart=True, - headers=headers) - # For `GET`, `HEAD`, `DELETE` - else: - r = self.agent(url).request(method, url, - fields=query_params, - headers=headers) + try: + # For `POST`, `PUT`, `PATCH` + if method in ['POST', 'PUT', 'PATCH']: + if query_params: + url += '?' + urlencode(query_params) + if headers['Content-Type'] == 'application/json': + r = self.pool_manager.request(method, url, + body=json.dumps(body), + headers=headers) + if headers['Content-Type'] == 'application/x-www-form-urlencoded': + r = self.pool_manager.request(method, url, + fields=post_params, + encode_multipart=False, + headers=headers) + if headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct Content-Type + # which generated by urllib3 will be overwritten. + del headers['Content-Type'] + r = self.pool_manager.request(method, url, + fields=post_params, + encode_multipart=True, + headers=headers) + # For `GET`, `HEAD`, `DELETE` + else: + r = self.pool_manager.request(method, url, + fields=query_params, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + r = RESTResponse(r) # In the python 3, the response.data is bytes. @@ -227,58 +228,20 @@ class ApiException(Exception): return error_message -class RESTClient(object): - """ - A class with all class methods to perform JSON requests. - """ - IMPL = RESTClientObject() - @classmethod - def request(cls, *n, **kw): - """ - Perform a REST request and parse the response. - """ - return cls.IMPL.request(*n, **kw) - @classmethod - def GET(cls, *n, **kw): - """ - Perform a GET request using `RESTClient.request()`. - """ - return cls.IMPL.GET(*n, **kw) - @classmethod - def HEAD(cls, *n, **kw): - """ - Perform a HEAD request using `RESTClient.request()`. - """ - return cls.IMPL.GET(*n, **kw) - @classmethod - def POST(cls, *n, **kw): - """ - Perform a POST request using `RESTClient.request()` - """ - return cls.IMPL.POST(*n, **kw) - @classmethod - def PUT(cls, *n, **kw): - """ - Perform a PUT request using `RESTClient.request()` - """ - return cls.IMPL.PUT(*n, **kw) - @classmethod - def PATCH(cls, *n, **kw): - """ - Perform a PATCH request using `RESTClient.request()` - """ - return cls.IMPL.PATCH(*n, **kw) - @classmethod - def DELETE(cls, *n, **kw): - """ - Perform a DELETE request using `RESTClient.request()` - """ - return cls.IMPL.DELETE(*n, **kw) + + + + + + + + + diff --git a/samples/client/petstore/python/swagger_client/api_client.py b/samples/client/petstore/python/swagger_client/api_client.py index 33e8acb8ba16..1030bf9a8385 100644 --- a/samples/client/petstore/python/swagger_client/api_client.py +++ b/samples/client/petstore/python/swagger_client/api_client.py @@ -20,7 +20,7 @@ Copyright 2015 SmartBear Software from __future__ import absolute_import from . import models -from .rest import RESTClient +from .rest import RESTClientObject from .rest import ApiException import os @@ -71,6 +71,7 @@ class ApiClient(object): """ Constructor of the class. """ + self.rest_client = RESTClientObject() self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value @@ -330,35 +331,35 @@ class ApiClient(object): Makes the HTTP request using RESTClient. """ if method == "GET": - return RESTClient.GET(url, - query_params=query_params, - headers=headers) + return self.rest_client.GET(url, + query_params=query_params, + headers=headers) elif method == "HEAD": - return RESTClient.HEAD(url, - query_params=query_params, - headers=headers) + return self.rest_client.HEAD(url, + query_params=query_params, + headers=headers) elif method == "POST": - return RESTClient.POST(url, - query_params=query_params, - headers=headers, - post_params=post_params, - body=body) + return self.rest_client.POST(url, + query_params=query_params, + headers=headers, + post_params=post_params, + body=body) elif method == "PUT": - return RESTClient.PUT(url, - query_params=query_params, - headers=headers, - post_params=post_params, - body=body) + return self.rest_client.PUT(url, + query_params=query_params, + headers=headers, + post_params=post_params, + body=body) elif method == "PATCH": - return RESTClient.PATCH(url, - query_params=query_params, - headers=headers, - post_params=post_params, - body=body) + return self.rest_client.PATCH(url, + query_params=query_params, + headers=headers, + post_params=post_params, + body=body) elif method == "DELETE": - return RESTClient.DELETE(url, - query_params=query_params, - headers=headers) + return self.rest_client.DELETE(url, + query_params=query_params, + headers=headers) else: raise ValueError( "http method must be `GET`, `HEAD`," diff --git a/samples/client/petstore/python/swagger_client/apis/pet_api.py b/samples/client/petstore/python/swagger_client/apis/pet_api.py index 0dcdbc9ddae9..b162cc534c38 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -42,7 +42,7 @@ class PetApi(object): self.api_client = api_client else: if not config.api_client: - config.api_client = ApiClient('http://petstore.swagger.io/v2') + config.api_client = ApiClient() self.api_client = config.api_client def update_pet(self, **kwargs): diff --git a/samples/client/petstore/python/swagger_client/apis/store_api.py b/samples/client/petstore/python/swagger_client/apis/store_api.py index affb76f6c8b1..9e08a0b2f473 100644 --- a/samples/client/petstore/python/swagger_client/apis/store_api.py +++ b/samples/client/petstore/python/swagger_client/apis/store_api.py @@ -42,7 +42,7 @@ class StoreApi(object): self.api_client = api_client else: if not config.api_client: - config.api_client = ApiClient('http://petstore.swagger.io/v2') + config.api_client = ApiClient() self.api_client = config.api_client def get_inventory(self, **kwargs): diff --git a/samples/client/petstore/python/swagger_client/apis/user_api.py b/samples/client/petstore/python/swagger_client/apis/user_api.py index 574379491ec0..1c96e1e923ee 100644 --- a/samples/client/petstore/python/swagger_client/apis/user_api.py +++ b/samples/client/petstore/python/swagger_client/apis/user_api.py @@ -42,7 +42,7 @@ class UserApi(object): self.api_client = api_client else: if not config.api_client: - config.api_client = ApiClient('http://petstore.swagger.io/v2') + config.api_client = ApiClient() self.api_client = config.api_client def create_user(self, **kwargs): diff --git a/samples/client/petstore/python/swagger_client/configuration.py b/samples/client/petstore/python/swagger_client/configuration.py index b253f561abe4..4ca9342c0571 100644 --- a/samples/client/petstore/python/swagger_client/configuration.py +++ b/samples/client/petstore/python/swagger_client/configuration.py @@ -79,6 +79,12 @@ class Configuration(object): self.__debug = False self.init_logger() + # SSL/TLS verification + # Set this to false to skip verifying SSL certificate when calling API from https server. + self.verify_ssl = True + # Set this to customize the certificate file to verify the peer. + self.ssl_ca_cert = None + def init_logger(self): """ Initializes logger settings. diff --git a/samples/client/petstore/python/swagger_client/rest.py b/samples/client/petstore/python/swagger_client/rest.py index f9f85f294dc1..1481cbff3d52 100644 --- a/samples/client/petstore/python/swagger_client/rest.py +++ b/samples/client/petstore/python/swagger_client/rest.py @@ -18,6 +18,7 @@ Copyright 2015 SmartBear Software Credit: this file (rest.py) is modified based on rest.py in Dropbox Python SDK: https://www.dropbox.com/developers/core/sdks/python """ +from __future__ import absolute_import import sys import io @@ -29,6 +30,8 @@ import logging # python 2 and python 3 compatibility library from six import iteritems +from .configuration import Configuration + try: import urllib3 except ImportError: @@ -69,31 +72,24 @@ class RESTResponse(io.IOBase): class RESTClientObject(object): def __init__(self, pools_size=4): - # http pool manager - self.pool_manager = urllib3.PoolManager( - num_pools=pools_size - ) + if Configuration().verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + if Configuration().ssl_ca_cert: + ca_certs = Configuration().ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() # https pool manager - # certificates validated using Mozilla’s root certificates - self.ssl_pool_manager = urllib3.PoolManager( + self.pool_manager = urllib3.PoolManager( num_pools=pools_size, - cert_reqs=ssl.CERT_REQUIRED, - ca_certs=certifi.where() + cert_reqs=cert_reqs, + ca_certs=ca_certs ) - def agent(self, url): - """ - Use `urllib3.util.parse_url` for backward compatibility. - Return proper pool manager for the http/https schemes. - """ - url = urllib3.util.parse_url(url) - scheme = url.scheme - if scheme == 'https': - return self.ssl_pool_manager - else: - return self.pool_manager - def request(self, method, url, query_params=None, headers=None, body=None, post_params=None): """ @@ -120,32 +116,37 @@ class RESTClientObject(object): if 'Content-Type' not in headers: headers['Content-Type'] = 'application/json' - # For `POST`, `PUT`, `PATCH` - if method in ['POST', 'PUT', 'PATCH']: - if query_params: - url += '?' + urlencode(query_params) - if headers['Content-Type'] == 'application/json': - r = self.agent(url).request(method, url, - body=json.dumps(body), - headers=headers) - if headers['Content-Type'] == 'application/x-www-form-urlencoded': - r = self.agent(url).request(method, url, - fields=post_params, - encode_multipart=False, - headers=headers) - if headers['Content-Type'] == 'multipart/form-data': - # must del headers['Content-Type'], or the correct Content-Type - # which generated by urllib3 will be overwritten. - del headers['Content-Type'] - r = self.agent(url).request(method, url, - fields=post_params, - encode_multipart=True, - headers=headers) - # For `GET`, `HEAD`, `DELETE` - else: - r = self.agent(url).request(method, url, - fields=query_params, - headers=headers) + try: + # For `POST`, `PUT`, `PATCH` + if method in ['POST', 'PUT', 'PATCH']: + if query_params: + url += '?' + urlencode(query_params) + if headers['Content-Type'] == 'application/json': + r = self.pool_manager.request(method, url, + body=json.dumps(body), + headers=headers) + if headers['Content-Type'] == 'application/x-www-form-urlencoded': + r = self.pool_manager.request(method, url, + fields=post_params, + encode_multipart=False, + headers=headers) + if headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct Content-Type + # which generated by urllib3 will be overwritten. + del headers['Content-Type'] + r = self.pool_manager.request(method, url, + fields=post_params, + encode_multipart=True, + headers=headers) + # For `GET`, `HEAD`, `DELETE` + else: + r = self.pool_manager.request(method, url, + fields=query_params, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + r = RESTResponse(r) # In the python 3, the response.data is bytes. @@ -227,58 +228,20 @@ class ApiException(Exception): return error_message -class RESTClient(object): - """ - A class with all class methods to perform JSON requests. - """ - IMPL = RESTClientObject() - @classmethod - def request(cls, *n, **kw): - """ - Perform a REST request and parse the response. - """ - return cls.IMPL.request(*n, **kw) - @classmethod - def GET(cls, *n, **kw): - """ - Perform a GET request using `RESTClient.request()`. - """ - return cls.IMPL.GET(*n, **kw) - @classmethod - def HEAD(cls, *n, **kw): - """ - Perform a HEAD request using `RESTClient.request()`. - """ - return cls.IMPL.GET(*n, **kw) - @classmethod - def POST(cls, *n, **kw): - """ - Perform a POST request using `RESTClient.request()` - """ - return cls.IMPL.POST(*n, **kw) - @classmethod - def PUT(cls, *n, **kw): - """ - Perform a PUT request using `RESTClient.request()` - """ - return cls.IMPL.PUT(*n, **kw) - @classmethod - def PATCH(cls, *n, **kw): - """ - Perform a PATCH request using `RESTClient.request()` - """ - return cls.IMPL.PATCH(*n, **kw) - @classmethod - def DELETE(cls, *n, **kw): - """ - Perform a DELETE request using `RESTClient.request()` - """ - return cls.IMPL.DELETE(*n, **kw) + + + + + + + + + From d434b7c440206735bac71f41d17f11715405555f Mon Sep 17 00:00:00 2001 From: Hugo Wood Date: Fri, 21 Aug 2015 17:39:40 +0200 Subject: [PATCH 090/109] fix invalid JSON being generated in swagger.json of Node.js server --- .../codegen/languages/NodeJSServerCodegen.java | 16 ++++++++-------- .../src/main/resources/nodejs/swagger.mustache | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java index 5d0a7034537f..10070ece5121 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java @@ -207,11 +207,14 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig } @SuppressWarnings("unchecked") - private Map getOperations(Map objs) { + private List> getOperations(Map objs) { + List> result = new ArrayList>(); Map apiInfo = (Map) objs.get("apiInfo"); List> apis = (List>) apiInfo.get("apis"); - Map api = apis.get(0); - return (Map) api.get("operations"); + for (Map api : apis) { + result.add((Map) api.get("operations")); + } + return result; } private List> sortOperationsByPath(List ops) { @@ -221,7 +224,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig opsByPath.put(op.path, op); } - List> opsByPathList = new ArrayList>(); + List> opsByPathList = new ArrayList>(); for (Entry> entry : opsByPath.asMap().entrySet()) { Map opsByPathEntry = new HashMap(); opsByPathList.add(opsByPathEntry); @@ -239,16 +242,13 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig @Override public Map postProcessSupportingFileData(Map objs) { - Map operations = getOperations(objs); - - if (operations != null) { + for (Map operations : getOperations(objs)) { @SuppressWarnings("unchecked") List ops = (List) operations.get("operation"); List> opsByPathList = sortOperationsByPath(ops); operations.put("operationsByPath", opsByPathList); } - return super.postProcessSupportingFileData(objs); } } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/nodejs/swagger.mustache b/modules/swagger-codegen/src/main/resources/nodejs/swagger.mustache index 59940f08b157..3b975e53b807 100644 --- a/modules/swagger-codegen/src/main/resources/nodejs/swagger.mustache +++ b/modules/swagger-codegen/src/main/resources/nodejs/swagger.mustache @@ -14,7 +14,7 @@ {{#operations}} {{#operationsByPath}} "{{{path}}}": { - {{#operation}} + {{#operation}} "{{httpMethod}}": { "summary": "{{summary}}", "description":"{{notes}}", @@ -34,7 +34,6 @@ {{/operation}} } {{#hasMore}},{{/hasMore}} {{/operationsByPath}} - {{#hasMore}},{{/hasMore}} {{/operations}} {{/apis}} {{/apiInfo}} From e5811ebdc747b878a20256dad10187e22e9e3216 Mon Sep 17 00:00:00 2001 From: russellb337 Date: Wed, 26 Aug 2015 17:38:51 -0700 Subject: [PATCH 091/109] expose more generate options in the cli --- modules/swagger-codegen-cli/pom.xml | 23 +- .../io/swagger/codegen/cmd/ConfigHelp.java | 25 +- .../java/io/swagger/codegen/cmd/Generate.java | 140 +++++-- .../cmd/utils/CodegenConfigLoader.java | 34 ++ .../codegen/cmd/utils/OptionUtils.java | 43 +++ .../io/swagger/codegen/cmd/GenerateTest.java | 352 ++++++++++++++++++ .../cmd/utils/CodegenConfigLoaderTest.java | 59 +++ .../codegen/cmd/utils/OptionUtilsTest.java | 52 +++ modules/swagger-codegen/pom.xml | 6 + .../io/swagger/codegen/ClientOptInput.java | 7 +- .../main/java/io/swagger/codegen/Codegen.java | 2 +- .../io/swagger/codegen/CodegenConfig.java | 2 + .../io/swagger/codegen/CodegenConstants.java | 36 ++ .../io/swagger/codegen/DefaultCodegen.java | 16 +- .../languages/AkkaScalaClientCodegen.java | 9 +- .../languages/AndroidClientCodegen.java | 39 +- .../languages/AsyncScalaClientCodegen.java | 9 +- .../codegen/languages/FlashClientCodegen.java | 27 +- .../codegen/languages/JavaClientCodegen.java | 72 ++-- .../languages/JavaInflectorServerCodegen.java | 9 +- .../codegen/languages/JaxRSServerCodegen.java | 14 +- .../codegen/languages/PhpClientCodegen.java | 29 +- .../languages/RetrofitClientCodegen.java | 9 +- .../codegen/languages/ScalaClientCodegen.java | 9 +- .../languages/ScalatraServerCodegen.java | 9 +- .../codegen/languages/SilexServerCodegen.java | 9 +- .../languages/SpringMVCServerCodegen.java | 10 +- .../codegen/languages/StaticDocCodegen.java | 9 +- .../languages/StaticHtmlGenerator.java | 9 +- .../codegen/DefaultGeneratorTest.java} | 61 +-- .../src/test/resources/petstore.json | 0 pom.xml | 43 +++ 32 files changed, 932 insertions(+), 241 deletions(-) create mode 100644 modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/CodegenConfigLoader.java create mode 100644 modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/OptionUtils.java create mode 100644 modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/GenerateTest.java create mode 100644 modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/CodegenConfigLoaderTest.java create mode 100644 modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/OptionUtilsTest.java create mode 100644 modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java rename modules/{swagger-codegen-cli/src/test/java/io/swagger/codegen/GenerateTest.java => swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java} (51%) rename modules/{swagger-codegen-cli => swagger-codegen}/src/test/resources/petstore.json (100%) diff --git a/modules/swagger-codegen-cli/pom.xml b/modules/swagger-codegen-cli/pom.xml index 13f7f5c01525..9c0b6af1bcd5 100644 --- a/modules/swagger-codegen-cli/pom.xml +++ b/modules/swagger-codegen-cli/pom.xml @@ -70,33 +70,40 @@ swagger-codegen ${project.version} - io.airlift airline 0.7 - com.googlecode.lambdaj lambdaj 2.3.3 - org.slf4j slf4j-simple ${slf4j-version} - - junit - junit - ${junit-version} + org.testng + testng + ${testng-version} + test + + + org.jmockit + jmockit + ${jmockit-version} + test + + + org.reflections + reflections + ${reflections-version} test - \ No newline at end of file diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/ConfigHelp.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/ConfigHelp.java index 78e4b9bd6baf..5a7c46eefeb3 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/ConfigHelp.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/ConfigHelp.java @@ -4,6 +4,7 @@ import io.airlift.airline.Command; import io.airlift.airline.Option; import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.cmd.utils.CodegenConfigLoader; import java.util.ServiceLoader; @@ -16,32 +17,10 @@ public class ConfigHelp implements Runnable { description = "language to get config help for") private String lang; - /** - * Tries to load config class with SPI first, then with class name directly from classpath - * - * @param name name of config, or full qualified class name in classpath - * @return config class - */ - private static CodegenConfig forName(String name) { - ServiceLoader loader = load(CodegenConfig.class); - for (CodegenConfig config : loader) { - if (config.getName().equals(name)) { - return config; - } - } - - // else try to load directly - try { - return (CodegenConfig) Class.forName(name).newInstance(); - } catch (Exception e) { - throw new RuntimeException("Can't load config class with name ".concat(name), e); - } - } - @Override public void run() { System.out.println(); - CodegenConfig config = forName(lang); + CodegenConfig config = CodegenConfigLoader.forName(lang); System.out.println("CONFIG OPTIONS"); for (CliOption langCliOption : config.cliOptions()) { System.out.println("\t" + langCliOption.getOpt()); diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java index cf22ae91b629..9e4754f9a1d2 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java @@ -8,14 +8,20 @@ import io.swagger.codegen.CliOption; import io.swagger.codegen.ClientOptInput; import io.swagger.codegen.ClientOpts; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.DefaultGenerator; +import io.swagger.codegen.cmd.utils.CodegenConfigLoader; +import io.swagger.codegen.cmd.utils.OptionUtils; import io.swagger.models.Swagger; import io.swagger.parser.SwaggerParser; +import org.apache.commons.lang3.tuple.Pair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.util.ServiceLoader; +import java.util.List; +import java.util.Map; +import java.util.Set; import static java.util.ServiceLoader.load; import static org.apache.commons.lang3.StringUtils.isNotEmpty; @@ -31,8 +37,6 @@ public class Generate implements Runnable { public static final Logger LOG = LoggerFactory.getLogger(Generate.class); - public static final String TEMPLATE_DIR_PARAM = "templateDir"; - @Option(name = {"-v", "--verbose"}, description = "verbose mode") private boolean verbose; @@ -70,27 +74,42 @@ public class Generate implements Runnable { "overwritten during the generation.") private boolean skipOverwrite; - /** - * Tries to load config class with SPI first, then with class name directly from classpath - * - * @param name name of config, or full qualified class name in classpath - * @return config class - */ - private static CodegenConfig forName(String name) { - ServiceLoader loader = load(CodegenConfig.class); - for (CodegenConfig config : loader) { - if (config.getName().equals(name)) { - return config; - } - } + @Option(name = {"--api-package"}, title = "api package", description = CodegenConstants.API_PACKAGE_DESC) + private String apiPackage; - // else try to load directly - try { - return (CodegenConfig) Class.forName(name).newInstance(); - } catch (Exception e) { - throw new RuntimeException("Can't load config class with name ".concat(name), e); - } - } + @Option(name = {"--model-package"}, title = "model package", description = CodegenConstants.MODEL_PACKAGE_DESC) + private String modelPackage; + + @Option(name = {"--instantiation-types"}, title = "instantiation types", description = "sets instantiation type mappings in the format of type=instantiatedType,type=instantiatedType." + + "For example (in Java): array=ArrayList,map=HashMap. In other words array types will get instantiated as ArrayList in generated code.") + private String instantiationTypes; + + @Option(name = {"--type-mappings"}, title = "type mappings", description = "sets mappings between swagger spec types and generated code types " + + "in the format of swaggerType=generatedType,swaggerType=generatedType. For example: array=List,map=Map,string=String") + private String typeMappings; + + @Option(name = {"--additional-properties"}, title = "additional properties", description = "sets additional properties that can be referenced by the mustache templates in the format of name=value,name=value") + private String additionalProperties; + + @Option(name = {"--language-specific-primitives"}, title = "language specific primitives", + description = "specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double") + private String languageSpecificPrimitives; + + @Option(name = {"--import-mappings"}, title = "import mappings", + description = "specifies mappings between a given class and the import that should be used for that class in the format of type=import,type=import") + private String importMappings; + + @Option(name = {"--invoker-package"}, title = "invoker package", description = CodegenConstants.INVOKER_PACKAGE_DESC) + private String invokerPackage; + + @Option(name = {"--group-id"}, title = "group id", description = CodegenConstants.GROUP_ID_DESC) + private String groupId; + + @Option(name = {"--artifact-id"}, title = "artifact id", description = CodegenConstants.ARTIFACT_ID_DESC) + private String artifactId; + + @Option(name = {"--artifact-version"}, title = "artifact version", description = CodegenConstants.ARTIFACT_VERSION_DESC) + private String artifactVersion; @Override public void run() { @@ -98,19 +117,30 @@ public class Generate implements Runnable { setSystemProperties(); - ClientOptInput input = new ClientOptInput(); + CodegenConfig config = CodegenConfigLoader.forName(lang); - if (isNotEmpty(auth)) { - input.setAuth(auth); - } - - CodegenConfig config = forName(lang); config.setOutputDir(new File(output).getAbsolutePath()); + config.setSkipOverwrite(skipOverwrite); - if (null != templateDir) { - config.additionalProperties().put(TEMPLATE_DIR_PARAM, new File(templateDir).getAbsolutePath()); + putKeyValuePairsInMap(config.instantiationTypes(), instantiationTypes); + putKeyValuePairsInMap(config.typeMapping(), typeMappings); + putKeyValuePairsInMap(config.additionalProperties(), additionalProperties); + putKeyValuePairsInMap(config.importMapping(), importMappings); + + addValuesToSet(config.languageSpecificPrimitives(), languageSpecificPrimitives); + + checkAndSetAdditionalProperty(config, apiPackage, CodegenConstants.API_PACKAGE); + checkAndSetAdditionalProperty(config, modelPackage, CodegenConstants.MODEL_PACKAGE); + + if(isNotEmpty(templateDir)) { + config.additionalProperties().put(CodegenConstants.TEMPLATE_DIR, new File(templateDir).getAbsolutePath()); } + checkAndSetAdditionalProperty(config, invokerPackage, CodegenConstants.INVOKER_PACKAGE); + checkAndSetAdditionalProperty(config, groupId, CodegenConstants.GROUP_ID); + checkAndSetAdditionalProperty(config, artifactId, CodegenConstants.ARTIFACT_ID); + checkAndSetAdditionalProperty(config, artifactVersion, CodegenConstants.ARTIFACT_VERSION); + if (null != configFile) { Config genConfig = ConfigParser.read(configFile); if (null != genConfig) { @@ -127,24 +157,52 @@ public class Generate implements Runnable { } } - config.setSkipOverwrite(skipOverwrite); - input.setConfig(config); + ClientOptInput input = new ClientOptInput().config(config); + + if (isNotEmpty(auth)) { + input.setAuth(auth); + } Swagger swagger = new SwaggerParser().read(spec, input.getAuthorizationValues(), true); new DefaultGenerator().opts(input.opts(new ClientOpts()).swagger(swagger)).generate(); } - private void setSystemProperties() { - if (systemProperties != null && systemProperties.length() > 0) { - for (String property : systemProperties.split(",")) { - int ix = property.indexOf('='); - if (ix > 0 && ix < property.length() - 1) { - System.setProperty(property.substring(0, ix), property.substring(ix + 1)); - } - } + private void addValuesToSet(Set set, String csvProperty) { + final List values = OptionUtils.splitCommaSeparatedList(csvProperty); + + for (String value : values) { + set.add(value); } } + private void checkAndSetAdditionalProperty(CodegenConfig config, String property, String propertyKey) { + checkAndSetAdditionalProperty(config, property, property, propertyKey); + } + + private void checkAndSetAdditionalProperty(CodegenConfig config, String property, String valueToSet, String propertyKey) { + if(isNotEmpty(property)) { + config.additionalProperties().put(propertyKey, valueToSet); + } + } + + private void setSystemProperties() { + + final List> systemPropertyPairs = OptionUtils.parseCommaSeparatedTuples(systemProperties); + + for (Pair pair : systemPropertyPairs) { + System.setProperty(pair.getLeft(), pair.getRight()); + } + } + + private void putKeyValuePairsInMap(Map map, String commaSeparatedKVPairs) { + final List> pairs = OptionUtils.parseCommaSeparatedTuples(commaSeparatedKVPairs); + + for (Pair pair : pairs) { + map.put(pair.getLeft(), pair.getRight()); + } + } + + /** * If true parameter, adds system properties which enables debug mode in generator * diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/CodegenConfigLoader.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/CodegenConfigLoader.java new file mode 100644 index 000000000000..2e068bccb474 --- /dev/null +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/CodegenConfigLoader.java @@ -0,0 +1,34 @@ +package io.swagger.codegen.cmd.utils; + +import io.swagger.codegen.CodegenConfig; + +import java.util.ServiceLoader; + +import static java.util.ServiceLoader.load; + +/** + * Created by russellb337 on 8/25/15. + */ +public class CodegenConfigLoader { + /** + * Tries to load config class with SPI first, then with class name directly from classpath + * + * @param name name of config, or full qualified class name in classpath + * @return config class + */ + public static CodegenConfig forName(String name) { + ServiceLoader loader = load(CodegenConfig.class); + for (CodegenConfig config : loader) { + if (config.getName().equals(name)) { + return config; + } + } + + // else try to load directly + try { + return (CodegenConfig) Class.forName(name).newInstance(); + } catch (Exception e) { + throw new RuntimeException("Can't load config class with name ".concat(name), e); + } + } +} diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/OptionUtils.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/OptionUtils.java new file mode 100644 index 000000000000..34d567274125 --- /dev/null +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/OptionUtils.java @@ -0,0 +1,43 @@ +package io.swagger.codegen.cmd.utils; + +import org.apache.commons.lang3.tuple.Pair; + +import java.util.ArrayList; +import java.util.List; + +import static org.apache.commons.lang3.StringUtils.isNotEmpty; + +public class OptionUtils { + + public static List> parseCommaSeparatedTuples(String input) { + + List> results = new ArrayList>(); + + final List tuples = splitCommaSeparatedList(input); + + for (String tuple : tuples) { + int ix = tuple.indexOf('='); + if (ix > 0 && ix < tuple.length() - 1) { + final Pair pair = Pair.of(tuple.substring(0, ix), tuple.substring(ix + 1)); + results.add(pair); + } + } + + return results; + } + + public static List splitCommaSeparatedList(String input) { + + List results = new ArrayList(); + + if(input != null && !input.isEmpty()) { + for (String value : input.split(",")) { + if(isNotEmpty(value)) + results.add(value); + } + } + + return results; + } + +} diff --git a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/GenerateTest.java b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/GenerateTest.java new file mode 100644 index 000000000000..2fc414e884e2 --- /dev/null +++ b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/GenerateTest.java @@ -0,0 +1,352 @@ +package io.swagger.codegen.cmd; + +import config.Config; +import config.ConfigParser; +import io.swagger.codegen.ClientOptInput; +import io.swagger.codegen.ClientOpts; +import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.DefaultGenerator; +import io.swagger.codegen.SwaggerCodegen; +import io.swagger.codegen.cmd.utils.CodegenConfigLoader; +import io.swagger.codegen.languages.JavaClientCodegen; +import io.swagger.models.Swagger; +import io.swagger.models.auth.AuthorizationValue; +import io.swagger.parser.SwaggerParser; +import mockit.Expectations; +import mockit.FullVerifications; +import mockit.Injectable; +import mockit.Mocked; +import mockit.StrictExpectations; +import org.apache.commons.lang3.ArrayUtils; +import org.testng.annotations.Test; + +import java.io.File; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +public class GenerateTest { + + @Mocked + SwaggerParser parser; + + @Injectable + Swagger swagger; + + @Mocked + DefaultGenerator defaultGenerator; + + @Mocked + CodegenConfigLoader codegenConfigLoader; + + @Mocked + ClientOptInput clientOptInput; + + @Injectable + List authorizationValues; + + @Test + public void testVerbose_ShortArg() throws Exception { + doVerboseTest("-v"); + } + + @Test + public void testVerbose_LongArg() throws Exception { + doVerboseTest("--verbose"); + } + + @Test + public void testRequiredArgs_ShortArgs() throws Exception { + doRequiredArgsTest("-l", "-o", "-i"); + } + + @Test + public void testRequiredArgs_LongArgs() throws Exception { + doRequiredArgsTest("--lang", "--output", "--input-spec"); + } + + @Test + public void testTemplateDir() throws Exception { + final String absolutePath = new File("src").getAbsolutePath(); + + doSingleAdditionalPropertyTest("--template-dir", CodegenConstants.TEMPLATE_DIR, "src", absolutePath); + doSingleAdditionalPropertyTest("--template-dir", CodegenConstants.TEMPLATE_DIR, absolutePath, absolutePath); + doSingleAdditionalPropertyTest("-t", CodegenConstants.TEMPLATE_DIR, "src", absolutePath); + doSingleAdditionalPropertyTest("-t", CodegenConstants.TEMPLATE_DIR, absolutePath, absolutePath); + } + + @Test + public void testAuth() throws Exception { + + final String auth = "hello:world"; + + new StrictExpectations() {{ + clientOptInput.setAuth(auth); + times = 1; + }}; + + setupAndRunGenericTest("-a", auth); + + new StrictExpectations() {{ + clientOptInput.setAuth(auth); + times = 1; + }}; + + setupAndRunGenericTest("--auth", auth); + } + + @Test + public void testSystemProperties() throws Exception { + + new StrictExpectations(System.class) {{ + System.setProperty("hello", "world"); + times = 1; + System.setProperty("foo", "bar"); + times = 1; + }}; + + setupAndRunGenericTest("-D", "hello=world,foo=bar"); + } + + @Test + public void testConfig(@Mocked final ConfigParser parser) throws Exception { + + final String configFilePath = "config.json"; + final String invokerPackage = "com.foo.bar.invoker"; + final String groupId = "com.foo.bar"; + Map configMap = new HashMap(); + configMap.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + configMap.put(CodegenConstants.GROUP_ID, groupId); + final Config config = new Config(configMap); + + final String[] configArgs = {"-c", "--config"}; + + for (String configArg : configArgs) { + new StrictExpectations() {{ + parser.read(configFilePath); + times = 1; + result = config; + + }}; + + final CodegenConfig codegenConfig = setupAndRunGenericTest(configArg, configFilePath); + + assertValueInMap(codegenConfig.additionalProperties(), CodegenConstants.INVOKER_PACKAGE, invokerPackage); + assertValueInMap(codegenConfig.additionalProperties(), CodegenConstants.GROUP_ID, groupId); + } + } + + @Test + public void testSkipOverwrite() throws Exception { + + CodegenConfig codegenConfig1 = setupAndRunGenericTest(); + assertFalse(codegenConfig1.isSkipOverwrite()); + + CodegenConfig codegenConfig2 = setupAndRunGenericTest("-s"); + assertTrue(codegenConfig2.isSkipOverwrite()); + + CodegenConfig codegenConfig3 = setupAndRunGenericTest("--skip-overwrite"); + assertTrue(codegenConfig3.isSkipOverwrite()); + } + + @Test + public void testApiPackage() throws Exception { + doSingleAdditionalPropertyTest("--api-package", CodegenConstants.API_PACKAGE, "io.foo.bar.api"); + } + + @Test + public void testModelPackage() throws Exception { + doSingleAdditionalPropertyTest("--model-package", CodegenConstants.MODEL_PACKAGE, "io.foo.bar.models"); + } + + @Test + public void testInstantiationTypes() throws Exception { + + final CodegenConfig codegenConfig = setupAndRunGenericTest("--instantiation-types", "foo=bar,hello=world"); + + assertValueInMap(codegenConfig.instantiationTypes(), "foo", "bar"); + assertValueInMap(codegenConfig.instantiationTypes(), "hello", "world"); + } + + @Test + public void testTypeMappings() throws Exception { + final CodegenConfig codegenConfig = setupAndRunGenericTest("--type-mappings", "foo=bar,hello=world"); + + assertValueInMap(codegenConfig.typeMapping(), "foo", "bar"); + assertValueInMap(codegenConfig.typeMapping(), "hello", "world"); + } + + @Test + public void testAdditionalProperties() throws Exception { + final CodegenConfig codegenConfig = setupAndRunGenericTest("--additional-properties", "foo=bar,hello=world"); + + assertValueInMap(codegenConfig.additionalProperties(), "foo", "bar"); + assertValueInMap(codegenConfig.additionalProperties(), "hello", "world"); + } + + @Test + public void testLanguageSpecificPrimitives() throws Exception { + final CodegenConfig codegenConfig = setupAndRunGenericTest("--language-specific-primitives", "foo,bar,hello,world"); + + final Set languageSpecificPrimitives = codegenConfig.languageSpecificPrimitives(); + + assertTrue(languageSpecificPrimitives.contains("foo")); + assertTrue(languageSpecificPrimitives.contains("bar")); + assertTrue(languageSpecificPrimitives.contains("hello")); + assertTrue(languageSpecificPrimitives.contains("world")); + } + + @Test + public void testImportMappings() throws Exception { + final CodegenConfig codegenConfig = setupAndRunGenericTest("--import-mappings", "foo=bar,hello=world"); + + assertValueInMap(codegenConfig.importMapping(), "foo", "bar"); + assertValueInMap(codegenConfig.importMapping(), "hello", "world"); + } + + @Test + public void testInvokerPackage() throws Exception { + doSingleAdditionalPropertyTest("--invoker-package", CodegenConstants.INVOKER_PACKAGE, "io.foo.bar.invoker"); + } + + @Test + public void testGroupId() throws Exception { + doSingleAdditionalPropertyTest("--group-id", CodegenConstants.GROUP_ID, "io.foo.bar"); + } + + @Test + public void testArtifactId() throws Exception { + doSingleAdditionalPropertyTest("--artifact-id", CodegenConstants.ARTIFACT_ID, "awesome-api"); + } + + @Test + public void testArtifactVersion() throws Exception { + doSingleAdditionalPropertyTest("--artifact-version", CodegenConstants.ARTIFACT_VERSION, "1.2.3"); + } + + private void doVerboseTest(String verboseFlag) { + new StrictExpectations(System.class) {{ + System.setProperty("debugSwagger", ""); + times = 1; + System.setProperty("debugModels", ""); + times = 1; + System.setProperty("debugOperations", ""); + times = 1; + System.setProperty("debugSupportingFiles", ""); + times = 1; + }}; + + setupAndRunGenericTest(verboseFlag); + } + + private void doRequiredArgsTest(String langFlag, String outputDirFlag, String inputSpecFlag) { + final String spec = "swagger.yaml"; + final String lang = "java"; + final String outputDir = "src/main/java"; + + final String[] args = {"generate", langFlag, lang, outputDirFlag, outputDir, inputSpecFlag, spec}; + + final CodegenConfig config = new JavaClientCodegen(); + + setupStandardExpectations(spec, lang, config); + + SwaggerCodegen.main(args); + + new FullVerifications() {{ + }}; + + assertEquals(config.getOutputDir(), new File(outputDir).getAbsolutePath()); + } + + private void doSingleAdditionalPropertyTest(String cliArg, String additionalPropertyKey, String expectedValue) { + doSingleAdditionalPropertyTest(cliArg, additionalPropertyKey, expectedValue, expectedValue); + } + + private void doSingleAdditionalPropertyTest(String cliArg, String additionalPropertyKey, String cliValue, String additionalPropertyValue) { + + final CodegenConfig config = setupAndRunGenericTest(cliArg, cliValue); + + assertValueInMap(config.additionalProperties(), additionalPropertyKey, additionalPropertyValue); + } + + private CodegenConfig setupAndRunGenericTest(String... additionalParameters) { + + final String spec = "swagger.yaml"; + final String lang = "java"; + + final String[] commonArgs = {"generate", "-l", lang, "-o", "path/to/some/directory", "-i", spec}; + + String[] argsToUse = ArrayUtils.addAll(commonArgs, additionalParameters); + + final CodegenConfig config = new JavaClientCodegen(); + + setupStandardExpectations(spec, lang, config); + + SwaggerCodegen.main(argsToUse); + + new FullVerifications() {{ + }}; + + return config; + } + + private void assertValueInMap(Map map, String propertyKey, String expectedPropertyValue) { + assertTrue(map.containsKey(propertyKey)); + assertEquals(map.get(propertyKey), expectedPropertyValue); + } + + private void setupStandardExpectations(final String spec, final String languageName, final CodegenConfig config) { + + new Expectations() {{ + CodegenConfigLoader.forName(languageName); + times = 1; + result = config; + + new ClientOptInput(); + times = 1; + result = clientOptInput; + + clientOptInput.config(config); + times = 1; + result = clientOptInput; + + new SwaggerParser(); + times = 1; + result = parser; + + clientOptInput.getAuthorizationValues(); + times = 1; + result = authorizationValues; + + parser.read(spec, authorizationValues, true); + times = 1; + result = swagger; + + new DefaultGenerator(); + times = 1; + result = defaultGenerator; + + clientOptInput.opts((ClientOpts) any); + times = 1; + result = clientOptInput; + + clientOptInput.swagger(swagger); + times = 1; + result = clientOptInput; + + defaultGenerator.opts(clientOptInput); + times = 1; + result = defaultGenerator; + + defaultGenerator.generate(); + times = 1; + }}; + } + +} diff --git a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/CodegenConfigLoaderTest.java b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/CodegenConfigLoaderTest.java new file mode 100644 index 000000000000..0bfd6175f8d3 --- /dev/null +++ b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/CodegenConfigLoaderTest.java @@ -0,0 +1,59 @@ +package io.swagger.codegen.cmd.utils; + +import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.DefaultCodegen; +import org.reflections.Reflections; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import static org.testng.Assert.assertEquals; + +public class CodegenConfigLoaderTest { + + @DataProvider(name = "codegenConfig") + public Object[][] createCodegenConfigDataSet() throws Exception { + + Reflections reflections = new Reflections("io.swagger.codegen.languages"); + final Set> subTypesOf = reflections.getSubTypesOf(DefaultCodegen.class); + + List codegenConfigList = new ArrayList(); + + for (Class aClass : subTypesOf) { + if (!Modifier.isAbstract(aClass.getModifiers())) { + final DefaultCodegen defaultCodegen = aClass.newInstance(); + codegenConfigList.add((CodegenConfig) defaultCodegen); + } + } + + Object[][] result = new Object[codegenConfigList.size()][1]; + + for (int i = 0; i < codegenConfigList.size(); i++) { + result[i]= new Object[]{codegenConfigList.get(i)}; + } + + return result; + } + + @Test(dataProvider = "codegenConfig") + public void testLoadByName(CodegenConfig codegenConfig) throws Exception { + final CodegenConfig loadedConfig = CodegenConfigLoader.forName(codegenConfig.getName()); + + assertEquals(loadedConfig.getClass(), codegenConfig.getClass()); + assertEquals(loadedConfig.getName(), codegenConfig.getName()); + } + + @Test(dataProvider = "codegenConfig") + public void testLoadByFullQualifiedName(CodegenConfig codegenConfig) throws Exception { + final CodegenConfig loadedConfig = CodegenConfigLoader.forName(codegenConfig.getClass().getName()); + + assertEquals(loadedConfig.getClass(), codegenConfig.getClass()); + assertEquals(loadedConfig.getName(), codegenConfig.getName()); + + + } +} diff --git a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/OptionUtilsTest.java b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/OptionUtilsTest.java new file mode 100644 index 000000000000..a7dc4d7f1cd4 --- /dev/null +++ b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/OptionUtilsTest.java @@ -0,0 +1,52 @@ +package io.swagger.codegen.cmd.utils; + +import org.apache.commons.lang3.tuple.Pair; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +public class OptionUtilsTest { + + @Test + public void splitCommaSeparatedList() throws Exception { + doCommaSeparatedListTest("a,b,c", Arrays.asList("a", "b", "c")); + doCommaSeparatedListTest("a,,c", Arrays.asList("a", "c")); + doCommaSeparatedListTest("", new ArrayList()); + doCommaSeparatedListTest(null, new ArrayList()); + } + + @Test + public void testParseCommaSeparatedTuples() throws Exception { + doTupleListTest("a=1,b=2,c=3", Arrays.asList(Pair.of("a", "1"), Pair.of("b", "2"), Pair.of("c", "3"))); + doTupleListTest("a=1,,c=3", Arrays.asList(Pair.of("a", "1"), Pair.of("c", "3"))); + doTupleListTest("a=1,xyz,c=3", Arrays.asList(Pair.of("a", "1"), Pair.of("c", "3"))); + doTupleListTest("a=1,=,c=3", Arrays.asList(Pair.of("a", "1"), Pair.of("c", "3"))); + doTupleListTest("", new ArrayList>()); + doTupleListTest(null, new ArrayList>()); + } + + private void doTupleListTest(String input, List> expectedResults) { + final List> result = OptionUtils.parseCommaSeparatedTuples(input); + assertNotNull(result); + assertEquals(result.size(), expectedResults.size()); + for (int i = 0; i < expectedResults.size(); i++) { + final Pair actualPair = result.get(i); + final Pair expected = expectedResults.get(i); + assertEquals(actualPair, expected); + } + } + + private void doCommaSeparatedListTest(String csvStr, List expectedResults) { + final List result = OptionUtils.splitCommaSeparatedList(csvStr); + assertNotNull(result); + assertEquals(result.size(), expectedResults.size()); + for (int i = 0; i < expectedResults.size(); i++) { + assertEquals(result.get(i), expectedResults.get(i)); + } + } +} diff --git a/modules/swagger-codegen/pom.xml b/modules/swagger-codegen/pom.xml index a392e98bda43..0f640d577ada 100644 --- a/modules/swagger-codegen/pom.xml +++ b/modules/swagger-codegen/pom.xml @@ -334,6 +334,12 @@ ${scala-version} test + + org.testng + testng + ${testng-version} + test + diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOptInput.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOptInput.java index da026c7f0400..56c4c66835a2 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOptInput.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOptInput.java @@ -10,7 +10,7 @@ import java.util.ArrayList; import java.util.List; public class ClientOptInput { - protected CodegenConfig config; + private CodegenConfig config; private ClientOpts opts; private Swagger swagger; private List auths; @@ -25,6 +25,11 @@ public class ClientOptInput { return this; } + public ClientOptInput config(CodegenConfig codegenConfig) { + this.setConfig(codegenConfig); + return this; + } + public String getAuth() { if (auths != null) { StringBuilder b = new StringBuilder(); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/Codegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/Codegen.java index c99e04e54949..d4c0707f1a73 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/Codegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/Codegen.java @@ -85,7 +85,7 @@ public class Codegen extends DefaultGenerator { swagger = new SwaggerParser().read(cmd.getOptionValue("i"), clientOptInput.getAuthorizationValues(), true); } if (cmd.hasOption("t")) { - clientOpts.getProperties().put("templateDir", String.valueOf(cmd.getOptionValue("t"))); + clientOpts.getProperties().put(CodegenConstants.TEMPLATE_DIR, String.valueOf(cmd.getOptionValue("t"))); } } catch (Exception e) { usage(options); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java index 9cbf32a154c7..1b0e349dacaf 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java @@ -83,6 +83,8 @@ public interface CodegenConfig { Map modelTemplateFiles(); + Set languageSpecificPrimitives(); + void processSwagger(Swagger swagger); String toApiFilename(String name); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java new file mode 100644 index 000000000000..c4bdad9c6eab --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java @@ -0,0 +1,36 @@ +package io.swagger.codegen; + +/** + * A class for storing constants that are used throughout the project. + */ +public class CodegenConstants { + public static final String API_PACKAGE = "apiPackage"; + public static final String API_PACKAGE_DESC = "package for generated api classes"; + + public static final String MODEL_PACKAGE = "modelPackage"; + public static final String MODEL_PACKAGE_DESC = "package for generated models"; + + public static final String TEMPLATE_DIR = "templateDir"; + + + public static final String INVOKER_PACKAGE = "invokerPackage"; + public static final String INVOKER_PACKAGE_DESC = "root package for generated code"; + + public static final String GROUP_ID = "groupId"; + public static final String GROUP_ID_DESC = "groupId in generated pom.xml"; + + public static final String ARTIFACT_ID = "artifactId"; + public static final String ARTIFACT_ID_DESC = "artifactId in generated pom.xml"; + + public static final String ARTIFACT_VERSION = "artifactVersion"; + public static final String ARTIFACT_VERSION_DESC = "artifact version in generated pom.xml"; + + public static final String SOURCE_FOLDER = "sourceFolder"; + public static final String SOURCE_FOLDER_DESC = "source folder for generated code"; + + public static final String LOCAL_VARIABLE_PREFIX = "localVariablePrefix"; + public static final String LOCAL_VARIABLE_PREFIX_DESC = "prefix for generated code members and local variables"; + + public static final String SERIALIZABLE_MODEL = "serializableModel"; + public static final String SERIALIZABLE_MODEL_DESC = "boolean - toggle \"implements Serializable\" for generated models"; +} 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 1422b1c36a0c..f15a8785f972 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 @@ -91,16 +91,16 @@ public class DefaultCodegen { } public void processOpts() { - if (additionalProperties.containsKey("templateDir")) { - this.setTemplateDir((String) additionalProperties.get("templateDir")); + if (additionalProperties.containsKey(CodegenConstants.TEMPLATE_DIR)) { + this.setTemplateDir((String) additionalProperties.get(CodegenConstants.TEMPLATE_DIR)); } - if (additionalProperties.containsKey("modelPackage")) { - this.setModelPackage((String) additionalProperties.get("modelPackage")); + if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) { + this.setModelPackage((String) additionalProperties.get(CodegenConstants.MODEL_PACKAGE)); } - if (additionalProperties.containsKey("apiPackage")) { - this.setApiPackage((String) additionalProperties.get("apiPackage")); + if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) { + this.setApiPackage((String) additionalProperties.get(CodegenConstants.API_PACKAGE)); } } @@ -336,8 +336,8 @@ public class DefaultCodegen { importMapping.put("LocalDate", "org.joda.time.*"); importMapping.put("LocalTime", "org.joda.time.*"); - cliOptions.add(new CliOption("modelPackage", "package for generated models")); - cliOptions.add(new CliOption("apiPackage", "package for generated api classes")); + cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC)); + cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AkkaScalaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AkkaScalaClientCodegen.java index f9490e3d3dd7..c40eb6535430 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AkkaScalaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AkkaScalaClientCodegen.java @@ -4,6 +4,7 @@ import com.google.common.base.CaseFormat; import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Template; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.CodegenProperty; import io.swagger.codegen.CodegenResponse; @@ -80,10 +81,10 @@ public class AkkaScalaClientCodegen extends DefaultCodegen implements CodegenCon "trait", "try", "true", "type", "val", "var", "while", "with", "yield") ); - additionalProperties.put("invokerPackage", invokerPackage); - additionalProperties.put("groupId", groupId); - additionalProperties.put("artifactId", artifactId); - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); additionalProperties.put("configKey", configKey); additionalProperties.put("configKeyPath", configKeyPath); additionalProperties.put("defaultTimeout", defaultTimeoutInMs); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java index f570cc42e821..9c55053e59cd 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java @@ -2,6 +2,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; @@ -58,11 +59,11 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi instantiationTypes.put("array", "ArrayList"); instantiationTypes.put("map", "HashMap"); - cliOptions.add(new CliOption("invokerPackage", "root package to use for the generated code")); - cliOptions.add(new CliOption("groupId", "groupId for use in the generated build.gradle and pom.xml")); - cliOptions.add(new CliOption("artifactId", "artifactId for use in the generated build.gradle and pom.xml")); - cliOptions.add(new CliOption("artifactVersion", "artifact version for use in the generated build.gradle and pom.xml")); - cliOptions.add(new CliOption("sourceFolder", "source folder for generated code")); + cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC)); + cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, "groupId for use in the generated build.gradle and pom.xml")); + cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, "artifactId for use in the generated build.gradle and pom.xml")); + cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "artifact version for use in the generated build.gradle and pom.xml")); + cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)); cliOptions.add(new CliOption("useAndroidMavenGradlePlugin", "A flag to toggle android-maven gradle plugin. Default is true.")); } @@ -187,36 +188,36 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi public void processOpts() { super.processOpts(); - if (additionalProperties.containsKey("invokerPackage")) { - this.setInvokerPackage((String) additionalProperties.get("invokerPackage")); + if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { + this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); } else { //not set, use default to be passed to template - additionalProperties.put("invokerPackage", invokerPackage); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); } - if (additionalProperties.containsKey("groupId")) { - this.setGroupId((String) additionalProperties.get("groupId")); + if (additionalProperties.containsKey(CodegenConstants.GROUP_ID)) { + this.setGroupId((String) additionalProperties.get(CodegenConstants.GROUP_ID)); } else { //not set, use to be passed to template - additionalProperties.put("groupId", groupId); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); } - if (additionalProperties.containsKey("artifactId")) { - this.setArtifactId((String) additionalProperties.get("artifactId")); + if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_ID)) { + this.setArtifactId((String) additionalProperties.get(CodegenConstants.ARTIFACT_ID)); } else { //not set, use to be passed to template - additionalProperties.put("artifactId", artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); } - if (additionalProperties.containsKey("artifactVersion")) { - this.setArtifactVersion((String) additionalProperties.get("artifactVersion")); + if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) { + this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION)); } else { //not set, use to be passed to template - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); } - if (additionalProperties.containsKey("sourceFolder")) { - this.setSourceFolder((String) additionalProperties.get("sourceFolder")); + if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { + this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); } if (additionalProperties.containsKey("useAndroidMavenGradlePlugin")) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AsyncScalaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AsyncScalaClientCodegen.java index 53faf2f9e1fc..38e6328a8e55 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AsyncScalaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AsyncScalaClientCodegen.java @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; @@ -52,10 +53,10 @@ public class AsyncScalaClientCodegen extends DefaultCodegen implements CodegenCo "trait", "try", "true", "type", "val", "var", "while", "with", "yield") ); - additionalProperties.put("invokerPackage", invokerPackage); - additionalProperties.put("groupId", groupId); - additionalProperties.put("artifactId", artifactId); - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); additionalProperties.put("asyncHttpClient", asyncHttpClient); additionalProperties.put("authScheme", authScheme); additionalProperties.put("authPreemptive", authPreemptive); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java index ca0979fb694d..7c484c38a0b9 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java @@ -2,34 +2,27 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.MapProperty; -import io.swagger.models.properties.Property; -import io.swagger.models.properties.AbstractNumericProperty; -import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.BooleanProperty; import io.swagger.models.properties.DateProperty; import io.swagger.models.properties.DateTimeProperty; -import io.swagger.models.properties.DecimalProperty; import io.swagger.models.properties.DoubleProperty; import io.swagger.models.properties.FloatProperty; import io.swagger.models.properties.IntegerProperty; import io.swagger.models.properties.LongProperty; import io.swagger.models.properties.MapProperty; import io.swagger.models.properties.Property; -import io.swagger.models.properties.PropertyBuilder; -import io.swagger.models.properties.RefProperty; import io.swagger.models.properties.StringProperty; +import org.apache.commons.lang.StringUtils; import java.io.File; import java.util.Arrays; -import java.util.HashSet; import java.util.HashMap; - -import org.apache.commons.lang.StringUtils; +import java.util.HashSet; public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig { protected String packageName = "io.swagger"; @@ -82,8 +75,8 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig cliOptions.clear(); cliOptions.add(new CliOption("packageName", "flash package name (convention: package.name), default: io.swagger")); cliOptions.add(new CliOption("packageVersion", "flash package version, default: 1.0.0")); - cliOptions.add(new CliOption("invokerPackage", "root package for generated code")); - cliOptions.add(new CliOption("sourceFolder", "source folder for generated code. e.g. src/main/flex")); + cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC)); + cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "source folder for generated code. e.g. src/main/flex")); } @@ -91,15 +84,15 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig public void processOpts() { super.processOpts(); - if (additionalProperties.containsKey("invokerPackage")) { - this.setInvokerPackage((String) additionalProperties.get("invokerPackage")); + if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { + this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); } else { //not set, use default to be passed to template - additionalProperties.put("invokerPackage", invokerPackage); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); } - if (additionalProperties.containsKey("sourceFolder")) { - this.setSourceFolder((String) additionalProperties.get("sourceFolder")); + if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { + this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); } if (additionalProperties.containsKey("packageName")) { 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 40818acd2d3a..4cfd79ec3457 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 @@ -3,24 +3,19 @@ package io.swagger.codegen.languages; import com.google.common.base.Strings; import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenModel; import io.swagger.codegen.CodegenProperty; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; -import io.swagger.models.ComposedModel; import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.RefModel; import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.MapProperty; import io.swagger.models.properties.Property; -import io.swagger.models.properties.StringProperty; import java.io.File; -import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -72,14 +67,13 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { instantiationTypes.put("array", "ArrayList"); instantiationTypes.put("map", "HashMap"); - cliOptions.add(new CliOption("invokerPackage", "root package for generated code")); - cliOptions.add(new CliOption("groupId", "groupId in generated pom.xml")); - cliOptions.add(new CliOption("artifactId", "artifactId in generated pom.xml")); - cliOptions.add(new CliOption("artifactVersion", "artifact version in generated pom.xml")); - cliOptions.add(new CliOption("sourceFolder", "source folder for generated code")); - cliOptions.add(new CliOption("localVariablePrefix", "prefix for generated code members and local variables")); - - cliOptions.add(new CliOption("serializableModel", "boolean - toggle \"implements Serializable\" for generated models")); + cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC)); + cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC)); + cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC)); + cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC)); + cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)); + cliOptions.add(new CliOption(CodegenConstants.LOCAL_VARIABLE_PREFIX, CodegenConstants.LOCAL_VARIABLE_PREFIX_DESC)); + cliOptions.add(new CliOption(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC)); supportedLibraries.put("", "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2"); supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6"); @@ -102,49 +96,49 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { public void processOpts() { super.processOpts(); - if (additionalProperties.containsKey("invokerPackage")) { - this.setInvokerPackage((String) additionalProperties.get("invokerPackage")); + if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { + this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); } else { //not set, use default to be passed to template - additionalProperties.put("invokerPackage", invokerPackage); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); } - if (additionalProperties.containsKey("groupId")) { - this.setGroupId((String) additionalProperties.get("groupId")); + if (additionalProperties.containsKey(CodegenConstants.GROUP_ID)) { + this.setGroupId((String) additionalProperties.get(CodegenConstants.GROUP_ID)); } else { //not set, use to be passed to template - additionalProperties.put("groupId", groupId); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); } - if (additionalProperties.containsKey("artifactId")) { - this.setArtifactId((String) additionalProperties.get("artifactId")); + if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_ID)) { + this.setArtifactId((String) additionalProperties.get(CodegenConstants.ARTIFACT_ID)); } else { //not set, use to be passed to template - additionalProperties.put("artifactId", artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); } - if (additionalProperties.containsKey("artifactVersion")) { - this.setArtifactVersion((String) additionalProperties.get("artifactVersion")); + if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) { + this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION)); } else { //not set, use to be passed to template - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); } - if (additionalProperties.containsKey("sourceFolder")) { - this.setSourceFolder((String) additionalProperties.get("sourceFolder")); + if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { + this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); } - if (additionalProperties.containsKey("localVariablePrefix")) { - this.setLocalVariablePrefix((String) additionalProperties.get("localVariablePrefix")); + if (additionalProperties.containsKey(CodegenConstants.LOCAL_VARIABLE_PREFIX)) { + this.setLocalVariablePrefix((String) additionalProperties.get(CodegenConstants.LOCAL_VARIABLE_PREFIX)); } - if (additionalProperties.containsKey("serializableModel")) { - this.setSerializableModel(Boolean.valueOf((String)additionalProperties.get("serializableModel").toString())); + if (additionalProperties.containsKey(CodegenConstants.SERIALIZABLE_MODEL)) { + this.setSerializableModel(Boolean.valueOf((String)additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL).toString())); } // need to put back serializableModel (boolean) into additionalProperties as value in additionalProperties is string - additionalProperties.put("serializableModel", serializableModel); + additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel); this.sanitizeConfig(); @@ -170,18 +164,18 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { // the whole additionalProperties object is injected into the main object passed to the mustache layer this.setApiPackage(sanitizePackageName(apiPackage)); - if (additionalProperties.containsKey("apiPackage")) { - this.additionalProperties.put("apiPackage", apiPackage); + if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) { + this.additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); } this.setModelPackage(sanitizePackageName(modelPackage)); - if (additionalProperties.containsKey("modelPackage")) { - this.additionalProperties.put("modelPackage", modelPackage); + if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) { + this.additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); } this.setInvokerPackage(sanitizePackageName(invokerPackage)); - if (additionalProperties.containsKey("invokerPackage")) { - this.additionalProperties.put("invokerPackage", invokerPackage); + if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { + this.additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java index 168e214aef15..56dbdd0e48b8 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.CodegenType; import io.swagger.codegen.SupportingFile; @@ -38,10 +39,10 @@ public class JavaInflectorServerCodegen extends JavaClientCodegen implements Cod apiPackage = System.getProperty("swagger.codegen.inflector.apipackage", "io.swagger.handler"); modelPackage = System.getProperty("swagger.codegen.inflector.modelpackage", "io.swagger.model"); - additionalProperties.put("invokerPackage", invokerPackage); - additionalProperties.put("groupId", groupId); - additionalProperties.put("artifactId", artifactId); - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); additionalProperties.put("title", title); languageSpecificPrimitives = new HashSet( diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java index 01261799556c..3966cb9bea71 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java @@ -1,14 +1,12 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CodegenConfig; -import io.swagger.codegen.CodegenResponse; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenOperation; +import io.swagger.codegen.CodegenResponse; import io.swagger.codegen.CodegenType; import io.swagger.codegen.SupportingFile; import io.swagger.models.Operation; -import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.MapProperty; -import io.swagger.models.properties.Property; import java.io.File; import java.util.ArrayList; @@ -39,10 +37,10 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf apiPackage = System.getProperty("swagger.codegen.jaxrs.apipackage", "io.swagger.api"); modelPackage = System.getProperty("swagger.codegen.jaxrs.modelpackage", "io.swagger.model"); - additionalProperties.put("invokerPackage", invokerPackage); - additionalProperties.put("groupId", groupId); - additionalProperties.put("artifactId", artifactId); - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); additionalProperties.put("title", title); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index cd88d916e03b..234e1508e6ed 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -2,6 +2,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; @@ -84,12 +85,12 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("object", "object"); typeMapping.put("DateTime", "\\DateTime"); - cliOptions.add(new CliOption("invokerPackage", "The main namespace to use for all classes. e.g. Yay\\Pets")); + cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, "The main namespace to use for all classes. e.g. Yay\\Pets")); cliOptions.add(new CliOption("packagePath", "The main package name for classes. e.g. GeneratedPetstore")); cliOptions.add(new CliOption("srcBasePath", "The directory under packagePath to serve as source root.")); cliOptions.add(new CliOption("composerVendorName", "The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets")); cliOptions.add(new CliOption("composerProjectName", "The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client")); - cliOptions.add(new CliOption("artifactVersion", "The version to use in the composer package version field. e.g. 1.2.3")); + cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "The version to use in the composer package version field. e.g. 1.2.3")); } public String getPackagePath() { @@ -153,22 +154,22 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { additionalProperties.put("srcBasePath", srcBasePath); } - if (additionalProperties.containsKey("invokerPackage")) { - this.setInvokerPackage((String) additionalProperties.get("invokerPackage")); + if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { + this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); } else { - additionalProperties.put("invokerPackage", invokerPackage); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); } - if (additionalProperties.containsKey("modelPackage")) { - this.setModelPackage((String) additionalProperties.get("modelPackage")); + if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) { + this.setModelPackage((String) additionalProperties.get(CodegenConstants.MODEL_PACKAGE)); } else { - additionalProperties.put("modelPackage", modelPackage); + additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); } - if (additionalProperties.containsKey("apiPackage")) { - this.setApiPackage((String) additionalProperties.get("apiPackage")); + if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) { + this.setApiPackage((String) additionalProperties.get(CodegenConstants.API_PACKAGE)); } else { - additionalProperties.put("apiPackage", apiPackage); + additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); } if (additionalProperties.containsKey("composerProjectName")) { @@ -183,10 +184,10 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { additionalProperties.put("composerVendorName", composerVendorName); } - if (additionalProperties.containsKey("artifactVersion")) { - this.setArtifactVersion((String) additionalProperties.get("artifactVersion")); + if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) { + this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION)); } else { - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); } additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RetrofitClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RetrofitClientCodegen.java index 66d3f19f948b..37c119edfb67 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RetrofitClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RetrofitClientCodegen.java @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; @@ -44,10 +45,10 @@ public class RetrofitClientCodegen extends DefaultCodegen implements CodegenConf "native", "super", "while") ); - additionalProperties.put("invokerPackage", invokerPackage); - additionalProperties.put("groupId", groupId); - additionalProperties.put("artifactId", artifactId); - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("service.mustache", diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java index 5d8ae4b89b63..003be5ab950b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; @@ -54,10 +55,10 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig "trait", "try", "true", "type", "val", "var", "while", "with", "yield") ); - additionalProperties.put("invokerPackage", invokerPackage); - additionalProperties.put("groupId", groupId); - additionalProperties.put("artifactId", artifactId); - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); additionalProperties.put("asyncHttpClient", asyncHttpClient); additionalProperties.put("authScheme", authScheme); additionalProperties.put("authPreemptive", authPreemptive); 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 d6b0f78253a9..9bab6a6cad03 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 @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; @@ -73,10 +74,10 @@ public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConf additionalProperties.put("infoEmail", "apiteam@swagger.io"); additionalProperties.put("licenseInfo", "All rights reserved"); additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html"); - additionalProperties.put("invokerPackage", invokerPackage); - additionalProperties.put("groupId", groupId); - additionalProperties.put("artifactId", artifactId); - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("build.sbt", "", "build.sbt")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SilexServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SilexServerCodegen.java index 8bd4d627d567..e25aae159760 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SilexServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SilexServerCodegen.java @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; @@ -41,10 +42,10 @@ public class SilexServerCodegen extends DefaultCodegen implements CodegenConfig "__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor") ); - additionalProperties.put("invokerPackage", invokerPackage); - additionalProperties.put("groupId", groupId); - additionalProperties.put("artifactId", artifactId); - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); // ref: http://php.net/manual/en/language.types.intro.php languageSpecificPrimitives = new HashSet( diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java index edc424f125c6..597fd1f19367 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java @@ -34,12 +34,12 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen configPackage = "io.swagger.configuration"; - additionalProperties.put("invokerPackage", invokerPackage); - additionalProperties.put("groupId", groupId); - additionalProperties.put("artifactId", artifactId); - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); additionalProperties.put("title", title); - additionalProperties.put("apiPackage", apiPackage); + additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); additionalProperties.put("configPackage", configPackage); languageSpecificPrimitives = new HashSet( diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticDocCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticDocCodegen.java index bfee70f1732c..c0ccf2a0a6f4 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticDocCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticDocCodegen.java @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; @@ -21,10 +22,10 @@ public class StaticDocCodegen extends DefaultCodegen implements CodegenConfig { apiTemplateFiles.put("operation.mustache", ".html"); templateDir = "swagger-static"; - additionalProperties.put("invokerPackage", invokerPackage); - additionalProperties.put("groupId", groupId); - additionalProperties.put("artifactId", artifactId); - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); supportingFiles.add(new SupportingFile("main.mustache", "", "main.js")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtmlGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtmlGenerator.java index 8a3244b00972..29cb5d55eaa6 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtmlGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/StaticHtmlGenerator.java @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenOperation; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; @@ -37,10 +38,10 @@ public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig additionalProperties.put("infoEmail", "hello@helloreverb.com"); additionalProperties.put("licenseInfo", "All rights reserved"); additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html"); - additionalProperties.put("invokerPackage", invokerPackage); - additionalProperties.put("groupId", groupId); - additionalProperties.put("artifactId", artifactId); - additionalProperties.put("artifactVersion", artifactVersion); + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); supportingFiles.add(new SupportingFile("index.mustache", "", "index.html")); reservedWords = new HashSet(); diff --git a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/GenerateTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java similarity index 51% rename from modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/GenerateTest.java rename to modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java index bd2a342e3e20..5da6a01763c5 100644 --- a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/GenerateTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java @@ -1,15 +1,13 @@ package io.swagger.codegen; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - +import io.swagger.codegen.languages.JavaClientCodegen; +import io.swagger.models.Swagger; +import io.swagger.parser.SwaggerParser; import org.apache.commons.io.FileUtils; -import org.junit.Rule; -import org.junit.Test; import org.junit.rules.TemporaryFolder; - -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.Assert.fail; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import java.io.BufferedWriter; import java.io.File; @@ -20,34 +18,53 @@ import java.io.Writer; import java.nio.charset.StandardCharsets; import java.util.Arrays; -public class GenerateTest { +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.fail; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * Tests for DefaultGenerator logic + */ +public class DefaultGeneratorTest { private static final String TEST_SKIP_OVERWRITE = "testSkipOverwrite"; private static final String POM_FILE = "pom.xml"; private static final String MODEL_ORDER_FILE = "/src/main/java/io/swagger/client/model/Order.java"; - @Rule public TemporaryFolder folder = new TemporaryFolder(); + @BeforeMethod + public void setUp() throws Exception { + folder.create(); + } + + @AfterMethod + public void tearDown() throws Exception { + folder.delete(); + } + @Test - public void testSkipOverwrite() throws IOException { + public void testSkipOverwrite() throws Exception { final File output = folder.getRoot(); - String[] args = {"generate", "-i", "src/test/resources/petstore.json", "-l", "java", "-o", output.getAbsolutePath()}; - String[] argsWithSparam = Arrays.copyOf(args, args.length + 1); - argsWithSparam[args.length] = "-s"; + final Swagger swagger = new SwaggerParser().read("src/test/resources/petstore.json"); + CodegenConfig codegenConfig = new JavaClientCodegen(); + codegenConfig.setOutputDir(output.getAbsolutePath()); - //generate content first time without -s flag, so all generated files should be recorded - SwaggerCodegen.main(args); + ClientOptInput clientOptInput = new ClientOptInput().opts(new ClientOpts()).swagger(swagger).config(codegenConfig); + + //generate content first time without skipOverwrite flag, so all generated files should be recorded + new DefaultGenerator().opts(clientOptInput).generate(); final File order = new File(output, MODEL_ORDER_FILE); assertTrue(order.exists()); //change content of one file changeContent(order); - //generate content second time without -s flag, so changed file should be rewritten - SwaggerCodegen.main(args); - //order = new File(output, MODEL_ORDER_FILE); + //generate content second time without skipOverwrite flag, so changed file should be rewritten + new DefaultGenerator().opts(clientOptInput).generate(); + assertTrue(!TEST_SKIP_OVERWRITE.equals(FileUtils.readFileToString(order, StandardCharsets.UTF_8))); //change content again @@ -58,9 +75,10 @@ public class GenerateTest { fail(); } - //generate content third time with -s flag, so changed file should not be rewritten + //generate content third time with skipOverwrite flag, so changed file should not be rewritten //and deleted file should be recorded - SwaggerCodegen.main(argsWithSparam); + codegenConfig.setSkipOverwrite(true); + new DefaultGenerator().opts(clientOptInput).generate(); assertEquals(FileUtils.readFileToString(order, StandardCharsets.UTF_8), TEST_SKIP_OVERWRITE); assertTrue(pom.exists()); } @@ -70,4 +88,5 @@ public class GenerateTest { out.write(TEST_SKIP_OVERWRITE); out.close(); } + } diff --git a/modules/swagger-codegen-cli/src/test/resources/petstore.json b/modules/swagger-codegen/src/test/resources/petstore.json similarity index 100% rename from modules/swagger-codegen-cli/src/test/resources/petstore.json rename to modules/swagger-codegen/src/test/resources/petstore.json diff --git a/pom.xml b/pom.xml index 4baa768bd763..8a5f5eac4d12 100644 --- a/pom.xml +++ b/pom.xml @@ -68,6 +68,27 @@ target ${project.artifactId}-${project.version} + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire-version} + + none:none + + + + test-testng + test + + test + + + none:none + org.testng:testng + + + + maven-dependency-plugin @@ -457,6 +478,24 @@ ${junit-version} test + + org.testng + testng + ${testng-version} + test + + + org.jmockit + jmockit + ${jmockit-version} + test + + + org.reflections + reflections + ${reflections-version} + test + @@ -482,5 +521,9 @@ 1.6.3 3.2.1 1.9 + 6.9.6 + 2.18.1 + 1.18 + 0.9.10 From cf5982d2c457b503bc1860f276f8e3c7da5990ba Mon Sep 17 00:00:00 2001 From: russellb337 Date: Wed, 26 Aug 2015 17:51:19 -0700 Subject: [PATCH 092/109] remove class comment --- .../java/io/swagger/codegen/cmd/utils/CodegenConfigLoader.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/CodegenConfigLoader.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/CodegenConfigLoader.java index 2e068bccb474..7b8e8883ca1f 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/CodegenConfigLoader.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/CodegenConfigLoader.java @@ -6,9 +6,6 @@ import java.util.ServiceLoader; import static java.util.ServiceLoader.load; -/** - * Created by russellb337 on 8/25/15. - */ public class CodegenConfigLoader { /** * Tries to load config class with SPI first, then with class name directly from classpath From 60fddcf3780e6fb4ce6a3e4d9ffc2ad18862daf2 Mon Sep 17 00:00:00 2001 From: russellb337 Date: Wed, 26 Aug 2015 17:55:02 -0700 Subject: [PATCH 093/109] adding back imports that somewhere got deleted during reformatting --- .../java/io/swagger/codegen/languages/JavaClientCodegen.java | 2 ++ 1 file changed, 2 insertions(+) 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 3150b602261f..6dea59ea7730 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 @@ -15,7 +15,9 @@ import io.swagger.models.properties.MapProperty; import io.swagger.models.properties.Property; import java.io.File; +import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; From 8ba4a6d7ad5cbc083948377722f61bf91ce827d8 Mon Sep 17 00:00:00 2001 From: russellb337 Date: Wed, 26 Aug 2015 18:25:23 -0700 Subject: [PATCH 094/109] downgrade reflections version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I’m guessing --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8a5f5eac4d12..4bd0dd2f3821 100644 --- a/pom.xml +++ b/pom.xml @@ -524,6 +524,6 @@ 6.9.6 2.18.1 1.18 - 0.9.10 + 0.9.9 From 99ed012fc6ba73c6bb030891177503478267abaa Mon Sep 17 00:00:00 2001 From: russellb337 Date: Wed, 26 Aug 2015 18:31:29 -0700 Subject: [PATCH 095/109] trying a new version of jetty --- .../src/main/resources/JavaInflector/pom.mustache | 2 +- .../swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache | 2 +- .../src/main/resources/JavaSpringMVC/pom.mustache | 2 +- modules/swagger-generator/pom.xml | 2 +- samples/server/petstore/java-inflector/pom.xml | 2 +- samples/server/petstore/jaxrs/pom.xml | 2 +- samples/server/petstore/spring-mvc/pom.xml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache index 20d5aaf30c64..fbdc8940b31f 100644 --- a/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache @@ -84,7 +84,7 @@ 1.0.0 1.5.3 - 9.2.9.v20150224 + 9.3.2.v20150730 1.0.1 4.8.2 1.6.3 diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache index ba58d23ca7f0..9d72123595d7 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache @@ -169,7 +169,7 @@ 1.5.3 - 9.2.9.v20150224 + 9.3.2.v20150730 1.18.1 1.6.3 4.8.1 diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache index ffbb0e435161..c8a918296e7d 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache @@ -151,7 +151,7 @@ 1.5.3 - 9.2.9.v20150224 + 9.3.2.v20150730 1.13 1.6.3 1.6.1 diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml index dbb092e98163..cdf44031067f 100644 --- a/modules/swagger-generator/pom.xml +++ b/modules/swagger-generator/pom.xml @@ -271,7 +271,7 @@ 1.0.0 2.5 1.3.2 - 9.2.9.v20150224 + 9.3.2.v20150730 2.4.1 diff --git a/samples/server/petstore/java-inflector/pom.xml b/samples/server/petstore/java-inflector/pom.xml index 7b7ec1d8b3d6..e8198cc66556 100644 --- a/samples/server/petstore/java-inflector/pom.xml +++ b/samples/server/petstore/java-inflector/pom.xml @@ -84,7 +84,7 @@ 1.0.0 1.5.3 - 9.2.9.v20150224 + 9.3.2.v20150730 1.0.1 4.8.2 1.6.3 diff --git a/samples/server/petstore/jaxrs/pom.xml b/samples/server/petstore/jaxrs/pom.xml index ae9f3e06162f..1ed91f0e8f7b 100644 --- a/samples/server/petstore/jaxrs/pom.xml +++ b/samples/server/petstore/jaxrs/pom.xml @@ -169,7 +169,7 @@ 1.5.3 - 9.2.9.v20150224 + 9.3.2.v20150730 1.18.1 1.6.3 4.8.1 diff --git a/samples/server/petstore/spring-mvc/pom.xml b/samples/server/petstore/spring-mvc/pom.xml index ad0b2c04acff..0498d2c3baa0 100644 --- a/samples/server/petstore/spring-mvc/pom.xml +++ b/samples/server/petstore/spring-mvc/pom.xml @@ -151,7 +151,7 @@ 1.5.3 - 9.2.9.v20150224 + 9.3.2.v20150730 1.13 1.6.3 1.6.1 From ccf0cc83754fbfe27d011cfe23c59d9005f037d0 Mon Sep 17 00:00:00 2001 From: russellb337 Date: Wed, 26 Aug 2015 18:35:22 -0700 Subject: [PATCH 096/109] whoops, didn't mean to upgrade the minor version --- .../src/main/resources/JavaInflector/pom.mustache | 2 +- .../swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache | 2 +- .../src/main/resources/JavaSpringMVC/pom.mustache | 2 +- modules/swagger-generator/pom.xml | 2 +- samples/server/petstore/java-inflector/pom.xml | 2 +- samples/server/petstore/jaxrs/pom.xml | 2 +- samples/server/petstore/spring-mvc/pom.xml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache index fbdc8940b31f..bfcbdfb1aa6f 100644 --- a/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache @@ -84,7 +84,7 @@ 1.0.0 1.5.3 - 9.3.2.v20150730 + 9.2.13.v20150730 1.0.1 4.8.2 1.6.3 diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache index 9d72123595d7..9c881d47cc29 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache @@ -169,7 +169,7 @@ 1.5.3 - 9.3.2.v20150730 + 9.2.13.v20150730 1.18.1 1.6.3 4.8.1 diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache index c8a918296e7d..dad6fd888460 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache @@ -151,7 +151,7 @@ 1.5.3 - 9.3.2.v20150730 + 9.2.13.v20150730 1.13 1.6.3 1.6.1 diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml index cdf44031067f..e631cb789c19 100644 --- a/modules/swagger-generator/pom.xml +++ b/modules/swagger-generator/pom.xml @@ -271,7 +271,7 @@ 1.0.0 2.5 1.3.2 - 9.3.2.v20150730 + 9.2.13.v20150730 2.4.1 diff --git a/samples/server/petstore/java-inflector/pom.xml b/samples/server/petstore/java-inflector/pom.xml index e8198cc66556..e3bb1ba541ba 100644 --- a/samples/server/petstore/java-inflector/pom.xml +++ b/samples/server/petstore/java-inflector/pom.xml @@ -84,7 +84,7 @@ 1.0.0 1.5.3 - 9.3.2.v20150730 + 9.2.13.v20150730 1.0.1 4.8.2 1.6.3 diff --git a/samples/server/petstore/jaxrs/pom.xml b/samples/server/petstore/jaxrs/pom.xml index 1ed91f0e8f7b..667bbd934f11 100644 --- a/samples/server/petstore/jaxrs/pom.xml +++ b/samples/server/petstore/jaxrs/pom.xml @@ -169,7 +169,7 @@ 1.5.3 - 9.3.2.v20150730 + 9.2.13.v20150730 1.18.1 1.6.3 4.8.1 diff --git a/samples/server/petstore/spring-mvc/pom.xml b/samples/server/petstore/spring-mvc/pom.xml index 0498d2c3baa0..102ebbd498ea 100644 --- a/samples/server/petstore/spring-mvc/pom.xml +++ b/samples/server/petstore/spring-mvc/pom.xml @@ -151,7 +151,7 @@ 1.5.3 - 9.3.2.v20150730 + 9.2.13.v20150730 1.13 1.6.3 1.6.1 From d31013d97747900dbcbde47c98a7d4b34f93f5fd Mon Sep 17 00:00:00 2001 From: russellb337 Date: Wed, 26 Aug 2015 18:50:29 -0700 Subject: [PATCH 097/109] remove reflections from parent pom --- pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pom.xml b/pom.xml index 4bd0dd2f3821..1dd80dcb1b97 100644 --- a/pom.xml +++ b/pom.xml @@ -490,12 +490,6 @@ ${jmockit-version} test - - org.reflections - reflections - ${reflections-version} - test - From fc4fce373184e5ee6419a66fd274997290578c35 Mon Sep 17 00:00:00 2001 From: F481 Date: Thu, 27 Aug 2015 08:06:24 +0200 Subject: [PATCH 098/109] write processOperation debug output only if the debugOperations property is set --- .../src/main/java/io/swagger/codegen/DefaultGenerator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index bcc86be0558f..e5a49f4eba46 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -425,7 +425,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { public void processOperation(String resourcePath, String httpMethod, Operation operation, Map> operations, Path path) { if (operation != null) { - LOGGER.info("processOperation: resourcePath= " + resourcePath + "\t;" + httpMethod + " " + operation + "\n"); + if (System.getProperty("debugOperations") != null) { + LOGGER.debug("processOperation: resourcePath= " + resourcePath + "\t;" + httpMethod + " " + operation + "\n"); + } List tags = operation.getTags(); if (tags == null) { tags = new ArrayList(); From 9453967815b5f927a71244723f42cb03fa4ca7c4 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 27 Aug 2015 16:14:07 +0800 Subject: [PATCH 099/109] add function to sanitize name --- .../io/swagger/codegen/DefaultCodegen.java | 35 +++++++++++++++++++ .../languages/CSharpClientCodegen.java | 6 ++-- .../codegen/languages/JavaClientCodegen.java | 6 ++-- .../codegen/languages/ObjcClientCodegen.java | 7 ++-- .../codegen/languages/PhpClientCodegen.java | 19 ++++++++++ .../languages/PythonClientCodegen.java | 8 ++--- .../codegen/languages/RubyClientCodegen.java | 6 ++-- .../src/test/scala/Java/JavaModelTest.scala | 14 ++++++++ .../python/swagger_client/__init__.py | 2 +- .../python/swagger_client/apis/__init__.py | 2 +- .../python/swagger_client/apis/pet_api.py | 2 +- 11 files changed, 87 insertions(+), 20 deletions(-) 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 1422b1c36a0c..e7ba4942e214 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 @@ -1439,4 +1439,39 @@ public class DefaultCodegen { } return new CliOption("library", sb.toString()); } + + /** + * sanitize name (parameter, property, method, etc) + * + * @param name string to be sanitize + * @return sanitized string + */ + public String sanitizeName(String name) { + // NOTE: performance wise, we should have written with 2 replaceAll to replace desired + // character with _ or empty character. Below aims to spell out different cases we've + // encountered so far and hopefully make it easier for others to add more special + // cases in the future. + + // input[] => input + name = name.replaceAll("\\[\\]", ""); + + // input[a][b] => input_a_b + name = name.replaceAll("\\[", "_"); + name = name.replaceAll("\\]", ""); + + // input(a)(b) => input_a_b + name = name.replaceAll("\\(", "_"); + name = name.replaceAll("\\)", ""); + + // input.name => input_name + name = name.replaceAll("\\.", "_"); + + // input-name => input_name + name = name.replaceAll("-", "_"); + + // remove everything else other than word, number and _ + // $php_variable => php_variable + return name.replaceAll("[^a-zA-Z0-9_]", ""); + + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index 1d7accd3b274..09ec05b078bf 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -146,8 +146,8 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig @Override public String toVarName(String name) { - // replace - with _ e.g. created-at => created_at - name = name.replaceAll("-", "_"); + // sanitize name + name = sanitizeName(name); // if it's all uppper case, do nothing if (name.matches("^[A-Z_]*$")) { @@ -249,7 +249,7 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig throw new RuntimeException(operationId + " (reserved word) cannot be used as method name"); } - return camelize(operationId); + return camelize(sanitizeName(operationId)); } } 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 f2347a88e903..5b186133e8d5 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 @@ -201,8 +201,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public String toVarName(String name) { - // replace - with _ e.g. created-at => created_at - name = name.replaceAll("-", "_"); + // sanitize name + name = sanitizeName(name); if("_".equals(name)) { name = "_u"; @@ -303,7 +303,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { throw new RuntimeException(operationId + " (reserved word) cannot be used as method name"); } - return camelize(operationId, true); + return camelize(sanitizeName(operationId), true); } @Override diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java index cb6ec79a9848..dfb4094f2b65 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 @@ -328,9 +328,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public String toVarName(String name) { - // replace non-word characters to `_` - // e.g. `created-at` to `created_at` - name = name.replaceAll("[^a-zA-Z0-9_]", "_"); + // sanitize name + name = sanitizeName(name); // if it's all upper case, do noting if (name.matches("^[A-Z_]$")) { @@ -371,7 +370,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { throw new RuntimeException(operationId + " (reserved word) cannot be used as method name"); } - return camelize(operationId, true); + return camelize(sanitizeName(operationId), true); } public void setClassPrefix(String classPrefix) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index 5f6c48120cb8..98c11c91c6b5 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -299,6 +299,9 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { this.setParameterNamingConvention((String) additionalProperties.get("variableNamingConvention")); } + // sanitize name + name = sanitizeName(name); + if ("camelCase".equals(variableNamingConvention)) { // return the name in camelCase style // phone_number => phoneNumber @@ -341,4 +344,20 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { // should be the same as the model name return toModelName(name); } + + @Override + public String toOperationId(String operationId) { + // throw exception if method name is empty + if (StringUtils.isEmpty(operationId)) { + throw new RuntimeException("Empty method name (operationId) not allowed"); + } + + // method name cannot use reserved keyword, e.g. return + if (reservedWords.contains(operationId)) { + throw new RuntimeException(operationId + " (reserved word) cannot be used as method name"); + } + + return camelize(sanitizeName(operationId), true); + } + } 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 9b685d1e2070..8926a79343a5 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,8 +167,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig @Override public String toVarName(String name) { - // replace - with _ e.g. created-at => created_at - name = name.replaceAll("-", "_"); + // sanitize name + name = sanitizeName(name); // if it's all uppper case, convert to lower case if (name.matches("^[A-Z_]*$")) { @@ -177,7 +177,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig // underscore the variable name // petId => pet_id - name = underscore(dropDots(name)); + name = underscore(name); // remove leading underscore name = name.replaceAll("^_*", ""); @@ -258,7 +258,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig throw new RuntimeException(operationId + " (reserved word) cannot be used as method name"); } - return underscore(operationId); + return underscore(sanitizeName(operationId)); } public void setPackageName(String packageName) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index 36a3f31aa486..4368fc3cef4b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -199,8 +199,8 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public String toVarName(String name) { - // replace - with _ e.g. created-at => created_at - name = name.replaceAll("-", "_"); + // sanitize name + name = sanitizeName(name); // if it's all uppper case, convert to lower case if (name.matches("^[A-Z_]*$")) { @@ -279,7 +279,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { throw new RuntimeException(operationId + " (reserved word) cannot be used as method name"); } - return underscore(operationId); + return underscore(sanitizeName(operationId)); } @Override diff --git a/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala b/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala index 2df8db477de4..1d044fbfdbec 100644 --- a/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala +++ b/modules/swagger-codegen/src/test/scala/Java/JavaModelTest.scala @@ -355,6 +355,20 @@ class JavaModelTest extends FlatSpec with Matchers { vars.get(0).name should be("createdAt") } + it should "convert query[password] to queryPassword" in { + val model = new ModelImpl() + .description("a sample model") + .property("query[password]", new StringProperty()) + + val codegen = new JavaClientCodegen() + val cm = codegen.fromModel("sample", model) + val vars = cm.vars + vars.get(0).baseName should be("query[password]") + vars.get(0).getter should be("getQueryPassword") + vars.get(0).setter should be("setQueryPassword") + vars.get(0).name should be("queryPassword") + } + it should "properly escape names per 567" in { val model = new ModelImpl() .description("a sample model") diff --git a/samples/client/petstore/python/swagger_client/__init__.py b/samples/client/petstore/python/swagger_client/__init__.py index 6e7b59f36fde..f61c5d55262a 100644 --- a/samples/client/petstore/python/swagger_client/__init__.py +++ b/samples/client/petstore/python/swagger_client/__init__.py @@ -9,8 +9,8 @@ from .models.order import Order # import apis into sdk package from .apis.user_api import UserApi -from .apis.store_api import StoreApi from .apis.pet_api import PetApi +from .apis.store_api import StoreApi # import ApiClient from .api_client import ApiClient diff --git a/samples/client/petstore/python/swagger_client/apis/__init__.py b/samples/client/petstore/python/swagger_client/apis/__init__.py index c0e09458f950..592a56e282d2 100644 --- a/samples/client/petstore/python/swagger_client/apis/__init__.py +++ b/samples/client/petstore/python/swagger_client/apis/__init__.py @@ -2,5 +2,5 @@ from __future__ import absolute_import # import apis into api package from .user_api import UserApi -from .store_api import StoreApi from .pet_api import PetApi +from .store_api import StoreApi diff --git a/samples/client/petstore/python/swagger_client/apis/pet_api.py b/samples/client/petstore/python/swagger_client/apis/pet_api.py index 0dcdbc9ddae9..aaf2bacd1e1f 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -409,7 +409,7 @@ class PetApi(object): select_header_content_type([]) # Authentication setting - auth_settings = ['petstore_auth', 'api_key'] + auth_settings = ['api_key', 'petstore_auth'] response = self.api_client.call_api(resource_path, method, path_params, From 50f60678314bfca1db9c4bcccd24ee19d6d31252 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 27 Aug 2015 16:47:41 +0800 Subject: [PATCH 100/109] add a case to handle space in name --- .../src/main/java/io/swagger/codegen/DefaultCodegen.java | 3 +++ 1 file changed, 3 insertions(+) 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 e7ba4942e214..b402f2ce487e 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 @@ -1468,6 +1468,9 @@ public class DefaultCodegen { // input-name => input_name name = name.replaceAll("-", "_"); + + // input name and age => input_name_and_age + name = name.replaceAll(" ", "_"); // remove everything else other than word, number and _ // $php_variable => php_variable From 074ba1ea546e352bc642581c4141d9f0a50b10d7 Mon Sep 17 00:00:00 2001 From: russellb337 Date: Thu, 27 Aug 2015 09:11:49 -0700 Subject: [PATCH 101/109] undo some of the debugging changes I made --- modules/swagger-codegen-cli/pom.xml | 6 ------ .../io/swagger/codegen/cmd/ConfigHelp.java | 6 +----- .../java/io/swagger/codegen/cmd/Generate.java | 3 +-- .../io/swagger/codegen/cmd/GenerateTest.java | 2 +- .../swagger/codegen/plugin/CodeGenMojo.java | 19 ++----------------- modules/swagger-codegen/pom.xml | 6 ++++++ .../swagger/codegen}/CodegenConfigLoader.java | 4 +--- .../main/resources/JavaInflector/pom.mustache | 2 +- .../src/main/resources/JavaJaxRS/pom.mustache | 2 +- .../main/resources/JavaSpringMVC/pom.mustache | 2 +- .../codegen}/CodegenConfigLoaderTest.java | 4 +--- modules/swagger-generator/pom.xml | 2 +- pom.xml | 2 +- .../server/petstore/java-inflector/pom.xml | 2 +- samples/server/petstore/jaxrs/pom.xml | 2 +- samples/server/petstore/spring-mvc/pom.xml | 2 +- 16 files changed, 21 insertions(+), 45 deletions(-) rename modules/{swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils => swagger-codegen/src/main/java/io/swagger/codegen}/CodegenConfigLoader.java (91%) rename modules/{swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils => swagger-codegen/src/test/java/io/swagger/codegen}/CodegenConfigLoaderTest.java (94%) diff --git a/modules/swagger-codegen-cli/pom.xml b/modules/swagger-codegen-cli/pom.xml index 9c0b6af1bcd5..5193e39531a6 100644 --- a/modules/swagger-codegen-cli/pom.xml +++ b/modules/swagger-codegen-cli/pom.xml @@ -98,12 +98,6 @@ ${jmockit-version} test - - org.reflections - reflections - ${reflections-version} - test - \ No newline at end of file diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/ConfigHelp.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/ConfigHelp.java index 5a7c46eefeb3..f7a128613b94 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/ConfigHelp.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/ConfigHelp.java @@ -4,11 +4,7 @@ import io.airlift.airline.Command; import io.airlift.airline.Option; import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; -import io.swagger.codegen.cmd.utils.CodegenConfigLoader; - -import java.util.ServiceLoader; - -import static java.util.ServiceLoader.load; +import io.swagger.codegen.CodegenConfigLoader; @Command(name = "config-help", description = "Config help for chosen lang") public class ConfigHelp implements Runnable { diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java index 9e4754f9a1d2..d6790a6aa8ff 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java @@ -8,9 +8,9 @@ import io.swagger.codegen.CliOption; import io.swagger.codegen.ClientOptInput; import io.swagger.codegen.ClientOpts; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConfigLoader; import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.DefaultGenerator; -import io.swagger.codegen.cmd.utils.CodegenConfigLoader; import io.swagger.codegen.cmd.utils.OptionUtils; import io.swagger.models.Swagger; import io.swagger.parser.SwaggerParser; @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import static java.util.ServiceLoader.load; import static org.apache.commons.lang3.StringUtils.isNotEmpty; /** diff --git a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/GenerateTest.java b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/GenerateTest.java index 2fc414e884e2..94a397df700d 100644 --- a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/GenerateTest.java +++ b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/GenerateTest.java @@ -8,7 +8,7 @@ import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.DefaultGenerator; import io.swagger.codegen.SwaggerCodegen; -import io.swagger.codegen.cmd.utils.CodegenConfigLoader; +import io.swagger.codegen.CodegenConfigLoader; import io.swagger.codegen.languages.JavaClientCodegen; import io.swagger.models.Swagger; import io.swagger.models.auth.AuthorizationValue; diff --git a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java index 41737ca0968e..7500fcfeb398 100644 --- a/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java +++ b/modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java @@ -20,6 +20,7 @@ import io.swagger.codegen.CliOption; import io.swagger.codegen.ClientOptInput; import io.swagger.codegen.ClientOpts; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenConfigLoader; import io.swagger.codegen.DefaultGenerator; import io.swagger.models.Swagger; import io.swagger.parser.SwaggerParser; @@ -121,7 +122,7 @@ public class CodeGenMojo extends AbstractMojo { public void execute() throws MojoExecutionException { Swagger swagger = new SwaggerParser().read(inputSpec); - CodegenConfig config = forName(language); + CodegenConfig config = CodegenConfigLoader.forName(language); config.setOutputDir(output.getAbsolutePath()); if (null != templateDirectory) { @@ -167,20 +168,4 @@ public class CodeGenMojo extends AbstractMojo { project.addCompileSourceRoot(output.toString()); } } - - private CodegenConfig forName(String name) { - ServiceLoader loader = ServiceLoader.load(CodegenConfig.class); - for (CodegenConfig config : loader) { - if (config.getName().equals(name)) { - return config; - } - } - - // else try to load directly - try { - return (CodegenConfig) Class.forName(name).newInstance(); - } catch (Exception e) { - throw new RuntimeException("Can't load config class with name ".concat(name), e); - } - } } diff --git a/modules/swagger-codegen/pom.xml b/modules/swagger-codegen/pom.xml index 0f640d577ada..b6caa0a684ae 100644 --- a/modules/swagger-codegen/pom.xml +++ b/modules/swagger-codegen/pom.xml @@ -340,6 +340,12 @@ ${testng-version} test + + org.reflections + reflections + ${reflections-version} + test + diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/CodegenConfigLoader.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfigLoader.java similarity index 91% rename from modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/CodegenConfigLoader.java rename to modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfigLoader.java index 7b8e8883ca1f..c578ab759128 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/utils/CodegenConfigLoader.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfigLoader.java @@ -1,6 +1,4 @@ -package io.swagger.codegen.cmd.utils; - -import io.swagger.codegen.CodegenConfig; +package io.swagger.codegen; import java.util.ServiceLoader; diff --git a/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache index bfcbdfb1aa6f..20d5aaf30c64 100644 --- a/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaInflector/pom.mustache @@ -84,7 +84,7 @@ 1.0.0 1.5.3 - 9.2.13.v20150730 + 9.2.9.v20150224 1.0.1 4.8.2 1.6.3 diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache index 9c881d47cc29..ba58d23ca7f0 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/pom.mustache @@ -169,7 +169,7 @@ 1.5.3 - 9.2.13.v20150730 + 9.2.9.v20150224 1.18.1 1.6.3 4.8.1 diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache index dad6fd888460..ffbb0e435161 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/pom.mustache @@ -151,7 +151,7 @@ 1.5.3 - 9.2.13.v20150730 + 9.2.9.v20150224 1.13 1.6.3 1.6.1 diff --git a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/CodegenConfigLoaderTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenConfigLoaderTest.java similarity index 94% rename from modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/CodegenConfigLoaderTest.java rename to modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenConfigLoaderTest.java index 0bfd6175f8d3..b91e506a4f96 100644 --- a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/CodegenConfigLoaderTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenConfigLoaderTest.java @@ -1,7 +1,5 @@ -package io.swagger.codegen.cmd.utils; +package io.swagger.codegen; -import io.swagger.codegen.CodegenConfig; -import io.swagger.codegen.DefaultCodegen; import org.reflections.Reflections; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml index e631cb789c19..dbb092e98163 100644 --- a/modules/swagger-generator/pom.xml +++ b/modules/swagger-generator/pom.xml @@ -271,7 +271,7 @@ 1.0.0 2.5 1.3.2 - 9.2.13.v20150730 + 9.2.9.v20150224 2.4.1 diff --git a/pom.xml b/pom.xml index 1dd80dcb1b97..2ff111c57452 100644 --- a/pom.xml +++ b/pom.xml @@ -518,6 +518,6 @@ 6.9.6 2.18.1 1.18 - 0.9.9 + 0.9.10 diff --git a/samples/server/petstore/java-inflector/pom.xml b/samples/server/petstore/java-inflector/pom.xml index e3bb1ba541ba..7b7ec1d8b3d6 100644 --- a/samples/server/petstore/java-inflector/pom.xml +++ b/samples/server/petstore/java-inflector/pom.xml @@ -84,7 +84,7 @@ 1.0.0 1.5.3 - 9.2.13.v20150730 + 9.2.9.v20150224 1.0.1 4.8.2 1.6.3 diff --git a/samples/server/petstore/jaxrs/pom.xml b/samples/server/petstore/jaxrs/pom.xml index 667bbd934f11..ae9f3e06162f 100644 --- a/samples/server/petstore/jaxrs/pom.xml +++ b/samples/server/petstore/jaxrs/pom.xml @@ -169,7 +169,7 @@ 1.5.3 - 9.2.13.v20150730 + 9.2.9.v20150224 1.18.1 1.6.3 4.8.1 diff --git a/samples/server/petstore/spring-mvc/pom.xml b/samples/server/petstore/spring-mvc/pom.xml index 102ebbd498ea..ad0b2c04acff 100644 --- a/samples/server/petstore/spring-mvc/pom.xml +++ b/samples/server/petstore/spring-mvc/pom.xml @@ -151,7 +151,7 @@ 1.5.3 - 9.2.13.v20150730 + 9.2.9.v20150224 1.13 1.6.3 1.6.1 From 32ffab45192ee0101c7cda55ed0a75585bf3f7b3 Mon Sep 17 00:00:00 2001 From: Paul Ebermann Date: Thu, 27 Aug 2015 19:17:40 +0200 Subject: [PATCH 102/109] fix issue #1143: add another null check. The problem was trying to iterate over a null list. --- .../java/io/swagger/codegen/languages/JavaClientCodegen.java | 2 ++ 1 file changed, 2 insertions(+) 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 fe9b9ed2e57d..93ca1911c572 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 @@ -342,6 +342,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { continue; List values = (List) allowableValues.get("values"); // put "enumVars" map into `allowableValues", including `name` and `value` + if (values == null) + continue; List> enumVars = new ArrayList>(); for (String value : values) { Map enumVar = new HashMap(); From 930c5191e0f4d251c795023799566a49a28ff8a0 Mon Sep 17 00:00:00 2001 From: Paul Ebermann Date: Fri, 28 Aug 2015 19:56:37 +0200 Subject: [PATCH 103/109] Issue #1146: trim string before escaping This removes leading and trailing whitespace before escaping strings. This gets rid of annoying `\n` in some string literals (e.g. in annotations). --- .../src/main/java/io/swagger/codegen/DefaultCodegen.java | 1 + 1 file changed, 1 insertion(+) 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 aeca659e42a9..f2f90665b1b0 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 @@ -126,6 +126,7 @@ public class DefaultCodegen { // override with any special text escaping logic public String escapeText(String input) { if (input != null) { + input = input.trim(); String output = input.replaceAll("\n", "\\\\n"); output = output.replace("\"", "\\\""); return output; From 1331484a0fe5c7fba69b553b340fd51cb88bae41 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 29 Aug 2015 22:39:44 +0800 Subject: [PATCH 104/109] fix urlencode in apiclient --- .../main/resources/csharp/ApiClient.mustache | 2 +- .../csharp/IO/Swagger/Client/ApiClient.cs | 22 +++++++++++++++--- .../SwaggerClientTest.csproj | 6 ++--- .../bin/Debug/SwaggerClientTest.dll | Bin 56320 -> 57344 bytes .../bin/Debug/SwaggerClientTest.dll.mdb | Bin 16840 -> 16975 bytes .../obj/Debug/SwaggerClientTest.dll | Bin 56320 -> 57344 bytes .../obj/Debug/SwaggerClientTest.dll.mdb | Bin 16840 -> 16975 bytes 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache index b74ab56ea107..38d95461d1d6 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache @@ -170,7 +170,7 @@ namespace {{packageName}}.Client /// Escaped string. public string EscapeString(string str) { - return RestSharp.Contrib.HttpUtility.UrlEncode(str); + return RestSharp.Extensions.StringExtensions.UrlDecode(str); } /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs index 9041bbf42f09..4d87e7bd9c6e 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs @@ -49,6 +49,16 @@ namespace IO.Swagger.Client { get { return _defaultHeaderMap; } } + + /// + /// Gets the status code of the previous request + /// + public int StatusCode { get; private set; } + + /// + /// Gets the response headers of the previous request + /// + public Dictionary ResponseHeaders { get; private set; } // Creates and sets up a RestRequest prior to a call. private RestRequest PrepareRequest( @@ -110,7 +120,10 @@ namespace IO.Swagger.Client { var request = PrepareRequest( path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - return (Object)RestClient.Execute(request); + var response = RestClient.Execute(request); + StatusCode = (int) response.StatusCode; + ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()); + return (Object) response; } /// @@ -133,7 +146,10 @@ namespace IO.Swagger.Client { var request = PrepareRequest( path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings); - return (Object) await RestClient.ExecuteTaskAsync(request); + var response = await RestClient.ExecuteTaskAsync(request); + StatusCode = (int)response.StatusCode; + ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()); + return (Object)response; } /// @@ -154,7 +170,7 @@ namespace IO.Swagger.Client /// Escaped string. public string EscapeString(string str) { - return RestSharp.Contrib.HttpUtility.UrlEncode(str); + return RestSharp.Extensions.StringExtensions.UrlDecode(str); } /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj index 670402c0cd2f..982ecc7a3158 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj @@ -32,15 +32,15 @@ Lib\SwaggerClient\bin\Newtonsoft.Json.dll - - Lib\SwaggerClient\bin\RestSharp.dll - packages\NUnit.2.6.4\lib\nunit.framework.dll + + Lib\SwaggerClient\bin\RestSharp.dll + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll index 0fa7c24ab8afb1ced9a6697b40d163fee0522e39..8f38016c832bf50d0ba402544b302681b7ea5fd7 100755 GIT binary patch literal 57344 zcmd^o3w&Hvwf8z_-jigKnWX8vq_lT|EB01*Z8dFw5r2axk$i=;#-`~^J)zh@}^z}_Ua-G>3H8t^xTJ_pxM5_#Lf%|um z%<)x5l;}sGg%y3xACWgPY~a(PU{kf5soZ|~YXKj0{tHmcJBjM#e>c~t5+Q=#cL;1y z)ZYvx(PU7yEjyIFi3mM#{-VHFIvCN6zU;0(;O);L0Z;m>+YLf$QSY*z*O7N zH}2?9gzY3PFvyI2wmSzwX)D?+Hu#w%A^_wT`zb`T*sl2FwwV;7rLfoo7b`0ZV~EL3 zW*U{pDXA%me!QXaJ4cmZ&{O44dcYb31? z7GT?WeW;;69LZNfGCvYYE(D_8uzplqA0Ga`7#cOHF+TzP+v_8W8y*o&hGWTKG89Qh zay^jji$knFnvCY)#PO!6q!YEk*CqEcyWQi1Ds6)4b7UGt^ork|7Y53_)zUt7^=N= zfupe(Mp^8&RNHHX$6lBlu-yP>Y%jQ*-(JVSf*4`=*KKIw+wrf!g5j`zH2+PMw|xzb z4~z31#@!l+YQCq3YCc_{viVdqwaY$*DK$D>3m*aj6F;6qYzy}>wLT_}nT+vVRK5v^ z7hA8_wmwtYI?29yma;WxY-?zkny&ZwrfchA#@}b_xhVe+v-PP^u5ELaQ(G1IZ?`q# zir9LKwsqEH>#fSxoUyGDGW@na1AdJLC8^d(BM!$K-!v9*RF_DWM}X}u6ggDoUjz7d z++OQlFa}B^`5Mz1kZUm=N9PLm3>aYt+>sEuebVrfz&qrbFd1rwG&;J#(TolPsaZY~ znCh7c9B0*Bz!D+jbD8kSAy z+uu1XDjN9)#2t&^f)N<4WHA4tGh9KJ8?w1>Bn!FR!$h(nF9fd+b^LUJ%HyXNPIQXL zq!l?9Ng0#fV*g-qkL01^6_T69cS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2j7+t|$Fe<>O!AkHH z>{Nk!Vy7GU9#{?DghuY*GBnbFZ-AMfPAH&t5R|^C6h|IS6Kcj)4Ck!sY*L diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll index 0fa7c24ab8afb1ced9a6697b40d163fee0522e39..8f38016c832bf50d0ba402544b302681b7ea5fd7 100755 GIT binary patch literal 57344 zcmd^o3w&Hvwf8z_-jigKnWX8vq_lT|EB01*Z8dFw5r2axk$i=;#-`~^J)zh@}^z}_Ua-G>3H8t^xTJ_pxM5_#Lf%|um z%<)x5l;}sGg%y3xACWgPY~a(PU{kf5soZ|~YXKj0{tHmcJBjM#e>c~t5+Q=#cL;1y z)ZYvx(PU7yEjyIFi3mM#{-VHFIvCN6zU;0(;O);L0Z;m>+YLf$QSY*z*O7N zH}2?9gzY3PFvyI2wmSzwX)D?+Hu#w%A^_wT`zb`T*sl2FwwV;7rLfoo7b`0ZV~EL3 zW*U{pDXA%me!QXaJ4cmZ&{O44dcYb31? z7GT?WeW;;69LZNfGCvYYE(D_8uzplqA0Ga`7#cOHF+TzP+v_8W8y*o&hGWTKG89Qh zay^jji$knFnvCY)#PO!6q!YEk*CqEcyWQi1Ds6)4b7UGt^ork|7Y53_)zUt7^=N= zfupe(Mp^8&RNHHX$6lBlu-yP>Y%jQ*-(JVSf*4`=*KKIw+wrf!g5j`zH2+PMw|xzb z4~z31#@!l+YQCq3YCc_{viVdqwaY$*DK$D>3m*aj6F;6qYzy}>wLT_}nT+vVRK5v^ z7hA8_wmwtYI?29yma;WxY-?zkny&ZwrfchA#@}b_xhVe+v-PP^u5ELaQ(G1IZ?`q# zir9LKwsqEH>#fSxoUyGDGW@na1AdJLC8^d(BM!$K-!v9*RF_DWM}X}u6ggDoUjz7d z++OQlFa}B^`5Mz1kZUm=N9PLm3>aYt+>sEuebVrfz&qrbFd1rwG&;J#(TolPsaZY~ znC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X?Dx^ukVdw#E zF+T%Gpr?Xg1dc*$!-+nH{utT}?F$@(t_4>E$Dt2`M*%0G&wx(@C!wE;Ai`2U`UE-+ zIt4fdy#bs9dx9Ety50~xp#HhAzkupB%aMi+2j7+t|$Fe<>O!AkHH z>{Nk!Vy7GU9#{?DghuY*GBnbFZ-AMfPAH&t5R|^C6h|IS6Kcj)4Ck!sY*L From 177436e69cf02c39df0eb207f386b48c02132d03 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 29 Aug 2015 22:43:22 +0800 Subject: [PATCH 105/109] fix decode with encode --- .../src/main/resources/csharp/ApiClient.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache index 38d95461d1d6..3399d84297da 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache @@ -170,7 +170,7 @@ namespace {{packageName}}.Client /// Escaped string. public string EscapeString(string str) { - return RestSharp.Extensions.StringExtensions.UrlDecode(str); + return RestSharp.Extensions.StringExtensions.UrlEncode(str); } /// From b846fa5c3ecc1c32a8156b90993809773f24e2b0 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 31 Aug 2015 18:44:01 +0800 Subject: [PATCH 106/109] update JMockit to 1.19 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2ff111c57452..4f0d717140aa 100644 --- a/pom.xml +++ b/pom.xml @@ -517,7 +517,7 @@ 1.9 6.9.6 2.18.1 - 1.18 + 1.19 0.9.10 From e0679c0b145eb82863682dcc33f2194b47824a23 Mon Sep 17 00:00:00 2001 From: Paul Ebermann Date: Mon, 31 Aug 2015 13:45:24 +0200 Subject: [PATCH 107/109] Issue #1142: sanitize the class name for Java model classes. This builds on #1139, calling the new sanitizeName() method before camelizing it when generating model names. --- .../java/io/swagger/codegen/languages/JavaClientCodegen.java | 2 ++ 1 file changed, 2 insertions(+) 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 aad744dd1ce4..643e6fc92e1a 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 @@ -237,6 +237,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public String toModelName(String name) { + name = sanitizeName(name); + // model name cannot use reserved keyword, e.g. return if (reservedWords.contains(name)) { throw new RuntimeException(name + " (reserved word) cannot be used as a model name"); From 92f9b33eb6c1cf7af246f1449c2b9c1372c21bad Mon Sep 17 00:00:00 2001 From: Paul Ebermann Date: Mon, 31 Aug 2015 15:14:54 +0200 Subject: [PATCH 108/109] Issue #1142: sanitize api name before camelizing. This builds on #1139 in order to solve another part of #1142: When the first component of a path contained a dash, the generated class name contained this dash too (for the "language" spring-mvc). --- .../io/swagger/codegen/languages/JaxRSServerCodegen.java | 2 +- .../codegen/languages/SpringMVCServerCodegen.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java index 3966cb9bea71..eb0f6be03e9d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java @@ -163,7 +163,7 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf if (name.length() == 0) { return "DefaultApi"; } - name = name.replaceAll("[^a-zA-Z0-9]+", "_"); + name = sanitizeName(name); return camelize(name) + "Api"; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java index 597fd1f19367..863a1aef2e70 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java @@ -175,6 +175,15 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen return objs; } + @Override + public String toApiName(String name) { + if (name.length() == 0) { + return "DefaultApi"; + } + name = sanitizeName(name); + return camelize(name) + "Api"; + } + public void setConfigPackage(String configPackage) { this.configPackage = configPackage; } From 2c64e0893b86e7105cf97a4159ccfd64fca6a1d7 Mon Sep 17 00:00:00 2001 From: xhh Date: Tue, 1 Sep 2015 20:04:47 +0800 Subject: [PATCH 109/109] Fix bug of hard-coded enum name in Java client --- .../swagger-codegen/src/main/resources/Java/enumClass.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/enumClass.mustache b/modules/swagger-codegen/src/main/resources/Java/enumClass.mustache index 1cef90b75a4a..68fc07aae7d7 100644 --- a/modules/swagger-codegen/src/main/resources/Java/enumClass.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/enumClass.mustache @@ -3,7 +3,7 @@ public enum {{datatypeWithEnum}} { private String value; - StatusEnum(String value) { + {{datatypeWithEnum}}(String value) { this.value = value; }