diff --git a/README.md b/README.md index 03876e61ed9..ff4d7467ca1 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ Great for creating libraries on your ci server, from the [Swagger Editor](http:/ There are different aspects of customizing the code generator beyond just creating or modifying templates. Each language has a supporting configuration file to handle different type mappings, etc: ``` -$ ls -1 modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/ +$ ls -1 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ AndroidClientCodegen.java AsyncScalaClientCodegen.java CSharpClientCodegen.java @@ -237,7 +237,7 @@ To change, for example, the prefix for the Objective-C generated files, simply s ``` package com.mycompany.swagger.codegen; -import com.wordnik.swagger.codegen.languages.*; +import io.swagger.codegen.languages.*; public class MyObjcCodegen extends ObjcClientCodegen { static { diff --git a/modules/swagger-codegen-cli/pom.xml b/modules/swagger-codegen-cli/pom.xml index 388dd1a8392..8f57c21653f 100644 --- a/modules/swagger-codegen-cli/pom.xml +++ b/modules/swagger-codegen-cli/pom.xml @@ -1,9 +1,9 @@ - com.wordnik + io.swagger swagger-codegen-project - 2.1.1-M2-SNAPSHOT + 2.1.1 ../.. 4.0.0 @@ -30,7 +30,7 @@ - com.wordnik.swagger.codegen.SwaggerCodegen + io.swagger.codegen.SwaggerCodegen @@ -74,7 +74,7 @@ - com.wordnik + io.swagger swagger-codegen ${project.version} diff --git a/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/SwaggerCodegen.java b/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/SwaggerCodegen.java deleted file mode 100644 index f2c794776ce..00000000000 --- a/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/SwaggerCodegen.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.wordnik.swagger.codegen; - -import com.wordnik.swagger.codegen.cmd.ConfigHelp; -import com.wordnik.swagger.codegen.cmd.Generate; -import com.wordnik.swagger.codegen.cmd.Langs; -import com.wordnik.swagger.codegen.cmd.Meta; -import io.airlift.airline.Cli; -import io.airlift.airline.Help; - -/** - * User: lanwen - * Date: 24.03.15 - * Time: 17:56 - * - * Command line interface for swagger codegen - * use `swagger-codegen-cli.jar help` for more info - * - * @since 2.1.3-M1 - */ -public class SwaggerCodegen { - - - public static void main(String[] args) { - Cli.CliBuilder builder = Cli.builder("swagger") - .withDescription("Swagger code generator CLI. More info on swagger.io") - .withDefaultCommand(Langs.class) - .withCommands( - Generate.class, - Meta.class, - Langs.class, - Help.class, - ConfigHelp.class - ); - - builder.build().parse(args).run(); - } -} diff --git a/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/ConfigHelp.java b/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/ConfigHelp.java deleted file mode 100644 index fbdca12e6e8..00000000000 --- a/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/ConfigHelp.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.wordnik.swagger.codegen.cmd; - -import com.wordnik.swagger.codegen.CliOption; -import com.wordnik.swagger.codegen.CodegenConfig; -import io.airlift.airline.Command; -import io.airlift.airline.Option; -import java.util.ServiceLoader; -import static java.util.ServiceLoader.load; - -@Command(name = "config-help", description = "Config help for chosen lang") -public class ConfigHelp implements Runnable { - - @Option(name = {"-l", "--lang"}, title = "language", required = true, - description = "language to get config help for") - private String lang; - - @Override - public void run() { - System.out.println(); - CodegenConfig config = forName(lang); - 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(); - } - } - - /** - * 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); - } - } -} diff --git a/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/Generate.java b/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/Generate.java deleted file mode 100644 index 3485eb8dd24..00000000000 --- a/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/Generate.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.wordnik.swagger.codegen.cmd; - -import com.wordnik.swagger.codegen.CliOption; -import com.wordnik.swagger.codegen.ClientOptInput; -import com.wordnik.swagger.codegen.ClientOpts; -import com.wordnik.swagger.codegen.CodegenConfig; -import com.wordnik.swagger.codegen.DefaultGenerator; -import com.wordnik.swagger.models.Swagger; -import config.Config; -import config.ConfigParser; -import io.airlift.airline.Command; -import io.airlift.airline.Option; -import io.swagger.parser.SwaggerParser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ServiceLoader; - -import static java.util.ServiceLoader.load; -import static org.apache.commons.lang3.StringUtils.isNotEmpty; - -/** - * User: lanwen - * Date: 24.03.15 - * Time: 20:22 - */ - -@Command(name = "generate", description = "Generate code with chosen lang") -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; - - @Option(name = {"-l", "--lang"}, title = "language", required = true, - description = "client language to generate (maybe class name in classpath, required)") - private String lang; - - @Option(name = {"-o", "--output"}, title = "output directory", - description = "where to write the generated files (current dir by default)") - private String output = ""; - - @Option(name = {"-i", "--input-spec"}, title = "spec file", required = true, - description = "location of the swagger spec, as URL or file (required)") - private String spec; - - @Option(name = {"-t", "--template-dir"}, title = "template directory", - description = "folder containing the template files") - private String templateDir; - - @Option(name = {"-a", "--auth"}, title = "authorization", - description = "adds authorization headers when fetching the swagger definitions remotely. " + - "Pass in a URL-encoded string of name:header with a comma separating multiple values") - private String auth; - - @Option( name= {"-D"}, title = "system properties", description = "sets specified system properties in " + - "the format of name=value,name=value") - private String systemProperties; - - @Option( name= {"-c", "--config"}, title = "configuration file", description = "Path to json configuration file. " + - "File content should be in a json format {\"optionKey\":\"optionValue\", \"optionKey1\":\"optionValue1\"...} " + - "Supported options can be different for each language. Run config-help -l {lang} command for language specific config options.") - private String configFile; - - @Override - public void run() { - verbosed(verbose); - - setSystemProperties(); - - ClientOptInput input = new ClientOptInput(); - - if (isNotEmpty(auth)) { - input.setAuth(auth); - } - - CodegenConfig config = forName(lang); - config.setOutputDir(new File(output).getAbsolutePath()); - - if (null != templateDir) { - config.additionalProperties().put(TEMPLATE_DIR_PARAM, new File(templateDir).getAbsolutePath()); - } - - if(null != configFile){ - 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())); - } - } - } - } - - input.setConfig(config); - - 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) ); - } - } - } - } - - /** - * If true parameter, adds system properties which enables debug mode in generator - * @param verbose - if true, enables debug mode - */ - private void verbosed(boolean verbose) { - if (!verbose) { - return; - } - LOG.info("\nVERBOSE MODE: ON. Additional debug options are injected" + - "\n - [debugSwagger] prints the swagger specification as interpreted by the codegen" + - "\n - [debugModels] prints models passed to the template engine" + - "\n - [debugOperations] prints operations passed to the template engine" + - "\n - [debugSupportingFiles] prints additional data passed to the template engine"); - - System.setProperty("debugSwagger", ""); - System.setProperty("debugModels", ""); - System.setProperty("debugOperations", ""); - System.setProperty("debugSupportingFiles", ""); - } - - /** - * 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); - } - } -} diff --git a/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/Langs.java b/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/Langs.java deleted file mode 100644 index 7942804d434..00000000000 --- a/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/Langs.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.wordnik.swagger.codegen.cmd; - -import ch.lambdaj.collection.LambdaIterable; -import com.wordnik.swagger.codegen.CodegenConfig; -import io.airlift.airline.Command; - -import static ch.lambdaj.Lambda.on; -import static ch.lambdaj.collection.LambdaCollections.with; -import static java.util.ServiceLoader.load; - -/** - * User: lanwen - * Date: 24.03.15 - * Time: 20:25 - */ -@Command(name = "langs", description = "Shows available langs") -public class Langs implements Runnable { - @Override - public void run() { - LambdaIterable langs = with(load(CodegenConfig.class)).extract(on(CodegenConfig.class).getName()); - System.out.printf("Available languages: %s%n", langs); - } -} diff --git a/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/Meta.java b/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/Meta.java deleted file mode 100644 index 47843de39ad..00000000000 --- a/modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd/Meta.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.wordnik.swagger.codegen.cmd; - -import ch.lambdaj.function.convert.Converter; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.samskivert.mustache.Mustache; -import com.wordnik.swagger.codegen.DefaultGenerator; -import com.wordnik.swagger.codegen.SupportingFile; -import io.airlift.airline.Command; -import io.airlift.airline.Option; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.io.Reader; -import java.util.List; -import java.util.Map; - -import static ch.lambdaj.collection.LambdaCollections.with; -import static com.google.common.base.Joiner.on; - -/** - * User: lanwen - * Date: 24.03.15 - * Time: 20:22 - */ - -@Command(name = "meta", description = "MetaGenerator. Generator for creating a new template set " + - "and configuration for Codegen. The output will be based on the language you " + - "specify, and includes default templates to include.") -public class Meta implements Runnable { - - private static final Logger LOG = LoggerFactory.getLogger(Meta.class); - - private static final String TEMPLATE_DIR_CLASSPATH = "codegen"; - private static final String MUSTACHE_EXTENSION = ".mustache"; - - @Option(name = {"-o", "--output"}, title = "output directory", - description = "where to write the generated files (current dir by default)") - private String outputFolder = ""; - - @Option(name = {"-n", "--name"}, title = "name", - description = "the human-readable name of the generator") - private String name = "default"; - - @Option(name = {"-p", "--package"}, title = "package", - description = "the package to put the main class into (defaults to com.wordnik.swagger.codegen)") - private String targetPackage = "com.wordnik.swagger.codegen"; - - @Override - public void run() { - final File targetDir = new File(outputFolder); - LOG.info("writing to folder [{}]", targetDir.getAbsolutePath()); - - String mainClass = StringUtils.capitalize(name) + "Generator"; - - List supportingFiles = ImmutableList.of( - new SupportingFile("pom.mustache", "", "pom.xml"), - new SupportingFile("generatorClass.mustache", - on(File.separator).join("src/main/java", asPath(targetPackage)), mainClass.concat(".java")), - new SupportingFile("README.mustache", "", "README.md"), - new SupportingFile("api.template", "src/main/resources" + File.separator + name, "api.mustache"), - new SupportingFile("model.template", "src/main/resources" + File.separator + name, "model.mustache"), - new SupportingFile("services.mustache", - "src/main/resources/META-INF/services", "com.wordnik.swagger.codegen.CodegenConfig") - ); - - Map data = new ImmutableMap.Builder() - .put("generatorPackage", targetPackage) - .put("generatorClass", mainClass) - .put("name", name) - .put("fullyQualifiedGeneratorClass", targetPackage + "." + mainClass).build(); - - - with(supportingFiles).convert(processFiles(targetDir, data)); - } - - /** - * Converter method to process supporting files: execute with mustache, - * or simply copy to destination directory - * @param targetDir - destination directory - * @param data - map with additional params needed to process templates - * @return converter object to pass to lambdaj - */ - private Converter processFiles(final File targetDir, final Map data) { - return new Converter() { - private DefaultGenerator generator = new DefaultGenerator(); - - @Override - public File convert(SupportingFile support) { - try { - File destinationFolder = new File(new File(targetDir.getAbsolutePath()), support.folder); - File outputFile = new File(destinationFolder, support.destinationFilename); - - String template = generator - .readTemplate(new File(TEMPLATE_DIR_CLASSPATH, support.templateFile).getPath()); - String formatted = template; - - if (support.templateFile.endsWith(MUSTACHE_EXTENSION)) { - LOG.info("writing file to {}", outputFile.getAbsolutePath()); - formatted = Mustache.compiler().withLoader(loader(generator)) - .defaultValue("") - .compile(template) - .execute(data); - } else { - LOG.info("copying file to {}", outputFile.getAbsolutePath()); - } - - FileUtils.writeStringToFile(outputFile, formatted); - return outputFile; - - } catch (IOException e) { - throw new RuntimeException("Can't generate project", e); - } - } - }; - } - - /** - * Creates mustache loader for template using classpath loader - * @param generator - class with reader getter - * @return loader for template - */ - private Mustache.TemplateLoader loader(final DefaultGenerator generator) { - return new Mustache.TemplateLoader() { - public Reader getTemplate(String name) { - return generator.getTemplateReader(TEMPLATE_DIR_CLASSPATH - + File.separator + name.concat(MUSTACHE_EXTENSION)); - } - }; - } - - /** - * Converts package name to path on file system - * @param packageName - package name to convert - * @return relative path - */ - private String asPath(String packageName) { - return packageName.replace(".", File.separator); - } -} diff --git a/modules/swagger-codegen-cli/src/main/resources/logback.xml b/modules/swagger-codegen-cli/src/main/resources/logback.xml index 4e86443d8d3..273b46980db 100644 --- a/modules/swagger-codegen-cli/src/main/resources/logback.xml +++ b/modules/swagger-codegen-cli/src/main/resources/logback.xml @@ -5,7 +5,7 @@ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - + 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 9300657dc51..fd53c6db3e2 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 @@ -22,7 +22,7 @@ public class AkkaScalaClientCodegen extends DefaultCodegen implements CodegenCon protected String mainPackage = "io.swagger.client"; protected String invokerPackage = mainPackage + ".core"; - protected String groupId = "com.wordnik"; + protected String groupId = "io.swagger"; protected String artifactId = "swagger-client"; protected String artifactVersion = "1.0.0"; protected String sourceFolder = "src/main/scala"; 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 aa202060f1e..5e06d3fd3f5 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 @@ -8,7 +8,7 @@ import java.io.File; public class AsyncScalaClientCodegen extends DefaultCodegen implements CodegenConfig { protected String invokerPackage = "io.swagger.client"; - protected String groupId = "com.wordnik"; + protected String groupId = "io.swagger"; protected String artifactId = "swagger-async-scala-client"; protected String artifactVersion = "1.0.0"; protected String sourceFolder = "src/main/scala"; diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java index 8b4bef52ebe..4e381b112f7 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java @@ -9,7 +9,7 @@ import java.io.File; public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig { protected String invokerPackage = "SwaggerClient"; - protected String groupId = "com.wordnik"; + protected String groupId = "io.swagger"; protected String artifactId = "swagger-client"; protected String artifactVersion = "1.0.0"; 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 e1bdf1d0d5d..b82419c450f 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 @@ -9,7 +9,7 @@ import java.io.File; public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { protected String invokerPackage = "com.wordnik.client"; - protected String groupId = "com.wordnik"; + protected String groupId = "io.swagger"; protected String artifactId = "swagger-client"; protected String artifactVersion = "1.0.0"; 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 2acc7c4cd0a..1d1dc579d78 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 @@ -8,7 +8,7 @@ import java.io.File; public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig { protected String invokerPackage = "io.swagger.client"; - protected String groupId = "com.wordnik"; + protected String groupId = "io.swagger"; protected String artifactId = "swagger-scala-client"; protected String artifactVersion = "1.0.0"; protected String sourceFolder = "src/main/scala"; 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 df2c7e7f0b5..aadbf9a7231 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 @@ -9,7 +9,7 @@ import java.io.File; public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConfig { protected String invokerPackage = "com.wordnik.client"; - protected String groupId = "com.wordnik"; + protected String groupId = "io.swagger"; protected String artifactId = "swagger-client"; protected String artifactVersion = "1.0.0"; protected String sourceFolder = "src/main/scala"; 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 4c3a894155b..9120315ab3a 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 @@ -32,7 +32,7 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen } public SpringMVCServerCodegen() { - super(); + super.processOpts(); outputFolder = "generated-code/javaSpringMVC"; modelTemplateFiles.put("model.mustache", ".java"); apiTemplateFiles.put("api.mustache", ".java"); @@ -50,6 +50,22 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen additionalProperties.put("apiPackage", apiPackage); additionalProperties.put("configPackage", configPackage); + languageSpecificPrimitives = new HashSet( + Arrays.asList( + "String", + "boolean", + "Boolean", + "Double", + "Integer", + "Long", + "Float") + ); + } + + @Override + public void processOpts() { + super.processOpts(); + supportingFiles.clear(); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); @@ -73,16 +89,6 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen supportingFiles.add(new SupportingFile("swagger.properties", ("src.main.resources").replace(".", java.io.File.separator), "swagger.properties")); - languageSpecificPrimitives = new HashSet( - Arrays.asList( - "String", - "boolean", - "Boolean", - "Double", - "Integer", - "Long", - "Float") - ); } @Override 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 cb403727337..b751b62147f 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 @@ -8,7 +8,7 @@ import java.io.File; public class StaticDocCodegen extends DefaultCodegen implements CodegenConfig { protected String invokerPackage = "com.wordnik.client"; - protected String groupId = "com.wordnik"; + protected String groupId = "io.swagger"; protected String artifactId = "swagger-client"; protected String artifactVersion = "1.0.0"; protected String sourceFolder = "docs"; 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 0b6e269a859..96d004fe5e1 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 @@ -11,7 +11,7 @@ import java.io.File; public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig { private static final String ALL_OPERATIONS = ""; protected String invokerPackage = "com.wordnik.client"; - protected String groupId = "com.wordnik"; + protected String groupId = "io.swagger"; protected String artifactId = "swagger-client"; protected String artifactVersion = "1.0.0"; protected String sourceFolder = "src/main/scala"; diff --git a/modules/swagger-codegen/src/main/resources/Java/model.mustache b/modules/swagger-codegen/src/main/resources/Java/model.mustache index b6135636597..0e12f514c48 100644 --- a/modules/swagger-codegen/src/main/resources/Java/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/model.mustache @@ -3,7 +3,7 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} -import com.wordnik.swagger.annotations.*; +import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache index a0afd38f634..3216b60d516 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/api.mustache @@ -4,7 +4,7 @@ import {{modelPackage}}.*; import {{package}}.{{classname}}Service; import {{package}}.factories.{{classname}}ServiceFactory; -import com.wordnik.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiParam; import com.sun.jersey.multipart.FormDataParam; @@ -25,7 +25,7 @@ import javax.ws.rs.*; @Path("/{{baseName}}") {{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} {{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} -@com.wordnik.swagger.annotations.Api(value = "/{{baseName}}", description = "the {{baseName}} API") +@io.swagger.annotations.Api(value = "/{{baseName}}", description = "the {{baseName}} API") {{#operations}} public class {{classname}} { @@ -36,9 +36,9 @@ public class {{classname}} { {{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}} {{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} {{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} - @com.wordnik.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}) - @com.wordnik.swagger.annotations.ApiResponses(value = { {{#responses}} - @com.wordnik.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}"){{#hasMore}}, + @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}}, {{/hasMore}}{{/responses}} }) public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/model.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/model.mustache index 98901e392bc..300d5e61dd9 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/model.mustache @@ -3,7 +3,7 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} -import com.wordnik.swagger.annotations.*; +import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/web.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/web.mustache index 752615b76b7..ae6f6d4d692 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/web.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/web.mustache @@ -8,7 +8,7 @@ com.sun.jersey.spi.container.servlet.ServletContainer com.sun.jersey.config.property.packages - com.wordnik.swagger.jaxrs.json;com.wordnik.swagger.jaxrs.listing;{{apiPackage}} + io.swagger.jaxrs.json;io.swagger.jaxrs.listing;{{apiPackage}} com.sun.jersey.spi.container.ContainerRequestFilters @@ -23,7 +23,7 @@ DefaultJaxrsConfig - com.wordnik.swagger.jaxrs.config.DefaultJaxrsConfig + io.swagger.jaxrs.config.DefaultJaxrsConfig api.version 1.0.0 diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache index 007a4a75ccf..d6a24b69311 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/api.mustache @@ -5,11 +5,11 @@ import {{modelPackage}}.*; {{#imports}}import {{import}}; {{/imports}} -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; -import com.wordnik.swagger.annotations.ApiParam; -import com.wordnik.swagger.annotations.ApiResponse; -import com.wordnik.swagger.annotations.ApiResponses; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache index 98901e392bc..300d5e61dd9 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpringMVC/model.mustache @@ -3,7 +3,7 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} -import com.wordnik.swagger.annotations.*; +import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/com.wordnik.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/com.wordnik.swagger.codegen.CodegenConfig deleted file mode 100644 index 4dec8a51df5..00000000000 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/com.wordnik.swagger.codegen.CodegenConfig +++ /dev/null @@ -1,24 +0,0 @@ -com.wordnik.swagger.codegen.languages.AndroidClientCodegen -com.wordnik.swagger.codegen.languages.AsyncScalaClientCodegen -com.wordnik.swagger.codegen.languages.CSharpClientCodegen -com.wordnik.swagger.codegen.languages.JavaClientCodegen -com.wordnik.swagger.codegen.languages.JaxRSServerCodegen -com.wordnik.swagger.codegen.languages.NodeJSServerCodegen -com.wordnik.swagger.codegen.languages.ObjcClientCodegen -com.wordnik.swagger.codegen.languages.PerlClientCodegen -com.wordnik.swagger.codegen.languages.PhpClientCodegen -com.wordnik.swagger.codegen.languages.PythonClientCodegen -com.wordnik.swagger.codegen.languages.Python3ClientCodegen -com.wordnik.swagger.codegen.languages.Qt5CPPGenerator -com.wordnik.swagger.codegen.languages.RetrofitClientCodegen -com.wordnik.swagger.codegen.languages.RubyClientCodegen -com.wordnik.swagger.codegen.languages.ScalaClientCodegen -com.wordnik.swagger.codegen.languages.ScalatraServerCodegen -com.wordnik.swagger.codegen.languages.SpringMVCServerCodegen -com.wordnik.swagger.codegen.languages.StaticDocCodegen -com.wordnik.swagger.codegen.languages.StaticHtmlGenerator -com.wordnik.swagger.codegen.languages.SwaggerGenerator -com.wordnik.swagger.codegen.languages.SwaggerYamlGenerator -com.wordnik.swagger.codegen.languages.SwiftGenerator -com.wordnik.swagger.codegen.languages.TizenClientCodegen -com.wordnik.swagger.codegen.languages.AkkaScalaClientCodegen diff --git a/modules/swagger-codegen/src/main/resources/android-java/model.mustache b/modules/swagger-codegen/src/main/resources/android-java/model.mustache index 0090e74d0dc..6c805a832e4 100644 --- a/modules/swagger-codegen/src/main/resources/android-java/model.mustache +++ b/modules/swagger-codegen/src/main/resources/android-java/model.mustache @@ -3,7 +3,7 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} -import com.wordnik.swagger.annotations.*; +import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; {{#models}} diff --git a/modules/swagger-codegen/src/main/resources/asyncscala/api.mustache b/modules/swagger-codegen/src/main/resources/asyncscala/api.mustache index 603676e22bc..cd12ae18806 100644 --- a/modules/swagger-codegen/src/main/resources/asyncscala/api.mustache +++ b/modules/swagger-codegen/src/main/resources/asyncscala/api.mustache @@ -2,7 +2,7 @@ package {{package}} {{#imports}}import {{import}} {{/imports}} -import com.wordnik.swagger.client._ +import io.swagger.client._ import scala.concurrent.{ Future, Await } import scala.concurrent.duration._ import collection.mutable diff --git a/modules/swagger-codegen/src/main/resources/asyncscala/client.mustache b/modules/swagger-codegen/src/main/resources/asyncscala/client.mustache index ea7efa354cb..7d2093f8609 100644 --- a/modules/swagger-codegen/src/main/resources/asyncscala/client.mustache +++ b/modules/swagger-codegen/src/main/resources/asyncscala/client.mustache @@ -4,7 +4,7 @@ package {{invokerPackage}} {{/imports}} import {{apiPackage}}._ -import com.wordnik.swagger.client._ +import io.swagger.client._ import java.io.Closeable diff --git a/modules/swagger-codegen/src/main/resources/asyncscala/sbt.mustache b/modules/swagger-codegen/src/main/resources/asyncscala/sbt.mustache index b96e132d8a7..aef5e1f389a 100644 --- a/modules/swagger-codegen/src/main/resources/asyncscala/sbt.mustache +++ b/modules/swagger-codegen/src/main/resources/asyncscala/sbt.mustache @@ -3,7 +3,7 @@ organization := "{{package}}" name := "{{projectName}}-client" libraryDependencies ++= Seq( - "com.wordnik.swagger" %% "swagger-async-httpclient" % "0.3.5", + "io.swagger" %% "swagger-async-httpclient" % "0.3.5", "joda-time" % "joda-time" % "2.3", "org.joda" % "joda-convert" % "1.3.1", "ch.qos.logback" % "logback-classic" % "1.0.13" % "provided", diff --git a/modules/swagger-codegen/src/main/resources/codegen/README.mustache b/modules/swagger-codegen/src/main/resources/codegen/README.mustache index d40b9b35813..a434038ec41 100644 --- a/modules/swagger-codegen/src/main/resources/codegen/README.mustache +++ b/modules/swagger-codegen/src/main/resources/codegen/README.mustache @@ -26,7 +26,7 @@ At this point, you've likely generated a client setup. It will include somethin |----- {{name}} // template files |----- META-INF |------ services -|------- com.wordnik.swagger.codegen.CodegenConfig +|------- io.swagger.codegen.CodegenConfig ``` You _will_ need to make changes in at least the following: @@ -46,7 +46,7 @@ mvn package In your generator project. A single jar file will be produced in `target`. You can now use that with codegen: ``` -java -cp /path/to/swagger-codegen-distribution:/path/to/your/jar com.wordnik.swagger.codegen.Codegen -l {{name}} -o ./test +java -cp /path/to/swagger-codegen-distribution:/path/to/your/jar io.swagger.codegen.Codegen -l {{name}} -o ./test ``` Now your templates are available to the client generator and you can write output values @@ -67,7 +67,7 @@ the object you have available during client generation: # -DdebugOperations prints operations passed to the template engine # -DdebugSupportingFiles prints additional data passed to the template engine -java -DdebugOperations -cp /path/to/swagger-codegen-distribution:/path/to/your/jar com.wordnik.swagger.codegen.Codegen -l {{name}} -o ./test +java -DdebugOperations -cp /path/to/swagger-codegen-distribution:/path/to/your/jar io.swagger.codegen.Codegen -l {{name}} -o ./test ``` Will, for example, output the debug info for operations. You can use this info diff --git a/modules/swagger-codegen/src/main/resources/codegen/generatorClass.mustache b/modules/swagger-codegen/src/main/resources/codegen/generatorClass.mustache index 53b3a60ad1b..788ef78834b 100644 --- a/modules/swagger-codegen/src/main/resources/codegen/generatorClass.mustache +++ b/modules/swagger-codegen/src/main/resources/codegen/generatorClass.mustache @@ -1,7 +1,7 @@ package {{generatorPackage}}; -import com.wordnik.swagger.codegen.*; -import com.wordnik.swagger.models.properties.*; +import io.swagger.codegen.*; +import io.swagger.models.properties.*; import java.util.*; import java.io.File; @@ -16,7 +16,7 @@ public class {{generatorClass}} extends DefaultCodegen implements CodegenConfig * Configures the type of generator. * * @return the CodegenType for this generator - * @see com.wordnik.swagger.codegen.CodegenType + * @see io.swagger.codegen.CodegenType */ public CodegenType getTag() { return CodegenType.CLIENT; @@ -173,7 +173,7 @@ public class {{generatorClass}} extends DefaultCodegen implements CodegenConfig * either language specific types via `typeMapping` or into complex models if there is not a mapping. * * @return a string value of the type or complex model for this property - * @see com.wordnik.swagger.models.properties.Property + * @see io.swagger.models.properties.Property */ @Override public String getSwaggerType(Property p) { diff --git a/modules/swagger-codegen/src/main/resources/flash/ApiClientEvent.as b/modules/swagger-codegen/src/main/resources/flash/ApiClientEvent.as index 313da09ea78..d64cd304d49 100644 --- a/modules/swagger-codegen/src/main/resources/flash/ApiClientEvent.as +++ b/modules/swagger-codegen/src/main/resources/flash/ApiClientEvent.as @@ -1,5 +1,5 @@ -package com.wordnik.swagger.event { -import com.wordnik.swagger.event.Response; +package io.swagger.event { +import io.swagger.event.Response; import flash.events.Event; diff --git a/modules/swagger-codegen/src/main/resources/flash/ApiError.as b/modules/swagger-codegen/src/main/resources/flash/ApiError.as index 13d09415829..c8ac95a5c59 100644 --- a/modules/swagger-codegen/src/main/resources/flash/ApiError.as +++ b/modules/swagger-codegen/src/main/resources/flash/ApiError.as @@ -1,4 +1,4 @@ -package com.wordnik.swagger.exception +package io.swagger.exception { public class ApiError extends Error { diff --git a/modules/swagger-codegen/src/main/resources/flash/ApiErrorCodes.as b/modules/swagger-codegen/src/main/resources/flash/ApiErrorCodes.as index abe12178361..e5ea46480aa 100644 --- a/modules/swagger-codegen/src/main/resources/flash/ApiErrorCodes.as +++ b/modules/swagger-codegen/src/main/resources/flash/ApiErrorCodes.as @@ -1,4 +1,4 @@ -package com.wordnik.swagger.exception +package io.swagger.exception { public class ApiErrorCodes { diff --git a/modules/swagger-codegen/src/main/resources/flash/ApiInvoker.as b/modules/swagger-codegen/src/main/resources/flash/ApiInvoker.as index 40ad41af65f..897b95a4f6e 100644 --- a/modules/swagger-codegen/src/main/resources/flash/ApiInvoker.as +++ b/modules/swagger-codegen/src/main/resources/flash/ApiInvoker.as @@ -1,11 +1,11 @@ -package com.wordnik.swagger.common +package io.swagger.common { import asaxb.xml.bind.ASAXBContext; import asaxb.xml.bind.Unmarshaller; -import com.wordnik.swagger.event.ApiClientEvent; -import com.wordnik.swagger.event.Response; -import com.wordnik.swagger.common.ApiUserCredentials; +import io.swagger.event.ApiClientEvent; +import io.swagger.event.Response; +import io.swagger.common.ApiUserCredentials; import flash.events.EventDispatcher; import flash.utils.Dictionary; diff --git a/modules/swagger-codegen/src/main/resources/flash/ApiUrlHelper.as b/modules/swagger-codegen/src/main/resources/flash/ApiUrlHelper.as index affa1eb0ff9..4333c6c7e4c 100644 --- a/modules/swagger-codegen/src/main/resources/flash/ApiUrlHelper.as +++ b/modules/swagger-codegen/src/main/resources/flash/ApiUrlHelper.as @@ -1,5 +1,5 @@ -package com.wordnik.swagger.common { -import com.wordnik.swagger.common.ApiUserCredentials; +package io.swagger.common { +import io.swagger.common.ApiUserCredentials; /** * @private diff --git a/modules/swagger-codegen/src/main/resources/flash/ApiUserCredentials.as b/modules/swagger-codegen/src/main/resources/flash/ApiUserCredentials.as index a7536c213e2..118d917a247 100644 --- a/modules/swagger-codegen/src/main/resources/flash/ApiUserCredentials.as +++ b/modules/swagger-codegen/src/main/resources/flash/ApiUserCredentials.as @@ -1,4 +1,4 @@ -package com.wordnik.swagger.common { +package io.swagger.common { /** * Api account credentials. diff --git a/modules/swagger-codegen/src/main/resources/flash/ListWrapper.as b/modules/swagger-codegen/src/main/resources/flash/ListWrapper.as index 1ea2ebead00..b22890ad1d1 100644 --- a/modules/swagger-codegen/src/main/resources/flash/ListWrapper.as +++ b/modules/swagger-codegen/src/main/resources/flash/ListWrapper.as @@ -1,4 +1,4 @@ -package com.wordnik.swagger.common +package io.swagger.common { public interface ListWrapper { diff --git a/modules/swagger-codegen/src/main/resources/flash/Response.as b/modules/swagger-codegen/src/main/resources/flash/Response.as index 56cceb61959..a43b7980a38 100644 --- a/modules/swagger-codegen/src/main/resources/flash/Response.as +++ b/modules/swagger-codegen/src/main/resources/flash/Response.as @@ -1,4 +1,4 @@ -package com.wordnik.swagger.event { +package io.swagger.event { /** * Response contains info on the result of an API invocation. diff --git a/modules/swagger-codegen/src/main/resources/flash/SwaggerApi.as b/modules/swagger-codegen/src/main/resources/flash/SwaggerApi.as index a78f3105cb1..059de642a74 100644 --- a/modules/swagger-codegen/src/main/resources/flash/SwaggerApi.as +++ b/modules/swagger-codegen/src/main/resources/flash/SwaggerApi.as @@ -1,6 +1,6 @@ -package com.wordnik.swagger.common +package io.swagger.common { - import com.wordnik.swagger.common.ApiUserCredentials; + import io.swagger.common.ApiUserCredentials; import flash.events.EventDispatcher; import flash.events.IEventDispatcher; diff --git a/modules/swagger-codegen/src/main/resources/flash/XMLWriter.as b/modules/swagger-codegen/src/main/resources/flash/XMLWriter.as index 067f49e6301..0b08066775b 100644 --- a/modules/swagger-codegen/src/main/resources/flash/XMLWriter.as +++ b/modules/swagger-codegen/src/main/resources/flash/XMLWriter.as @@ -1,4 +1,4 @@ -package com.wordnik.swagger.common +package io.swagger.common { public class XMLWriter { diff --git a/modules/swagger-codegen/src/main/resources/flash/api.mustache b/modules/swagger-codegen/src/main/resources/flash/api.mustache index 647ec763a24..b1f11e92438 100644 --- a/modules/swagger-codegen/src/main/resources/flash/api.mustache +++ b/modules/swagger-codegen/src/main/resources/flash/api.mustache @@ -1,11 +1,11 @@ package {{package}} { -import com.wordnik.swagger.common.ApiInvoker; -import com.wordnik.swagger.exception.ApiErrorCodes; -import com.wordnik.swagger.exception.ApiError; -import com.wordnik.swagger.common.ApiUserCredentials; -import com.wordnik.swagger.event.Response; -import com.wordnik.swagger.common.SwaggerApi; +import io.swagger.common.ApiInvoker; +import io.swagger.exception.ApiErrorCodes; +import io.swagger.exception.ApiError; +import io.swagger.common.ApiUserCredentials; +import io.swagger.event.Response; +import io.swagger.common.SwaggerApi; {{#imports}}import {{import}}; {{/imports}} diff --git a/modules/swagger-codegen/src/main/resources/flash/build.xml b/modules/swagger-codegen/src/main/resources/flash/build.xml index 6861dd464ec..4f021b0b8b2 100644 --- a/modules/swagger-codegen/src/main/resources/flash/build.xml +++ b/modules/swagger-codegen/src/main/resources/flash/build.xml @@ -62,11 +62,11 @@ - - - - - + + + + + diff --git a/modules/swagger-codegen/src/main/resources/flash/modelList.mustache b/modules/swagger-codegen/src/main/resources/flash/modelList.mustache index b0c3bd73f83..7741902bcaa 100644 --- a/modules/swagger-codegen/src/main/resources/flash/modelList.mustache +++ b/modules/swagger-codegen/src/main/resources/flash/modelList.mustache @@ -1,6 +1,6 @@ package {{package}} { -import com.wordnik.swagger.common.ListWrapper; +import io.swagger.common.ListWrapper; {{#imports}}import {{import}}; {{/imports}} diff --git a/modules/swagger-codegen/src/main/resources/logback.xml b/modules/swagger-codegen/src/main/resources/logback.xml index c7d0db9d3a2..bcfc95e538d 100644 --- a/modules/swagger-codegen/src/main/resources/logback.xml +++ b/modules/swagger-codegen/src/main/resources/logback.xml @@ -5,7 +5,7 @@ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - + diff --git a/modules/swagger-codegen/src/main/resources/retrofit/model.mustache b/modules/swagger-codegen/src/main/resources/retrofit/model.mustache index f4446d5a1ef..85213ed4c95 100644 --- a/modules/swagger-codegen/src/main/resources/retrofit/model.mustache +++ b/modules/swagger-codegen/src/main/resources/retrofit/model.mustache @@ -3,7 +3,7 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} -import com.wordnik.swagger.annotations.*; +import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; {{#models}} diff --git a/modules/swagger-codegen/src/main/resources/scalatra/Bootstrap.mustache b/modules/swagger-codegen/src/main/resources/scalatra/Bootstrap.mustache index 64c0b07eb28..5121079424f 100644 --- a/modules/swagger-codegen/src/main/resources/scalatra/Bootstrap.mustache +++ b/modules/swagger-codegen/src/main/resources/scalatra/Bootstrap.mustache @@ -1,6 +1,6 @@ import {{apiPackage}}._ import akka.actor.ActorSystem -import com.wordnik.swagger.app.{ResourcesApp, SwaggerApp} +import io.swagger.app.{ResourcesApp, SwaggerApp} import javax.servlet.ServletContext import org.scalatra.LifeCycle diff --git a/modules/swagger-codegen/src/main/resources/scalatra/ServletApp.mustache b/modules/swagger-codegen/src/main/resources/scalatra/ServletApp.mustache index f6e53468ec9..423b8644712 100644 --- a/modules/swagger-codegen/src/main/resources/scalatra/ServletApp.mustache +++ b/modules/swagger-codegen/src/main/resources/scalatra/ServletApp.mustache @@ -1,4 +1,4 @@ -package com.wordnik.swagger.app +package io.swagger.app import _root_.akka.actor.ActorSystem diff --git a/modules/swagger-codegen/src/test/scala/SwaggerMigratorTest.scala b/modules/swagger-codegen/src/test/scala/SwaggerMigratorTest.scala index 6c78fa147c1..2fce3c45e45 100644 --- a/modules/swagger-codegen/src/test/scala/SwaggerMigratorTest.scala +++ b/modules/swagger-codegen/src/test/scala/SwaggerMigratorTest.scala @@ -17,6 +17,5 @@ class SwaggerMigratorTest extends FlatSpec with Matchers { it should "read a 1.2 spec" in { val loader = new SwaggerParser() val swagger = loader.read("src/test/resources/1_2/petstore-1.2/api-docs") - Json.prettyPrint(swagger) } } \ No newline at end of file diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml index e5b7b2c341f..2bbbffed0ee 100644 --- a/modules/swagger-generator/pom.xml +++ b/modules/swagger-generator/pom.xml @@ -1,9 +1,9 @@ 4.0.0 - com.wordnik + io.swagger swagger-codegen-project - 2.1.1-M2-SNAPSHOT + 2.1.1 ../.. swagger-generator @@ -130,12 +130,12 @@ - com.wordnik + io.swagger swagger-jersey2-jaxrs ${swagger-core-version} - com.wordnik + io.swagger swagger-codegen ${project.parent.version} @@ -149,18 +149,7 @@ logback-core ${logback-version} - - org.scalatest - scalatest_2.10 - ${scala-test-version} - test - - - junit - junit - ${junit-version} - test - + javax.servlet servlet-api @@ -213,6 +202,12 @@ ${scala-test-version} test + + junit + junit + ${junit-version} + test + org.scala-lang scala-library diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/Bootstrap.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/Bootstrap.java deleted file mode 100644 index 7035b60d1f7..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/Bootstrap.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright 2015 Reverb, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.wordnik.swagger.generator; - -import com.wordnik.swagger.models.*; - -import javax.servlet.http.HttpServlet; -import javax.servlet.ServletContext; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; - -public class Bootstrap extends HttpServlet { - public void init(ServletConfig config) throws ServletException { - ServletContext context = config.getServletContext(); - - DynamicSwaggerConfig bc = new DynamicSwaggerConfig(); - bc.setBasePath("/api"); - bc.setTitle("Swagger Generator"); - bc.setDescription("This is an online swagger codegen server. You can find out more " + - "at https://github.com/swagger-api/swagger-codegen or on irc.freenode.net, #swagger." + - "http://helloreverb.com/terms/"); - bc.setTermsOfServiceUrl("http://helloreverb.com/terms/"); - bc.setContact("apiteam@swagger.io"); - bc.setLicense("Apache 2.0"); - bc.setVersion("1.0.0"); - bc.setHost("generator.swagger.io"); - bc.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html"); - bc.setResourcePackage("com.wordnik.swagger.generator.resource"); - bc.setScan(true); - } -} diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/DynamicSwaggerConfig.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/DynamicSwaggerConfig.java deleted file mode 100644 index 60983c230ac..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/DynamicSwaggerConfig.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.wordnik.swagger.generator; - -import com.wordnik.swagger.models.*; -import com.wordnik.swagger.models.parameters.*; -import com.wordnik.swagger.models.properties.*; -import com.wordnik.swagger.codegen.*; - -import com.wordnik.swagger.util.Json; - -import com.wordnik.swagger.jaxrs.config.BeanConfig; - -import java.util.*; - -public class DynamicSwaggerConfig extends BeanConfig { - static List clients = new ArrayList(); - static List servers = new ArrayList(); - static { - List extensions = Codegen.getExtensions(); - for(CodegenConfig config : extensions) { - if(config.getTag().equals(CodegenType.CLIENT) || config.getTag().equals(CodegenType.DOCUMENTATION)) { - clients.add(config.getName()); - } - else if(config.getTag().equals(CodegenType.SERVER)) { - servers.add(config.getName()); - } - } - } - - @Override - public Swagger configure(Swagger swagger) { - Path clientPath = swagger.getPaths().get("/gen/clients/{language}"); - // update the path description based on what clients are available via SPI - if(clientPath != null) { - Operation post = clientPath.getPost(); - Parameter framework = post.getParameters().get(0); - if(framework instanceof PathParameter) { - PathParameter param = (PathParameter) framework; - StringBuilder b = new StringBuilder(); - for(String client : clients) { - if(b.toString().length() > 0) - b.append(", "); - b.append(client); - } - param.setDescription("available clients: " + b.toString()); - } - } - - Path serverPath = swagger.getPaths().get("/gen/servers/{framework}"); - // update the path description based on what servers are available via SPI - if(serverPath != null) { - Operation post = serverPath.getPost(); - Parameter framework = post.getParameters().get(0); - if(framework instanceof PathParameter) { - PathParameter param = (PathParameter) framework; - StringBuilder b = new StringBuilder(); - for(String server : servers) { - if(b.toString().length() > 0) - b.append(", "); - b.append(server); - } - param.setDescription("available clients: " + b.toString()); - } - } - - return swagger.info(getInfo()) - .host(getHost()) - .basePath("/api"); - } -} \ No newline at end of file diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/exception/ApiException.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/exception/ApiException.java deleted file mode 100644 index 1383c791aac..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/exception/ApiException.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright 2015 Reverb, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.wordnik.swagger.generator.exception; - -public class ApiException extends Exception{ - private int code; - public ApiException (int code, String msg) { - super(msg); - this.code = code; - } -} diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/exception/BadRequestException.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/exception/BadRequestException.java deleted file mode 100644 index c0883b30eda..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/exception/BadRequestException.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright 2015 Reverb, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.wordnik.swagger.generator.exception; - -public class BadRequestException extends ApiException { - private int code; - public BadRequestException (int code, String msg) { - super(code, msg); - this.code = code; - } -} diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/exception/NotFoundException.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/exception/NotFoundException.java deleted file mode 100644 index e9a302b2f1e..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/exception/NotFoundException.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright 2015 Reverb, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.wordnik.swagger.generator.exception; - -public class NotFoundException extends ApiException { - private int code; - public NotFoundException (int code, String msg) { - super(code, msg); - this.code = code; - } -} diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/ApiResponse.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/ApiResponse.java deleted file mode 100644 index 1dfc431b073..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/ApiResponse.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright 2015 Reverb, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.wordnik.swagger.generator.model; - -import javax.xml.bind.annotation.XmlTransient; - -@javax.xml.bind.annotation.XmlRootElement -public class ApiResponse { - 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 ApiResponse(){} - - public ApiResponse(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/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/Generated.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/Generated.java deleted file mode 100644 index 6436498ac3f..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/Generated.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2015 Reverb, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.wordnik.swagger.generator.model; - -public class Generated { - private String filename; - private String friendlyName; - - public String getFilename() { - return filename; - } - public void setFilename(String filename) { - this.filename = filename; - } - - public String getFriendlyName() { - return friendlyName; - } - public void setFriendlyName(String friendlyName) { - this.friendlyName = friendlyName; - } -} diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/GeneratorInput.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/GeneratorInput.java deleted file mode 100644 index 9c5a2aa15ce..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/GeneratorInput.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.wordnik.swagger.generator.model; - -import com.wordnik.swagger.annotations.ApiModelProperty; -import com.wordnik.swagger.models.auth.SecuritySchemeDefinition; - -import com.fasterxml.jackson.databind.*; - -import java.util.*; - -public class GeneratorInput { - private JsonNode spec; - private Map options; - private String swaggerUrl; - private SecuritySchemeDefinition auth; - - @ApiModelProperty(dataType="Object") - public JsonNode getSpec() { - return spec; - } - public void setSpec(JsonNode spec) { - this.spec = spec; - } - - public Map getOptions() { - return options; - } - public void setOptions(Map options) { - this.options = options; - } - - public String getSwaggerUrl() { - return swaggerUrl; - } - public void setSwaggerUrl(String url) { - this.swaggerUrl = url; - } - - public SecuritySchemeDefinition getSecurityDefinition() { - return auth; - } - public void setSecurityDefinition(SecuritySchemeDefinition auth) { - this.auth = auth; - } -} \ No newline at end of file diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/InputOption.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/InputOption.java deleted file mode 100644 index deee8e23c69..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/InputOption.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright 2015 Reverb, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.wordnik.swagger.generator.model; - -public class InputOption { - private String name; - private String description; - private Boolean required; - private String defaultValue; - - public InputOption() {} - - public InputOption(String name, String description, String defaultValue, Boolean required) { - this.name = name; - this.description = description; - this.defaultValue = defaultValue; - this.required = required; - } - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDescription() { - return description; - } - - public void setRequired(Boolean required) { - this.required = required; - } - - public Boolean getRequired() { - return required; - } - - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - public String getDefaultValue() { - return defaultValue; - } -} diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/ResponseCode.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/ResponseCode.java deleted file mode 100644 index 77271a6c72f..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/ResponseCode.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.wordnik.swagger.generator.model; - -public class ResponseCode { - private String code; - private String link; - public ResponseCode() {} - - public ResponseCode(String code, String link) { - setCode(code); - setLink(link); - } - - public String getCode() { - return code; - } - public void setCode(String code) { - this.code = code; - } - - public String getLink() { - return link; - } - public void setLink(String link) { - this.link = link; - } -} \ No newline at end of file diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/online/Generator.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/online/Generator.java deleted file mode 100644 index 7a161b970bc..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/online/Generator.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.wordnik.swagger.generator.online; - -import io.swagger.parser.SwaggerParser; - -import com.wordnik.swagger.generator.exception.*; -import com.wordnik.swagger.codegen.*; -import com.wordnik.swagger.models.Swagger; -import com.wordnik.swagger.generator.model.*; -import com.wordnik.swagger.util.Json; -import com.wordnik.swagger.generator.util.ZipUtil; - -import com.fasterxml.jackson.databind.JsonNode; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.List; -import java.util.ArrayList; - -public class Generator { - static Logger LOGGER = LoggerFactory.getLogger(Generator.class); - - public static String generateClient(String language, GeneratorInput opts) throws ApiException { - Swagger swagger; - LOGGER.debug("generate client for " + language); - if(opts == null) { - throw new BadRequestException(400, "No options were supplied"); - } - JsonNode node = opts.getSpec(); - if(node == null) { - if(opts.getSwaggerUrl() != null) { - swagger = new SwaggerParser().read(opts.getSwaggerUrl()); - } - else - throw new BadRequestException(400, "No swagger specification was supplied"); - } - else { - swagger = new SwaggerParser().read(node); - } - if(swagger == null) { - throw new BadRequestException(400, "The swagger specification supplied was not valid"); - } - - ClientOptInput clientOptInput = new ClientOptInput(); - ClientOpts clientOpts = new ClientOpts(); - String outputFolder = getTmpFolder().getAbsolutePath() + File.separator + language + "-client"; - String outputFilename = outputFolder + "-bundle.zip"; - - clientOptInput - .opts(clientOpts) - .swagger(swagger); - - CodegenConfig codegenConfig = Codegen.getConfig(language); - if(codegenConfig == null) { - throw new BadRequestException(400, "Unsupported target " + language + " supplied"); - } - - codegenConfig.setOutputDir(outputFolder); - - Json.prettyPrint(clientOpts); - - clientOptInput.setConfig(codegenConfig); - - try{ - List files = new Codegen().opts(clientOptInput).generate(); - if(files.size() > 0) { - List filesToAdd = new ArrayList(); - System.out.println("adding to " + outputFolder); - filesToAdd.add(new File(outputFolder)); - ZipUtil zip = new ZipUtil(); - zip.compressFiles(filesToAdd, outputFilename); - } - else { - throw new BadRequestException(400, "A target generation was attempted, but no files were created!"); - } - } - catch (Exception e) { - throw new BadRequestException(500, "Unable to build target: " + e.getMessage()); - } - return outputFilename; - } - - public static String generateServer(String language, GeneratorInput opts) throws ApiException { - LOGGER.debug("generate server for " + language); - Swagger swagger; - if(opts == null) { - throw new BadRequestException(400, "No options were supplied"); - } - if(opts == null) { - throw new BadRequestException(400, "No options were supplied"); - } - JsonNode node = opts.getSpec(); - if(node == null) { - if(opts.getSwaggerUrl() != null) { - swagger = new SwaggerParser().read(opts.getSwaggerUrl()); - } - else - throw new BadRequestException(400, "No swagger specification was supplied"); - } - else { - swagger = new SwaggerParser().read(node); - } - if(swagger == null) { - throw new BadRequestException(400, "The swagger specification supplied was not valid"); - } - - ClientOptInput clientOptInput = new ClientOptInput(); - ClientOpts clientOpts = new ClientOpts(); - String outputFolder = getTmpFolder().getAbsolutePath() + File.separator + language + "-server"; - String outputFilename = outputFolder + "-bundle.zip"; - - clientOptInput - .opts(clientOpts) - .swagger(swagger); - - CodegenConfig codegenConfig = Codegen.getConfig(language); - if(codegenConfig == null) { - throw new BadRequestException(400, "Unsupported target " + language + " supplied"); - } - - codegenConfig.setOutputDir(outputFolder); - - Json.prettyPrint(clientOpts); - - clientOptInput.setConfig(codegenConfig); - - try{ - List files = new Codegen().opts(clientOptInput).generate(); - if(files.size() > 0) { - List filesToAdd = new ArrayList(); - filesToAdd.add(new File(outputFolder)); - ZipUtil zip = new ZipUtil(); - zip.compressFiles(filesToAdd, outputFilename); - } - else { - throw new BadRequestException(400, "A target generation was attempted, but no files were created!"); - } - } - catch (Exception e) { - throw new BadRequestException(500, "Unable to build target: " + e.getMessage()); - } - return outputFilename; - } - - public static InputOption clientOptions(String language) { - return null; - } - - public static InputOption serverOptions(String language) { - return null; - } - - protected static File getTmpFolder() { - try { - File outputFolder = File.createTempFile("codegen-", "-tmp"); - outputFolder.delete(); - outputFolder.mkdir(); - outputFolder.deleteOnExit(); - return outputFolder; - } - catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/resource/ExceptionWriter.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/resource/ExceptionWriter.java deleted file mode 100644 index f052c79f311..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/resource/ExceptionWriter.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.wordnik.swagger.generator.resource; - -import com.wordnik.swagger.generator.util.ValidationException; - -import com.wordnik.swagger.generator.exception.ApiException; -import com.wordnik.swagger.generator.exception.BadRequestException; -import com.wordnik.swagger.generator.exception.NotFoundException; -import com.wordnik.swagger.generator.model.ApiResponse; - -import javax.ws.rs.ext.*; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; - -@Provider -public class ExceptionWriter implements ExceptionMapper { - public Response toResponse(Exception exception) { - if (exception instanceof javax.ws.rs.WebApplicationException) { - javax.ws.rs.WebApplicationException e = (javax.ws.rs.WebApplicationException) exception; - return Response - .status(e.getResponse().getStatus()) - .entity(new ApiResponse(e.getResponse().getStatus(), - exception.getMessage())).build(); - } else if (exception instanceof com.fasterxml.jackson.core.JsonParseException) { - return Response.status(400) - .entity(new ApiResponse(400, "bad input")).build(); - } else if (exception instanceof ValidationException) { - ValidationException e = (ValidationException) exception; - return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build(); - } else if (exception instanceof NotFoundException) { - return Response - .status(Status.NOT_FOUND) - .entity(new ApiResponse(ApiResponse.ERROR, exception - .getMessage())).build(); - } else if (exception instanceof BadRequestException) { - return Response - .status(Status.BAD_REQUEST) - .entity(new ApiResponse(ApiResponse.ERROR, exception - .getMessage())).build(); - } else if (exception instanceof ApiException) { - return Response - .status(Status.BAD_REQUEST) - .entity(new ApiResponse(ApiResponse.ERROR, exception - .getMessage())).build(); - } else { - return Response.status(500) - .entity(new ApiResponse(500, "something bad happened")) - .build(); - } - } -} \ No newline at end of file diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/resource/SwaggerResource.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/resource/SwaggerResource.java deleted file mode 100644 index 4dba39bfb9a..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/resource/SwaggerResource.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.wordnik.swagger.generator.resource; - -import com.wordnik.swagger.codegen.*; -import com.wordnik.swagger.generator.util.*; -import com.wordnik.swagger.annotations.*; -import com.wordnik.swagger.generator.model.*; -import com.wordnik.swagger.generator.exception.BadRequestException; -import com.wordnik.swagger.generator.online.Generator; - -import java.io.File; -import java.util.*; - -import javax.ws.rs.*; -import javax.ws.rs.core.*; - -@Path("/gen") -@Api(value = "/gen", description = "Resource for generating swagger components") -public class SwaggerResource { - private static Map fileMap = new HashMap(); - - static List clients = new ArrayList(); - static List servers = new ArrayList(); - static { - List extensions = Codegen.getExtensions(); - for(CodegenConfig config : extensions) { - if(config.getTag().equals(CodegenType.CLIENT) || config.getTag().equals(CodegenType.DOCUMENTATION)) { - clients.add(config.getName()); - } - else if(config.getTag().equals(CodegenType.SERVER)) { - servers.add(config.getName()); - } - } - } - - @GET - @Path("/download/{fileId}") - @Produces({MediaType.APPLICATION_OCTET_STREAM}) - @ApiOperation(value = "Downloads a pre-generated file", - response = String.class, - tags = {"clients", "servers"}) - public Response downloadFile(@PathParam("fileId") String fileId) throws Exception { - Generated g = fileMap.get(fileId); - System.out.println("looking for fileId " + fileId); - System.out.println("got filename " + g.getFilename()); - if(g.getFilename() != null) { - byte[] bytes = org.apache.commons.io.FileUtils.readFileToByteArray(new java.io.File(g.getFilename())); - - return Response.ok(bytes, "application/zip") - .header("Content-Disposition","attachment; filename=\"" + g.getFriendlyName() + "-generated.zip\"") - .header("Accept-Range", "bytes") - .header("Content-Length", bytes.length) - .build(); - } - else { - return Response.status(404).build(); - } - } - - @POST - @Path("/clients/{language}") - @ApiOperation( - value = "Generates a client library based on the config", - response = ResponseCode.class, - tags = "clients") - public Response generateClient( - @ApiParam(value = "The target language for the client library", allowableValues = "android,java,php,objc,docs", required = true) @PathParam("language") String language, - @ApiParam(value = "Configuration for building the client library", required = true) GeneratorInput opts) throws Exception { - - String filename = Generator.generateClient(language, opts); - - if(filename != null) { - String code = String.valueOf(System.currentTimeMillis()); - Generated g = new Generated(); - g.setFilename(filename); - g.setFriendlyName(language + "-client"); - fileMap.put(code, g); - System.out.println(code + ", " + filename); - String link = "http://generator.swagger.io/api/gen/download/" + code; - return Response.ok().entity(new ResponseCode(code, link)).build(); - } - else { - return Response.status(500).build(); - } - } - - @GET - @Path("/clients") - @ApiOperation(value = "Gets languages supported by the client generator", - response = String.class, - responseContainer = "List", - tags = "clients") - public Response clientOptions() { - String[] languages = new String[clients.size()]; - languages = clients.toArray(languages); - return Response.ok().entity(languages).build(); - } - - @GET - @Path("/servers") - @ApiOperation(value = "Gets languages supported by the server generator", - response = String.class, - responseContainer = "List", - tags = "servers") - public Response serverOptions() { - String[] languages = new String[servers.size()]; - languages = servers.toArray(languages); - return Response.ok().entity(languages).build(); - } - - @POST - @Path("/servers/{framework}") - @ApiOperation(value = "Generates a server library for the supplied server framework", - response = ResponseCode.class, - tags = "servers") - public Response generateServerForLanguage( - @ApiParam(value = "framework", allowableValues = "jaxrs,nodejs", required = true) @PathParam("framework") String framework, - @ApiParam(value = "parameters", required = true) GeneratorInput opts) - throws Exception { - if(framework == null) - throw new BadRequestException(400, "Framework is required"); - String filename = Generator.generateServer(framework, opts); - System.out.println("generated name: " + filename); - - if(filename != null) { - String code = String.valueOf(System.currentTimeMillis()); - Generated g = new Generated(); - g.setFilename(filename); - g.setFriendlyName(framework + "-server"); - fileMap.put(code, g); - System.out.println(code + ", " + filename); - String link = "http://generator.swagger.io/api/gen/download/" + code; - return Response.ok().entity(new ResponseCode(code, link)).build(); - } - else { - return Response.status(500).build(); - } - } -} diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/util/ApiOriginFilter.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/util/ApiOriginFilter.java deleted file mode 100644 index b9d279d20a8..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/util/ApiOriginFilter.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2015 Reverb, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.wordnik.swagger.generator.util; - -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/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/util/ValidationException.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/util/ValidationException.java deleted file mode 100644 index 19747367ca0..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/util/ValidationException.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.wordnik.swagger.generator.util; - -import java.util.List; - -public class ValidationException extends Exception { - private int code; - private String msg; - private List errors; - - public ValidationException(String msg) { - super(msg); - } - - public int getCode() { - return code; - } - public void setCode(int code) { - this.code = code; - } - - public String getMessage() { - return msg; - } - public void setMessage(String msg) { - this.msg = msg; - } -} \ No newline at end of file diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/util/ValidationMessage.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/util/ValidationMessage.java deleted file mode 100644 index b64633de2bd..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/util/ValidationMessage.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.wordnik.swagger.generator.util; - -public class ValidationMessage { - private String path, message, severity; - - public String getPath() { - return path; - } - public void setPath(String path) { - this.path = path; - } - - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - public String getSeverity() { - return severity; - } - public void setSeverity(String severity) { - this.severity = severity; - } -} \ No newline at end of file diff --git a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/util/ZipUtil.java b/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/util/ZipUtil.java deleted file mode 100644 index 1d090bf96d3..00000000000 --- a/modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/util/ZipUtil.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright 2015 Reverb, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.wordnik.swagger.generator.util; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.List; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -/** -* This utility compresses a list of files to standard ZIP format file. -* It is able to compresses all sub files and sub directories, recursively. -* @author Ha Minh Nam -* -*/ -public class ZipUtil { - /** - * A constants for buffer size used to read/write data - */ - private static final int BUFFER_SIZE = 4096; - - /** - * Compresses a collection of files to a destination zip file - * @param listFiles A collection of files and directories - * @param destZipFile The path of the destination zip file - * @throws FileNotFoundException - * @throws IOException - */ - public void compressFiles(List listFiles, String destZipFile) throws FileNotFoundException, IOException { - - ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(destZipFile)); - - for (File file : listFiles) { - if (file.isDirectory()) { - addFolderToZip(file, file.getName(), zos); - } else { - addFileToZip(file, zos); - } - } - - zos.flush(); - zos.close(); - } - - /** - * Adds a directory to the current zip output stream - * @param folder the directory to be added - * @param parentFolder the path of parent directory - * @param zos the current zip output stream - * @throws FileNotFoundException - * @throws IOException - */ - private void addFolderToZip(File folder, String parentFolder, - ZipOutputStream zos) throws FileNotFoundException, IOException { - for (File file : folder.listFiles()) { - if (file.isDirectory()) { - addFolderToZip(file, parentFolder + "/" + file.getName(), zos); - continue; - } - - zos.putNextEntry(new ZipEntry(parentFolder + "/" + file.getName())); - - BufferedInputStream bis = new BufferedInputStream( - new FileInputStream(file)); - - long bytesRead = 0; - byte[] bytesIn = new byte[BUFFER_SIZE]; - int read = 0; - - while ((read = bis.read(bytesIn)) != -1) { - zos.write(bytesIn, 0, read); - bytesRead += read; - } - - zos.closeEntry(); - - } - } - - /** - * Adds a file to the current zip output stream - * @param file the file to be added - * @param zos the current zip output stream - * @throws FileNotFoundException - * @throws IOException - */ - private void addFileToZip(File file, ZipOutputStream zos) - throws FileNotFoundException, IOException { - zos.putNextEntry(new ZipEntry(file.getName())); - - BufferedInputStream bis = new BufferedInputStream(new FileInputStream( - file)); - - long bytesRead = 0; - byte[] bytesIn = new byte[BUFFER_SIZE]; - int read = 0; - - while ((read = bis.read(bytesIn)) != -1) { - zos.write(bytesIn, 0, read); - bytesRead += read; - } - - zos.closeEntry(); - } -} \ No newline at end of file diff --git a/modules/swagger-generator/src/main/resources/logback.xml b/modules/swagger-generator/src/main/resources/logback.xml index f263bf8bde0..df76cd17b52 100644 --- a/modules/swagger-generator/src/main/resources/logback.xml +++ b/modules/swagger-generator/src/main/resources/logback.xml @@ -5,7 +5,7 @@ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - + diff --git a/modules/swagger-generator/src/main/webapp/WEB-INF/web.xml b/modules/swagger-generator/src/main/webapp/WEB-INF/web.xml index 7b363b797ed..882dc5fb1ea 100644 --- a/modules/swagger-generator/src/main/webapp/WEB-INF/web.xml +++ b/modules/swagger-generator/src/main/webapp/WEB-INF/web.xml @@ -9,17 +9,17 @@ jersey.config.server.provider.packages - com.wordnik.swagger.jaxrs.json, - com.wordnik.swagger.generator.resource + io.swagger.jaxrs.json, + io.swagger.generator.resource jersey.config.server.provider.classnames - com.wordnik.swagger.online.ExceptionWriter, - com.wordnik.swagger.jersey.listing.ApiListingResourceJSON, - com.wordnik.swagger.jersey.listing.JerseyApiDeclarationProvider, - com.wordnik.swagger.jersey.listing.JerseyResourceListingProvider + io.swagger.online.ExceptionWriter, + io.swagger.jersey.listing.ApiListingResourceJSON, + io.swagger.jersey.listing.JerseyApiDeclarationProvider, + io.swagger.jersey.listing.JerseyResourceListingProvider @@ -36,11 +36,11 @@ ApiOriginFilter - com.wordnik.swagger.generator.util.ApiOriginFilter + io.swagger.generator.util.ApiOriginFilter Bootstrap - com.wordnik.swagger.generator.Bootstrap + io.swagger.generator.Bootstrap 2 diff --git a/modules/swagger-generator/src/test/scala/GeneratorInputTest.scala b/modules/swagger-generator/src/test/scala/GeneratorInputTest.scala index 43e0f234800..f9820d96fa6 100644 --- a/modules/swagger-generator/src/test/scala/GeneratorInputTest.scala +++ b/modules/swagger-generator/src/test/scala/GeneratorInputTest.scala @@ -1,6 +1,6 @@ -import com.wordnik.swagger.generator.online._ -import com.wordnik.swagger.generator.model._ -import com.wordnik.swagger.util.Json +import io.swagger.generator.online._ +import io.swagger.generator.model._ +import io.swagger.util.Json import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner diff --git a/pom.xml b/pom.xml index c8d223cfb2c..610f6baa2e1 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ swagger-codegen-project pom swagger-codegen-project - 2.1.1-M2-SNAPSHOT + 2.1.1 https://github.com/swagger-api/swagger-codegen scm:git:git@github.com:swagger-api/swagger-codegen.git @@ -463,7 +463,7 @@ 1.0.7 - 2.10.4 + 2.11.1 2.3.4 1.5.2-M2 2.1.4 diff --git a/samples/client/petstore/android-java/build.gradle b/samples/client/petstore/android-java/build.gradle index 26a00d90da8..16ecd1b4d49 100644 --- a/samples/client/petstore/android-java/build.gradle +++ b/samples/client/petstore/android-java/build.gradle @@ -56,10 +56,10 @@ dependencies { compile "com.google.code.gson:gson:$gson_version" compile "org.apache.httpcomponents:httpcore:$httpclient_version" compile "org.apache.httpcomponents:httpclient:$httpclient_version" - compile ("org.apache.httpcomponents:httpcore:$httpcore_version") { + compile ("org.apache.httpcomponents:httpcore:$httpclient_version") { exclude(group: 'org.apache.httpcomponents', module: 'httpclient') } - compile ("org.apache.httpcomponents:httpmime:$httpmime_version") { + compile ("org.apache.httpcomponents:httpmime:$httpclient_version") { exclude(group: 'org.apache.httpcomponents', module: 'httpclient') } testCompile "junit:junit:$junit_version" diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs index 1f7ddccfb26..8596800f536 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs @@ -1,15 +1,134 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using RestSharp; using IO.Swagger.Client; using IO.Swagger.Model; namespace IO.Swagger.Api { + + public interface IPetApi { + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// + void UpdatePet (Pet Body); + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// + Task UpdatePetAsync (Pet Body); + + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// + void AddPet (Pet Body); + + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// + Task AddPetAsync (Pet Body); + + /// + /// Finds Pets by status Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// List + List FindPetsByStatus (List Status); + + /// + /// Finds Pets by status Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// List + Task> FindPetsByStatusAsync (List Status); + + /// + /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// List + List FindPetsByTags (List Tags); + + /// + /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// List + Task> FindPetsByTagsAsync (List Tags); + + /// + /// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// Pet + Pet GetPetById (long? PetId); + + /// + /// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// Pet + Task GetPetByIdAsync (long? PetId); + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated/// Updated name of the pet/// Updated status of the pet + /// + void UpdatePetWithForm (string PetId, string Name, string Status); + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated/// Updated name of the pet/// Updated status of the pet + /// + Task UpdatePetWithFormAsync (string PetId, string Name, string Status); + + /// + /// Deletes a pet + /// + /// /// Pet id to delete + /// + void DeletePet (string ApiKey, long? PetId); + + /// + /// Deletes a pet + /// + /// /// Pet id to delete + /// + Task DeletePetAsync (string ApiKey, long? PetId); + + /// + /// uploads an image + /// + /// ID of pet to update/// Additional data to pass to server/// file to upload + /// + void UploadFile (long? PetId, string AdditionalMetadata, string File); + + /// + /// uploads an image + /// + /// ID of pet to update/// Additional data to pass to server/// file to upload + /// + Task UploadFileAsync (long? PetId, string AdditionalMetadata, string File); + + } + /// /// Represents a collection of functions to interact with the API endpoints /// - public class PetApi { + public class PetApi : IPetApi { + /// /// Initializes a new instance of the class. /// @@ -88,7 +207,44 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content); + } + + return; + } + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + /// + public async Task UpdatePetAsync (Pet Body) { + + + + var path = "/pet"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + + + // authentication setting, if any + String[] authSettings = new String[] { "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content); } return; @@ -126,7 +282,44 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content); + } + + return; + } + + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + /// + public async Task AddPetAsync (Pet Body) { + + + + var path = "/pet"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + + + // authentication setting, if any + String[] authSettings = new String[] { "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content); } return; @@ -164,10 +357,46 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content); } return (List) apiClient.Deserialize(response.Content, typeof(List)); } + + /// + /// Finds Pets by status Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// List + public async Task> FindPetsByStatusAsync (List Status) { + + + + var path = "/pet/findByStatus"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + if (Status != null) queryParams.Add("status", apiClient.ParameterToString(Status)); // query parameter + + + + + + // authentication setting, if any + String[] authSettings = new String[] { "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content); + } + return (List) ApiInvoker.Deserialize(response.Content, typeof(List)); + } /// /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. @@ -201,10 +430,46 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content); } return (List) apiClient.Deserialize(response.Content, typeof(List)); } + + /// + /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// List + public async Task> FindPetsByTagsAsync (List Tags) { + + + + var path = "/pet/findByTags"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + if (Tags != null) queryParams.Add("tags", apiClient.ParameterToString(Tags)); // query parameter + + + + + + // authentication setting, if any + String[] authSettings = new String[] { "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content); + } + return (List) ApiInvoker.Deserialize(response.Content, typeof(List)); + } /// /// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions @@ -241,17 +506,54 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content); } return (Pet) apiClient.Deserialize(response.Content, typeof(Pet)); } + + /// + /// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// Pet + public async Task GetPetByIdAsync (long? PetId) { + + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling GetPetById"); + + + var path = "/pet/{petId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // authentication setting, if any + String[] authSettings = new String[] { "api_key", "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content); + } + return (Pet) ApiInvoker.Deserialize(response.Content, typeof(Pet)); + } /// /// Updates a pet in the store with form data /// - /// ID of pet that needs to be updated - /// Updated name of the pet - /// Updated status of the pet + /// ID of pet that needs to be updated/// Updated name of the pet/// Updated status of the pet /// public void UpdatePetWithForm (string PetId, string Name, string Status) { @@ -285,7 +587,49 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content); + } + + return; + } + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated/// Updated name of the pet/// Updated status of the pet + /// + public async Task UpdatePetWithFormAsync (string PetId, string Name, string Status) { + + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UpdatePetWithForm"); + + + var path = "/pet/{petId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + if (Name != null) formParams.Add("name", apiClient.ParameterToString(Name)); // form parameter + if (Status != null) formParams.Add("status", apiClient.ParameterToString(Status)); // form parameter + + + + // authentication setting, if any + String[] authSettings = new String[] { "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content); } return; @@ -294,8 +638,7 @@ namespace IO.Swagger.Api { /// /// Deletes a pet /// - /// - /// Pet id to delete + /// /// Pet id to delete /// public void DeletePet (string ApiKey, long? PetId) { @@ -328,7 +671,48 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content); + } + + return; + } + + /// + /// Deletes a pet + /// + /// /// Pet id to delete + /// + public async Task DeletePetAsync (string ApiKey, long? PetId) { + + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling DeletePet"); + + + var path = "/pet/{petId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + if (ApiKey != null) headerParams.Add("api_key", apiClient.ParameterToString(ApiKey)); // header parameter + + + + + // authentication setting, if any + String[] authSettings = new String[] { "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content); } return; @@ -337,9 +721,7 @@ namespace IO.Swagger.Api { /// /// uploads an image /// - /// ID of pet to update - /// Additional data to pass to server - /// file to upload + /// ID of pet to update/// Additional data to pass to server/// file to upload /// public void UploadFile (long? PetId, string AdditionalMetadata, string File) { @@ -373,12 +755,54 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content); + } + + return; + } + + /// + /// uploads an image + /// + /// ID of pet to update/// Additional data to pass to server/// file to upload + /// + public async Task UploadFileAsync (long? PetId, string AdditionalMetadata, string File) { + + + // verify the required parameter 'PetId' is set + if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UploadFile"); + + + var path = "/pet/{petId}/uploadImage"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + if (AdditionalMetadata != null) formParams.Add("additionalMetadata", apiClient.ParameterToString(AdditionalMetadata)); // form parameter + if (File != null) fileParams.Add("file", File); + + + + // authentication setting, if any + String[] authSettings = new String[] { "petstore_auth" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content); } return; } - } + } } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs index a789b3502a0..8cd175a6227 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs @@ -1,15 +1,78 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using RestSharp; using IO.Swagger.Client; using IO.Swagger.Model; namespace IO.Swagger.Api { + + public interface IStoreApi { + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + + /// Dictionary + Dictionary GetInventory (); + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + + /// Dictionary + Task> GetInventoryAsync (); + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// Order + Order PlaceOrder (Order Body); + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// Order + Task PlaceOrderAsync (Order Body); + + /// + /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// ID of pet that needs to be fetched + /// Order + Order GetOrderById (string OrderId); + + /// + /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// ID of pet that needs to be fetched + /// Order + Task GetOrderByIdAsync (string OrderId); + + /// + /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + /// + void DeleteOrder (string OrderId); + + /// + /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + /// + Task DeleteOrderAsync (string OrderId); + + } + /// /// Represents a collection of functions to interact with the API endpoints /// - public class StoreApi { + public class StoreApi : IStoreApi { + /// /// Initializes a new instance of the class. /// @@ -59,6 +122,7 @@ namespace IO.Swagger.Api { /// /// Returns pet inventories by status Returns a map of status codes to quantities /// + /// Dictionary public Dictionary GetInventory () { @@ -86,10 +150,45 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content); } return (Dictionary) apiClient.Deserialize(response.Content, typeof(Dictionary)); } + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + + /// Dictionary + public async Task> GetInventoryAsync () { + + + + var path = "/store/inventory"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // authentication setting, if any + String[] authSettings = new String[] { "api_key" }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content); + } + return (Dictionary) ApiInvoker.Deserialize(response.Content, typeof(Dictionary)); + } /// /// Place an order for a pet @@ -123,10 +222,46 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content); } return (Order) apiClient.Deserialize(response.Content, typeof(Order)); } + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + /// Order + public async Task PlaceOrderAsync (Order Body) { + + + + var path = "/store/order"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + + + // authentication setting, if any + String[] authSettings = new String[] { }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content); + } + return (Order) ApiInvoker.Deserialize(response.Content, typeof(Order)); + } /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -163,10 +298,49 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content); } return (Order) apiClient.Deserialize(response.Content, typeof(Order)); } + + /// + /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// ID of pet that needs to be fetched + /// Order + public async Task GetOrderByIdAsync (string OrderId) { + + + // verify the required parameter 'OrderId' is set + if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling GetOrderById"); + + + var path = "/store/order/{orderId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // authentication setting, if any + String[] authSettings = new String[] { }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content); + } + return (Order) ApiInvoker.Deserialize(response.Content, typeof(Order)); + } /// /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -203,12 +377,52 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content); + } + + return; + } + + /// + /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + /// + public async Task DeleteOrderAsync (string OrderId) { + + + // verify the required parameter 'OrderId' is set + if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling DeleteOrder"); + + + var path = "/store/order/{orderId}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // authentication setting, if any + String[] authSettings = new String[] { }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content); } return; } - } + } } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs index 35de41c2257..154ad67240c 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs @@ -1,15 +1,134 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using RestSharp; using IO.Swagger.Client; using IO.Swagger.Model; namespace IO.Swagger.Api { + + public interface IUserApi { + + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + /// + void CreateUser (User Body); + + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + /// + Task CreateUserAsync (User Body); + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + void CreateUsersWithArrayInput (List Body); + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + Task CreateUsersWithArrayInputAsync (List Body); + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + void CreateUsersWithListInput (List Body); + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + Task CreateUsersWithListInputAsync (List Body); + + /// + /// Logs user into the system + /// + /// The user name for login/// The password for login in clear text + /// string + string LoginUser (string Username, string Password); + + /// + /// Logs user into the system + /// + /// The user name for login/// The password for login in clear text + /// string + Task LoginUserAsync (string Username, string Password); + + /// + /// Logs out current logged in user session + /// + + /// + void LogoutUser (); + + /// + /// Logs out current logged in user session + /// + + /// + Task LogoutUserAsync (); + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// User + User GetUserByName (string Username); + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// User + Task GetUserByNameAsync (string Username); + + /// + /// Updated user This can only be done by the logged in user. + /// + /// name that need to be deleted/// Updated user object + /// + void UpdateUser (string Username, User Body); + + /// + /// Updated user This can only be done by the logged in user. + /// + /// name that need to be deleted/// Updated user object + /// + Task UpdateUserAsync (string Username, User Body); + + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + void DeleteUser (string Username); + + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + Task DeleteUserAsync (string Username); + + } + /// /// Represents a collection of functions to interact with the API endpoints /// - public class UserApi { + public class UserApi : IUserApi { + /// /// Initializes a new instance of the class. /// @@ -88,7 +207,44 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content); + } + + return; + } + + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + /// + public async Task CreateUserAsync (User Body) { + + + + var path = "/user"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + + + // authentication setting, if any + String[] authSettings = new String[] { }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content); } return; @@ -126,7 +282,44 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content); + } + + return; + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + public async Task CreateUsersWithArrayInputAsync (List Body) { + + + + var path = "/user/createWithArray"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + + + // authentication setting, if any + String[] authSettings = new String[] { }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content); } return; @@ -164,7 +357,44 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content); + } + + return; + } + + /// + /// Creates list of users with given input array + /// + /// List of user object + /// + public async Task CreateUsersWithListInputAsync (List Body) { + + + + var path = "/user/createWithList"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + + + // authentication setting, if any + String[] authSettings = new String[] { }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content); } return; @@ -173,8 +403,7 @@ namespace IO.Swagger.Api { /// /// Logs user into the system /// - /// The user name for login - /// The password for login in clear text + /// The user name for login/// The password for login in clear text /// string public string LoginUser (string Username, string Password) { @@ -204,14 +433,52 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content); } return (string) apiClient.Deserialize(response.Content, typeof(string)); } + + /// + /// Logs user into the system + /// + /// The user name for login/// The password for login in clear text + /// string + public async Task LoginUserAsync (string Username, string Password) { + + + + var path = "/user/login"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + if (Username != null) queryParams.Add("username", apiClient.ParameterToString(Username)); // query parameter + if (Password != null) queryParams.Add("password", apiClient.ParameterToString(Password)); // query parameter + + + + + + // authentication setting, if any + String[] authSettings = new String[] { }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content); + } + return (string) ApiInvoker.Deserialize(response.Content, typeof(string)); + } /// /// Logs out current logged in user session /// + /// public void LogoutUser () { @@ -239,7 +506,43 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content); + } + + return; + } + + /// + /// Logs out current logged in user session + /// + + /// + public async Task LogoutUserAsync () { + + + + var path = "/user/logout"; + path = path.Replace("{format}", "json"); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // authentication setting, if any + String[] authSettings = new String[] { }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content); } return; @@ -280,16 +583,54 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content); } return (User) apiClient.Deserialize(response.Content, typeof(User)); } + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + /// User + public async Task GetUserByNameAsync (string Username) { + + + // verify the required parameter 'Username' is set + if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling GetUserByName"); + + + var path = "/user/{username}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // authentication setting, if any + String[] authSettings = new String[] { }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content); + } + return (User) ApiInvoker.Deserialize(response.Content, typeof(User)); + } /// /// Updated user This can only be done by the logged in user. /// - /// name that need to be deleted - /// Updated user object + /// name that need to be deleted/// Updated user object /// public void UpdateUser (string Username, User Body) { @@ -322,7 +663,48 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content); + } + + return; + } + + /// + /// Updated user This can only be done by the logged in user. + /// + /// name that need to be deleted/// Updated user object + /// + public async Task UpdateUserAsync (string Username, User Body) { + + + // verify the required parameter 'Username' is set + if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling UpdateUser"); + + + var path = "/user/{username}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + postBody = apiClient.Serialize(Body); // http body (model) parameter + + + // authentication setting, if any + String[] authSettings = new String[] { }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content); } return; @@ -363,12 +745,52 @@ namespace IO.Swagger.Api { IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { - throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content); + throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content); + } + + return; + } + + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + public async Task DeleteUserAsync (string Username) { + + + // verify the required parameter 'Username' is set + if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling DeleteUser"); + + + var path = "/user/{username}"; + path = path.Replace("{format}", "json"); + path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username)); + + + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + var fileParams = new Dictionary(); + String postBody = null; + + + + + + + // authentication setting, if any + String[] authSettings = new String[] { }; + + // make the HTTP request + IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings); + if (((int)response.StatusCode) >= 400) { + throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content); } return; } - } + } } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiClient.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiClient.cs index 39d59f063f2..b001a38845c 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiClient.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiClient.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Net; using System.Text; +using System.Threading.Tasks; using Newtonsoft.Json; using RestSharp; @@ -36,7 +37,16 @@ namespace IO.Swagger.Client { private Dictionary defaultHeaderMap = new Dictionary(); - public Object CallApi(String Path, RestSharp.Method Method, Dictionary QueryParams, String PostBody, + public Object CallApi(String Path, RestSharp.Method Method, Dictionary QueryParams, String PostBody, + Dictionary HeaderParams, Dictionary FormParams, Dictionary FileParams, String[] AuthSettings) { + var response = Task.Run(async () => { + var resp = await CallApiAsync(Path, Method, QueryParams, PostBody, HeaderParams, FormParams, FileParams, AuthSettings); + return resp; + }); + return response.Result; + } + + public async Task CallApiAsync(String Path, RestSharp.Method Method, Dictionary QueryParams, String PostBody, Dictionary HeaderParams, Dictionary FormParams, Dictionary FileParams, String[] AuthSettings) { var request = new RestRequest(Path, Method); @@ -67,7 +77,7 @@ namespace IO.Swagger.Client { request.AddParameter("application/json", PostBody, ParameterType.RequestBody); // http body (model) parameter } - return (Object)restClient.Execute(request); + return (Object) await restClient.ExecuteTaskAsync(request); } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiException.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiException.cs index 691c2cd3fa2..f9cf380e683 100644 --- a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiException.cs +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiException.cs @@ -11,6 +11,12 @@ namespace IO.Swagger.Client { /// The error code (HTTP status code). public int ErrorCode { get; set; } + /// + /// Gets or sets the error content (body json object) + /// + /// The error content (Http response body). + public dynamic ErrorContent { get; private set; } + /// /// Initializes a new instance of the class. /// @@ -26,6 +32,11 @@ namespace IO.Swagger.Client { this.ErrorCode = errorCode; } + public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) { + this.ErrorCode = errorCode; + this.ErrorContent = errorContent; + } + } } diff --git a/samples/client/petstore/objc/Podfile b/samples/client/petstore/objc/Podfile index 9a1ad058940..61b00df61ad 100644 --- a/samples/client/petstore/objc/Podfile +++ b/samples/client/petstore/objc/Podfile @@ -1,5 +1,5 @@ platform :ios, '6.0' -xcodeproj 'PetstoreClient/PetstoreClient.xcodeproj' +xcodeproj 'swaggerClient/swaggerClient.xcodeproj' pod 'AFNetworking', '~> 2.1' pod 'JSONModel', '~> 1.0' pod 'ISO8601' diff --git a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Pet.java index 66a02367c90..3ae04239744 100644 --- a/samples/client/petstore/retrofit/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/retrofit/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 com.wordnik.swagger.annotations.*; import com.google.gson.annotations.SerializedName; diff --git a/samples/client/petstore/scala/pom.xml b/samples/client/petstore/scala/pom.xml index b6dd4493a0b..74bb2feed86 100644 --- a/samples/client/petstore/scala/pom.xml +++ b/samples/client/petstore/scala/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - com.wordnik + io.swagger swagger-scala-client jar swagger-scala-client diff --git a/samples/html/index.html b/samples/html/index.html index 3cfd67d8d59..e595d3ea40d 100644 --- a/samples/html/index.html +++ b/samples/html/index.html @@ -301,7 +301,7 @@

Example data

Content-Type: application/xml
-
not implemented com.wordnik.swagger.models.properties.MapProperty@3e
+
not implemented io.swagger.models.properties.MapProperty@3e

@@ -332,7 +332,7 @@ "complete" : true, "status" : "aeiou", "quantity" : 123, - "shipDate" : "2015-05-23T15:56:49.441+0000" + "shipDate" : "2015-06-07T06:42:05.171+0000" }

Example data

@@ -341,7 +341,7 @@ <id>123456</id> <petId>123456</petId> <quantity>0</quantity> - <shipDate>2015-05-23T08:56:49.444Z</shipDate> + <shipDate>2015-06-06T23:42:05.174Z</shipDate> <status>string</status> <complete>true</complete> </Order> @@ -375,7 +375,7 @@ "complete" : true, "status" : "aeiou", "quantity" : 123, - "shipDate" : "2015-05-23T15:56:49.445+0000" + "shipDate" : "2015-06-07T06:42:05.175+0000" }

Example data

@@ -384,7 +384,7 @@ <id>123456</id> <petId>123456</petId> <quantity>0</quantity> - <shipDate>2015-05-23T08:56:49.445Z</shipDate> + <shipDate>2015-06-06T23:42:05.176Z</shipDate> <status>string</status> <complete>true</complete> </Order> 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 d5fd9c48e07..e67773ed634 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 @@ -44,7 +44,6 @@ public class PetApi { public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body) throws NotFoundException { - // do some magic! return delegate.updatePet(body); } @POST @@ -57,7 +56,6 @@ public class PetApi { public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body) throws NotFoundException { - // do some magic! return delegate.addPet(body); } @GET @@ -72,7 +70,6 @@ public class PetApi { public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue="available") @QueryParam("status") List status) throws NotFoundException { - // do some magic! return delegate.findPetsByStatus(status); } @GET @@ -87,7 +84,6 @@ public class PetApi { public Response findPetsByTags(@ApiParam(value = "Tags to filter by") @QueryParam("tags") List tags) throws NotFoundException { - // do some magic! return delegate.findPetsByTags(tags); } @GET @@ -104,7 +100,6 @@ public class PetApi { public Response getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("petId") Long petId) throws NotFoundException { - // do some magic! return delegate.getPetById(petId); } @POST @@ -119,7 +114,6 @@ public class PetApi { @ApiParam(value = "Updated name of the pet" )@FormParam("name") String name, @ApiParam(value = "Updated status of the pet" )@FormParam("status") String status) throws NotFoundException { - // do some magic! return delegate.updatePetWithForm(petId,name,status); } @DELETE @@ -133,7 +127,6 @@ public class PetApi { public Response deletePet(@ApiParam(value = "" )@HeaderParam("api_key") String apiKey, @ApiParam(value = "Pet id to delete",required=true ) @PathParam("petId") Long petId) throws NotFoundException { - // do some magic! return delegate.deletePet(apiKey,petId); } @POST @@ -149,7 +142,6 @@ public class PetApi { @ApiParam(value = "file to upload") @FormDataParam("file") InputStream inputStream, @ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail) throws NotFoundException { - // do some magic! return delegate.uploadFile(petId,additionalMetadata,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 7c8dff02ffa..790d4c4c3f6 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 @@ -40,7 +40,6 @@ public class StoreApi { public Response getInventory() throws NotFoundException { - // do some magic! return delegate.getInventory(); } @POST @@ -55,7 +54,6 @@ public class StoreApi { public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body) throws NotFoundException { - // do some magic! return delegate.placeOrder(body); } @GET @@ -72,7 +70,6 @@ public class StoreApi { public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("orderId") String orderId) throws NotFoundException { - // do some magic! return delegate.getOrderById(orderId); } @DELETE @@ -87,7 +84,6 @@ public class StoreApi { public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathParam("orderId") String orderId) throws NotFoundException { - // do some magic! return delegate.deleteOrder(orderId); } } 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 f0c5493f848..979476c41c6 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 @@ -40,7 +40,6 @@ public class UserApi { public Response createUser(@ApiParam(value = "Created user object" ) User body) throws NotFoundException { - // do some magic! return delegate.createUser(body); } @POST @@ -53,7 +52,6 @@ public class UserApi { public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ) List body) throws NotFoundException { - // do some magic! return delegate.createUsersWithArrayInput(body); } @POST @@ -66,7 +64,6 @@ public class UserApi { public Response createUsersWithListInput(@ApiParam(value = "List of user object" ) List body) throws NotFoundException { - // do some magic! return delegate.createUsersWithListInput(body); } @GET @@ -82,7 +79,6 @@ public class UserApi { 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 { - // do some magic! return delegate.loginUser(username,password); } @GET @@ -95,7 +91,6 @@ public class UserApi { public Response logoutUser() throws NotFoundException { - // do some magic! return delegate.logoutUser(); } @GET @@ -112,7 +107,6 @@ public class UserApi { public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathParam("username") String username) throws NotFoundException { - // do some magic! return delegate.getUserByName(username); } @PUT @@ -128,7 +122,6 @@ public class UserApi { 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 { - // do some magic! return delegate.updateUser(username,body); } @DELETE @@ -143,7 +136,6 @@ public class UserApi { public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathParam("username") String username) throws NotFoundException { - // do some magic! return delegate.deleteUser(username); } }