From d45d36d8a2e3c5dd0218d3a00b8d0ea9a3de33eb Mon Sep 17 00:00:00 2001 From: oskar Date: Wed, 6 Apr 2016 21:51:17 +0200 Subject: [PATCH 01/26] Fixing broken enumeration swagger/json types for JaxRS-CXF templates. --- .../main/resources/JavaJaxRS/cxf/api.mustache | 4 +++ .../JavaJaxRS/cxf/enumClass.mustache | 27 ++++++++++++------- .../resources/JavaJaxRS/cxf/pojo.mustache | 3 ++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache index 346a7a7d0a12..5d25496a1b3f 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache @@ -3,6 +3,10 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; import javax.ws.rs.*; import javax.ws.rs.core.Response; diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/enumClass.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/enumClass.mustache index 1ef4a61efbed..5d6d4805f8a4 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/enumClass.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/enumClass.mustache @@ -1,16 +1,23 @@ -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - -@XmlType(name="{{classname}}") +@XmlType(name="{{datatypeWithEnum}}") @XmlEnum -public enum {{classname}} { - {{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/allowableValues}} - - public String value() { - return name(); +public enum {{datatypeWithEnum}} { + + {{#allowableValues}} + {{#enumVars}}{{name}}({{datatype}}.valueOf("{{value}}")){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}} + {{/allowableValues}} + + + private {{datatype}} value; + + {{datatypeWithEnum}} ({{datatype}} v) { + value = v; } - public static {{classname}} fromValue(String v) { + public String value() { + return value; + } + + public static {{datatypeWithEnum}} fromValue(String v) { return valueOf(v); } } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache index b42a6d3b3eb7..f17abb0d2220 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache @@ -3,9 +3,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; @XmlAccessorType(XmlAccessType.FIELD) -{{#hasVars}} @XmlType(name = "{{classn,ame}}", propOrder = +{{#hasVars}} @XmlType(name = "{{classname}}", propOrder = { {{#vars}}"{{name}}"{{^-last}}, {{/-last}}{{/vars}} }){{/hasVars}} {{^hasVars}}@XmlType(name = "{{classname}}"){{/hasVars}} From f4fc88c6be064d02b29acf19f1834ab8441c3c2e Mon Sep 17 00:00:00 2001 From: Kristof Vrolijkx Date: Tue, 19 Apr 2016 11:02:36 +0200 Subject: [PATCH 02/26] #1809 Adding basic angular2 typescript codegen. --- .../TypeScriptAngularClientCodegen.java | 16 +- .../TypescriptAngular2ClientCodegen.java | 81 ++++++++ .../services/io.swagger.codegen.CodegenConfig | 1 + .../typescript-angular2/api.mustache | 88 +++++++++ .../typescript-angular2/model.d.mustache | 17 ++ .../typescript-angular2/model.mustache | 37 ++++ ...peScriptAngular2ClientOptionsProvider.java | 32 +++ .../TypeScriptAngular2ClientOptionsTest.java | 35 ++++ .../TypeScriptAngular2ModelTest.java | 183 ++++++++++++++++++ 9 files changed, 482 insertions(+), 8 deletions(-) create mode 100644 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypescriptAngular2ClientCodegen.java create mode 100644 modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache create mode 100644 modules/swagger-codegen/src/main/resources/typescript-angular2/model.d.mustache create mode 100644 modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/options/TypeScriptAngular2ClientOptionsProvider.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java index 6237331cf807..670805efafdb 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java @@ -1,8 +1,9 @@ package io.swagger.codegen.languages; -import io.swagger.codegen.SupportingFile; import java.io.File; +import io.swagger.codegen.SupportingFile; + public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCodegen { @Override @@ -14,14 +15,13 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode public String getHelp() { return "Generates a TypeScript AngularJS client library."; } - - @Override - public void processOpts() { - super.processOpts(); - supportingFiles.add(new SupportingFile("api.d.mustache", apiPackage().replace('.', File.separatorChar), "api.d.ts")); - supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); - //supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + @Override + public void processOpts() { + super.processOpts(); + supportingFiles.add(new SupportingFile("api.d.mustache", apiPackage().replace('.', File.separatorChar), "api.d.ts")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + //supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypescriptAngular2ClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypescriptAngular2ClientCodegen.java new file mode 100644 index 000000000000..676fabc55566 --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypescriptAngular2ClientCodegen.java @@ -0,0 +1,81 @@ +package io.swagger.codegen.languages; + +import java.io.File; + +import io.swagger.codegen.CodegenParameter; +import io.swagger.codegen.SupportingFile; +import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.FileProperty; +import io.swagger.models.properties.MapProperty; +import io.swagger.models.properties.Property; + +public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCodegen { + + public TypeScriptAngular2ClientCodegen() { + super(); + this.outputFolder = "generated-code/typescript-angular2"; + + embeddedTemplateDir = templateDir = "typescript-angular2"; + modelTemplateFiles.put("model.mustache", ".ts"); + apiTemplateFiles.put("api.mustache", ".ts"); + typeMapping.put("Date","Date"); + apiPackage = "api"; + modelPackage = "model"; + } + + @Override + public String getName() { + return "TypeScript-Angular2"; + } + + @Override + public String getHelp() { + return "Generates a TypeScript Angular2 client library."; + } + + @Override + public void processOpts() { + super.processOpts(); + supportingFiles.clear(); + supportingFiles.add(new SupportingFile("model.d.mustache", modelPackage().replace('.', File.separatorChar), "model.d.ts")); + } + + @Override + public String getTypeDeclaration(Property p) { + Property inner; + if(p instanceof ArrayProperty) { + ArrayProperty mp1 = (ArrayProperty)p; + inner = mp1.getItems(); + return this.getSwaggerType(p) + "<" + this.getTypeDeclaration(inner) + ">"; + } else if(p instanceof MapProperty) { + MapProperty mp = (MapProperty)p; + inner = mp.getAdditionalProperties(); + return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }"; + } else { + return p instanceof FileProperty ? "any" : super.getTypeDeclaration(p); + } + } + + @Override + public String getSwaggerType(Property p) { + String swaggerType = super.getSwaggerType(p); + return addModelPrefix(swaggerType); + } + + private String addModelPrefix(String swaggerType) { + String type = null; + if (typeMapping.containsKey(swaggerType)) { + type = typeMapping.get(swaggerType); + if (languageSpecificPrimitives.contains(type)) + return type; + } else + type = "model." + swaggerType; + return type; + } + + @Override + public void postProcessParameter(CodegenParameter parameter) { + super.postProcessParameter(parameter); + parameter.dataType = addModelPrefix(parameter.dataType); + } +} diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index 070b084fdb62..50d5357285db 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -34,6 +34,7 @@ io.swagger.codegen.languages.SwaggerGenerator io.swagger.codegen.languages.SwaggerYamlGenerator io.swagger.codegen.languages.SwiftCodegen io.swagger.codegen.languages.TizenClientCodegen +io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen io.swagger.codegen.languages.TypeScriptAngularClientCodegen io.swagger.codegen.languages.TypeScriptNodeClientCodegen io.swagger.codegen.languages.AkkaScalaClientCodegen diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache new file mode 100644 index 000000000000..5c2d412d5c0a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache @@ -0,0 +1,88 @@ +import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from 'angular2/http'; +import {Injectable} from 'angular2/core'; +import {Observable} from 'rxjs/Observable'; +import * as model from "../model/model.d.ts" +import {AppSettings} from "../../AppSettings" + +/* tslint:disable:no-unused-variable member-ordering */ + +{{#operations}} +'use strict'; + +{{#description}} +/** + * {{&description}} + */ +{{/description}} +@Injectable() +export class {{classname}} { + protected basePath = '{{basePath}}'; + public defaultHeaders : Headers = new Headers(); + + constructor(protected http: Http, appSettigs: AppSettings) { + if (appSettigs && appSettigs.apiBaseUrl) { + this.basePath = appSettigs.apiBaseUrl; + } + } + +{{#operation}} + /** + * {{summary}} + * {{notes}} + {{#allParams}}* @param {{paramName}} {{description}} + {{/allParams}}*/ + public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> { + const path = this.basePath + '{{path}}'{{#pathParams}} + .replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}}; + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; +{{#hasFormParams}} + let formParams = new URLSearchParams(); + +{{/hasFormParams}} +{{#allParams}} +{{#required}} + // verify required parameter '{{paramName}}' is set + if (!{{paramName}}) { + throw new Error('Missing required parameter {{paramName}} when calling {{nickname}}'); + } +{{/required}} +{{/allParams}} +{{#queryParams}} + if ({{paramName}} !== undefined) { + queryParameters['{{baseName}}'] = {{paramName}}; + } + +{{/queryParams}} +{{#headerParams}} + headerParams.set('{{baseName}}', {{paramName }}); + +{{/headerParams}} +{{#hasFormParams}} + headerParams.set('Content-Type', 'application/x-www-form-urlencoded'); + +{{/hasFormParams}} +{{#formParams}} + formParams['{{baseName}}'] = {{paramName}}; + +{{/formParams}} + let requestOptions: RequestOptionsArgs = { + method: '{{httpMethod}}', + headers: headerParams, + search: queryParameters + }; + {{#bodyParam}} + requestOptions.body = JSOG.stringify({{paramName}}); + {{/bodyParam}} + {{#hasFormParams}} + requestOptions.body = formParams.toString(); + {{/hasFormParams}} + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + +{{/operation}} +} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/model.d.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.d.mustache new file mode 100644 index 000000000000..8973ef01ecd5 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.d.mustache @@ -0,0 +1,17 @@ +{{#models}} +{{#model}} +export { {{{classname}}} } from './{{{ classname }}}'; +{{/model}} +{{/models}} + + +/* +{{#apiInfo}} +{{#apis}} +{{#operations}} +export * from './{{classname}}'; +{{/operations}} +{{/apis}} +{{/apiInfo}} +*/ + diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache new file mode 100644 index 000000000000..ff36a380e94f --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache @@ -0,0 +1,37 @@ +{{#models}} +{{#model}} +'use strict'; +import * as model from "./model.d.ts" + +{{#description}} +/** + * {{{description}}} + */ +{{/description}} +export interface {{classname}} {{#parent}}extends model.{{{parent}}} {{/parent}}{ +{{#vars}} + +{{#description}} + /** + * {{{description}}} + */ +{{/description}} + + {{name}}?: {{#isEnum}}{{classname}}.{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; +{{/vars}} +} + +{{#hasEnums}} +export namespace {{classname}} { +{{#vars}} +{{#isEnum}} + + export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} + {{.}} = '{{.}}',{{/values}}{{/allowableValues}} + } +{{/isEnum}} +{{/vars}} +} +{{/hasEnums}} +{{/model}} +{{/models}} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/TypeScriptAngular2ClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/TypeScriptAngular2ClientOptionsProvider.java new file mode 100644 index 000000000000..c7bddc9f6634 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/TypeScriptAngular2ClientOptionsProvider.java @@ -0,0 +1,32 @@ +package io.swagger.codegen.options; + +import com.google.common.collect.ImmutableMap; + +import java.util.Map; + +import io.swagger.codegen.CodegenConstants; + +public class TypeScriptAngular2ClientOptionsProvider implements OptionsProvider { + public static final String SORT_PARAMS_VALUE = "false"; + public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true"; + public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase"; + + @Override + public String getLanguage() { + return "typescript-angular2"; + } + + @Override + public Map createOptions() { + ImmutableMap.Builder builder = new ImmutableMap.Builder(); + return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE) + .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) + .put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE) + .build(); + } + + @Override + public boolean isServer() { + return false; + } +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java new file mode 100644 index 000000000000..4c56a7dfab2b --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java @@ -0,0 +1,35 @@ +package io.swagger.codegen.typescriptangular2; + +import io.swagger.codegen.AbstractOptionsTest; +import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen; +import io.swagger.codegen.options.TypeScriptAngular2ClientOptionsProvider; +import io.swagger.codegen.options.TypeScriptAngularClientOptionsProvider; +import mockit.Expectations; +import mockit.Tested; + +public class TypeScriptAngular2ClientOptionsTest extends AbstractOptionsTest { + + @Tested + private TypeScriptAngular2ClientCodegen clientCodegen; + + public TypeScriptAngular2ClientOptionsTest() { + super(new TypeScriptAngular2ClientOptionsProvider()); + } + + @Override + protected CodegenConfig getCodegenConfig() { + return clientCodegen; + } + + @SuppressWarnings("unused") + @Override + protected void setExpectations() { + new Expectations(clientCodegen) {{ + clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(TypeScriptAngularClientOptionsProvider.SORT_PARAMS_VALUE)); + times = 1; + clientCodegen.setModelPropertyNaming(TypeScriptAngularClientOptionsProvider.MODEL_PROPERTY_NAMING_VALUE); + times = 1; + }}; + } +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java new file mode 100644 index 000000000000..8f6968012020 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java @@ -0,0 +1,183 @@ +package io.swagger.codegen.typescriptangular2; + +import com.google.common.collect.Sets; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.codegen.CodegenModel; +import io.swagger.codegen.CodegenProperty; +import io.swagger.codegen.DefaultCodegen; +import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen; +import io.swagger.models.ArrayModel; +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.DateTimeProperty; +import io.swagger.models.properties.LongProperty; +import io.swagger.models.properties.RefProperty; +import io.swagger.models.properties.StringProperty; + +@SuppressWarnings("static-method") +public class TypeScriptAngular2ModelTest { + + @Test(description = "convert a simple TypeScript Angular2 model") + public void simpleModelTest() { + final Model model = new ModelImpl() + .description("a sample model") + .property("id", new LongProperty()) + .property("name", new StringProperty()) + .property("createdAt", new DateTimeProperty()) + .required("id") + .required("name"); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); + final CodegenModel cm = codegen.fromModel("sample", model); + + Assert.assertEquals(cm.name, "sample"); + Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.description, "a sample model"); + Assert.assertEquals(cm.vars.size(), 3); + + final CodegenProperty property1 = cm.vars.get(0); + Assert.assertEquals(property1.baseName, "id"); + Assert.assertEquals(property1.datatype, "number"); + Assert.assertEquals(property1.name, "id"); + Assert.assertEquals(property1.defaultValue, "null"); + Assert.assertEquals(property1.baseType, "number"); + Assert.assertTrue(property1.hasMore); + Assert.assertTrue(property1.required); + Assert.assertTrue(property1.isNotContainer); + + final CodegenProperty property2 = cm.vars.get(1); + Assert.assertEquals(property2.baseName, "name"); + Assert.assertEquals(property2.datatype, "string"); + Assert.assertEquals(property2.name, "name"); + Assert.assertEquals(property2.defaultValue, "null"); + Assert.assertEquals(property2.baseType, "string"); + Assert.assertTrue(property2.hasMore); + Assert.assertTrue(property2.required); + Assert.assertTrue(property2.isNotContainer); + + final CodegenProperty property3 = cm.vars.get(2); + Assert.assertEquals(property3.baseName, "createdAt"); + Assert.assertEquals(property3.complexType, null); + Assert.assertEquals(property3.datatype, "Date"); + Assert.assertEquals(property3.name, "createdAt"); + Assert.assertEquals(property3.defaultValue, "null"); + Assert.assertNull(property3.hasMore); + Assert.assertNull(property3.required); + Assert.assertTrue(property3.isNotContainer); + } + + @Test(description = "convert a model with list property") + public void listPropertyTest() { + final Model model = new ModelImpl() + .description("a sample model") + .property("id", new LongProperty()) + .property("urls", new ArrayProperty().items(new StringProperty())) + .required("id"); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); + final CodegenModel cm = codegen.fromModel("sample", model); + + Assert.assertEquals(cm.name, "sample"); + Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.description, "a sample model"); + Assert.assertEquals(cm.vars.size(), 2); + + final CodegenProperty property1 = cm.vars.get(0); + Assert.assertEquals(property1.baseName, "id"); + Assert.assertEquals(property1.datatype, "number"); + Assert.assertEquals(property1.name, "id"); + Assert.assertEquals(property1.defaultValue, "null"); + Assert.assertEquals(property1.baseType, "number"); + Assert.assertTrue(property1.hasMore); + Assert.assertTrue(property1.required); + Assert.assertTrue(property1.isNotContainer); + + final CodegenProperty property2 = cm.vars.get(1); + Assert.assertEquals(property2.baseName, "urls"); + Assert.assertEquals(property2.datatype, "Array"); + Assert.assertEquals(property2.name, "urls"); + Assert.assertEquals(property2.baseType, "Array"); + Assert.assertNull(property2.hasMore); + Assert.assertNull(property2.required); + Assert.assertTrue(property2.isContainer); + } + + @Test(description = "convert a model with complex property") + public void complexPropertyTest() { + final Model model = new ModelImpl() + .description("a sample model") + .property("children", new RefProperty("#/definitions/Children")); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); + final CodegenModel cm = codegen.fromModel("sample", model); + + Assert.assertEquals(cm.name, "sample"); + Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.description, "a sample model"); + Assert.assertEquals(cm.vars.size(), 1); + + final CodegenProperty property1 = cm.vars.get(0); + Assert.assertEquals(property1.baseName, "children"); + Assert.assertEquals(property1.datatype, "model.Children"); + Assert.assertEquals(property1.name, "children"); + Assert.assertEquals(property1.defaultValue, "null"); + Assert.assertEquals(property1.baseType, "model.Children"); + Assert.assertNull(property1.required); + Assert.assertTrue(property1.isNotContainer); + } + + @Test(description = "convert a model with complex list property") + public void complexListPropertyTest() { + final Model model = new ModelImpl() + .description("a sample model") + .property("children", new ArrayProperty() + .items(new RefProperty("#/definitions/Children"))); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); + final CodegenModel cm = codegen.fromModel("sample", model); + + Assert.assertEquals(cm.name, "sample"); + Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.description, "a sample model"); + Assert.assertEquals(cm.vars.size(), 1); + + final CodegenProperty property1 = cm.vars.get(0); + Assert.assertEquals(property1.baseName, "children"); + Assert.assertEquals(property1.complexType, "model.Children"); + Assert.assertEquals(property1.datatype, "Array"); + Assert.assertEquals(property1.name, "children"); + Assert.assertEquals(property1.baseType, "Array"); + Assert.assertNull(property1.required); + Assert.assertTrue(property1.isContainer); + } + + @Test(description = "convert an array model") + public void arrayModelTest() { + final Model model = new ArrayModel() + .description("an array model") + .items(new RefProperty("#/definitions/Children")); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); + final CodegenModel cm = codegen.fromModel("sample", model); + + Assert.assertEquals(cm.name, "sample"); + Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.description, "an array model"); + Assert.assertEquals(cm.vars.size(), 0); + } + + @Test(description = "convert a map model") + public void mapModelTest() { + final Model model = new ModelImpl() + .description("a map model") + .additionalProperties(new RefProperty("#/definitions/Children")); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); + final CodegenModel cm = codegen.fromModel("sample", model); + + Assert.assertEquals(cm.name, "sample"); + Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.description, "a map model"); + Assert.assertEquals(cm.vars.size(), 0); + Assert.assertEquals(cm.imports.size(), 1); + Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("model.Children")).size(), 1); + } +} From c54bceffe388e30ef0b559a02c7996e5444dc9c6 Mon Sep 17 00:00:00 2001 From: Kristof Vrolijkx Date: Tue, 19 Apr 2016 11:56:29 +0200 Subject: [PATCH 03/26] #1809 Some small template changes. --- modules/swagger-codegen-cli/pom.xml | 2 +- modules/swagger-codegen-maven-plugin/pom.xml | 2 +- modules/swagger-codegen/pom.xml | 2 +- .../languages/TypescriptAngular2ClientCodegen.java | 2 +- .../main/resources/typescript-angular2/api.mustache | 7 +++---- .../resources/typescript-angular2/model.d.mustache | 6 +++--- .../main/resources/typescript-angular2/model.mustache | 10 ++++------ modules/swagger-generator/pom.xml | 2 +- pom.xml | 2 +- 9 files changed, 16 insertions(+), 19 deletions(-) diff --git a/modules/swagger-codegen-cli/pom.xml b/modules/swagger-codegen-cli/pom.xml index 90a14b16deb2..bcdf4fb1da2c 100644 --- a/modules/swagger-codegen-cli/pom.xml +++ b/modules/swagger-codegen-cli/pom.xml @@ -3,7 +3,7 @@ io.swagger swagger-codegen-project - 2.1.6 + 2.1.7-SNAPSHOT ../.. 4.0.0 diff --git a/modules/swagger-codegen-maven-plugin/pom.xml b/modules/swagger-codegen-maven-plugin/pom.xml index b45e0d978748..10cd4e7d90f6 100644 --- a/modules/swagger-codegen-maven-plugin/pom.xml +++ b/modules/swagger-codegen-maven-plugin/pom.xml @@ -6,7 +6,7 @@ io.swagger swagger-codegen-project - 2.1.6 + 2.1.7-SNAPSHOT ../.. swagger-codegen-maven-plugin diff --git a/modules/swagger-codegen/pom.xml b/modules/swagger-codegen/pom.xml index afaecfc35126..a5f8907c7219 100644 --- a/modules/swagger-codegen/pom.xml +++ b/modules/swagger-codegen/pom.xml @@ -3,7 +3,7 @@ io.swagger swagger-codegen-project - 2.1.6 + 2.1.7-SNAPSHOT ../.. 4.0.0 diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypescriptAngular2ClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypescriptAngular2ClientCodegen.java index 676fabc55566..e23f4482dfa7 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypescriptAngular2ClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypescriptAngular2ClientCodegen.java @@ -25,7 +25,7 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod @Override public String getName() { - return "TypeScript-Angular2"; + return "typescript-angular2"; } @Override diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache index 5c2d412d5c0a..34a9b14da1e4 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache @@ -2,7 +2,6 @@ import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from 'angu import {Injectable} from 'angular2/core'; import {Observable} from 'rxjs/Observable'; import * as model from "../model/model.d.ts" -import {AppSettings} from "../../AppSettings" /* tslint:disable:no-unused-variable member-ordering */ @@ -19,9 +18,9 @@ export class {{classname}} { protected basePath = '{{basePath}}'; public defaultHeaders : Headers = new Headers(); - constructor(protected http: Http, appSettigs: AppSettings) { - if (appSettigs && appSettigs.apiBaseUrl) { - this.basePath = appSettigs.apiBaseUrl; + constructor(protected http: Http, basePath: string) { + if (basePath) { + this.basePath = basePath; } } diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/model.d.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.d.mustache index 8973ef01ecd5..e682f9bb2e7a 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/model.d.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.d.mustache @@ -1,11 +1,11 @@ {{#models}} {{#model}} -export { {{{classname}}} } from './{{{ classname }}}'; +export * from './{{{ classname }}}'; {{/model}} {{/models}} -/* + {{#apiInfo}} {{#apis}} {{#operations}} @@ -13,5 +13,5 @@ export * from './{{classname}}'; {{/operations}} {{/apis}} {{/apiInfo}} -*/ + diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache index ff36a380e94f..5272576afd89 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache @@ -17,21 +17,19 @@ export interface {{classname}} {{#parent}}extends model.{{{parent}}} {{/parent}} */ {{/description}} - {{name}}?: {{#isEnum}}{{classname}}.{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; + {{name}}?: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; {{/vars}} } {{#hasEnums}} -export namespace {{classname}} { {{#vars}} {{#isEnum}} - export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} - {{.}} = '{{.}}',{{/values}}{{/allowableValues}} - } +export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} + {{.}} = '{{.}}',{{/values}}{{/allowableValues}} +} {{/isEnum}} {{/vars}} -} {{/hasEnums}} {{/model}} {{/models}} diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml index 2d2b45d78921..ffd02dc352a4 100644 --- a/modules/swagger-generator/pom.xml +++ b/modules/swagger-generator/pom.xml @@ -4,7 +4,7 @@ io.swagger swagger-codegen-project - 2.1.6 + 2.1.7-SNAPSHOT ../.. swagger-generator diff --git a/pom.xml b/pom.xml index 9ac1890ea914..e881d136cb29 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ swagger-codegen-project pom swagger-codegen-project - 2.1.6 + 2.1.7-SNAPSHOT https://github.com/swagger-api/swagger-codegen scm:git:git@github.com:swagger-api/swagger-codegen.git From 13cd2af10535778c5a587f77c16c6aab2b09cb33 Mon Sep 17 00:00:00 2001 From: Kristof Vrolijkx Date: Tue, 19 Apr 2016 11:57:55 +0200 Subject: [PATCH 04/26] Revert: #1809 changing the poms --- modules/swagger-codegen-cli/pom.xml | 2 +- modules/swagger-codegen-maven-plugin/pom.xml | 2 +- modules/swagger-codegen/pom.xml | 2 +- modules/swagger-generator/pom.xml | 2 +- pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen-cli/pom.xml b/modules/swagger-codegen-cli/pom.xml index bcdf4fb1da2c..90a14b16deb2 100644 --- a/modules/swagger-codegen-cli/pom.xml +++ b/modules/swagger-codegen-cli/pom.xml @@ -3,7 +3,7 @@ io.swagger swagger-codegen-project - 2.1.7-SNAPSHOT + 2.1.6 ../.. 4.0.0 diff --git a/modules/swagger-codegen-maven-plugin/pom.xml b/modules/swagger-codegen-maven-plugin/pom.xml index 10cd4e7d90f6..b45e0d978748 100644 --- a/modules/swagger-codegen-maven-plugin/pom.xml +++ b/modules/swagger-codegen-maven-plugin/pom.xml @@ -6,7 +6,7 @@ io.swagger swagger-codegen-project - 2.1.7-SNAPSHOT + 2.1.6 ../.. swagger-codegen-maven-plugin diff --git a/modules/swagger-codegen/pom.xml b/modules/swagger-codegen/pom.xml index a5f8907c7219..afaecfc35126 100644 --- a/modules/swagger-codegen/pom.xml +++ b/modules/swagger-codegen/pom.xml @@ -3,7 +3,7 @@ io.swagger swagger-codegen-project - 2.1.7-SNAPSHOT + 2.1.6 ../.. 4.0.0 diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml index ffd02dc352a4..2d2b45d78921 100644 --- a/modules/swagger-generator/pom.xml +++ b/modules/swagger-generator/pom.xml @@ -4,7 +4,7 @@ io.swagger swagger-codegen-project - 2.1.7-SNAPSHOT + 2.1.6 ../.. swagger-generator diff --git a/pom.xml b/pom.xml index e881d136cb29..9ac1890ea914 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ swagger-codegen-project pom swagger-codegen-project - 2.1.7-SNAPSHOT + 2.1.6 https://github.com/swagger-api/swagger-codegen scm:git:git@github.com:swagger-api/swagger-codegen.git From 034c1fbb21296a1102c51d431af1b16260f4ca09 Mon Sep 17 00:00:00 2001 From: Kristof Vrolijkx Date: Tue, 19 Apr 2016 12:59:23 +0200 Subject: [PATCH 05/26] #1809 resolve casing conflict part1 --- .../TypeScriptAngular2ClientCodegen2.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen2.java diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen2.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen2.java new file mode 100644 index 000000000000..522736cb4121 --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen2.java @@ -0,0 +1,81 @@ +package io.swagger.codegen.languages; + +import java.io.File; + +import io.swagger.codegen.CodegenParameter; +import io.swagger.codegen.SupportingFile; +import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.FileProperty; +import io.swagger.models.properties.MapProperty; +import io.swagger.models.properties.Property; + +public class TypeScriptAngular2ClientCodegen2 extends AbstractTypeScriptClientCodegen { + + public TypeScriptAngular2ClientCodegen2() { + super(); + this.outputFolder = "generated-code/typescript-angular2"; + + embeddedTemplateDir = templateDir = "typescript-angular2"; + modelTemplateFiles.put("model.mustache", ".ts"); + apiTemplateFiles.put("api.mustache", ".ts"); + typeMapping.put("Date","Date"); + apiPackage = "api"; + modelPackage = "model"; + } + + @Override + public String getName() { + return "typescript-angular2"; + } + + @Override + public String getHelp() { + return "Generates a TypeScript Angular2 client library."; + } + + @Override + public void processOpts() { + super.processOpts(); + supportingFiles.clear(); + supportingFiles.add(new SupportingFile("model.d.mustache", modelPackage().replace('.', File.separatorChar), "model.d.ts")); + } + + @Override + public String getTypeDeclaration(Property p) { + Property inner; + if(p instanceof ArrayProperty) { + ArrayProperty mp1 = (ArrayProperty)p; + inner = mp1.getItems(); + return this.getSwaggerType(p) + "<" + this.getTypeDeclaration(inner) + ">"; + } else if(p instanceof MapProperty) { + MapProperty mp = (MapProperty)p; + inner = mp.getAdditionalProperties(); + return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }"; + } else { + return p instanceof FileProperty ? "any" : super.getTypeDeclaration(p); + } + } + + @Override + public String getSwaggerType(Property p) { + String swaggerType = super.getSwaggerType(p); + return addModelPrefix(swaggerType); + } + + private String addModelPrefix(String swaggerType) { + String type = null; + if (typeMapping.containsKey(swaggerType)) { + type = typeMapping.get(swaggerType); + if (languageSpecificPrimitives.contains(type)) + return type; + } else + type = "model." + swaggerType; + return type; + } + + @Override + public void postProcessParameter(CodegenParameter parameter) { + super.postProcessParameter(parameter); + parameter.dataType = addModelPrefix(parameter.dataType); + } +} From e94c43387410c3870de4aacb5033f70132e18417 Mon Sep 17 00:00:00 2001 From: Kristof Vrolijkx Date: Tue, 19 Apr 2016 13:00:18 +0200 Subject: [PATCH 06/26] #1809 resolve casing conflict part1 --- .../TypescriptAngular2ClientCodegen.java | 81 ------------------- .../services/io.swagger.codegen.CodegenConfig | 2 +- .../TypeScriptAngular2ClientOptionsTest.java | 4 +- .../TypeScriptAngular2ModelTest.java | 14 ++-- 4 files changed, 10 insertions(+), 91 deletions(-) delete mode 100644 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypescriptAngular2ClientCodegen.java diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypescriptAngular2ClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypescriptAngular2ClientCodegen.java deleted file mode 100644 index e23f4482dfa7..000000000000 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypescriptAngular2ClientCodegen.java +++ /dev/null @@ -1,81 +0,0 @@ -package io.swagger.codegen.languages; - -import java.io.File; - -import io.swagger.codegen.CodegenParameter; -import io.swagger.codegen.SupportingFile; -import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.FileProperty; -import io.swagger.models.properties.MapProperty; -import io.swagger.models.properties.Property; - -public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCodegen { - - public TypeScriptAngular2ClientCodegen() { - super(); - this.outputFolder = "generated-code/typescript-angular2"; - - embeddedTemplateDir = templateDir = "typescript-angular2"; - modelTemplateFiles.put("model.mustache", ".ts"); - apiTemplateFiles.put("api.mustache", ".ts"); - typeMapping.put("Date","Date"); - apiPackage = "api"; - modelPackage = "model"; - } - - @Override - public String getName() { - return "typescript-angular2"; - } - - @Override - public String getHelp() { - return "Generates a TypeScript Angular2 client library."; - } - - @Override - public void processOpts() { - super.processOpts(); - supportingFiles.clear(); - supportingFiles.add(new SupportingFile("model.d.mustache", modelPackage().replace('.', File.separatorChar), "model.d.ts")); - } - - @Override - public String getTypeDeclaration(Property p) { - Property inner; - if(p instanceof ArrayProperty) { - ArrayProperty mp1 = (ArrayProperty)p; - inner = mp1.getItems(); - return this.getSwaggerType(p) + "<" + this.getTypeDeclaration(inner) + ">"; - } else if(p instanceof MapProperty) { - MapProperty mp = (MapProperty)p; - inner = mp.getAdditionalProperties(); - return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }"; - } else { - return p instanceof FileProperty ? "any" : super.getTypeDeclaration(p); - } - } - - @Override - public String getSwaggerType(Property p) { - String swaggerType = super.getSwaggerType(p); - return addModelPrefix(swaggerType); - } - - private String addModelPrefix(String swaggerType) { - String type = null; - if (typeMapping.containsKey(swaggerType)) { - type = typeMapping.get(swaggerType); - if (languageSpecificPrimitives.contains(type)) - return type; - } else - type = "model." + swaggerType; - return type; - } - - @Override - public void postProcessParameter(CodegenParameter parameter) { - super.postProcessParameter(parameter); - parameter.dataType = addModelPrefix(parameter.dataType); - } -} diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index 50d5357285db..0276b4b9c695 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -34,7 +34,7 @@ io.swagger.codegen.languages.SwaggerGenerator io.swagger.codegen.languages.SwaggerYamlGenerator io.swagger.codegen.languages.SwiftCodegen io.swagger.codegen.languages.TizenClientCodegen -io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen +io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen2 io.swagger.codegen.languages.TypeScriptAngularClientCodegen io.swagger.codegen.languages.TypeScriptNodeClientCodegen io.swagger.codegen.languages.AkkaScalaClientCodegen diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java index 4c56a7dfab2b..6831fac4134d 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java @@ -2,7 +2,7 @@ package io.swagger.codegen.typescriptangular2; import io.swagger.codegen.AbstractOptionsTest; import io.swagger.codegen.CodegenConfig; -import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen; +import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen2; import io.swagger.codegen.options.TypeScriptAngular2ClientOptionsProvider; import io.swagger.codegen.options.TypeScriptAngularClientOptionsProvider; import mockit.Expectations; @@ -11,7 +11,7 @@ import mockit.Tested; public class TypeScriptAngular2ClientOptionsTest extends AbstractOptionsTest { @Tested - private TypeScriptAngular2ClientCodegen clientCodegen; + private TypeScriptAngular2ClientCodegen2 clientCodegen; public TypeScriptAngular2ClientOptionsTest() { super(new TypeScriptAngular2ClientOptionsProvider()); diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java index 8f6968012020..33411d066f45 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java @@ -8,7 +8,7 @@ import org.testng.annotations.Test; import io.swagger.codegen.CodegenModel; import io.swagger.codegen.CodegenProperty; import io.swagger.codegen.DefaultCodegen; -import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen; +import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen2; import io.swagger.models.ArrayModel; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -30,7 +30,7 @@ public class TypeScriptAngular2ModelTest { .property("createdAt", new DateTimeProperty()) .required("id") .required("name"); - final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen2(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); @@ -76,7 +76,7 @@ public class TypeScriptAngular2ModelTest { .property("id", new LongProperty()) .property("urls", new ArrayProperty().items(new StringProperty())) .required("id"); - final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen2(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); @@ -109,7 +109,7 @@ public class TypeScriptAngular2ModelTest { final Model model = new ModelImpl() .description("a sample model") .property("children", new RefProperty("#/definitions/Children")); - final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen2(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); @@ -133,7 +133,7 @@ public class TypeScriptAngular2ModelTest { .description("a sample model") .property("children", new ArrayProperty() .items(new RefProperty("#/definitions/Children"))); - final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen2(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); @@ -156,7 +156,7 @@ public class TypeScriptAngular2ModelTest { final Model model = new ArrayModel() .description("an array model") .items(new RefProperty("#/definitions/Children")); - final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen2(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); @@ -170,7 +170,7 @@ public class TypeScriptAngular2ModelTest { final Model model = new ModelImpl() .description("a map model") .additionalProperties(new RefProperty("#/definitions/Children")); - final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen2(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); From c3dfa5dbaba17b66f934c23fe59b6dca22e0afbd Mon Sep 17 00:00:00 2001 From: Kristof Vrolijkx Date: Tue, 19 Apr 2016 13:00:38 +0200 Subject: [PATCH 07/26] #1809 resolve casing conflict part2 --- ...2.java => TypeScriptAngular2ClientCodegen.java} | 4 ++-- .../services/io.swagger.codegen.CodegenConfig | 2 +- .../TypeScriptAngular2ClientOptionsTest.java | 4 ++-- .../TypeScriptAngular2ModelTest.java | 14 +++++++------- 4 files changed, 12 insertions(+), 12 deletions(-) rename modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/{TypeScriptAngular2ClientCodegen2.java => TypeScriptAngular2ClientCodegen.java} (94%) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen2.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java similarity index 94% rename from modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen2.java rename to modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java index 522736cb4121..e23f4482dfa7 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen2.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java @@ -9,9 +9,9 @@ import io.swagger.models.properties.FileProperty; import io.swagger.models.properties.MapProperty; import io.swagger.models.properties.Property; -public class TypeScriptAngular2ClientCodegen2 extends AbstractTypeScriptClientCodegen { +public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCodegen { - public TypeScriptAngular2ClientCodegen2() { + public TypeScriptAngular2ClientCodegen() { super(); this.outputFolder = "generated-code/typescript-angular2"; diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index 0276b4b9c695..50d5357285db 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -34,7 +34,7 @@ io.swagger.codegen.languages.SwaggerGenerator io.swagger.codegen.languages.SwaggerYamlGenerator io.swagger.codegen.languages.SwiftCodegen io.swagger.codegen.languages.TizenClientCodegen -io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen2 +io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen io.swagger.codegen.languages.TypeScriptAngularClientCodegen io.swagger.codegen.languages.TypeScriptNodeClientCodegen io.swagger.codegen.languages.AkkaScalaClientCodegen diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java index 6831fac4134d..4c56a7dfab2b 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ClientOptionsTest.java @@ -2,7 +2,7 @@ package io.swagger.codegen.typescriptangular2; import io.swagger.codegen.AbstractOptionsTest; import io.swagger.codegen.CodegenConfig; -import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen2; +import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen; import io.swagger.codegen.options.TypeScriptAngular2ClientOptionsProvider; import io.swagger.codegen.options.TypeScriptAngularClientOptionsProvider; import mockit.Expectations; @@ -11,7 +11,7 @@ import mockit.Tested; public class TypeScriptAngular2ClientOptionsTest extends AbstractOptionsTest { @Tested - private TypeScriptAngular2ClientCodegen2 clientCodegen; + private TypeScriptAngular2ClientCodegen clientCodegen; public TypeScriptAngular2ClientOptionsTest() { super(new TypeScriptAngular2ClientOptionsProvider()); diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java index 33411d066f45..8f6968012020 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptangular2/TypeScriptAngular2ModelTest.java @@ -8,7 +8,7 @@ import org.testng.annotations.Test; import io.swagger.codegen.CodegenModel; import io.swagger.codegen.CodegenProperty; import io.swagger.codegen.DefaultCodegen; -import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen2; +import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen; import io.swagger.models.ArrayModel; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -30,7 +30,7 @@ public class TypeScriptAngular2ModelTest { .property("createdAt", new DateTimeProperty()) .required("id") .required("name"); - final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen2(); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); @@ -76,7 +76,7 @@ public class TypeScriptAngular2ModelTest { .property("id", new LongProperty()) .property("urls", new ArrayProperty().items(new StringProperty())) .required("id"); - final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen2(); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); @@ -109,7 +109,7 @@ public class TypeScriptAngular2ModelTest { final Model model = new ModelImpl() .description("a sample model") .property("children", new RefProperty("#/definitions/Children")); - final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen2(); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); @@ -133,7 +133,7 @@ public class TypeScriptAngular2ModelTest { .description("a sample model") .property("children", new ArrayProperty() .items(new RefProperty("#/definitions/Children"))); - final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen2(); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); @@ -156,7 +156,7 @@ public class TypeScriptAngular2ModelTest { final Model model = new ArrayModel() .description("an array model") .items(new RefProperty("#/definitions/Children")); - final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen2(); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); @@ -170,7 +170,7 @@ public class TypeScriptAngular2ModelTest { final Model model = new ModelImpl() .description("a map model") .additionalProperties(new RefProperty("#/definitions/Children")); - final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen2(); + final DefaultCodegen codegen = new TypeScriptAngular2ClientCodegen(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); From d2510b6593712fb0ca730bef202dc0be67c15a1f Mon Sep 17 00:00:00 2001 From: Kristof Vrolijkx Date: Tue, 19 Apr 2016 13:25:28 +0200 Subject: [PATCH 08/26] #1809 replacing JSOG with JSON which is provided by the browser. --- .../src/main/resources/typescript-angular2/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache index 34a9b14da1e4..b5625698a3d9 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache @@ -72,7 +72,7 @@ export class {{classname}} { search: queryParameters }; {{#bodyParam}} - requestOptions.body = JSOG.stringify({{paramName}}); + requestOptions.body = JSON.stringify({{paramName}}); {{/bodyParam}} {{#hasFormParams}} requestOptions.body = formParams.toString(); From a69757ad73ed15438d1c631439825f890336f44d Mon Sep 17 00:00:00 2001 From: Kristof Vrolijkx Date: Tue, 19 Apr 2016 14:13:16 +0200 Subject: [PATCH 09/26] #1809 adding samples with .sh and .bat scripts --- bin/typescript-angular2-petstore.sh | 31 +++ ...a-petstore.sh => async-scala-petstore.bat} | 0 bin/windows/typescript-angular2.bat | 10 + .../typescript-angular2/model.d.mustache | 2 +- .../typescript-angular2/model.mustache | 10 +- .../typescript-angular2/api/PetApi.ts | 236 ++++++++++++++++++ .../typescript-angular2/api/StoreApi.ts | 111 ++++++++ .../typescript-angular2/api/UserApi.ts | 209 ++++++++++++++++ .../typescript-angular2/model/Category.ts | 12 + .../typescript-angular2/model/Order.ts | 35 +++ .../petstore/typescript-angular2/model/Pet.ts | 35 +++ .../petstore/typescript-angular2/model/Tag.ts | 12 + .../typescript-angular2/model/User.ts | 33 +++ .../typescript-angular2/model/model.d.ts | 13 + 14 files changed, 744 insertions(+), 5 deletions(-) create mode 100755 bin/typescript-angular2-petstore.sh rename bin/windows/{async-scala-petstore.sh => async-scala-petstore.bat} (100%) create mode 100755 bin/windows/typescript-angular2.bat create mode 100644 samples/client/petstore/typescript-angular2/api/PetApi.ts create mode 100644 samples/client/petstore/typescript-angular2/api/StoreApi.ts create mode 100644 samples/client/petstore/typescript-angular2/api/UserApi.ts create mode 100644 samples/client/petstore/typescript-angular2/model/Category.ts create mode 100644 samples/client/petstore/typescript-angular2/model/Order.ts create mode 100644 samples/client/petstore/typescript-angular2/model/Pet.ts create mode 100644 samples/client/petstore/typescript-angular2/model/Tag.ts create mode 100644 samples/client/petstore/typescript-angular2/model/User.ts create mode 100644 samples/client/petstore/typescript-angular2/model/model.d.ts diff --git a/bin/typescript-angular2-petstore.sh b/bin/typescript-angular2-petstore.sh new file mode 100755 index 000000000000..4ad341f64f8f --- /dev/null +++ b/bin/typescript-angular2-petstore.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-angular2 -o samples/client/petstore/typescript-angular2" + +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/windows/async-scala-petstore.sh b/bin/windows/async-scala-petstore.bat similarity index 100% rename from bin/windows/async-scala-petstore.sh rename to bin/windows/async-scala-petstore.bat diff --git a/bin/windows/typescript-angular2.bat b/bin/windows/typescript-angular2.bat new file mode 100755 index 000000000000..7657d184fd15 --- /dev/null +++ b/bin/windows/typescript-angular2.bat @@ -0,0 +1,10 @@ +set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar + +If Not Exist %executable% ( + mvn clean package +) + +set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties +set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-angular -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l typescript-angular2 -o samples\client\petstore\typescript-angular + +java %JAVA_OPTS% -jar %executable% %ags% diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/model.d.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.d.mustache index e682f9bb2e7a..1da8b543fce2 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/model.d.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.d.mustache @@ -9,7 +9,7 @@ export * from './{{{ classname }}}'; {{#apiInfo}} {{#apis}} {{#operations}} -export * from './{{classname}}'; +export * from '../api/{{classname}}'; {{/operations}} {{/apis}} {{/apiInfo}} diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache index 5272576afd89..ff36a380e94f 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/model.mustache @@ -17,19 +17,21 @@ export interface {{classname}} {{#parent}}extends model.{{{parent}}} {{/parent}} */ {{/description}} - {{name}}?: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; + {{name}}?: {{#isEnum}}{{classname}}.{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; {{/vars}} } {{#hasEnums}} +export namespace {{classname}} { {{#vars}} {{#isEnum}} -export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} - {{.}} = '{{.}}',{{/values}}{{/allowableValues}} -} + export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} + {{.}} = '{{.}}',{{/values}}{{/allowableValues}} + } {{/isEnum}} {{/vars}} +} {{/hasEnums}} {{/model}} {{/models}} diff --git a/samples/client/petstore/typescript-angular2/api/PetApi.ts b/samples/client/petstore/typescript-angular2/api/PetApi.ts new file mode 100644 index 000000000000..dd949cfdbe1b --- /dev/null +++ b/samples/client/petstore/typescript-angular2/api/PetApi.ts @@ -0,0 +1,236 @@ +import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from 'angular2/http'; +import {Injectable} from 'angular2/core'; +import {Observable} from 'rxjs/Observable'; +import * as model from "../model/model.d.ts" + +/* tslint:disable:no-unused-variable member-ordering */ + +'use strict'; + +@Injectable() +export class PetApi { + protected basePath = 'http://petstore.swagger.io/v2'; + public defaultHeaders : Headers = new Headers(); + + constructor(protected http: Http, basePath: string) { + if (basePath) { + this.basePath = basePath; + } + } + + /** + * Add a new pet to the store + * + * @param body Pet object that needs to be added to the store + */ + public addPet (body?: model.Pet, extraHttpRequestParams?: any ) : Observable<{}> { + const path = this.basePath + '/pet'; + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + let requestOptions: RequestOptionsArgs = { + method: 'POST', + headers: headerParams, + search: queryParameters + }; + requestOptions.body = JSON.stringify(body); + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet (petId: number, apiKey?: string, extraHttpRequestParams?: any ) : Observable<{}> { + const path = this.basePath + '/pet/{petId}' + .replace('{' + 'petId' + '}', String(petId)); + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + // verify required parameter 'petId' is set + if (!petId) { + throw new Error('Missing required parameter petId when calling deletePet'); + } + headerParams.set('api_key', apiKey); + + let requestOptions: RequestOptionsArgs = { + method: 'DELETE', + headers: headerParams, + search: queryParameters + }; + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma seperated strings + * @param status Status values that need to be considered for filter + */ + public findPetsByStatus (status?: model.Array, extraHttpRequestParams?: any ) : Observable> { + const path = this.basePath + '/pet/findByStatus'; + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + if (status !== undefined) { + queryParameters['status'] = status; + } + + let requestOptions: RequestOptionsArgs = { + method: 'GET', + headers: headerParams, + search: queryParameters + }; + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Finds Pets by tags + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by + */ + public findPetsByTags (tags?: model.Array, extraHttpRequestParams?: any ) : Observable> { + const path = this.basePath + '/pet/findByTags'; + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + if (tags !== undefined) { + queryParameters['tags'] = tags; + } + + let requestOptions: RequestOptionsArgs = { + method: 'GET', + headers: headerParams, + search: queryParameters + }; + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Find pet by ID + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + */ + public getPetById (petId: number, extraHttpRequestParams?: any ) : Observable { + const path = this.basePath + '/pet/{petId}' + .replace('{' + 'petId' + '}', String(petId)); + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + // verify required parameter 'petId' is set + if (!petId) { + throw new Error('Missing required parameter petId when calling getPetById'); + } + let requestOptions: RequestOptionsArgs = { + method: 'GET', + headers: headerParams, + search: queryParameters + }; + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + */ + public updatePet (body?: model.Pet, extraHttpRequestParams?: any ) : Observable<{}> { + const path = this.basePath + '/pet'; + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + let requestOptions: RequestOptionsArgs = { + method: 'PUT', + headers: headerParams, + search: queryParameters + }; + requestOptions.body = JSON.stringify(body); + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + */ + public updatePetWithForm (petId: string, name?: string, status?: string, extraHttpRequestParams?: any ) : Observable<{}> { + const path = this.basePath + '/pet/{petId}' + .replace('{' + 'petId' + '}', String(petId)); + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + let formParams = new URLSearchParams(); + + // verify required parameter 'petId' is set + if (!petId) { + throw new Error('Missing required parameter petId when calling updatePetWithForm'); + } + headerParams.set('Content-Type', 'application/x-www-form-urlencoded'); + + formParams['name'] = name; + + formParams['status'] = status; + + let requestOptions: RequestOptionsArgs = { + method: 'POST', + headers: headerParams, + search: queryParameters + }; + requestOptions.body = formParams.toString(); + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * uploads an image + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile (petId: number, additionalMetadata?: string, file?: model.any, extraHttpRequestParams?: any ) : Observable<{}> { + const path = this.basePath + '/pet/{petId}/uploadImage' + .replace('{' + 'petId' + '}', String(petId)); + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + let formParams = new URLSearchParams(); + + // verify required parameter 'petId' is set + if (!petId) { + throw new Error('Missing required parameter petId when calling uploadFile'); + } + headerParams.set('Content-Type', 'application/x-www-form-urlencoded'); + + formParams['additionalMetadata'] = additionalMetadata; + + formParams['file'] = file; + + let requestOptions: RequestOptionsArgs = { + method: 'POST', + headers: headerParams, + search: queryParameters + }; + requestOptions.body = formParams.toString(); + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + +} diff --git a/samples/client/petstore/typescript-angular2/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/api/StoreApi.ts new file mode 100644 index 000000000000..01b5469985db --- /dev/null +++ b/samples/client/petstore/typescript-angular2/api/StoreApi.ts @@ -0,0 +1,111 @@ +import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from 'angular2/http'; +import {Injectable} from 'angular2/core'; +import {Observable} from 'rxjs/Observable'; +import * as model from "../model/model.d.ts" + +/* tslint:disable:no-unused-variable member-ordering */ + +'use strict'; + +@Injectable() +export class StoreApi { + protected basePath = 'http://petstore.swagger.io/v2'; + public defaultHeaders : Headers = new Headers(); + + constructor(protected http: Http, basePath: string) { + if (basePath) { + this.basePath = basePath; + } + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted + */ + public deleteOrder (orderId: string, extraHttpRequestParams?: any ) : Observable<{}> { + const path = this.basePath + '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', String(orderId)); + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + // verify required parameter 'orderId' is set + if (!orderId) { + throw new Error('Missing required parameter orderId when calling deleteOrder'); + } + let requestOptions: RequestOptionsArgs = { + method: 'DELETE', + headers: headerParams, + search: queryParameters + }; + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + */ + public getInventory (extraHttpRequestParams?: any ) : Observable<{ [key: string]: number; }> { + const path = this.basePath + '/store/inventory'; + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + let requestOptions: RequestOptionsArgs = { + method: 'GET', + headers: headerParams, + search: queryParameters + }; + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param orderId ID of pet that needs to be fetched + */ + public getOrderById (orderId: string, extraHttpRequestParams?: any ) : Observable { + const path = this.basePath + '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', String(orderId)); + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + // verify required parameter 'orderId' is set + if (!orderId) { + throw new Error('Missing required parameter orderId when calling getOrderById'); + } + let requestOptions: RequestOptionsArgs = { + method: 'GET', + headers: headerParams, + search: queryParameters + }; + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet + */ + public placeOrder (body?: model.Order, extraHttpRequestParams?: any ) : Observable { + const path = this.basePath + '/store/order'; + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + let requestOptions: RequestOptionsArgs = { + method: 'POST', + headers: headerParams, + search: queryParameters + }; + requestOptions.body = JSON.stringify(body); + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + +} diff --git a/samples/client/petstore/typescript-angular2/api/UserApi.ts b/samples/client/petstore/typescript-angular2/api/UserApi.ts new file mode 100644 index 000000000000..424c9d404be9 --- /dev/null +++ b/samples/client/petstore/typescript-angular2/api/UserApi.ts @@ -0,0 +1,209 @@ +import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from 'angular2/http'; +import {Injectable} from 'angular2/core'; +import {Observable} from 'rxjs/Observable'; +import * as model from "../model/model.d.ts" + +/* tslint:disable:no-unused-variable member-ordering */ + +'use strict'; + +@Injectable() +export class UserApi { + protected basePath = 'http://petstore.swagger.io/v2'; + public defaultHeaders : Headers = new Headers(); + + constructor(protected http: Http, basePath: string) { + if (basePath) { + this.basePath = basePath; + } + } + + /** + * Create user + * This can only be done by the logged in user. + * @param body Created user object + */ + public createUser (body?: model.User, extraHttpRequestParams?: any ) : Observable<{}> { + const path = this.basePath + '/user'; + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + let requestOptions: RequestOptionsArgs = { + method: 'POST', + headers: headerParams, + search: queryParameters + }; + requestOptions.body = JSON.stringify(body); + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithArrayInput (body?: model.Array, extraHttpRequestParams?: any ) : Observable<{}> { + const path = this.basePath + '/user/createWithArray'; + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + let requestOptions: RequestOptionsArgs = { + method: 'POST', + headers: headerParams, + search: queryParameters + }; + requestOptions.body = JSON.stringify(body); + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithListInput (body?: model.Array, extraHttpRequestParams?: any ) : Observable<{}> { + const path = this.basePath + '/user/createWithList'; + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + let requestOptions: RequestOptionsArgs = { + method: 'POST', + headers: headerParams, + search: queryParameters + }; + requestOptions.body = JSON.stringify(body); + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + */ + public deleteUser (username: string, extraHttpRequestParams?: any ) : Observable<{}> { + const path = this.basePath + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + // verify required parameter 'username' is set + if (!username) { + throw new Error('Missing required parameter username when calling deleteUser'); + } + let requestOptions: RequestOptionsArgs = { + method: 'DELETE', + headers: headerParams, + search: queryParameters + }; + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName (username: string, extraHttpRequestParams?: any ) : Observable { + const path = this.basePath + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + // verify required parameter 'username' is set + if (!username) { + throw new Error('Missing required parameter username when calling getUserByName'); + } + let requestOptions: RequestOptionsArgs = { + method: 'GET', + headers: headerParams, + search: queryParameters + }; + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser (username?: string, password?: string, extraHttpRequestParams?: any ) : Observable { + const path = this.basePath + '/user/login'; + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + if (username !== undefined) { + queryParameters['username'] = username; + } + + if (password !== undefined) { + queryParameters['password'] = password; + } + + let requestOptions: RequestOptionsArgs = { + method: 'GET', + headers: headerParams, + search: queryParameters + }; + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Logs out current logged in user session + * + */ + public logoutUser (extraHttpRequestParams?: any ) : Observable<{}> { + const path = this.basePath + '/user/logout'; + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + let requestOptions: RequestOptionsArgs = { + method: 'GET', + headers: headerParams, + search: queryParameters + }; + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted + * @param body Updated user object + */ + public updateUser (username: string, body?: model.User, extraHttpRequestParams?: any ) : Observable<{}> { + const path = this.basePath + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + + let queryParameters: any = ""; // This should probably be an object in the future + let headerParams = this.defaultHeaders; + // verify required parameter 'username' is set + if (!username) { + throw new Error('Missing required parameter username when calling updateUser'); + } + let requestOptions: RequestOptionsArgs = { + method: 'PUT', + headers: headerParams, + search: queryParameters + }; + requestOptions.body = JSON.stringify(body); + + return this.http.request(path, requestOptions) + .map(response => response.json()); + } + +} diff --git a/samples/client/petstore/typescript-angular2/model/Category.ts b/samples/client/petstore/typescript-angular2/model/Category.ts new file mode 100644 index 000000000000..d68c9c746a1d --- /dev/null +++ b/samples/client/petstore/typescript-angular2/model/Category.ts @@ -0,0 +1,12 @@ +'use strict'; +import * as model from "./model.d.ts" + +export interface Category { + + + id?: number; + + + name?: string; +} + diff --git a/samples/client/petstore/typescript-angular2/model/Order.ts b/samples/client/petstore/typescript-angular2/model/Order.ts new file mode 100644 index 000000000000..70fbf0c71179 --- /dev/null +++ b/samples/client/petstore/typescript-angular2/model/Order.ts @@ -0,0 +1,35 @@ +'use strict'; +import * as model from "./model.d.ts" + +export interface Order { + + + id?: number; + + + petId?: number; + + + quantity?: number; + + + shipDate?: Date; + + /** + * Order Status + */ + + status?: Order.StatusEnum; + + + complete?: boolean; +} + +export namespace Order { + + export enum StatusEnum { + placed = 'placed', + approved = 'approved', + delivered = 'delivered', + } +} diff --git a/samples/client/petstore/typescript-angular2/model/Pet.ts b/samples/client/petstore/typescript-angular2/model/Pet.ts new file mode 100644 index 000000000000..bcf39e551d3f --- /dev/null +++ b/samples/client/petstore/typescript-angular2/model/Pet.ts @@ -0,0 +1,35 @@ +'use strict'; +import * as model from "./model.d.ts" + +export interface Pet { + + + id?: number; + + + category?: model.Category; + + + name?: string; + + + photoUrls?: Array; + + + tags?: Array; + + /** + * pet status in the store + */ + + status?: Pet.StatusEnum; +} + +export namespace Pet { + + export enum StatusEnum { + available = 'available', + pending = 'pending', + sold = 'sold', + } +} diff --git a/samples/client/petstore/typescript-angular2/model/Tag.ts b/samples/client/petstore/typescript-angular2/model/Tag.ts new file mode 100644 index 000000000000..3e708ce1eda9 --- /dev/null +++ b/samples/client/petstore/typescript-angular2/model/Tag.ts @@ -0,0 +1,12 @@ +'use strict'; +import * as model from "./model.d.ts" + +export interface Tag { + + + id?: number; + + + name?: string; +} + diff --git a/samples/client/petstore/typescript-angular2/model/User.ts b/samples/client/petstore/typescript-angular2/model/User.ts new file mode 100644 index 000000000000..a5513a6ee6f6 --- /dev/null +++ b/samples/client/petstore/typescript-angular2/model/User.ts @@ -0,0 +1,33 @@ +'use strict'; +import * as model from "./model.d.ts" + +export interface User { + + + id?: number; + + + username?: string; + + + firstName?: string; + + + lastName?: string; + + + email?: string; + + + password?: string; + + + phone?: string; + + /** + * User Status + */ + + userStatus?: number; +} + diff --git a/samples/client/petstore/typescript-angular2/model/model.d.ts b/samples/client/petstore/typescript-angular2/model/model.d.ts new file mode 100644 index 000000000000..cbdd34f8917f --- /dev/null +++ b/samples/client/petstore/typescript-angular2/model/model.d.ts @@ -0,0 +1,13 @@ +export * from './Category'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; + + + +export * from '../api/PetApi'; +export * from '../api/StoreApi'; +export * from '../api/UserApi'; + + From dcad308f533bf70689e8651c9bdccfc809b094e8 Mon Sep 17 00:00:00 2001 From: Kristof Vrolijkx Date: Tue, 19 Apr 2016 14:16:38 +0200 Subject: [PATCH 10/26] #1809 added typescript-angular2-petstore.sh to all all-petstore.sh --- bin/all-petstore.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/all-petstore.sh b/bin/all-petstore.sh index f1e8ae4b1161..cb7eb4ffc96c 100755 --- a/bin/all-petstore.sh +++ b/bin/all-petstore.sh @@ -48,4 +48,5 @@ cd $APP_DIR ./bin/swift-petstore.sh ./bin/tizen-petstore.sh ./bin/typescript-angular-petstore.sh +./bin/typescript-angular2-petstore.sh ./bin/typescript-node-petstore.sh From ccc52c255491acc099f82fca8eb1158c16b40c8e Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 19 Apr 2016 23:41:26 +0800 Subject: [PATCH 11/26] update gem spec --- .../src/main/resources/ruby/gemspec.mustache | 11 +- samples/client/petstore/ruby/Gemfile.lock | 12 +- samples/client/petstore/ruby/README.md | 4 +- samples/client/petstore/ruby/docs/PetApi.md | 253 +++--------------- samples/client/petstore/ruby/docs/StoreApi.md | 161 +---------- samples/client/petstore/ruby/petstore.gemspec | 11 +- 6 files changed, 70 insertions(+), 382 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache b/modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache index 7ab8a9e73d7a..f26fb70bc44a 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache @@ -13,13 +13,12 @@ Gem::Specification.new do |s| s.description = "{{gemDescription}}" s.license = "{{gemLicense}}" + s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' + s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3' - s.add_runtime_dependency 'typhoeus', '~> 0.2', '>= 0.2.1' - s.add_runtime_dependency 'json', '~> 1.4', '>= 1.4.6' - - s.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0' - s.add_development_dependency 'vcr', '~> 2.9', '>= 2.9.3' - s.add_development_dependency 'webmock', '~> 1.6', '>= 1.6.2' + s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0' + s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1' + s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3' s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6' s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2' s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16' diff --git a/samples/client/petstore/ruby/Gemfile.lock b/samples/client/petstore/ruby/Gemfile.lock index e7812e458459..98c02ee91636 100644 --- a/samples/client/petstore/ruby/Gemfile.lock +++ b/samples/client/petstore/ruby/Gemfile.lock @@ -2,8 +2,8 @@ PATH remote: . specs: petstore (1.0.0) - json (~> 1.4, >= 1.4.6) - typhoeus (~> 0.2, >= 0.2.1) + json (~> 1.8, >= 1.8.3) + typhoeus (~> 1.0, >= 1.0.1) GEM remote: http://rubygems.org/ @@ -19,10 +19,10 @@ GEM crack (0.4.2) safe_yaml (~> 1.0.0) diff-lcs (1.2.5) - ethon (0.7.3) + ethon (0.8.1) ffi (>= 1.3.0) ffi (1.9.8) - json (1.8.2) + json (1.8.3) rspec (3.2.0) rspec-core (~> 3.2.0) rspec-expectations (~> 3.2.0) @@ -39,8 +39,8 @@ GEM safe_yaml (1.0.4) sys-uname (0.9.2) ffi (>= 1.0.0) - typhoeus (0.7.1) - ethon (>= 0.7.1) + typhoeus (1.0.1) + ethon (>= 0.8.0) vcr (2.9.3) webmock (1.21.0) addressable (>= 2.3.6) diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 90622ef668aa..d5fc3c8405b1 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-13T17:44:36.129+08:00 +- Build date: 2016-04-19T23:40:36.993+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -133,7 +133,7 @@ Class | Method | HTTP request | Description - **Type**: OAuth - **Flow**: implicit -- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog - **Scopes**: - write:pets: modify pets in your account - read:pets: read your pets diff --git a/samples/client/petstore/ruby/docs/PetApi.md b/samples/client/petstore/ruby/docs/PetApi.md index 36ca634b7392..d485993c6ed3 100644 --- a/samples/client/petstore/ruby/docs/PetApi.md +++ b/samples/client/petstore/ruby/docs/PetApi.md @@ -5,20 +5,17 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- [**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store -[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store [**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet [**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status [**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags [**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID -[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' [**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet [**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data [**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image # **add_pet** -> add_pet(opts) +> add_pet(body) Add a new pet to the store @@ -36,13 +33,12 @@ end api_instance = Petstore::PetApi.new -opts = { - body: Petstore::Pet.new # Pet | Pet object that needs to be added to the store -} +body = Petstore::Pet.new # Pet | Pet object that needs to be added to the store + begin #Add a new pet to the store - api_instance.add_pet(opts) + api_instance.add_pet(body) rescue Petstore::ApiError => e puts "Exception when calling PetApi->add_pet: #{e}" end @@ -52,7 +48,7 @@ end Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -65,59 +61,7 @@ nil (empty response body) ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml - - - -# **add_pet_using_byte_array** -> add_pet_using_byte_array(opts) - -Fake endpoint to test byte array in body parameter for adding a new pet to the store - - - -### Example -```ruby -# load the gem -require 'petstore' -# setup authorization -Petstore.configure do |config| - # Configure OAuth2 access token for authorization: petstore_auth - config.access_token = 'YOUR ACCESS TOKEN' -end - -api_instance = Petstore::PetApi.new - -opts = { - body: "B" # String | Pet object in the form of byte array -} - -begin - #Fake endpoint to test byte array in body parameter for adding a new pet to the store - api_instance.add_pet_using_byte_array(opts) -rescue Petstore::ApiError => e - puts "Exception when calling PetApi->add_pet_using_byte_array: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | **String**| Pet object in the form of byte array | [optional] - -### Return type - -nil (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json @@ -172,12 +116,12 @@ nil (empty response body) ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **find_pets_by_status** -> Array<Pet> find_pets_by_status(opts) +> Array<Pet> find_pets_by_status(status) Finds Pets by status @@ -195,13 +139,12 @@ end api_instance = Petstore::PetApi.new -opts = { - status: ["available"] # Array | Status values that need to be considered for query -} +status = ["status_example"] # Array | Status values that need to be considered for filter + begin #Finds Pets by status - result = api_instance.find_pets_by_status(opts) + result = api_instance.find_pets_by_status(status) p result rescue Petstore::ApiError => e puts "Exception when calling PetApi->find_pets_by_status: #{e}" @@ -212,7 +155,7 @@ end Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **status** | [**Array<String>**](String.md)| Status values that need to be considered for query | [optional] [default to available] + **status** | [**Array<String>**](String.md)| Status values that need to be considered for filter | ### Return type @@ -225,16 +168,16 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **find_pets_by_tags** -> Array<Pet> find_pets_by_tags(opts) +> Array<Pet> find_pets_by_tags(tags) Finds Pets by tags -Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. ### Example ```ruby @@ -248,13 +191,12 @@ end api_instance = Petstore::PetApi.new -opts = { - tags: ["tags_example"] # Array | Tags to filter by -} +tags = ["tags_example"] # Array | Tags to filter by + begin #Finds Pets by tags - result = api_instance.find_pets_by_tags(opts) + result = api_instance.find_pets_by_tags(tags) p result rescue Petstore::ApiError => e puts "Exception when calling PetApi->find_pets_by_tags: #{e}" @@ -265,7 +207,7 @@ end Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **tags** | [**Array<String>**](String.md)| Tags to filter by | [optional] + **tags** | [**Array<String>**](String.md)| Tags to filter by | ### Return type @@ -278,7 +220,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json @@ -287,7 +229,7 @@ Name | Type | Description | Notes Find pet by ID -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions +Returns a single pet ### Example ```ruby @@ -299,14 +241,11 @@ Petstore.configure do |config| config.api_key['api_key'] = 'YOUR API KEY' # Uncomment the following line to set a prefix for the API key, e.g. 'BEARER' (defaults to nil) #config.api_key_prefix['api_key'] = 'BEARER' - - # Configure OAuth2 access token for authorization: petstore_auth - config.access_token = 'YOUR ACCESS TOKEN' end api_instance = Petstore::PetApi.new -pet_id = 789 # Integer | ID of pet that needs to be fetched +pet_id = 789 # Integer | ID of pet to return begin @@ -322,7 +261,7 @@ end Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet_id** | **Integer**| ID of pet that needs to be fetched | + **pet_id** | **Integer**| ID of pet to return | ### Return type @@ -330,131 +269,17 @@ Name | Type | Description | Notes ### Authorization -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) +[api_key](../README.md#api_key) ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **get_pet_by_id_in_object** -> InlineResponse200 get_pet_by_id_in_object(pet_id) - -Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - -### Example -```ruby -# load the gem -require 'petstore' -# setup authorization -Petstore.configure do |config| - # Configure API key authorization: api_key - config.api_key['api_key'] = 'YOUR API KEY' - # Uncomment the following line to set a prefix for the API key, e.g. 'BEARER' (defaults to nil) - #config.api_key_prefix['api_key'] = 'BEARER' - - # Configure OAuth2 access token for authorization: petstore_auth - config.access_token = 'YOUR ACCESS TOKEN' -end - -api_instance = Petstore::PetApi.new - -pet_id = 789 # Integer | ID of pet that needs to be fetched - - -begin - #Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - result = api_instance.get_pet_by_id_in_object(pet_id) - p result -rescue Petstore::ApiError => e - puts "Exception when calling PetApi->get_pet_by_id_in_object: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **Integer**| ID of pet that needs to be fetched | - -### Return type - -[**InlineResponse200**](InlineResponse200.md) - -### Authorization - -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **pet_pet_idtesting_byte_arraytrue_get** -> String pet_pet_idtesting_byte_arraytrue_get(pet_id) - -Fake endpoint to test byte array return by 'Find pet by ID' - -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - -### Example -```ruby -# load the gem -require 'petstore' -# setup authorization -Petstore.configure do |config| - # Configure API key authorization: api_key - config.api_key['api_key'] = 'YOUR API KEY' - # Uncomment the following line to set a prefix for the API key, e.g. 'BEARER' (defaults to nil) - #config.api_key_prefix['api_key'] = 'BEARER' - - # Configure OAuth2 access token for authorization: petstore_auth - config.access_token = 'YOUR ACCESS TOKEN' -end - -api_instance = Petstore::PetApi.new - -pet_id = 789 # Integer | ID of pet that needs to be fetched - - -begin - #Fake endpoint to test byte array return by 'Find pet by ID' - result = api_instance.pet_pet_idtesting_byte_arraytrue_get(pet_id) - p result -rescue Petstore::ApiError => e - puts "Exception when calling PetApi->pet_pet_idtesting_byte_arraytrue_get: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **Integer**| ID of pet that needs to be fetched | - -### Return type - -**String** - -### Authorization - -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **update_pet** -> update_pet(opts) +> update_pet(body) Update an existing pet @@ -472,13 +297,12 @@ end api_instance = Petstore::PetApi.new -opts = { - body: Petstore::Pet.new # Pet | Pet object that needs to be added to the store -} +body = Petstore::Pet.new # Pet | Pet object that needs to be added to the store + begin #Update an existing pet - api_instance.update_pet(opts) + api_instance.update_pet(body) rescue Petstore::ApiError => e puts "Exception when calling PetApi->update_pet: #{e}" end @@ -488,7 +312,7 @@ end Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -501,7 +325,7 @@ nil (empty response body) ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json @@ -524,7 +348,7 @@ end api_instance = Petstore::PetApi.new -pet_id = "pet_id_example" # String | ID of pet that needs to be updated +pet_id = 789 # Integer | ID of pet that needs to be updated opts = { name: "name_example", # String | Updated name of the pet @@ -543,7 +367,7 @@ end Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet_id** | **String**| ID of pet that needs to be updated | + **pet_id** | **Integer**| ID of pet that needs to be updated | **name** | **String**| Updated name of the pet | [optional] **status** | **String**| Updated status of the pet | [optional] @@ -558,12 +382,12 @@ nil (empty response body) ### HTTP request headers - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **upload_file** -> upload_file(pet_id, opts) +> ApiResponse upload_file(pet_id, opts) uploads an image @@ -590,7 +414,8 @@ opts = { begin #uploads an image - api_instance.upload_file(pet_id, opts) + result = api_instance.upload_file(pet_id, opts) + p result rescue Petstore::ApiError => e puts "Exception when calling PetApi->upload_file: #{e}" end @@ -606,7 +431,7 @@ Name | Type | Description | Notes ### Return type -nil (empty response body) +[**ApiResponse**](ApiResponse.md) ### Authorization @@ -615,7 +440,7 @@ nil (empty response body) ### HTTP request headers - **Content-Type**: multipart/form-data - - **Accept**: application/json, application/xml + - **Accept**: application/json diff --git a/samples/client/petstore/ruby/docs/StoreApi.md b/samples/client/petstore/ruby/docs/StoreApi.md index 9165f119ba58..8c607b9d7c9b 100644 --- a/samples/client/petstore/ruby/docs/StoreApi.md +++ b/samples/client/petstore/ruby/docs/StoreApi.md @@ -5,9 +5,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- [**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -[**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status [**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status -[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' [**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID [**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet @@ -54,67 +52,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **find_orders_by_status** -> Array<Order> find_orders_by_status(opts) - -Finds orders by status - -A single status value can be provided as a string - -### Example -```ruby -# load the gem -require 'petstore' -# setup authorization -Petstore.configure do |config| - # Configure API key authorization: test_api_client_id - config.api_key['x-test_api_client_id'] = 'YOUR API KEY' - # Uncomment the following line to set a prefix for the API key, e.g. 'BEARER' (defaults to nil) - #config.api_key_prefix['x-test_api_client_id'] = 'BEARER' - - # Configure API key authorization: test_api_client_secret - config.api_key['x-test_api_client_secret'] = 'YOUR API KEY' - # Uncomment the following line to set a prefix for the API key, e.g. 'BEARER' (defaults to nil) - #config.api_key_prefix['x-test_api_client_secret'] = 'BEARER' -end - -api_instance = Petstore::StoreApi.new - -opts = { - status: "placed" # String | Status value that needs to be considered for query -} - -begin - #Finds orders by status - result = api_instance.find_orders_by_status(opts) - p result -rescue Petstore::ApiError => e - puts "Exception when calling StoreApi->find_orders_by_status: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **status** | **String**| Status value that needs to be considered for query | [optional] [default to placed] - -### Return type - -[**Array<Order>**](Order.md) - -### Authorization - -[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json @@ -162,55 +100,7 @@ This endpoint does not need any parameter. ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - - - -# **get_inventory_in_object** -> Object get_inventory_in_object - -Fake endpoint to test arbitrary object return by 'Get inventory' - -Returns an arbitrary object which is actually a map of status codes to quantities - -### Example -```ruby -# load the gem -require 'petstore' -# setup authorization -Petstore.configure do |config| - # Configure API key authorization: api_key - config.api_key['api_key'] = 'YOUR API KEY' - # Uncomment the following line to set a prefix for the API key, e.g. 'BEARER' (defaults to nil) - #config.api_key_prefix['api_key'] = 'BEARER' -end - -api_instance = Petstore::StoreApi.new - -begin - #Fake endpoint to test arbitrary object return by 'Get inventory' - result = api_instance.get_inventory_in_object - p result -rescue Petstore::ApiError => e - puts "Exception when calling StoreApi->get_inventory_in_object: #{e}" -end -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -**Object** - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/json @@ -225,22 +115,10 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge ```ruby # load the gem require 'petstore' -# setup authorization -Petstore.configure do |config| - # Configure API key authorization: test_api_key_header - config.api_key['test_api_key_header'] = 'YOUR API KEY' - # Uncomment the following line to set a prefix for the API key, e.g. 'BEARER' (defaults to nil) - #config.api_key_prefix['test_api_key_header'] = 'BEARER' - - # Configure API key authorization: test_api_key_query - config.api_key['test_api_key_query'] = 'YOUR API KEY' - # Uncomment the following line to set a prefix for the API key, e.g. 'BEARER' (defaults to nil) - #config.api_key_prefix['test_api_key_query'] = 'BEARER' -end api_instance = Petstore::StoreApi.new -order_id = "order_id_example" # String | ID of pet that needs to be fetched +order_id = 789 # Integer | ID of pet that needs to be fetched begin @@ -256,7 +134,7 @@ end Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order_id** | **String**| ID of pet that needs to be fetched | + **order_id** | **Integer**| ID of pet that needs to be fetched | ### Return type @@ -264,17 +142,17 @@ Name | Type | Description | Notes ### Authorization -[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query) +No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json # **place_order** -> Order place_order(opts) +> Order place_order(body) Place an order for a pet @@ -284,28 +162,15 @@ Place an order for a pet ```ruby # load the gem require 'petstore' -# setup authorization -Petstore.configure do |config| - # Configure API key authorization: test_api_client_id - config.api_key['x-test_api_client_id'] = 'YOUR API KEY' - # Uncomment the following line to set a prefix for the API key, e.g. 'BEARER' (defaults to nil) - #config.api_key_prefix['x-test_api_client_id'] = 'BEARER' - - # Configure API key authorization: test_api_client_secret - config.api_key['x-test_api_client_secret'] = 'YOUR API KEY' - # Uncomment the following line to set a prefix for the API key, e.g. 'BEARER' (defaults to nil) - #config.api_key_prefix['x-test_api_client_secret'] = 'BEARER' -end api_instance = Petstore::StoreApi.new -opts = { - body: Petstore::Order.new # Order | order placed for purchasing the pet -} +body = Petstore::Order.new # Order | order placed for purchasing the pet + begin #Place an order for a pet - result = api_instance.place_order(opts) + result = api_instance.place_order(body) p result rescue Petstore::ApiError => e puts "Exception when calling StoreApi->place_order: #{e}" @@ -316,7 +181,7 @@ end Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional] + **body** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type @@ -324,12 +189,12 @@ Name | Type | Description | Notes ### Authorization -[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) +No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json diff --git a/samples/client/petstore/ruby/petstore.gemspec b/samples/client/petstore/ruby/petstore.gemspec index d9bb07c1902f..55ba462e2370 100644 --- a/samples/client/petstore/ruby/petstore.gemspec +++ b/samples/client/petstore/ruby/petstore.gemspec @@ -13,13 +13,12 @@ Gem::Specification.new do |s| s.description = "" s.license = "" + s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' + s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3' - s.add_runtime_dependency 'typhoeus', '~> 0.2', '>= 0.2.1' - s.add_runtime_dependency 'json', '~> 1.4', '>= 1.4.6' - - s.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0' - s.add_development_dependency 'vcr', '~> 2.9', '>= 2.9.3' - s.add_development_dependency 'webmock', '~> 1.6', '>= 1.6.2' + s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0' + s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1' + s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3' s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6' s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2' s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16' From 357cb70795b84efef94eb2217ddfabcd3219b2eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Tue, 19 Apr 2016 21:26:21 +0200 Subject: [PATCH 12/26] [PHP] Update PHP dependencies Updated minimum supported PHP version to 5.4. Updated development requirements to newest versions supporting PHP 5.4. --- .../src/main/resources/php/composer.mustache | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/php/composer.mustache b/modules/swagger-codegen/src/main/resources/php/composer.mustache index 64564e4ec57a..6ab42751a57c 100644 --- a/modules/swagger-codegen/src/main/resources/php/composer.mustache +++ b/modules/swagger-codegen/src/main/resources/php/composer.mustache @@ -17,15 +17,15 @@ } ], "require": { - "php": ">=5.3.3", + "php": ">=5.4", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*" }, "require-dev": { - "phpunit/phpunit": "~4.0", - "satooshi/php-coveralls": "~0.6.1", - "squizlabs/php_codesniffer": "~2.0" + "phpunit/phpunit": "~4.8", + "satooshi/php-coveralls": "~1.0", + "squizlabs/php_codesniffer": "~2.6" }, "autoload": { "psr-4": { "{{escapedInvokerPackage}}\\" : "{{srcBasePath}}/" } From ecfb71a0df94e95382800166be9ae68b78e2514f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Tue, 19 Apr 2016 21:32:11 +0200 Subject: [PATCH 13/26] [PHP] Regenerated petstore sample --- .../petstore/php/SwaggerClient-php/README.md | 14 +- .../php/SwaggerClient-php/composer.json | 8 +- .../php/SwaggerClient-php/docs/PetApi.md | 203 +++--------------- .../php/SwaggerClient-php/docs/StoreApi.md | 138 +----------- .../lib/ObjectSerializer.php | 2 +- 5 files changed, 45 insertions(+), 320 deletions(-) diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index d7a43368cac5..ac92e7daa212 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-12T20:01:35.068+08:00 +- Build date: 2016-04-19T21:31:44.449+02:00 - Build package: class io.swagger.codegen.languages.PhpClientCodegen ## Requirements @@ -122,12 +122,6 @@ Class | Method | HTTP request | Description ## Documentation For Authorization -## api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - ## petstore_auth - **Type**: OAuth @@ -137,6 +131,12 @@ Class | Method | HTTP request | Description - **write:pets**: modify pets in your account - **read:pets**: read your pets +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + ## Author diff --git a/samples/client/petstore/php/SwaggerClient-php/composer.json b/samples/client/petstore/php/SwaggerClient-php/composer.json index 3889aee8a363..2c63b2c8ba06 100644 --- a/samples/client/petstore/php/SwaggerClient-php/composer.json +++ b/samples/client/petstore/php/SwaggerClient-php/composer.json @@ -17,15 +17,15 @@ } ], "require": { - "php": ">=5.3.3", + "php": ">=5.4", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*" }, "require-dev": { - "phpunit/phpunit": "~4.0", - "satooshi/php-coveralls": "~0.6.1", - "squizlabs/php_codesniffer": "~2.0" + "phpunit/phpunit": "~4.8", + "satooshi/php-coveralls": "~1.0", + "squizlabs/php_codesniffer": "~2.6" }, "autoload": { "psr-4": { "Swagger\\Client\\" : "lib/" } diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md index ad4d3c804ef8..a2a06445c738 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md @@ -5,13 +5,10 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- [**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store -[**addPetUsingByteArray**](PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store [**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet [**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status [**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags [**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID -[**getPetByIdInObject**](PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -[**petPetIdtestingByteArraytrueGet**](PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image @@ -47,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**\Swagger\Client\Model\Pet**](\Swagger\Client\Model\Pet.md)| Pet object that needs to be added to the store | [optional] + **body** | [**\Swagger\Client\Model\Pet**](\Swagger\Client\Model\Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -60,54 +57,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **addPetUsingByteArray** -> addPetUsingByteArray($body) - -Fake endpoint to test byte array in body parameter for adding a new pet to the store - - - -### Example -```php -setAccessToken('YOUR_ACCESS_TOKEN'); - -$api_instance = new Swagger\Client\Api\PetApi(); -$body = "B"; // string | Pet object in the form of byte array - -try { - $api_instance->addPetUsingByteArray($body); -} catch (Exception $e) { - echo 'Exception when calling PetApi->addPetUsingByteArray: ', $e->getMessage(), "\n"; -} -?> -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | **string**| Pet object in the form of byte array | [optional] - -### Return type - -void (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -156,7 +106,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -176,7 +126,7 @@ require_once(__DIR__ . '/vendor/autoload.php'); Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\Api\PetApi(); -$status = array("available"); // string[] | Status values that need to be considered for query +$status = array("status_example"); // string[] | Status values that need to be considered for filter try { $result = $api_instance->findPetsByStatus($status); @@ -191,7 +141,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **status** | [**string[]**](string.md)| Status values that need to be considered for query | [optional] [default to available] + **status** | [**string[]**](string.md)| Status values that need to be considered for filter | ### Return type @@ -204,7 +154,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -213,7 +163,7 @@ Name | Type | Description | Notes Finds Pets by tags -Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. ### Example ```php @@ -239,7 +189,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **tags** | [**string[]**](string.md)| Tags to filter by | [optional] + **tags** | [**string[]**](string.md)| Tags to filter by | ### Return type @@ -252,7 +202,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -261,7 +211,7 @@ Name | Type | Description | Notes Find pet by ID -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions +Returns a single pet ### Example ```php @@ -272,11 +222,9 @@ require_once(__DIR__ . '/vendor/autoload.php'); Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); -// Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\Api\PetApi(); -$pet_id = 789; // int | ID of pet that needs to be fetched +$pet_id = 789; // int | ID of pet to return try { $result = $api_instance->getPetById($pet_id); @@ -291,7 +239,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet_id** | **int**| ID of pet that needs to be fetched | + **pet_id** | **int**| ID of pet to return | ### Return type @@ -299,116 +247,12 @@ Name | Type | Description | Notes ### Authorization -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) +[api_key](../README.md#api_key) ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **getPetByIdInObject** -> \Swagger\Client\Model\InlineResponse200 getPetByIdInObject($pet_id) - -Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - -### Example -```php -setApiKey('api_key', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); -// Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); - -$api_instance = new Swagger\Client\Api\PetApi(); -$pet_id = 789; // int | ID of pet that needs to be fetched - -try { - $result = $api_instance->getPetByIdInObject($pet_id); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling PetApi->getPetByIdInObject: ', $e->getMessage(), "\n"; -} -?> -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **int**| ID of pet that needs to be fetched | - -### Return type - -[**\Swagger\Client\Model\InlineResponse200**](InlineResponse200.md) - -### Authorization - -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **petPetIdtestingByteArraytrueGet** -> string petPetIdtestingByteArraytrueGet($pet_id) - -Fake endpoint to test byte array return by 'Find pet by ID' - -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - -### Example -```php -setApiKey('api_key', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); -// Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); - -$api_instance = new Swagger\Client\Api\PetApi(); -$pet_id = 789; // int | ID of pet that needs to be fetched - -try { - $result = $api_instance->petPetIdtestingByteArraytrueGet($pet_id); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling PetApi->petPetIdtestingByteArraytrueGet: ', $e->getMessage(), "\n"; -} -?> -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **int**| ID of pet that needs to be fetched | - -### Return type - -**string** - -### Authorization - -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -442,7 +286,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**\Swagger\Client\Model\Pet**](\Swagger\Client\Model\Pet.md)| Pet object that needs to be added to the store | [optional] + **body** | [**\Swagger\Client\Model\Pet**](\Swagger\Client\Model\Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -455,7 +299,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -475,7 +319,7 @@ require_once(__DIR__ . '/vendor/autoload.php'); Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $api_instance = new Swagger\Client\Api\PetApi(); -$pet_id = "pet_id_example"; // string | ID of pet that needs to be updated +$pet_id = 789; // int | ID of pet that needs to be updated $name = "name_example"; // string | Updated name of the pet $status = "status_example"; // string | Updated status of the pet @@ -491,7 +335,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet_id** | **string**| ID of pet that needs to be updated | + **pet_id** | **int**| ID of pet that needs to be updated | **name** | **string**| Updated name of the pet | [optional] **status** | **string**| Updated status of the pet | [optional] @@ -506,12 +350,12 @@ void (empty response body) ### HTTP request headers - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **uploadFile** -> uploadFile($pet_id, $additional_metadata, $file) +> \Swagger\Client\Model\ApiResponse uploadFile($pet_id, $additional_metadata, $file) uploads an image @@ -531,7 +375,8 @@ $additional_metadata = "additional_metadata_example"; // string | Additional dat $file = "/path/to/file.txt"; // \SplFileObject | file to upload try { - $api_instance->uploadFile($pet_id, $additional_metadata, $file); + $result = $api_instance->uploadFile($pet_id, $additional_metadata, $file); + print_r($result); } catch (Exception $e) { echo 'Exception when calling PetApi->uploadFile: ', $e->getMessage(), "\n"; } @@ -548,7 +393,7 @@ Name | Type | Description | Notes ### Return type -void (empty response body) +[**\Swagger\Client\Model\ApiResponse**](ApiResponse.md) ### Authorization @@ -557,7 +402,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: multipart/form-data - - **Accept**: application/json, application/xml + - **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md index 0ba6fa092de7..8198bf3dbf4f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md @@ -5,9 +5,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -[**findOrdersByStatus**](StoreApi.md#findOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status [**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -[**getInventoryInObject**](StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' [**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID [**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet @@ -52,61 +50,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **findOrdersByStatus** -> \Swagger\Client\Model\Order[] findOrdersByStatus($status) - -Finds orders by status - -A single status value can be provided as a string - -### Example -```php -setApiKey('x-test_api_client_id', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-test_api_client_id', 'BEARER'); -// Configure API key authorization: test_api_client_secret -Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('x-test_api_client_secret', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-test_api_client_secret', 'BEARER'); - -$api_instance = new Swagger\Client\Api\StoreApi(); -$status = "placed"; // string | Status value that needs to be considered for query - -try { - $result = $api_instance->findOrdersByStatus($status); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling StoreApi->findOrdersByStatus: ', $e->getMessage(), "\n"; -} -?> -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **status** | **string**| Status value that needs to be considered for query | [optional] [default to placed] - -### Return type - -[**\Swagger\Client\Model\Order[]**](Order.md) - -### Authorization - -[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -152,53 +96,7 @@ This endpoint does not need any parameter. ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **getInventoryInObject** -> object getInventoryInObject() - -Fake endpoint to test arbitrary object return by 'Get inventory' - -Returns an arbitrary object which is actually a map of status codes to quantities - -### Example -```php -setApiKey('api_key', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'BEARER'); - -$api_instance = new Swagger\Client\Api\StoreApi(); - -try { - $result = $api_instance->getInventoryInObject(); - print_r($result); -} catch (Exception $e) { - echo 'Exception when calling StoreApi->getInventoryInObject: ', $e->getMessage(), "\n"; -} -?> -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -**object** - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -214,17 +112,8 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge setApiKey('test_api_key_header', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('test_api_key_header', 'BEARER'); -// Configure API key authorization: test_api_key_query -Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('test_api_key_query', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('test_api_key_query', 'BEARER'); - $api_instance = new Swagger\Client\Api\StoreApi(); -$order_id = "order_id_example"; // string | ID of pet that needs to be fetched +$order_id = 789; // int | ID of pet that needs to be fetched try { $result = $api_instance->getOrderById($order_id); @@ -239,7 +128,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order_id** | **string**| ID of pet that needs to be fetched | + **order_id** | **int**| ID of pet that needs to be fetched | ### Return type @@ -247,12 +136,12 @@ Name | Type | Description | Notes ### Authorization -[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query) +No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -268,15 +157,6 @@ Place an order for a pet setApiKey('x-test_api_client_id', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-test_api_client_id', 'BEARER'); -// Configure API key authorization: test_api_client_secret -Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('x-test_api_client_secret', 'YOUR_API_KEY'); -// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-test_api_client_secret', 'BEARER'); - $api_instance = new Swagger\Client\Api\StoreApi(); $body = new \Swagger\Client\Model\Order(); // \Swagger\Client\Model\Order | order placed for purchasing the pet @@ -293,7 +173,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**\Swagger\Client\Model\Order**](\Swagger\Client\Model\Order.md)| order placed for purchasing the pet | [optional] + **body** | [**\Swagger\Client\Model\Order**](\Swagger\Client\Model\Order.md)| order placed for purchasing the pet | ### Return type @@ -301,12 +181,12 @@ Name | Type | Description | Notes ### Authorization -[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) +No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 3adaa899f5f8..ac63c18fbd5d 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -256,7 +256,7 @@ class ObjectSerializer } else { return null; } - } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { + } elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) { settype($data, $class); return $data; } elseif ($class === '\SplFileObject') { From 79bbab04ec9a97030d8be20f12ea94d64fb1e115 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Tue, 19 Apr 2016 21:17:43 +0100 Subject: [PATCH 14/26] Update required packages to latest stable version --- .../src/main/resources/python/setup.mustache | 2 +- samples/client/petstore/python/README.md | 2 +- samples/client/petstore/python/docs/PetApi.md | 231 +++--------------- .../client/petstore/python/docs/StoreApi.md | 148 +---------- samples/client/petstore/python/setup.py | 2 +- .../swagger_client.egg-info/requires.txt | 4 +- 6 files changed, 52 insertions(+), 337 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/python/setup.mustache b/modules/swagger-codegen/src/main/resources/python/setup.mustache index 08e110e35cce..f95b1f56a0ff 100644 --- a/modules/swagger-codegen/src/main/resources/python/setup.mustache +++ b/modules/swagger-codegen/src/main/resources/python/setup.mustache @@ -15,7 +15,7 @@ VERSION = "{{packageVersion}}" # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["urllib3 >= 1.10", "six >= 1.9", "certifi", "python-dateutil"] +REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"] setup( name=NAME, diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 85da3806f31c..309ae5d6374b 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https:// - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-14T17:57:34.564+08:00 +- Build date: 2016-04-19T21:05:59.494+01:00 - Build package: class io.swagger.codegen.languages.PythonClientCodegen ## Requirements. diff --git a/samples/client/petstore/python/docs/PetApi.md b/samples/client/petstore/python/docs/PetApi.md index 82a47548fb82..3b14d2b80621 100644 --- a/samples/client/petstore/python/docs/PetApi.md +++ b/samples/client/petstore/python/docs/PetApi.md @@ -5,20 +5,17 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- [**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store -[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store [**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet [**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status [**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags [**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID -[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' [**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet [**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data [**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image # **add_pet** -> add_pet(body=body) +> add_pet(body) Add a new pet to the store @@ -36,11 +33,11 @@ swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' # create an instance of the API class api_instance = swagger_client.PetApi() -body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store (optional) +body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store try: # Add a new pet to the store - api_instance.add_pet(body=body) + api_instance.add_pet(body) except ApiException as e: print "Exception when calling PetApi->add_pet: %s\n" % e ``` @@ -49,7 +46,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -62,56 +59,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **add_pet_using_byte_array** -> add_pet_using_byte_array(body=body) - -Fake endpoint to test byte array in body parameter for adding a new pet to the store - - - -### Example -```python -import time -import swagger_client -from swagger_client.rest import ApiException -from pprint import pprint - -# Configure OAuth2 access token for authorization: petstore_auth -swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' - -# create an instance of the API class -api_instance = swagger_client.PetApi() -body = 'B' # str | Pet object in the form of byte array (optional) - -try: - # Fake endpoint to test byte array in body parameter for adding a new pet to the store - api_instance.add_pet_using_byte_array(body=body) -except ApiException as e: - print "Exception when calling PetApi->add_pet_using_byte_array: %s\n" % e -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | **str**| Pet object in the form of byte array | [optional] - -### Return type - -void (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -162,12 +110,12 @@ void (empty response body) ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **find_pets_by_status** -> list[Pet] find_pets_by_status(status=status) +> list[Pet] find_pets_by_status(status) Finds Pets by status @@ -185,11 +133,11 @@ swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' # create an instance of the API class api_instance = swagger_client.PetApi() -status = ['available'] # list[str] | Status values that need to be considered for query (optional) (default to available) +status = ['status_example'] # list[str] | Status values that need to be considered for filter try: # Finds Pets by status - api_response = api_instance.find_pets_by_status(status=status) + api_response = api_instance.find_pets_by_status(status) pprint(api_response) except ApiException as e: print "Exception when calling PetApi->find_pets_by_status: %s\n" % e @@ -199,7 +147,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **status** | [**list[str]**](str.md)| Status values that need to be considered for query | [optional] [default to available] + **status** | [**list[str]**](str.md)| Status values that need to be considered for filter | ### Return type @@ -212,16 +160,16 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **find_pets_by_tags** -> list[Pet] find_pets_by_tags(tags=tags) +> list[Pet] find_pets_by_tags(tags) Finds Pets by tags -Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. ### Example ```python @@ -235,11 +183,11 @@ swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' # create an instance of the API class api_instance = swagger_client.PetApi() -tags = ['tags_example'] # list[str] | Tags to filter by (optional) +tags = ['tags_example'] # list[str] | Tags to filter by try: # Finds Pets by tags - api_response = api_instance.find_pets_by_tags(tags=tags) + api_response = api_instance.find_pets_by_tags(tags) pprint(api_response) except ApiException as e: print "Exception when calling PetApi->find_pets_by_tags: %s\n" % e @@ -249,7 +197,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **tags** | [**list[str]**](str.md)| Tags to filter by | [optional] + **tags** | [**list[str]**](str.md)| Tags to filter by | ### Return type @@ -262,7 +210,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -271,7 +219,7 @@ Name | Type | Description | Notes Find pet by ID -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions +Returns a single pet ### Example ```python @@ -284,12 +232,10 @@ from pprint import pprint swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. BEARER) for API key, if needed # swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' -# Configure OAuth2 access token for authorization: petstore_auth -swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' # create an instance of the API class api_instance = swagger_client.PetApi() -pet_id = 789 # int | ID of pet that needs to be fetched +pet_id = 789 # int | ID of pet to return try: # Find pet by ID @@ -303,7 +249,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet_id** | **int**| ID of pet that needs to be fetched | + **pet_id** | **int**| ID of pet to return | ### Return type @@ -311,125 +257,17 @@ Name | Type | Description | Notes ### Authorization -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) +[api_key](../README.md#api_key) ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **get_pet_by_id_in_object** -> InlineResponse200 get_pet_by_id_in_object(pet_id) - -Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - -### Example -```python -import time -import swagger_client -from swagger_client.rest import ApiException -from pprint import pprint - -# Configure API key authorization: api_key -swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' -# Configure OAuth2 access token for authorization: petstore_auth -swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' - -# create an instance of the API class -api_instance = swagger_client.PetApi() -pet_id = 789 # int | ID of pet that needs to be fetched - -try: - # Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - api_response = api_instance.get_pet_by_id_in_object(pet_id) - pprint(api_response) -except ApiException as e: - print "Exception when calling PetApi->get_pet_by_id_in_object: %s\n" % e -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **int**| ID of pet that needs to be fetched | - -### Return type - -[**InlineResponse200**](InlineResponse200.md) - -### Authorization - -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **pet_pet_idtesting_byte_arraytrue_get** -> str pet_pet_idtesting_byte_arraytrue_get(pet_id) - -Fake endpoint to test byte array return by 'Find pet by ID' - -Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - -### Example -```python -import time -import swagger_client -from swagger_client.rest import ApiException -from pprint import pprint - -# Configure API key authorization: api_key -swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' -# Configure OAuth2 access token for authorization: petstore_auth -swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' - -# create an instance of the API class -api_instance = swagger_client.PetApi() -pet_id = 789 # int | ID of pet that needs to be fetched - -try: - # Fake endpoint to test byte array return by 'Find pet by ID' - api_response = api_instance.pet_pet_idtesting_byte_arraytrue_get(pet_id) - pprint(api_response) -except ApiException as e: - print "Exception when calling PetApi->pet_pet_idtesting_byte_arraytrue_get: %s\n" % e -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **pet_id** | **int**| ID of pet that needs to be fetched | - -### Return type - -**str** - -### Authorization - -[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **update_pet** -> update_pet(body=body) +> update_pet(body) Update an existing pet @@ -447,11 +285,11 @@ swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' # create an instance of the API class api_instance = swagger_client.PetApi() -body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store (optional) +body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store try: # Update an existing pet - api_instance.update_pet(body=body) + api_instance.update_pet(body) except ApiException as e: print "Exception when calling PetApi->update_pet: %s\n" % e ``` @@ -460,7 +298,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -473,7 +311,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -496,7 +334,7 @@ swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' # create an instance of the API class api_instance = swagger_client.PetApi() -pet_id = 'pet_id_example' # str | ID of pet that needs to be updated +pet_id = 789 # int | ID of pet that needs to be updated name = 'name_example' # str | Updated name of the pet (optional) status = 'status_example' # str | Updated status of the pet (optional) @@ -511,7 +349,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet_id** | **str**| ID of pet that needs to be updated | + **pet_id** | **int**| ID of pet that needs to be updated | **name** | **str**| Updated name of the pet | [optional] **status** | **str**| Updated status of the pet | [optional] @@ -526,12 +364,12 @@ void (empty response body) ### HTTP request headers - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **upload_file** -> upload_file(pet_id, additional_metadata=additional_metadata, file=file) +> ApiResponse upload_file(pet_id, additional_metadata=additional_metadata, file=file) uploads an image @@ -555,7 +393,8 @@ file = '/path/to/file.txt' # file | file to upload (optional) try: # uploads an image - api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file) + api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file) + pprint(api_response) except ApiException as e: print "Exception when calling PetApi->upload_file: %s\n" % e ``` @@ -570,7 +409,7 @@ Name | Type | Description | Notes ### Return type -void (empty response body) +[**ApiResponse**](ApiResponse.md) ### Authorization @@ -579,7 +418,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: multipart/form-data - - **Accept**: application/json, application/xml + - **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/docs/StoreApi.md b/samples/client/petstore/python/docs/StoreApi.md index 89c5ff60eb94..04b4300d58de 100644 --- a/samples/client/petstore/python/docs/StoreApi.md +++ b/samples/client/petstore/python/docs/StoreApi.md @@ -5,9 +5,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- [**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -[**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status [**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status -[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' [**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID [**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet @@ -54,63 +52,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **find_orders_by_status** -> list[Order] find_orders_by_status(status=status) - -Finds orders by status - -A single status value can be provided as a string - -### Example -```python -import time -import swagger_client -from swagger_client.rest import ApiException -from pprint import pprint - -# Configure API key authorization: test_api_client_id -swagger_client.configuration.api_key['x-test_api_client_id'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -# swagger_client.configuration.api_key_prefix['x-test_api_client_id'] = 'BEARER' -# Configure API key authorization: test_api_client_secret -swagger_client.configuration.api_key['x-test_api_client_secret'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -# swagger_client.configuration.api_key_prefix['x-test_api_client_secret'] = 'BEARER' - -# create an instance of the API class -api_instance = swagger_client.StoreApi() -status = 'placed' # str | Status value that needs to be considered for query (optional) (default to placed) - -try: - # Finds orders by status - api_response = api_instance.find_orders_by_status(status=status) - pprint(api_response) -except ApiException as e: - print "Exception when calling StoreApi->find_orders_by_status: %s\n" % e -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **status** | **str**| Status value that needs to be considered for query | [optional] [default to placed] - -### Return type - -[**list[Order]**](Order.md) - -### Authorization - -[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -158,55 +100,7 @@ This endpoint does not need any parameter. ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **get_inventory_in_object** -> object get_inventory_in_object() - -Fake endpoint to test arbitrary object return by 'Get inventory' - -Returns an arbitrary object which is actually a map of status codes to quantities - -### Example -```python -import time -import swagger_client -from swagger_client.rest import ApiException -from pprint import pprint - -# Configure API key authorization: api_key -swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' - -# create an instance of the API class -api_instance = swagger_client.StoreApi() - -try: - # Fake endpoint to test arbitrary object return by 'Get inventory' - api_response = api_instance.get_inventory_in_object() - pprint(api_response) -except ApiException as e: - print "Exception when calling StoreApi->get_inventory_in_object: %s\n" % e -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -**object** - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -224,18 +118,9 @@ import swagger_client from swagger_client.rest import ApiException from pprint import pprint -# Configure API key authorization: test_api_key_header -swagger_client.configuration.api_key['test_api_key_header'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -# swagger_client.configuration.api_key_prefix['test_api_key_header'] = 'BEARER' -# Configure API key authorization: test_api_key_query -swagger_client.configuration.api_key['test_api_key_query'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -# swagger_client.configuration.api_key_prefix['test_api_key_query'] = 'BEARER' - # create an instance of the API class api_instance = swagger_client.StoreApi() -order_id = 'order_id_example' # str | ID of pet that needs to be fetched +order_id = 789 # int | ID of pet that needs to be fetched try: # Find purchase order by ID @@ -249,7 +134,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order_id** | **str**| ID of pet that needs to be fetched | + **order_id** | **int**| ID of pet that needs to be fetched | ### Return type @@ -257,17 +142,17 @@ Name | Type | Description | Notes ### Authorization -[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query) +No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **place_order** -> Order place_order(body=body) +> Order place_order(body) Place an order for a pet @@ -280,22 +165,13 @@ import swagger_client from swagger_client.rest import ApiException from pprint import pprint -# Configure API key authorization: test_api_client_id -swagger_client.configuration.api_key['x-test_api_client_id'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -# swagger_client.configuration.api_key_prefix['x-test_api_client_id'] = 'BEARER' -# Configure API key authorization: test_api_client_secret -swagger_client.configuration.api_key['x-test_api_client_secret'] = 'YOUR_API_KEY' -# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed -# swagger_client.configuration.api_key_prefix['x-test_api_client_secret'] = 'BEARER' - # create an instance of the API class api_instance = swagger_client.StoreApi() -body = swagger_client.Order() # Order | order placed for purchasing the pet (optional) +body = swagger_client.Order() # Order | order placed for purchasing the pet try: # Place an order for a pet - api_response = api_instance.place_order(body=body) + api_response = api_instance.place_order(body) pprint(api_response) except ApiException as e: print "Exception when calling StoreApi->place_order: %s\n" % e @@ -305,7 +181,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional] + **body** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type @@ -313,12 +189,12 @@ Name | Type | Description | Notes ### Authorization -[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) +No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/json, application/xml + - **Accept**: application/xml, application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/setup.py b/samples/client/petstore/python/setup.py index ef25bcba63b8..577fd8133bf2 100644 --- a/samples/client/petstore/python/setup.py +++ b/samples/client/petstore/python/setup.py @@ -15,7 +15,7 @@ VERSION = "1.0.0" # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["urllib3 >= 1.10", "six >= 1.9", "certifi", "python-dateutil"] +REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"] setup( name=NAME, diff --git a/samples/client/petstore/python/swagger_client.egg-info/requires.txt b/samples/client/petstore/python/swagger_client.egg-info/requires.txt index 367a059209fe..86355123cfff 100644 --- a/samples/client/petstore/python/swagger_client.egg-info/requires.txt +++ b/samples/client/petstore/python/swagger_client.egg-info/requires.txt @@ -1,4 +1,4 @@ -urllib3 >= 1.10 -six >= 1.9 +urllib3 >= 1.15 +six >= 1.10 certifi python-dateutil From 1178d31d1f21949cb6742dfb0d8aaebd2c434ed7 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 20 Apr 2016 15:57:18 +0800 Subject: [PATCH 15/26] update petstore sample --- .../Classes/Swaggers/APIs/PetAPI.swift | 385 ++++-------------- .../Classes/Swaggers/APIs/StoreAPI.swift | 217 ++-------- .../Classes/Swaggers/APIs/UserAPI.swift | 55 ++- .../Swaggers/AlamofireImplementations.swift | 2 +- .../Classes/Swaggers/Models.swift | 136 ------- .../Classes/Swaggers/Models/Animal.swift | 23 -- .../Classes/Swaggers/Models/Cat.swift | 25 -- .../Classes/Swaggers/Models/Dog.swift | 25 -- .../Classes/Swaggers/Models/FormatTest.swift | 46 --- .../Swaggers/Models/InlineResponse200.swift | 40 -- .../Swaggers/Models/Model200Response.swift | 24 -- .../Classes/Swaggers/Models/ModelReturn.swift | 24 -- .../Classes/Swaggers/Models/Name.swift | 26 -- .../Swaggers/Models/ObjectReturn.swift | 25 -- .../Swaggers/Models/SpecialModelName.swift | 24 -- 15 files changed, 144 insertions(+), 933 deletions(-) delete mode 100644 samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Animal.swift delete mode 100644 samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Cat.swift delete mode 100644 samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Dog.swift delete mode 100644 samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/FormatTest.swift delete mode 100644 samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift delete mode 100644 samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift delete mode 100644 samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift delete mode 100644 samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift delete mode 100644 samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ObjectReturn.swift delete mode 100644 samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift index 1d39c7885d31..64aa3c8803cf 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift @@ -63,58 +63,6 @@ public class PetAPI: APIBase { return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true) } - /** - Fake endpoint to test byte array in body parameter for adding a new pet to the store - - - parameter body: (body) Pet object in the form of byte array (optional) - - parameter completion: completion handler to receive the data and the error objects - */ - public class func addPetUsingByteArray(body body: String? = nil, completion: ((error: ErrorType?) -> Void)) { - addPetUsingByteArrayWithRequestBuilder(body: body).execute { (response, error) -> Void in - completion(error: error); - } - } - - /** - Fake endpoint to test byte array in body parameter for adding a new pet to the store - - - parameter body: (body) Pet object in the form of byte array (optional) - - returns: Promise - */ - public class func addPetUsingByteArray(body body: String? = nil) -> Promise { - let deferred = Promise.pendingPromise() - addPetUsingByteArray(body: body) { error in - if let error = error { - deferred.reject(error) - } else { - deferred.fulfill() - } - } - return deferred.promise - } - - /** - Fake endpoint to test byte array in body parameter for adding a new pet to the store - - POST /pet?testing_byte_array=true - - - - OAuth: - - type: oauth2 - - name: petstore_auth - - - parameter body: (body) Pet object in the form of byte array (optional) - - - returns: RequestBuilder - */ - public class func addPetUsingByteArrayWithRequestBuilder(body body: String? = nil) -> RequestBuilder { - let path = "/pet?testing_byte_array=true" - let URLString = PetstoreClientAPI.basePath + path - let parameters = body?.encodeToJSON() as? [String:AnyObject] - - let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - - return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true) - } - /** Deletes a pet @@ -173,7 +121,7 @@ public class PetAPI: APIBase { /** Finds Pets by status - - parameter status: (query) Status values that need to be considered for query (optional, default to available) + - parameter status: (query) Status values that need to be considered for filter (optional, default to available) - parameter completion: completion handler to receive the data and the error objects */ public class func findPetsByStatus(status status: [String]? = nil, completion: ((data: [Pet]?, error: ErrorType?) -> Void)) { @@ -185,7 +133,7 @@ public class PetAPI: APIBase { /** Finds Pets by status - - parameter status: (query) Status values that need to be considered for query (optional, default to available) + - parameter status: (query) Status values that need to be considered for filter (optional, default to available) - returns: Promise<[Pet]> */ public class func findPetsByStatus(status status: [String]? = nil) -> Promise<[Pet]> { @@ -203,58 +151,19 @@ public class PetAPI: APIBase { /** Finds Pets by status - GET /pet/findByStatus - - Multiple status values can be provided with comma separated strings + - Multiple status values can be provided with comma seperated strings - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", - "id" : 123456789, - "category" : { - "name" : "aeiou", - "id" : 123456789 - }, - "tags" : [ { - "name" : "aeiou", - "id" : 123456789 - } ], - "status" : "aeiou" -} ]}, {contentType=application/xml, example= - 123456 - doggie - - string - - - - string -}] - - examples: [{contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", - "id" : 123456789, - "category" : { - "name" : "aeiou", - "id" : 123456789 - }, - "tags" : [ { - "name" : "aeiou", - "id" : 123456789 - } ], - "status" : "aeiou" -} ]}, {contentType=application/xml, example= - 123456 - doggie - - string - - - - string -}] + - examples: [{example={ + "name" : "Puma", + "type" : "Dog", + "color" : "Black", + "gender" : "Female", + "breed" : "Mixed" +}, contentType=application/json}] - - parameter status: (query) Status values that need to be considered for query (optional, default to available) + - parameter status: (query) Status values that need to be considered for filter (optional, default to available) - returns: RequestBuilder<[Pet]> */ @@ -309,20 +218,20 @@ public class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", + - examples: [{example=[ { + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], "id" : 123456789, "category" : { - "name" : "aeiou", - "id" : 123456789 + "id" : 123456789, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 123456789 - } ], - "status" : "aeiou" -} ]}, {contentType=application/xml, example= + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}, {example= 123456 doggie @@ -331,21 +240,21 @@ public class PetAPI: APIBase { string -}] - - examples: [{contentType=application/json, example=[ { - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}] + - examples: [{example=[ { + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], "id" : 123456789, "category" : { - "name" : "aeiou", - "id" : 123456789 + "id" : 123456789, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 123456789 - } ], - "status" : "aeiou" -} ]}, {contentType=application/xml, example= + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +} ], contentType=application/json}, {example= 123456 doggie @@ -354,7 +263,7 @@ public class PetAPI: APIBase { string -}] +, contentType=application/xml}] - parameter tags: (query) Tags to filter by (optional) @@ -408,26 +317,26 @@ public class PetAPI: APIBase { Find pet by ID - GET /pet/{petId} - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - - OAuth: - - type: oauth2 - - name: petstore_auth - API Key: - type: apiKey api_key - name: api_key - - examples: [{contentType=application/json, example={ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", + - OAuth: + - type: oauth2 + - name: petstore_auth + - examples: [{example={ + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], "id" : 123456789, "category" : { - "name" : "aeiou", - "id" : 123456789 + "id" : 123456789, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 123456789 - } ], - "status" : "aeiou" -}}, {contentType=application/xml, example= + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +}, contentType=application/json}, {example= 123456 doggie @@ -436,21 +345,21 @@ public class PetAPI: APIBase { string -}] - - examples: [{contentType=application/json, example={ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", +, contentType=application/xml}] + - examples: [{example={ + "tags" : [ { + "id" : 123456789, + "name" : "aeiou" + } ], "id" : 123456789, "category" : { - "name" : "aeiou", - "id" : 123456789 + "id" : 123456789, + "name" : "aeiou" }, - "tags" : [ { - "name" : "aeiou", - "id" : 123456789 - } ], - "status" : "aeiou" -}}, {contentType=application/xml, example= + "status" : "aeiou", + "name" : "doggie", + "photoUrls" : [ "aeiou" ] +}, contentType=application/json}, {example= 123456 doggie @@ -459,7 +368,7 @@ public class PetAPI: APIBase { string -}] +, contentType=application/xml}] - parameter petId: (path) ID of pet that needs to be fetched @@ -478,158 +387,6 @@ public class PetAPI: APIBase { return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true) } - /** - Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - - - parameter petId: (path) ID of pet that needs to be fetched - - parameter completion: completion handler to receive the data and the error objects - */ - public class func getPetByIdInObject(petId petId: Int64, completion: ((data: InlineResponse200?, error: ErrorType?) -> Void)) { - getPetByIdInObjectWithRequestBuilder(petId: petId).execute { (response, error) -> Void in - completion(data: response?.body, error: error); - } - } - - /** - Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - - - parameter petId: (path) ID of pet that needs to be fetched - - returns: Promise - */ - public class func getPetByIdInObject(petId petId: Int64) -> Promise { - let deferred = Promise.pendingPromise() - getPetByIdInObject(petId: petId) { data, error in - if let error = error { - deferred.reject(error) - } else { - deferred.fulfill(data!) - } - } - return deferred.promise - } - - /** - Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - - GET /pet/{petId}?response=inline_arbitrary_object - - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - - OAuth: - - type: oauth2 - - name: petstore_auth - - API Key: - - type: apiKey api_key - - name: api_key - - examples: [{contentType=application/json, example={ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", - "id" : 123456789, - "category" : "{}", - "tags" : [ { - "name" : "aeiou", - "id" : 123456789 - } ], - "status" : "aeiou" -}}, {contentType=application/xml, example= - string - doggie - 123456 - not implemented io.swagger.models.properties.ObjectProperty@37ff6855 - string -}] - - examples: [{contentType=application/json, example={ - "photoUrls" : [ "aeiou" ], - "name" : "doggie", - "id" : 123456789, - "category" : "{}", - "tags" : [ { - "name" : "aeiou", - "id" : 123456789 - } ], - "status" : "aeiou" -}}, {contentType=application/xml, example= - string - doggie - 123456 - not implemented io.swagger.models.properties.ObjectProperty@37ff6855 - string -}] - - - parameter petId: (path) ID of pet that needs to be fetched - - - returns: RequestBuilder - */ - public class func getPetByIdInObjectWithRequestBuilder(petId petId: Int64) -> RequestBuilder { - var path = "/pet/{petId}?response=inline_arbitrary_object" - path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) - let URLString = PetstoreClientAPI.basePath + path - - let nillableParameters: [String:AnyObject?] = [:] - let parameters = APIHelper.rejectNil(nillableParameters) - - let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - - return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true) - } - - /** - Fake endpoint to test byte array return by 'Find pet by ID' - - - parameter petId: (path) ID of pet that needs to be fetched - - parameter completion: completion handler to receive the data and the error objects - */ - public class func petPetIdtestingByteArraytrueGet(petId petId: Int64, completion: ((data: String?, error: ErrorType?) -> Void)) { - petPetIdtestingByteArraytrueGetWithRequestBuilder(petId: petId).execute { (response, error) -> Void in - completion(data: response?.body, error: error); - } - } - - /** - Fake endpoint to test byte array return by 'Find pet by ID' - - - parameter petId: (path) ID of pet that needs to be fetched - - returns: Promise - */ - public class func petPetIdtestingByteArraytrueGet(petId petId: Int64) -> Promise { - let deferred = Promise.pendingPromise() - petPetIdtestingByteArraytrueGet(petId: petId) { data, error in - if let error = error { - deferred.reject(error) - } else { - deferred.fulfill(data!) - } - } - return deferred.promise - } - - /** - Fake endpoint to test byte array return by 'Find pet by ID' - - GET /pet/{petId}?testing_byte_array=true - - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - - OAuth: - - type: oauth2 - - name: petstore_auth - - API Key: - - type: apiKey api_key - - name: api_key - - examples: [{contentType=application/json, example=""}, {contentType=application/xml, example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e}] - - examples: [{contentType=application/json, example=""}, {contentType=application/xml, example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e}] - - - parameter petId: (path) ID of pet that needs to be fetched - - - returns: RequestBuilder - */ - public class func petPetIdtestingByteArraytrueGetWithRequestBuilder(petId petId: Int64) -> RequestBuilder { - var path = "/pet/{petId}?testing_byte_array=true" - path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) - let URLString = PetstoreClientAPI.basePath + path - - let nillableParameters: [String:AnyObject?] = [:] - let parameters = APIHelper.rejectNil(nillableParameters) - - let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - - return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true) - } - /** Update an existing pet @@ -751,11 +508,11 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet to update - parameter additionalMetadata: (form) Additional data to pass to server (optional) - - parameter _file: (form) file to upload (optional) + - parameter file: (form) file to upload (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func uploadFile(petId petId: Int64, additionalMetadata: String? = nil, _file: NSURL? = nil, completion: ((error: ErrorType?) -> Void)) { - uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, _file: _file).execute { (response, error) -> Void in + public class func uploadFile(petId petId: Int64, additionalMetadata: String? = nil, file: NSURL? = nil, completion: ((error: ErrorType?) -> Void)) { + uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { (response, error) -> Void in completion(error: error); } } @@ -765,12 +522,12 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet to update - parameter additionalMetadata: (form) Additional data to pass to server (optional) - - parameter _file: (form) file to upload (optional) + - parameter file: (form) file to upload (optional) - returns: Promise */ - public class func uploadFile(petId petId: Int64, additionalMetadata: String? = nil, _file: NSURL? = nil) -> Promise { + public class func uploadFile(petId petId: Int64, additionalMetadata: String? = nil, file: NSURL? = nil) -> Promise { let deferred = Promise.pendingPromise() - uploadFile(petId: petId, additionalMetadata: additionalMetadata, _file: _file) { error in + uploadFile(petId: petId, additionalMetadata: additionalMetadata, file: file) { error in if let error = error { deferred.reject(error) } else { @@ -790,18 +547,18 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet to update - parameter additionalMetadata: (form) Additional data to pass to server (optional) - - parameter _file: (form) file to upload (optional) + - parameter file: (form) file to upload (optional) - returns: RequestBuilder */ - public class func uploadFileWithRequestBuilder(petId petId: Int64, additionalMetadata: String? = nil, _file: NSURL? = nil) -> RequestBuilder { + public class func uploadFileWithRequestBuilder(petId petId: Int64, additionalMetadata: String? = nil, file: NSURL? = nil) -> RequestBuilder { var path = "/pet/{petId}/uploadImage" path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path let nillableParameters: [String:AnyObject?] = [ "additionalMetadata": additionalMetadata, - "file": _file + "file": file ] let parameters = APIHelper.rejectNil(nillableParameters) diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift index f4f0cea288be..4521afd3d89b 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift @@ -63,95 +63,6 @@ public class StoreAPI: APIBase { return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true) } - /** - Finds orders by status - - - parameter status: (query) Status value that needs to be considered for query (optional, default to placed) - - parameter completion: completion handler to receive the data and the error objects - */ - public class func findOrdersByStatus(status status: String? = nil, completion: ((data: [Order]?, error: ErrorType?) -> Void)) { - findOrdersByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in - completion(data: response?.body, error: error); - } - } - - /** - Finds orders by status - - - parameter status: (query) Status value that needs to be considered for query (optional, default to placed) - - returns: Promise<[Order]> - */ - public class func findOrdersByStatus(status status: String? = nil) -> Promise<[Order]> { - let deferred = Promise<[Order]>.pendingPromise() - findOrdersByStatus(status: status) { data, error in - if let error = error { - deferred.reject(error) - } else { - deferred.fulfill(data!) - } - } - return deferred.promise - } - - /** - Finds orders by status - - GET /store/findByStatus - - A single status value can be provided as a string - - API Key: - - type: apiKey x-test_api_client_id - - name: test_api_client_id - - API Key: - - type: apiKey x-test_api_client_secret - - name: test_api_client_secret - - examples: [{contentType=application/json, example=[ { - "petId" : 123456789, - "quantity" : 123, - "id" : 123456789, - "shipDate" : "2000-01-23T04:56:07.000+0000", - "complete" : true, - "status" : "aeiou" -} ]}, {contentType=application/xml, example= - 123456 - 123456 - 0 - 2000-01-23T04:56:07.000Z - string - true -}] - - examples: [{contentType=application/json, example=[ { - "petId" : 123456789, - "quantity" : 123, - "id" : 123456789, - "shipDate" : "2000-01-23T04:56:07.000+0000", - "complete" : true, - "status" : "aeiou" -} ]}, {contentType=application/xml, example= - 123456 - 123456 - 0 - 2000-01-23T04:56:07.000Z - string - true -}] - - - parameter status: (query) Status value that needs to be considered for query (optional, default to placed) - - - returns: RequestBuilder<[Order]> - */ - public class func findOrdersByStatusWithRequestBuilder(status status: String? = nil) -> RequestBuilder<[Order]> { - let path = "/store/findByStatus" - let URLString = PetstoreClientAPI.basePath + path - - let nillableParameters: [String:AnyObject?] = [ - "status": status - ] - let parameters = APIHelper.rejectNil(nillableParameters) - - let requestBuilder: RequestBuilder<[Order]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - - return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: false) - } - /** Returns pet inventories by status @@ -187,12 +98,12 @@ public class StoreAPI: APIBase { - API Key: - type: apiKey api_key - name: api_key - - examples: [{contentType=application/json, example={ + - examples: [{example={ "key" : 123 -}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}] - - examples: [{contentType=application/json, example={ +}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}] + - examples: [{example={ "key" : 123 -}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}] +}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}] - returns: RequestBuilder<[String:Int32]> */ @@ -208,58 +119,6 @@ public class StoreAPI: APIBase { return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true) } - /** - Fake endpoint to test arbitrary object return by 'Get inventory' - - - parameter completion: completion handler to receive the data and the error objects - */ - public class func getInventoryInObject(completion: ((data: AnyObject?, error: ErrorType?) -> Void)) { - getInventoryInObjectWithRequestBuilder().execute { (response, error) -> Void in - completion(data: response?.body, error: error); - } - } - - /** - Fake endpoint to test arbitrary object return by 'Get inventory' - - - returns: Promise - */ - public class func getInventoryInObject() -> Promise { - let deferred = Promise.pendingPromise() - getInventoryInObject() { data, error in - if let error = error { - deferred.reject(error) - } else { - deferred.fulfill(data!) - } - } - return deferred.promise - } - - /** - Fake endpoint to test arbitrary object return by 'Get inventory' - - GET /store/inventory?response=arbitrary_object - - Returns an arbitrary object which is actually a map of status codes to quantities - - API Key: - - type: apiKey api_key - - name: api_key - - examples: [{contentType=application/json, example="{}"}, {contentType=application/xml, example=not implemented io.swagger.models.properties.ObjectProperty@37aadb4f}] - - examples: [{contentType=application/json, example="{}"}, {contentType=application/xml, example=not implemented io.swagger.models.properties.ObjectProperty@37aadb4f}] - - - returns: RequestBuilder - */ - public class func getInventoryInObjectWithRequestBuilder() -> RequestBuilder { - let path = "/store/inventory?response=arbitrary_object" - let URLString = PetstoreClientAPI.basePath + path - - let nillableParameters: [String:AnyObject?] = [:] - let parameters = APIHelper.rejectNil(nillableParameters) - - let requestBuilder: RequestBuilder.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() - - return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true) - } - /** Find purchase order by ID @@ -294,42 +153,36 @@ public class StoreAPI: APIBase { Find purchase order by ID - GET /store/order/{orderId} - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - - API Key: - - type: apiKey test_api_key_query (QUERY) - - name: test_api_key_query - - API Key: - - type: apiKey test_api_key_header - - name: test_api_key_header - - examples: [{contentType=application/json, example={ - "petId" : 123456789, - "quantity" : 123, + - examples: [{example={ "id" : 123456789, - "shipDate" : "2000-01-23T04:56:07.000+0000", + "petId" : 123456789, "complete" : true, - "status" : "aeiou" -}}, {contentType=application/xml, example= + "status" : "aeiou", + "quantity" : 123, + "shipDate" : "2000-01-23T04:56:07.000+0000" +}, contentType=application/json}, {example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -}] - - examples: [{contentType=application/json, example={ - "petId" : 123456789, - "quantity" : 123, +, contentType=application/xml}] + - examples: [{example={ "id" : 123456789, - "shipDate" : "2000-01-23T04:56:07.000+0000", + "petId" : 123456789, "complete" : true, - "status" : "aeiou" -}}, {contentType=application/xml, example= + "status" : "aeiou", + "quantity" : 123, + "shipDate" : "2000-01-23T04:56:07.000+0000" +}, contentType=application/json}, {example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -}] +, contentType=application/xml}] - parameter orderId: (path) ID of pet that needs to be fetched @@ -382,42 +235,36 @@ public class StoreAPI: APIBase { Place an order for a pet - POST /store/order - - - API Key: - - type: apiKey x-test_api_client_id - - name: test_api_client_id - - API Key: - - type: apiKey x-test_api_client_secret - - name: test_api_client_secret - - examples: [{contentType=application/json, example={ - "petId" : 123456789, - "quantity" : 123, + - examples: [{example={ "id" : 123456789, - "shipDate" : "2000-01-23T04:56:07.000+0000", + "petId" : 123456789, "complete" : true, - "status" : "aeiou" -}}, {contentType=application/xml, example= + "status" : "aeiou", + "quantity" : 123, + "shipDate" : "2000-01-23T04:56:07.000+0000" +}, contentType=application/json}, {example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -}] - - examples: [{contentType=application/json, example={ - "petId" : 123456789, - "quantity" : 123, +, contentType=application/xml}] + - examples: [{example={ "id" : 123456789, - "shipDate" : "2000-01-23T04:56:07.000+0000", + "petId" : 123456789, "complete" : true, - "status" : "aeiou" -}}, {contentType=application/xml, example= + "status" : "aeiou", + "quantity" : 123, + "shipDate" : "2000-01-23T04:56:07.000+0000" +}, contentType=application/json}, {example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -}] +, contentType=application/xml}] - parameter body: (body) order placed for purchasing the pet (optional) diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift index 6a522eb8813b..62018cd83c27 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift @@ -192,9 +192,6 @@ public class UserAPI: APIBase { Delete user - DELETE /user/{username} - This can only be done by the logged in user. - - BASIC: - - type: basic - - name: test_http_basic - parameter username: (path) The name that needs to be deleted @@ -247,16 +244,44 @@ public class UserAPI: APIBase { Get user by user name - GET /user/{username} - - - examples: [{contentType=application/json, example={ - "id" : 1, - "username" : "johnp", - "firstName" : "John", - "lastName" : "Public", - "email" : "johnp@swagger.io", - "password" : "-secret-", - "phone" : "0123456789", - "userStatus" : 0 -}}] + - examples: [{example={ + "id" : 123456789, + "lastName" : "aeiou", + "phone" : "aeiou", + "username" : "aeiou", + "email" : "aeiou", + "userStatus" : 123, + "firstName" : "aeiou", + "password" : "aeiou" +}, contentType=application/json}, {example= + 123456 + string + string + string + string + string + string + 0 +, contentType=application/xml}] + - examples: [{example={ + "id" : 123456789, + "lastName" : "aeiou", + "phone" : "aeiou", + "username" : "aeiou", + "email" : "aeiou", + "userStatus" : 123, + "firstName" : "aeiou", + "password" : "aeiou" +}, contentType=application/json}, {example= + 123456 + string + string + string + string + string + string + 0 +, contentType=application/xml}] - parameter username: (path) The name that needs to be fetched. Use user1 for testing. @@ -311,8 +336,8 @@ public class UserAPI: APIBase { Logs user into the system - GET /user/login - - - examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}] - - examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}] + - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}] + - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}] - parameter username: (query) The user name for login (optional) - parameter password: (query) The password for login in clear text (optional) diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift index 6b4d36f94105..2faa0a6f24d2 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift @@ -75,7 +75,7 @@ class AlamofireRequestBuilder: RequestBuilder { request.authenticate(usingCredential: credential) } - request.responseJSON(options: .AllowFragments) { response in + request.validate().responseJSON(options: .AllowFragments) { response in managerStore.removeValueForKey(managerId) if response.result.isFailure { diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift index 3d3710ea2237..f9e2f72b9082 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift @@ -130,33 +130,6 @@ class Decoders { fatalError("formatter failed to parse \(source)") } - // Decoder for [Animal] - Decoders.addDecoder(clazz: [Animal].self) { (source: AnyObject) -> [Animal] in - return Decoders.decode(clazz: [Animal].self, source: source) - } - // Decoder for Animal - Decoders.addDecoder(clazz: Animal.self) { (source: AnyObject) -> Animal in - let sourceDictionary = source as! [NSObject:AnyObject] - let instance = Animal() - instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"]) - return instance - } - - - // Decoder for [Cat] - Decoders.addDecoder(clazz: [Cat].self) { (source: AnyObject) -> [Cat] in - return Decoders.decode(clazz: [Cat].self, source: source) - } - // Decoder for Cat - Decoders.addDecoder(clazz: Cat.self) { (source: AnyObject) -> Cat in - let sourceDictionary = source as! [NSObject:AnyObject] - let instance = Cat() - instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"]) - instance.declawed = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["declawed"]) - return instance - } - - // Decoder for [Category] Decoders.addDecoder(clazz: [Category].self) { (source: AnyObject) -> [Category] in return Decoders.decode(clazz: [Category].self, source: source) @@ -171,102 +144,6 @@ class Decoders { } - // Decoder for [Dog] - Decoders.addDecoder(clazz: [Dog].self) { (source: AnyObject) -> [Dog] in - return Decoders.decode(clazz: [Dog].self, source: source) - } - // Decoder for Dog - Decoders.addDecoder(clazz: Dog.self) { (source: AnyObject) -> Dog in - let sourceDictionary = source as! [NSObject:AnyObject] - let instance = Dog() - instance.className = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["className"]) - instance.breed = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["breed"]) - return instance - } - - - // Decoder for [FormatTest] - Decoders.addDecoder(clazz: [FormatTest].self) { (source: AnyObject) -> [FormatTest] in - return Decoders.decode(clazz: [FormatTest].self, source: source) - } - // Decoder for FormatTest - Decoders.addDecoder(clazz: FormatTest.self) { (source: AnyObject) -> FormatTest in - let sourceDictionary = source as! [NSObject:AnyObject] - let instance = FormatTest() - instance.integer = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["integer"]) - instance._int32 = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["int32"]) - instance._int64 = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["int64"]) - instance.number = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["number"]) - instance._float = Decoders.decodeOptional(clazz: Float.self, source: sourceDictionary["float"]) - instance._double = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["double"]) - instance._string = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["string"]) - instance.byte = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["byte"]) - instance.binary = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["binary"]) - instance.date = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["date"]) - instance.dateTime = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["dateTime"]) - instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"]) - return instance - } - - - // Decoder for [InlineResponse200] - Decoders.addDecoder(clazz: [InlineResponse200].self) { (source: AnyObject) -> [InlineResponse200] in - return Decoders.decode(clazz: [InlineResponse200].self, source: source) - } - // Decoder for InlineResponse200 - Decoders.addDecoder(clazz: InlineResponse200.self) { (source: AnyObject) -> InlineResponse200 in - let sourceDictionary = source as! [NSObject:AnyObject] - let instance = InlineResponse200() - instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"]) - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) - instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) - instance.category = Decoders.decodeOptional(clazz: AnyObject.self, source: sourceDictionary["category"]) - instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"]) - instance.status = InlineResponse200.Status(rawValue: (sourceDictionary["status"] as? String) ?? "") - return instance - } - - - // Decoder for [Model200Response] - Decoders.addDecoder(clazz: [Model200Response].self) { (source: AnyObject) -> [Model200Response] in - return Decoders.decode(clazz: [Model200Response].self, source: source) - } - // Decoder for Model200Response - Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject) -> Model200Response in - let sourceDictionary = source as! [NSObject:AnyObject] - let instance = Model200Response() - instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"]) - return instance - } - - - // Decoder for [ModelReturn] - Decoders.addDecoder(clazz: [ModelReturn].self) { (source: AnyObject) -> [ModelReturn] in - return Decoders.decode(clazz: [ModelReturn].self, source: source) - } - // Decoder for ModelReturn - Decoders.addDecoder(clazz: ModelReturn.self) { (source: AnyObject) -> ModelReturn in - let sourceDictionary = source as! [NSObject:AnyObject] - let instance = ModelReturn() - instance._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"]) - return instance - } - - - // Decoder for [Name] - Decoders.addDecoder(clazz: [Name].self) { (source: AnyObject) -> [Name] in - return Decoders.decode(clazz: [Name].self, source: source) - } - // Decoder for Name - Decoders.addDecoder(clazz: Name.self) { (source: AnyObject) -> Name in - let sourceDictionary = source as! [NSObject:AnyObject] - let instance = Name() - instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"]) - instance.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"]) - return instance - } - - // Decoder for [Order] Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject) -> [Order] in return Decoders.decode(clazz: [Order].self, source: source) @@ -303,19 +180,6 @@ class Decoders { } - // Decoder for [SpecialModelName] - Decoders.addDecoder(clazz: [SpecialModelName].self) { (source: AnyObject) -> [SpecialModelName] in - return Decoders.decode(clazz: [SpecialModelName].self, source: source) - } - // Decoder for SpecialModelName - Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject) -> SpecialModelName in - let sourceDictionary = source as! [NSObject:AnyObject] - let instance = SpecialModelName() - instance.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"]) - return instance - } - - // Decoder for [Tag] Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in return Decoders.decode(clazz: [Tag].self, source: source) diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Animal.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Animal.swift deleted file mode 100644 index 586b10f59312..000000000000 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Animal.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// Animal.swift -// -// Generated by swagger-codegen -// https://github.com/swagger-api/swagger-codegen -// - -import Foundation - - -public class Animal: JSONEncodable { - public var className: String? - - public init() {} - - // MARK: JSONEncodable - func encodeToJSON() -> AnyObject { - var nillableDictionary = [String:AnyObject?]() - nillableDictionary["className"] = self.className - let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] - return dictionary - } -} diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Cat.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Cat.swift deleted file mode 100644 index bdf66b563d2b..000000000000 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Cat.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// Cat.swift -// -// Generated by swagger-codegen -// https://github.com/swagger-api/swagger-codegen -// - -import Foundation - - -public class Cat: JSONEncodable { - public var className: String? - public var declawed: Bool? - - public init() {} - - // MARK: JSONEncodable - func encodeToJSON() -> AnyObject { - var nillableDictionary = [String:AnyObject?]() - nillableDictionary["className"] = self.className - nillableDictionary["declawed"] = self.declawed - let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] - return dictionary - } -} diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Dog.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Dog.swift deleted file mode 100644 index 8a1fafdfc673..000000000000 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Dog.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// Dog.swift -// -// Generated by swagger-codegen -// https://github.com/swagger-api/swagger-codegen -// - -import Foundation - - -public class Dog: JSONEncodable { - public var className: String? - public var breed: String? - - public init() {} - - // MARK: JSONEncodable - func encodeToJSON() -> AnyObject { - var nillableDictionary = [String:AnyObject?]() - nillableDictionary["className"] = self.className - nillableDictionary["breed"] = self.breed - let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] - return dictionary - } -} diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/FormatTest.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/FormatTest.swift deleted file mode 100644 index b84000125e31..000000000000 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/FormatTest.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// FormatTest.swift -// -// Generated by swagger-codegen -// https://github.com/swagger-api/swagger-codegen -// - -import Foundation - - -public class FormatTest: JSONEncodable { - public var integer: Int32? - public var _int32: Int32? - public var _int64: Int64? - public var number: Double? - public var _float: Float? - public var _double: Double? - public var _string: String? - public var byte: String? - public var binary: String? - public var date: NSDate? - public var dateTime: NSDate? - public var password: String? - - public init() {} - - // MARK: JSONEncodable - func encodeToJSON() -> AnyObject { - var nillableDictionary = [String:AnyObject?]() - nillableDictionary["integer"] = self.integer?.encodeToJSON() - nillableDictionary["int32"] = self._int32?.encodeToJSON() - nillableDictionary["int64"] = self._int64?.encodeToJSON() - nillableDictionary["int64"] = self._int64?.encodeToJSON() - nillableDictionary["number"] = self.number - nillableDictionary["float"] = self._float - nillableDictionary["double"] = self._double - nillableDictionary["string"] = self._string - nillableDictionary["byte"] = self.byte - nillableDictionary["binary"] = self.binary - nillableDictionary["date"] = self.date?.encodeToJSON() - nillableDictionary["dateTime"] = self.dateTime?.encodeToJSON() - nillableDictionary["password"] = self.password - let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] - return dictionary - } -} diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift deleted file mode 100644 index a9397e868baf..000000000000 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift +++ /dev/null @@ -1,40 +0,0 @@ -// -// InlineResponse200.swift -// -// Generated by swagger-codegen -// https://github.com/swagger-api/swagger-codegen -// - -import Foundation - - -public class InlineResponse200: JSONEncodable { - public enum Status: String { - case Available = "available" - case Pending = "pending" - case Sold = "sold" - } - public var photoUrls: [String]? - public var name: String? - public var id: Int64? - public var category: AnyObject? - public var tags: [Tag]? - /** pet status in the store */ - public var status: Status? - - public init() {} - - // MARK: JSONEncodable - func encodeToJSON() -> AnyObject { - var nillableDictionary = [String:AnyObject?]() - nillableDictionary["photoUrls"] = self.photoUrls?.encodeToJSON() - nillableDictionary["name"] = self.name - nillableDictionary["id"] = self.id?.encodeToJSON() - nillableDictionary["id"] = self.id?.encodeToJSON() - nillableDictionary["category"] = self.category - nillableDictionary["tags"] = self.tags?.encodeToJSON() - nillableDictionary["status"] = self.status?.rawValue - let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] - return dictionary - } -} diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift deleted file mode 100644 index 43cc68a5c2dd..000000000000 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// Model200Response.swift -// -// Generated by swagger-codegen -// https://github.com/swagger-api/swagger-codegen -// - -import Foundation - - -/** Model for testing model name starting with number */ -public class Model200Response: JSONEncodable { - public var name: Int32? - - public init() {} - - // MARK: JSONEncodable - func encodeToJSON() -> AnyObject { - var nillableDictionary = [String:AnyObject?]() - nillableDictionary["name"] = self.name?.encodeToJSON() - let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] - return dictionary - } -} diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift deleted file mode 100644 index 80e2ef13b241..000000000000 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// ModelReturn.swift -// -// Generated by swagger-codegen -// https://github.com/swagger-api/swagger-codegen -// - -import Foundation - - -/** Model for testing reserved words */ -public class ModelReturn: JSONEncodable { - public var _return: Int32? - - public init() {} - - // MARK: JSONEncodable - func encodeToJSON() -> AnyObject { - var nillableDictionary = [String:AnyObject?]() - nillableDictionary["return"] = self._return?.encodeToJSON() - let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] - return dictionary - } -} diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift deleted file mode 100644 index a0e40281d45a..000000000000 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// Name.swift -// -// Generated by swagger-codegen -// https://github.com/swagger-api/swagger-codegen -// - -import Foundation - - -/** Model for testing model name same as property name */ -public class Name: JSONEncodable { - public var name: Int32? - public var snakeCase: Int32? - - public init() {} - - // MARK: JSONEncodable - func encodeToJSON() -> AnyObject { - var nillableDictionary = [String:AnyObject?]() - nillableDictionary["name"] = self.name?.encodeToJSON() - nillableDictionary["snake_case"] = self.snakeCase?.encodeToJSON() - let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] - return dictionary - } -} diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ObjectReturn.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ObjectReturn.swift deleted file mode 100644 index 85985274ef44..000000000000 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ObjectReturn.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// ObjectReturn.swift -// -// Generated by swagger-codegen -// https://github.com/swagger-api/swagger-codegen -// - -import Foundation - - -public class ObjectReturn: JSONEncodable { - - public var _return: Int? - - - public init() {} - - // MARK: JSONEncodable - func encodeToJSON() -> AnyObject { - var nillableDictionary = [String:AnyObject?]() - nillableDictionary["_return"] = self._return - let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] - return dictionary - } -} diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift deleted file mode 100644 index cb92fbd2f786..000000000000 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// SpecialModelName.swift -// -// Generated by swagger-codegen -// https://github.com/swagger-api/swagger-codegen -// - -import Foundation - - -public class SpecialModelName: JSONEncodable { - public var specialPropertyName: Int64? - - public init() {} - - // MARK: JSONEncodable - func encodeToJSON() -> AnyObject { - var nillableDictionary = [String:AnyObject?]() - nillableDictionary["$special[property.name]"] = self.specialPropertyName?.encodeToJSON() - nillableDictionary["$special[property.name]"] = self.specialPropertyName?.encodeToJSON() - let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] - return dictionary - } -} From 37600e11729dce68a31af48931d15949bc62c8a8 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 20 Apr 2016 18:49:29 +0800 Subject: [PATCH 16/26] add default value to gem spec --- .../src/main/resources/ruby/gemspec.mustache | 14 +++++++------- samples/client/petstore/ruby/README.md | 2 +- samples/client/petstore/ruby/petstore.gemspec | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache b/modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache index f26fb70bc44a..65884d0f562c 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/gemspec.mustache @@ -3,15 +3,15 @@ $:.push File.expand_path("../lib", __FILE__) require "{{gemName}}/version" Gem::Specification.new do |s| - s.name = "{{gemName}}" + s.name = "{{gemName}}{{^gemName}}{{{appName}}}{{/gemName}}" s.version = {{moduleName}}::VERSION s.platform = Gem::Platform::RUBY - s.authors = ["{{gemAuthor}}"] - s.email = ["{{gemAuthorEmail}}"] - s.homepage = "{{gemHomepage}}" - s.summary = "{{gemSummary}}" - s.description = "{{gemDescription}}" - s.license = "{{gemLicense}}" + s.authors = ["{{gemAuthor}}{{^gemAuthor}}Swagger-Codegen{{/gemAuthor}}"] + s.email = ["{{gemAuthorEmail}}{{^gemAuthorEmail}}{{infoEmail}}{{/gemAuthorEmail}}"] + s.homepage = "{{gemHomepage}}{{^gemHomepage}}https://github.com/swagger-api/swagger-codegen{{/gemHomepage}}" + s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}" + s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}" + s.license = "{{gemLicense}}{{^gemLicense}}{{{licenseInfo}}}{{^licenseInfo}}Apache 2.0{{/licenseInfo}}{{/gemLicense}}" s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3' diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index d5fc3c8405b1..4dc28289fa39 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-19T23:40:36.993+08:00 +- Build date: 2016-04-20T18:46:00.664+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation diff --git a/samples/client/petstore/ruby/petstore.gemspec b/samples/client/petstore/ruby/petstore.gemspec index 55ba462e2370..08b733a09213 100644 --- a/samples/client/petstore/ruby/petstore.gemspec +++ b/samples/client/petstore/ruby/petstore.gemspec @@ -6,12 +6,12 @@ Gem::Specification.new do |s| s.name = "petstore" s.version = Petstore::VERSION s.platform = Gem::Platform::RUBY - s.authors = [""] - s.email = [""] - s.homepage = "" - s.summary = "" - s.description = "" - s.license = "" + s.authors = ["Swagger-Codegen"] + s.email = ["apiteam@swagger.io"] + s.homepage = "https://github.com/swagger-api/swagger-codegen" + s.summary = "Swagger Petstore Ruby Gem" + s.description = "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose." + s.license = "Apache 2.0" s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3' From a92ac4537ebd377f705bbfdebb17bfd78b85564a Mon Sep 17 00:00:00 2001 From: abcsun Date: Thu, 14 Apr 2016 15:21:31 +0800 Subject: [PATCH 17/26] init lumen 5.2 --- output/LumenServer/README.md | 77 ++++++ output/LumenServer/pom.xml | 102 ++++++++ .../LumenservercodegenGenerator.java | 221 ++++++++++++++++++ .../app/Console/Commands/.gitkeep | 0 .../LumenServerCodegen/app/Console/Kernel.php | 29 +++ .../app/Exceptions/Handler.php | 50 ++++ .../app/Http/Controllers/Controller.php | 10 + .../Http/Controllers/ExampleController.php | 18 ++ .../app/Http/Middleware/Authenticate.php | 44 ++++ .../app/Http/Middleware/ExampleMiddleware.php | 20 ++ .../LumenServerCodegen/app/Http/routes.php | 16 ++ .../app/Providers/AppServiceProvider.php | 18 ++ .../app/Providers/AuthServiceProvider.php | 40 ++++ .../app/Providers/EventServiceProvider.php | 19 ++ .../resources/LumenServerCodegen/app/User.php | 34 +++ .../main/resources/LumenServerCodegen/artisan | 35 +++ .../LumenServerCodegen/bootstrap/app.php | 100 ++++++++ .../LumenServerCodegen/composer.json | 17 ++ .../resources/LumenServerCodegen/phpunit.xml | 26 +++ .../LumenServerCodegen/public/.htaccess | 16 ++ .../LumenServerCodegen/public/index.php | 28 +++ .../resources/LumenServerCodegen/readme.md | 21 ++ .../LumenServerCodegen/storage/app/.gitignore | 2 + .../storage/framework/views/.gitignore | 2 + .../storage/logs/.gitignore | 2 + .../LumenServerCodegen/tests/ExampleTest.php | 20 ++ .../LumenServerCodegen/tests/TestCase.php | 14 ++ .../services/io.swagger.codegen.CodegenConfig | 1 + 28 files changed, 982 insertions(+) create mode 100644 output/LumenServer/README.md create mode 100644 output/LumenServer/pom.xml create mode 100644 output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Commands/.gitkeep create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Kernel.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Exceptions/Handler.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Controllers/Controller.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Controllers/ExampleController.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Middleware/Authenticate.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Middleware/ExampleMiddleware.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/routes.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/AppServiceProvider.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/AuthServiceProvider.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/EventServiceProvider.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/User.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/artisan create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/bootstrap/app.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/composer.json create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/phpunit.xml create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/public/.htaccess create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/public/index.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/readme.md create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/storage/app/.gitignore create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/storage/framework/views/.gitignore create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/storage/logs/.gitignore create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/tests/ExampleTest.php create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/tests/TestCase.php create mode 100644 output/LumenServer/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig diff --git a/output/LumenServer/README.md b/output/LumenServer/README.md new file mode 100644 index 000000000000..7d2059b95ac0 --- /dev/null +++ b/output/LumenServer/README.md @@ -0,0 +1,77 @@ +# Swagger Codegen for the LumenServerCodegen library + +## Overview +This is a boiler-plate project to generate your own client library with Swagger. It's goal is +to get you started with the basic plumbing so you can put in your own logic. It won't work without +your changes applied. + +## What's Swagger? +The goal of Swaggerâ„¢ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swagger removes the guesswork in calling the service. + + +Check out [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) for additional information about the Swagger project, including additional libraries with support for other languages and more. + +## How do I use this? +At this point, you've likely generated a client setup. It will include something along these lines: + +``` +. +|- README.md // this file +|- pom.xml // build script +|-- src +|--- main +|---- java +|----- io.swagger.codegen.languages.LumenservercodegenGenerator.java // generator file +|---- resources +|----- LumenServerCodegen // template files +|----- META-INF +|------ services +|------- io.swagger.codegen.CodegenConfig +``` + +You _will_ need to make changes in at least the following: + +`LumenservercodegenGenerator.java` + +Templates in this folder: + +`src/main/resources/LumenServerCodegen` + +Once modified, you can run this: + +``` +mvn package +``` + +In your generator project. A single jar file will be produced in `target`. You can now use that with codegen: + +``` +java -cp output/LumenServer/target/LumenServerCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen + +java -cp output/LumenServer/target/LumenServerCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen generate -l LumenServerCodegen -i http://petstore.swagger.io/v2/swagger.json -o lumen + +``` + +Now your templates are available to the client generator and you can write output values + +## But how do I modify this? +The `LumenservercodegenGenerator.java` has comments in it--lots of comments. There is no good substitute +for reading the code more, though. See how the `LumenservercodegenGenerator` implements `CodegenConfig`. +That class has the signature of all values that can be overridden. + +For the templates themselves, you have a number of values available to you for generation. +You can execute the `java` command from above while passing different debug flags to show +the object you have available during client generation: + +``` +# The following additional debug options are available for all codegen targets: +# -DdebugSwagger prints the OpenAPI Specification as interpreted by the codegen +# -DdebugModels prints models passed to the template engine +# -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 io.swagger.codegen.Codegen -l LumenServerCodegen -o ./test +``` + +Will, for example, output the debug info for operations. You can use this info +in the `api.mustache` file. \ No newline at end of file diff --git a/output/LumenServer/pom.xml b/output/LumenServer/pom.xml new file mode 100644 index 000000000000..b8791dddd881 --- /dev/null +++ b/output/LumenServer/pom.xml @@ -0,0 +1,102 @@ + + 4.0.0 + io.swagger + LumenServerCodegen-swagger-codegen + jar + LumenServerCodegen-swagger-codegen + 1.0.0 + + 2.2.0 + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + pertest + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add_sources + generate-sources + + add-source + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + + + + io.swagger + swagger-codegen + ${swagger-codegen-version} + provided + + + + 2.1.6 + 1.0.0 + 4.8.1 + + diff --git a/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java b/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java new file mode 100644 index 000000000000..e3f6309e973a --- /dev/null +++ b/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java @@ -0,0 +1,221 @@ +package io.swagger.codegen.languages; + +import io.swagger.codegen.*; +import io.swagger.models.properties.*; + +import java.util.*; +import java.io.File; + +public class LumenservercodegenGenerator extends DefaultCodegen implements CodegenConfig { + + // source folder where to write the files + protected String sourceFolder = "src"; + protected String apiVersion = "1.0.0"; + + /** + * Configures the type of generator. + * + * @return the CodegenType for this generator + * @see io.swagger.codegen.CodegenType + */ + public CodegenType getTag() { + return CodegenType.CLIENT; + } + + /** + * Configures a friendly name for the generator. This will be used by the generator + * to select the library with the -l flag. + * + * @return the friendly name for the generator + */ + public String getName() { + return "LumenServerCodegen"; + } + + /** + * Returns human-friendly help for the generator. Provide the consumer with help + * tips, parameters here + * + * @return A string value for the help message + */ + public String getHelp() { + return "Generates a LumenServerCodegen client library."; + } + + public LumenservercodegenGenerator() { + super(); + + // set the output folder here + outputFolder = "generated-code/LumenServerCodegen"; + + /** + * Models. You can write model files using the modelTemplateFiles map. + * if you want to create one template for file, you can do so here. + * for multiple files for model, just put another entry in the `modelTemplateFiles` with + * a different extension + */ + // modelTemplateFiles.put( + // "model.mustache", // the template to use + // ".sample"); // the extension for each file to write + + /** + * Api classes. You can write classes for each Api file with the apiTemplateFiles map. + * as with models, add multiple entries with different extensions for multiple files per + * class + */ + // apiTemplateFiles.put( + // "api.mustache", // the template to use + // ".sample"); // the extension for each file to write + + /** + * Template Location. This is the location which templates will be read from. The generator + * will use the resource stream to attempt to read the templates. + */ + templateDir = "LumenServerCodegen"; + + /** + * Api Package. Optional, if needed, this can be used in templates + */ + apiPackage = "io.swagger.client.api"; + + /** + * Model Package. Optional, if needed, this can be used in templates + */ + modelPackage = "io.swagger.client.model"; + + /** + * Reserved words. Override this with reserved words specific to your language + */ + reservedWords = new HashSet ( + Arrays.asList( + "sample1", // replace with static values + "sample2") + ); + + /** + * Additional Properties. These values can be passed to the templates and + * are available in models, apis, and supporting files + */ + additionalProperties.put("apiVersion", apiVersion); + + /** + * Supporting Files. You can write single files for the generator with the + * entire object tree available. If the input file has a suffix of `.mustache + * it will be processed by the template engine. Otherwise, it will be copied + */ + String packagePath = "LumenServer"; + supportingFiles.add(new SupportingFile("composer.json", packagePath, "composer.json")); + supportingFiles.add(new SupportingFile("readme.md", packagePath, "readme.md")); + supportingFiles.add(new SupportingFile("artisan", packagePath, "artisan")); + // supportingFiles.add(new SupportingFile("server.php", packagePath, "server.php")); + + supportingFiles.add(new SupportingFile("bootstrap" + File.separator + "app.php", packagePath + File.separator + "bootstrap", "app.php")); + + supportingFiles.add(new SupportingFile("public" + File.separator + "index.php", packagePath + File.separator + "public", "index.php")); + + supportingFiles.add(new SupportingFile("app" + File.separator + "User.php", packagePath + File.separator + "app", "User.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Console" + File.separator + "Kernel.php", packagePath + File.separator + "app" + File.separator + "Console", "Kernel.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Exceptions" + File.separator + "Handler.php", packagePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php")); + // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Kernel.php", packagePath + File.separator + "app" + File.separator + "Http", "Kernel.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "routes.php", packagePath + File.separator + "app" + File.separator + "Http", "routes.php")); + + supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Controller.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "ExampleController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "ExampleController.php")); + // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator + "AuthController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator, "AuthController.php")); + // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator + "PasswordController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator, "PasswordController.php")); + + supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "Authenticate.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "ExampleMiddleware.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "ExampleMiddleware.php")); + // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "RedirectIfAuthenticated.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "RedirectIfAuthenticated.php")); + // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "VerifyCsrfToken.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "VerifyCsrfToken.php")); + + // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Requests" + File.separator + "Request.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Requests" + File.separator, "Request.php")); + + supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "AppServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "AppServiceProvider.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "AuthServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "AuthServiceProvider.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "EventServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "EventServiceProvider.php")); + // supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "RouteServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "RouteServiceProvider.php")); + + // supportingFiles.add(new SupportingFile("config" + File.separator + "app.php", packagePath + File.separator + "config" + File.separator, "app.php")); + + /** + * Language Specific Primitives. These types will not trigger imports by + * the client generator + */ + languageSpecificPrimitives = new HashSet( + Arrays.asList( + "Type1", // replace these with your types + "Type2") + ); + } + + /** + * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping + * those terms here. This logic is only called if a variable matches the reseved words + * + * @return the escaped term + */ + @Override + public String escapeReservedWord(String name) { + return "_" + name; // add an underscore to the name + } + + /** + * Location to write model files. You can use the modelPackage() as defined when the class is + * instantiated + */ + public String modelFileFolder() { + return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar); + } + + /** + * Location to write api files. You can use the apiPackage() as defined when the class is + * instantiated + */ + @Override + public String apiFileFolder() { + return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar); + } + + /** + * Optional - type declaration. This is a String which is used by the templates to instantiate your + * types. There is typically special handling for different property types + * + * @return a string value used as the `dataType` field for model templates, `returnType` for api templates + */ + @Override + public String getTypeDeclaration(Property p) { + if(p instanceof ArrayProperty) { + ArrayProperty ap = (ArrayProperty) p; + Property inner = ap.getItems(); + return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]"; + } + else if (p instanceof MapProperty) { + MapProperty mp = (MapProperty) p; + Property inner = mp.getAdditionalProperties(); + return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]"; + } + return super.getTypeDeclaration(p); + } + + /** + * Optional - swagger type conversion. This is used to map swagger types in a `Property` into + * either language specific types via `typeMapping` or into complex models if there is not a mapping. + * + * @return a string value of the type or complex model for this property + * @see io.swagger.models.properties.Property + */ + @Override + public String getSwaggerType(Property p) { + String swaggerType = super.getSwaggerType(p); + String type = null; + if(typeMapping.containsKey(swaggerType)) { + type = typeMapping.get(swaggerType); + if(languageSpecificPrimitives.contains(type)) + return toModelName(type); + } + else + type = swaggerType; + return toModelName(type); + } +} \ No newline at end of file diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Commands/.gitkeep b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Commands/.gitkeep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Kernel.php b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Kernel.php new file mode 100644 index 000000000000..ad6e311cdd04 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Kernel.php @@ -0,0 +1,29 @@ +auth = $auth; + } + + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @param string|null $guard + * @return mixed + */ + public function handle($request, Closure $next, $guard = null) + { + if ($this->auth->guard($guard)->guest()) { + return response('Unauthorized.', 401); + } + + return $next($request); + } +} diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Middleware/ExampleMiddleware.php b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Middleware/ExampleMiddleware.php new file mode 100644 index 000000000000..166581c8e69b --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Middleware/ExampleMiddleware.php @@ -0,0 +1,20 @@ +get('/', function () use ($app) { + return $app->version(); +}); diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/AppServiceProvider.php b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/AppServiceProvider.php new file mode 100644 index 000000000000..ddec04694c37 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/AppServiceProvider.php @@ -0,0 +1,18 @@ +input('api_token')) { + return User::where('api_token', $request->input('api_token'))->first(); + } + }); + } +} diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/EventServiceProvider.php b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/EventServiceProvider.php new file mode 100644 index 000000000000..0b8f3934fb3c --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/EventServiceProvider.php @@ -0,0 +1,19 @@ + [ + 'App\Listeners\EventListener', + ], + ]; +} diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/User.php b/output/LumenServer/src/main/resources/LumenServerCodegen/app/User.php new file mode 100644 index 000000000000..fd4de31172cf --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/app/User.php @@ -0,0 +1,34 @@ +make( + 'Illuminate\Contracts\Console\Kernel' +); + +exit($kernel->handle(new ArgvInput, new ConsoleOutput)); diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/bootstrap/app.php b/output/LumenServer/src/main/resources/LumenServerCodegen/bootstrap/app.php new file mode 100644 index 000000000000..5487cb5480f0 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/bootstrap/app.php @@ -0,0 +1,100 @@ +load(); +} catch (Dotenv\Exception\InvalidPathException $e) { + // +} + +/* +|-------------------------------------------------------------------------- +| Create The Application +|-------------------------------------------------------------------------- +| +| Here we will load the environment and create the application instance +| that serves as the central piece of this framework. We'll use this +| application as an "IoC" container and router for this framework. +| +*/ + +$app = new Laravel\Lumen\Application( + realpath(__DIR__.'/../') +); + +// $app->withFacades(); + +// $app->withEloquent(); + +/* +|-------------------------------------------------------------------------- +| Register Container Bindings +|-------------------------------------------------------------------------- +| +| Now we will register a few bindings in the service container. We will +| register the exception handler and the console kernel. You may add +| your own bindings here if you like or you can make another file. +| +*/ + +$app->singleton( + Illuminate\Contracts\Debug\ExceptionHandler::class, + App\Exceptions\Handler::class +); + +$app->singleton( + Illuminate\Contracts\Console\Kernel::class, + App\Console\Kernel::class +); + +/* +|-------------------------------------------------------------------------- +| Register Middleware +|-------------------------------------------------------------------------- +| +| Next, we will register the middleware with the application. These can +| be global middleware that run before and after each request into a +| route or middleware that'll be assigned to some specific routes. +| +*/ + +// $app->middleware([ +// App\Http\Middleware\ExampleMiddleware::class +// ]); + +// $app->routeMiddleware([ +// 'auth' => App\Http\Middleware\Authenticate::class, +// ]); + +/* +|-------------------------------------------------------------------------- +| Register Service Providers +|-------------------------------------------------------------------------- +| +| Here we will register all of the application's service providers which +| are used to bind services into the container. Service providers are +| totally optional, so you are not required to uncomment this line. +| +*/ + +// $app->register(App\Providers\AppServiceProvider::class); +// $app->register(App\Providers\AuthServiceProvider::class); +// $app->register(App\Providers\EventServiceProvider::class); + +/* +|-------------------------------------------------------------------------- +| Load The Application Routes +|-------------------------------------------------------------------------- +| +| Next we will include the routes file so that they can all be added to +| the application. This will provide all of the URLs the application +| can respond to, as well as the controllers that may handle them. +| +*/ + +$app->group(['namespace' => 'App\Http\Controllers'], function ($app) { + require __DIR__.'/../app/Http/routes.php'; +}); + +return $app; diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/composer.json b/output/LumenServer/src/main/resources/LumenServerCodegen/composer.json new file mode 100644 index 000000000000..62df199e76a7 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/composer.json @@ -0,0 +1,17 @@ +{ + "name": "laravel/lumen", + "description": "The Laravel Lumen Framework.", + "keywords": ["framework", "laravel", "lumen"], + "license": "MIT", + "type": "project", + "require": { + "php": ">=5.5.9", + "laravel/lumen-framework": "5.2.*", + "vlucas/phpdotenv": "~2.2" + }, + "autoload": { + "psr-4": { + "App\\": "app/" + } + } +} diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/phpunit.xml b/output/LumenServer/src/main/resources/LumenServerCodegen/phpunit.xml new file mode 100644 index 000000000000..77c29fe1630e --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/phpunit.xml @@ -0,0 +1,26 @@ + + + + + ./tests/ + + + + + app/ + + + + + + + diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/public/.htaccess b/output/LumenServer/src/main/resources/LumenServerCodegen/public/.htaccess new file mode 100644 index 000000000000..8eb2dd0ddfa5 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/public/.htaccess @@ -0,0 +1,16 @@ + + + Options -MultiViews + + + RewriteEngine On + + # Redirect Trailing Slashes If Not A Folder... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)/$ /$1 [L,R=301] + + # Handle Front Controller... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/public/index.php b/output/LumenServer/src/main/resources/LumenServerCodegen/public/index.php new file mode 100644 index 000000000000..04aa08688e00 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/public/index.php @@ -0,0 +1,28 @@ +run(); diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/readme.md b/output/LumenServer/src/main/resources/LumenServerCodegen/readme.md new file mode 100644 index 000000000000..9605e5f3f459 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/readme.md @@ -0,0 +1,21 @@ +## Lumen PHP Framework + +[![Build Status](https://travis-ci.org/laravel/lumen-framework.svg)](https://travis-ci.org/laravel/lumen-framework) +[![Total Downloads](https://poser.pugx.org/laravel/lumen-framework/d/total.svg)](https://packagist.org/packages/laravel/lumen-framework) +[![Latest Stable Version](https://poser.pugx.org/laravel/lumen-framework/v/stable.svg)](https://packagist.org/packages/laravel/lumen-framework) +[![Latest Unstable Version](https://poser.pugx.org/laravel/lumen-framework/v/unstable.svg)](https://packagist.org/packages/laravel/lumen-framework) +[![License](https://poser.pugx.org/laravel/lumen-framework/license.svg)](https://packagist.org/packages/laravel/lumen-framework) + +Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching. + +## Official Documentation + +Documentation for the framework can be found on the [Lumen website](http://lumen.laravel.com/docs). + +## Security Vulnerabilities + +If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. + +### License + +The Lumen framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/storage/app/.gitignore b/output/LumenServer/src/main/resources/LumenServerCodegen/storage/app/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/storage/app/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/storage/framework/views/.gitignore b/output/LumenServer/src/main/resources/LumenServerCodegen/storage/framework/views/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/storage/framework/views/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/storage/logs/.gitignore b/output/LumenServer/src/main/resources/LumenServerCodegen/storage/logs/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/storage/logs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/tests/ExampleTest.php b/output/LumenServer/src/main/resources/LumenServerCodegen/tests/ExampleTest.php new file mode 100644 index 000000000000..2b206c66173e --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/tests/ExampleTest.php @@ -0,0 +1,20 @@ +get('/'); + + $this->assertEquals( + $this->response->getContent(), $this->app->version() + ); + } +} diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/tests/TestCase.php b/output/LumenServer/src/main/resources/LumenServerCodegen/tests/TestCase.php new file mode 100644 index 000000000000..651d9cbd67f3 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/tests/TestCase.php @@ -0,0 +1,14 @@ + Date: Fri, 15 Apr 2016 18:07:58 +0800 Subject: [PATCH 18/26] add route.mustache --- .../LumenservercodegenGenerator.java | 16 +++++++++- .../LumenServerCodegen/index.mustache | 30 ++++++++++++++++++ .../LumenServerCodegen/model.mustache | 15 +++++++++ .../LumenServerCodegen/route.mustache | 31 +++++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/index.mustache create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/model.mustache create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/route.mustache diff --git a/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java b/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java index e3f6309e973a..434c087ac7f9 100644 --- a/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java +++ b/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java @@ -47,6 +47,12 @@ public class LumenservercodegenGenerator extends DefaultCodegen implements Codeg // set the output folder here outputFolder = "generated-code/LumenServerCodegen"; + String packagePath = "SwaggerServer"; + + modelPackage = packagePath + "\\lib\\Models"; + apiPackage = packagePath + "\\lib"; + // outputFolder = "generated-code" + File.separator + "slim"; + modelTemplateFiles.put("model.mustache", ".php"); /** * Models. You can write model files using the modelTemplateFiles map. @@ -66,6 +72,12 @@ public class LumenservercodegenGenerator extends DefaultCodegen implements Codeg // apiTemplateFiles.put( // "api.mustache", // the template to use // ".sample"); // the extension for each file to write + + + // no api files + apiTemplateFiles.clear(); + + // embeddedTemplateDir = templateDir = "slim"; /** * Template Location. This is the location which templates will be read from. The generator @@ -103,7 +115,9 @@ public class LumenservercodegenGenerator extends DefaultCodegen implements Codeg * entire object tree available. If the input file has a suffix of `.mustache * it will be processed by the template engine. Otherwise, it will be copied */ - String packagePath = "LumenServer"; + // supportingFiles.add(new SupportingFile("index.mustache", packagePath, "index.php")); + supportingFiles.add(new SupportingFile("route.mustache", packagePath, "route.php")); + supportingFiles.add(new SupportingFile("composer.json", packagePath, "composer.json")); supportingFiles.add(new SupportingFile("readme.md", packagePath, "readme.md")); supportingFiles.add(new SupportingFile("artisan", packagePath, "artisan")); diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/index.mustache b/output/LumenServer/src/main/resources/LumenServerCodegen/index.mustache new file mode 100644 index 000000000000..fa5b9105f524 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/index.mustache @@ -0,0 +1,30 @@ +{{httpMethod}}('{{path}}', function($request, $response, $args) { + {{#hasHeaderParams}}$headers = $request->getHeaders();{{/hasHeaderParams}} + {{#hasQueryParams}}$queryParams = $request->getQueryParams(); + {{#queryParams}}${{paramName}} = $queryParams['{{paramName}}'];{{newline}} {{/queryParams}}{{/hasQueryParams}} + {{#hasFormParams}}{{#formParams}}${{paramName}} = $args['{{paramName}}'];{{newline}} {{/formParams}}{{/hasFormParams}} + {{#hasBodyParam}}$body = $request->getParsedBody();{{/hasBodyParam}} + $response->write('How about implementing {{nickname}} as a {{httpMethod}} method ?'); + return $response; + }); + +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +$app->run(); \ No newline at end of file diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/model.mustache b/output/LumenServer/src/main/resources/LumenServerCodegen/model.mustache new file mode 100644 index 000000000000..48f586793ee3 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/model.mustache @@ -0,0 +1,15 @@ +getQueryParams(); + {{#queryParams}}${{paramName}} = $queryParams['{{paramName}}'];{{newline}} {{/queryParams}}{{/hasQueryParams}} + + {{#hasQueryParams}}$inputs = Request::all(); + {{#inputs}}${{paramName}} = $inputs['{{paramName}}'];{{newline}} + {{/inputs}}{{/hasQueryParams}} + + {{#hasFormParams}}{{#formParams}}${{paramName}} = $args['{{paramName}}'];{{newline}} {{/formParams}}{{/hasFormParams}} + {{#hasBodyParam}}$body = $app->request->getParsedBody();{{/hasBodyParam}} + return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); + }); + +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + From 1b71597e84d2fb15ce8753b7d4ed88a4cd94e235 Mon Sep 17 00:00:00 2001 From: abcsun Date: Tue, 19 Apr 2016 12:14:22 +0800 Subject: [PATCH 19/26] update the routes.mustache --- .../LumenservercodegenGenerator.java | 12 +++---- .../app/Http/routes.mustache | 28 +++++++++++++++++ .../LumenServerCodegen/app/Http/routes.php | 16 ---------- .../LumenServerCodegen/bootstrap/app.php | 2 ++ .../LumenServerCodegen/index.mustache | 30 ------------------ .../LumenServerCodegen/model.mustache | 15 --------- .../resources/LumenServerCodegen/phpunit.xml | 26 ---------------- .../LumenServerCodegen/route.mustache | 31 ------------------- .../LumenServerCodegen/routes.mustache | 28 +++++++++++++++++ 9 files changed, 64 insertions(+), 124 deletions(-) create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/routes.mustache delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/routes.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/index.mustache delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/model.mustache delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/phpunit.xml delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/route.mustache create mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/routes.mustache diff --git a/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java b/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java index 434c087ac7f9..01974e13c305 100644 --- a/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java +++ b/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java @@ -49,10 +49,10 @@ public class LumenservercodegenGenerator extends DefaultCodegen implements Codeg outputFolder = "generated-code/LumenServerCodegen"; String packagePath = "SwaggerServer"; - modelPackage = packagePath + "\\lib\\Models"; - apiPackage = packagePath + "\\lib"; - // outputFolder = "generated-code" + File.separator + "slim"; - modelTemplateFiles.put("model.mustache", ".php"); + // modelPackage = packagePath + "\\lib\\Models"; + // apiPackage = packagePath + "\\lib"; + // // outputFolder = "generated-code" + File.separator + "slim"; + // modelTemplateFiles.put("model.mustache", ".php"); /** * Models. You can write model files using the modelTemplateFiles map. @@ -116,7 +116,7 @@ public class LumenservercodegenGenerator extends DefaultCodegen implements Codeg * it will be processed by the template engine. Otherwise, it will be copied */ // supportingFiles.add(new SupportingFile("index.mustache", packagePath, "index.php")); - supportingFiles.add(new SupportingFile("route.mustache", packagePath, "route.php")); + // supportingFiles.add(new SupportingFile("routes.mustache", packagePath, "routes.php")); supportingFiles.add(new SupportingFile("composer.json", packagePath, "composer.json")); supportingFiles.add(new SupportingFile("readme.md", packagePath, "readme.md")); @@ -131,7 +131,7 @@ public class LumenservercodegenGenerator extends DefaultCodegen implements Codeg supportingFiles.add(new SupportingFile("app" + File.separator + "Console" + File.separator + "Kernel.php", packagePath + File.separator + "app" + File.separator + "Console", "Kernel.php")); supportingFiles.add(new SupportingFile("app" + File.separator + "Exceptions" + File.separator + "Handler.php", packagePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php")); // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Kernel.php", packagePath + File.separator + "app" + File.separator + "Http", "Kernel.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "routes.php", packagePath + File.separator + "app" + File.separator + "Http", "routes.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "routes.mustache", packagePath + File.separator + "app" + File.separator + "Http", "routes.php")); supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Controller.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php")); supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "ExampleController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "ExampleController.php")); diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/routes.mustache b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/routes.mustache new file mode 100644 index 000000000000..3166f9479357 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/routes.mustache @@ -0,0 +1,28 @@ +get('/', function () use ($app) { + return $app->version(); +}); + +{{#apis}}{{#operations}}{{#operation}} +/** + * {{httpMethod}} {{nickname}} + * Summary: {{summary}} + * Notes: {{notes}} +{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}} + */ +$app->{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}}, {{/pathParams}}$null = null) use ($app) { + {{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}} + {{#hasQueryParams}}{{#queryParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} + {{/queryParams}}{{/hasQueryParams}} + {{#hasFormParams}}{{#formParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} {{/formParams}}{{/hasFormParams}} + + return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); + }); + +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/routes.php b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/routes.php deleted file mode 100644 index f2c5b17fdbf7..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/routes.php +++ /dev/null @@ -1,16 +0,0 @@ -get('/', function () use ($app) { - return $app->version(); -}); diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/bootstrap/app.php b/output/LumenServer/src/main/resources/LumenServerCodegen/bootstrap/app.php index 5487cb5480f0..9bc334dd8866 100644 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/bootstrap/app.php +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/bootstrap/app.php @@ -48,6 +48,8 @@ $app->singleton( App\Console\Kernel::class ); +class_alias('Illuminate\Support\Facades\Request', 'Request'); //to use the Reqesut facade + /* |-------------------------------------------------------------------------- | Register Middleware diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/index.mustache b/output/LumenServer/src/main/resources/LumenServerCodegen/index.mustache deleted file mode 100644 index fa5b9105f524..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/index.mustache +++ /dev/null @@ -1,30 +0,0 @@ -{{httpMethod}}('{{path}}', function($request, $response, $args) { - {{#hasHeaderParams}}$headers = $request->getHeaders();{{/hasHeaderParams}} - {{#hasQueryParams}}$queryParams = $request->getQueryParams(); - {{#queryParams}}${{paramName}} = $queryParams['{{paramName}}'];{{newline}} {{/queryParams}}{{/hasQueryParams}} - {{#hasFormParams}}{{#formParams}}${{paramName}} = $args['{{paramName}}'];{{newline}} {{/formParams}}{{/hasFormParams}} - {{#hasBodyParam}}$body = $request->getParsedBody();{{/hasBodyParam}} - $response->write('How about implementing {{nickname}} as a {{httpMethod}} method ?'); - return $response; - }); - -{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} - -$app->run(); \ No newline at end of file diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/model.mustache b/output/LumenServer/src/main/resources/LumenServerCodegen/model.mustache deleted file mode 100644 index 48f586793ee3..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/model.mustache +++ /dev/null @@ -1,15 +0,0 @@ - - - - - ./tests/ - - - - - app/ - - - - - - - diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/route.mustache b/output/LumenServer/src/main/resources/LumenServerCodegen/route.mustache deleted file mode 100644 index 415c4c082d8c..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/route.mustache +++ /dev/null @@ -1,31 +0,0 @@ -getQueryParams(); - {{#queryParams}}${{paramName}} = $queryParams['{{paramName}}'];{{newline}} {{/queryParams}}{{/hasQueryParams}} - - {{#hasQueryParams}}$inputs = Request::all(); - {{#inputs}}${{paramName}} = $inputs['{{paramName}}'];{{newline}} - {{/inputs}}{{/hasQueryParams}} - - {{#hasFormParams}}{{#formParams}}${{paramName}} = $args['{{paramName}}'];{{newline}} {{/formParams}}{{/hasFormParams}} - {{#hasBodyParam}}$body = $app->request->getParsedBody();{{/hasBodyParam}} - return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); - }); - -{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} - diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/routes.mustache b/output/LumenServer/src/main/resources/LumenServerCodegen/routes.mustache new file mode 100644 index 000000000000..be2fac8d86e5 --- /dev/null +++ b/output/LumenServer/src/main/resources/LumenServerCodegen/routes.mustache @@ -0,0 +1,28 @@ +get('/', function () use ($app) { + return $app->version(); +}); + +{{#apis}}{{#operations}}{{#operation}} +/** + * {{httpMethod}} {{nickname}} + * Summary: {{summary}} + * Notes: {{notes}} +{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}} + */ +Route::{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}}, {{/pathParams}}null) use ($app) { + {{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}} + {{#hasQueryParams}}{{#queryParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} + {{/queryParams}}{{/hasQueryParams}} + {{#hasFormParams}}{{#formParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} {{/formParams}}{{/hasFormParams}} + + return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); + }); + +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + From 8866403629301f2126e8134acbfb691441d394f2 Mon Sep 17 00:00:00 2001 From: abcsun Date: Wed, 20 Apr 2016 15:52:18 +0800 Subject: [PATCH 20/26] remove the output folder --- output/LumenServer/README.md | 77 ------ output/LumenServer/pom.xml | 102 -------- .../LumenservercodegenGenerator.java | 235 ------------------ .../app/Console/Commands/.gitkeep | 0 .../LumenServerCodegen/app/Console/Kernel.php | 29 --- .../app/Exceptions/Handler.php | 50 ---- .../app/Http/Controllers/Controller.php | 10 - .../Http/Controllers/ExampleController.php | 18 -- .../app/Http/Middleware/Authenticate.php | 44 ---- .../app/Http/Middleware/ExampleMiddleware.php | 20 -- .../app/Http/routes.mustache | 28 --- .../app/Providers/AppServiceProvider.php | 18 -- .../app/Providers/AuthServiceProvider.php | 40 --- .../app/Providers/EventServiceProvider.php | 19 -- .../resources/LumenServerCodegen/app/User.php | 34 --- .../main/resources/LumenServerCodegen/artisan | 35 --- .../LumenServerCodegen/bootstrap/app.php | 102 -------- .../LumenServerCodegen/composer.json | 17 -- .../LumenServerCodegen/public/.htaccess | 16 -- .../LumenServerCodegen/public/index.php | 28 --- .../resources/LumenServerCodegen/readme.md | 21 -- .../LumenServerCodegen/routes.mustache | 28 --- .../LumenServerCodegen/storage/app/.gitignore | 2 - .../storage/framework/views/.gitignore | 2 - .../storage/logs/.gitignore | 2 - .../LumenServerCodegen/tests/ExampleTest.php | 20 -- .../LumenServerCodegen/tests/TestCase.php | 14 -- .../services/io.swagger.codegen.CodegenConfig | 1 - 28 files changed, 1012 deletions(-) delete mode 100644 output/LumenServer/README.md delete mode 100644 output/LumenServer/pom.xml delete mode 100644 output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Commands/.gitkeep delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Kernel.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Exceptions/Handler.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Controllers/Controller.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Controllers/ExampleController.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Middleware/Authenticate.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Middleware/ExampleMiddleware.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/routes.mustache delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/AppServiceProvider.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/AuthServiceProvider.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/EventServiceProvider.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/app/User.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/artisan delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/bootstrap/app.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/composer.json delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/public/.htaccess delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/public/index.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/readme.md delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/routes.mustache delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/storage/app/.gitignore delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/storage/framework/views/.gitignore delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/storage/logs/.gitignore delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/tests/ExampleTest.php delete mode 100644 output/LumenServer/src/main/resources/LumenServerCodegen/tests/TestCase.php delete mode 100644 output/LumenServer/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig diff --git a/output/LumenServer/README.md b/output/LumenServer/README.md deleted file mode 100644 index 7d2059b95ac0..000000000000 --- a/output/LumenServer/README.md +++ /dev/null @@ -1,77 +0,0 @@ -# Swagger Codegen for the LumenServerCodegen library - -## Overview -This is a boiler-plate project to generate your own client library with Swagger. It's goal is -to get you started with the basic plumbing so you can put in your own logic. It won't work without -your changes applied. - -## What's Swagger? -The goal of Swaggerâ„¢ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swagger removes the guesswork in calling the service. - - -Check out [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) for additional information about the Swagger project, including additional libraries with support for other languages and more. - -## How do I use this? -At this point, you've likely generated a client setup. It will include something along these lines: - -``` -. -|- README.md // this file -|- pom.xml // build script -|-- src -|--- main -|---- java -|----- io.swagger.codegen.languages.LumenservercodegenGenerator.java // generator file -|---- resources -|----- LumenServerCodegen // template files -|----- META-INF -|------ services -|------- io.swagger.codegen.CodegenConfig -``` - -You _will_ need to make changes in at least the following: - -`LumenservercodegenGenerator.java` - -Templates in this folder: - -`src/main/resources/LumenServerCodegen` - -Once modified, you can run this: - -``` -mvn package -``` - -In your generator project. A single jar file will be produced in `target`. You can now use that with codegen: - -``` -java -cp output/LumenServer/target/LumenServerCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen - -java -cp output/LumenServer/target/LumenServerCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen generate -l LumenServerCodegen -i http://petstore.swagger.io/v2/swagger.json -o lumen - -``` - -Now your templates are available to the client generator and you can write output values - -## But how do I modify this? -The `LumenservercodegenGenerator.java` has comments in it--lots of comments. There is no good substitute -for reading the code more, though. See how the `LumenservercodegenGenerator` implements `CodegenConfig`. -That class has the signature of all values that can be overridden. - -For the templates themselves, you have a number of values available to you for generation. -You can execute the `java` command from above while passing different debug flags to show -the object you have available during client generation: - -``` -# The following additional debug options are available for all codegen targets: -# -DdebugSwagger prints the OpenAPI Specification as interpreted by the codegen -# -DdebugModels prints models passed to the template engine -# -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 io.swagger.codegen.Codegen -l LumenServerCodegen -o ./test -``` - -Will, for example, output the debug info for operations. You can use this info -in the `api.mustache` file. \ No newline at end of file diff --git a/output/LumenServer/pom.xml b/output/LumenServer/pom.xml deleted file mode 100644 index b8791dddd881..000000000000 --- a/output/LumenServer/pom.xml +++ /dev/null @@ -1,102 +0,0 @@ - - 4.0.0 - io.swagger - LumenServerCodegen-swagger-codegen - jar - LumenServerCodegen-swagger-codegen - 1.0.0 - - 2.2.0 - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.12 - - - - loggerPath - conf/log4j.properties - - - -Xms512m -Xmx1500m - methods - pertest - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.2 - - - - jar - test-jar - - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add_sources - generate-sources - - add-source - - - - src/main/java - - - - - add_test_sources - generate-test-sources - - add-test-source - - - - src/test/java - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - - - - - - - io.swagger - swagger-codegen - ${swagger-codegen-version} - provided - - - - 2.1.6 - 1.0.0 - 4.8.1 - - diff --git a/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java b/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java deleted file mode 100644 index 01974e13c305..000000000000 --- a/output/LumenServer/src/main/java/io/swagger/codegen/languages/LumenservercodegenGenerator.java +++ /dev/null @@ -1,235 +0,0 @@ -package io.swagger.codegen.languages; - -import io.swagger.codegen.*; -import io.swagger.models.properties.*; - -import java.util.*; -import java.io.File; - -public class LumenservercodegenGenerator extends DefaultCodegen implements CodegenConfig { - - // source folder where to write the files - protected String sourceFolder = "src"; - protected String apiVersion = "1.0.0"; - - /** - * Configures the type of generator. - * - * @return the CodegenType for this generator - * @see io.swagger.codegen.CodegenType - */ - public CodegenType getTag() { - return CodegenType.CLIENT; - } - - /** - * Configures a friendly name for the generator. This will be used by the generator - * to select the library with the -l flag. - * - * @return the friendly name for the generator - */ - public String getName() { - return "LumenServerCodegen"; - } - - /** - * Returns human-friendly help for the generator. Provide the consumer with help - * tips, parameters here - * - * @return A string value for the help message - */ - public String getHelp() { - return "Generates a LumenServerCodegen client library."; - } - - public LumenservercodegenGenerator() { - super(); - - // set the output folder here - outputFolder = "generated-code/LumenServerCodegen"; - String packagePath = "SwaggerServer"; - - // modelPackage = packagePath + "\\lib\\Models"; - // apiPackage = packagePath + "\\lib"; - // // outputFolder = "generated-code" + File.separator + "slim"; - // modelTemplateFiles.put("model.mustache", ".php"); - - /** - * Models. You can write model files using the modelTemplateFiles map. - * if you want to create one template for file, you can do so here. - * for multiple files for model, just put another entry in the `modelTemplateFiles` with - * a different extension - */ - // modelTemplateFiles.put( - // "model.mustache", // the template to use - // ".sample"); // the extension for each file to write - - /** - * Api classes. You can write classes for each Api file with the apiTemplateFiles map. - * as with models, add multiple entries with different extensions for multiple files per - * class - */ - // apiTemplateFiles.put( - // "api.mustache", // the template to use - // ".sample"); // the extension for each file to write - - - // no api files - apiTemplateFiles.clear(); - - // embeddedTemplateDir = templateDir = "slim"; - - /** - * Template Location. This is the location which templates will be read from. The generator - * will use the resource stream to attempt to read the templates. - */ - templateDir = "LumenServerCodegen"; - - /** - * Api Package. Optional, if needed, this can be used in templates - */ - apiPackage = "io.swagger.client.api"; - - /** - * Model Package. Optional, if needed, this can be used in templates - */ - modelPackage = "io.swagger.client.model"; - - /** - * Reserved words. Override this with reserved words specific to your language - */ - reservedWords = new HashSet ( - Arrays.asList( - "sample1", // replace with static values - "sample2") - ); - - /** - * Additional Properties. These values can be passed to the templates and - * are available in models, apis, and supporting files - */ - additionalProperties.put("apiVersion", apiVersion); - - /** - * Supporting Files. You can write single files for the generator with the - * entire object tree available. If the input file has a suffix of `.mustache - * it will be processed by the template engine. Otherwise, it will be copied - */ - // supportingFiles.add(new SupportingFile("index.mustache", packagePath, "index.php")); - // supportingFiles.add(new SupportingFile("routes.mustache", packagePath, "routes.php")); - - supportingFiles.add(new SupportingFile("composer.json", packagePath, "composer.json")); - supportingFiles.add(new SupportingFile("readme.md", packagePath, "readme.md")); - supportingFiles.add(new SupportingFile("artisan", packagePath, "artisan")); - // supportingFiles.add(new SupportingFile("server.php", packagePath, "server.php")); - - supportingFiles.add(new SupportingFile("bootstrap" + File.separator + "app.php", packagePath + File.separator + "bootstrap", "app.php")); - - supportingFiles.add(new SupportingFile("public" + File.separator + "index.php", packagePath + File.separator + "public", "index.php")); - - supportingFiles.add(new SupportingFile("app" + File.separator + "User.php", packagePath + File.separator + "app", "User.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Console" + File.separator + "Kernel.php", packagePath + File.separator + "app" + File.separator + "Console", "Kernel.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Exceptions" + File.separator + "Handler.php", packagePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Kernel.php", packagePath + File.separator + "app" + File.separator + "Http", "Kernel.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "routes.mustache", packagePath + File.separator + "app" + File.separator + "Http", "routes.php")); - - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Controller.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "ExampleController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "ExampleController.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator + "AuthController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator, "AuthController.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator + "PasswordController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator, "PasswordController.php")); - - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "Authenticate.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "ExampleMiddleware.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "ExampleMiddleware.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "RedirectIfAuthenticated.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "RedirectIfAuthenticated.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "VerifyCsrfToken.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "VerifyCsrfToken.php")); - - // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Requests" + File.separator + "Request.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Requests" + File.separator, "Request.php")); - - supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "AppServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "AppServiceProvider.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "AuthServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "AuthServiceProvider.php")); - supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "EventServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "EventServiceProvider.php")); - // supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "RouteServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "RouteServiceProvider.php")); - - // supportingFiles.add(new SupportingFile("config" + File.separator + "app.php", packagePath + File.separator + "config" + File.separator, "app.php")); - - /** - * Language Specific Primitives. These types will not trigger imports by - * the client generator - */ - languageSpecificPrimitives = new HashSet( - Arrays.asList( - "Type1", // replace these with your types - "Type2") - ); - } - - /** - * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping - * those terms here. This logic is only called if a variable matches the reseved words - * - * @return the escaped term - */ - @Override - public String escapeReservedWord(String name) { - return "_" + name; // add an underscore to the name - } - - /** - * Location to write model files. You can use the modelPackage() as defined when the class is - * instantiated - */ - public String modelFileFolder() { - return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar); - } - - /** - * Location to write api files. You can use the apiPackage() as defined when the class is - * instantiated - */ - @Override - public String apiFileFolder() { - return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar); - } - - /** - * Optional - type declaration. This is a String which is used by the templates to instantiate your - * types. There is typically special handling for different property types - * - * @return a string value used as the `dataType` field for model templates, `returnType` for api templates - */ - @Override - public String getTypeDeclaration(Property p) { - if(p instanceof ArrayProperty) { - ArrayProperty ap = (ArrayProperty) p; - Property inner = ap.getItems(); - return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]"; - } - else if (p instanceof MapProperty) { - MapProperty mp = (MapProperty) p; - Property inner = mp.getAdditionalProperties(); - return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]"; - } - return super.getTypeDeclaration(p); - } - - /** - * Optional - swagger type conversion. This is used to map swagger types in a `Property` into - * either language specific types via `typeMapping` or into complex models if there is not a mapping. - * - * @return a string value of the type or complex model for this property - * @see io.swagger.models.properties.Property - */ - @Override - public String getSwaggerType(Property p) { - String swaggerType = super.getSwaggerType(p); - String type = null; - if(typeMapping.containsKey(swaggerType)) { - type = typeMapping.get(swaggerType); - if(languageSpecificPrimitives.contains(type)) - return toModelName(type); - } - else - type = swaggerType; - return toModelName(type); - } -} \ No newline at end of file diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Commands/.gitkeep b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Commands/.gitkeep deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Kernel.php b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Kernel.php deleted file mode 100644 index ad6e311cdd04..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Console/Kernel.php +++ /dev/null @@ -1,29 +0,0 @@ -auth = $auth; - } - - /** - * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @param string|null $guard - * @return mixed - */ - public function handle($request, Closure $next, $guard = null) - { - if ($this->auth->guard($guard)->guest()) { - return response('Unauthorized.', 401); - } - - return $next($request); - } -} diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Middleware/ExampleMiddleware.php b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Middleware/ExampleMiddleware.php deleted file mode 100644 index 166581c8e69b..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Http/Middleware/ExampleMiddleware.php +++ /dev/null @@ -1,20 +0,0 @@ -get('/', function () use ($app) { - return $app->version(); -}); - -{{#apis}}{{#operations}}{{#operation}} -/** - * {{httpMethod}} {{nickname}} - * Summary: {{summary}} - * Notes: {{notes}} -{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}} - */ -$app->{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}}, {{/pathParams}}$null = null) use ($app) { - {{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}} - {{#hasQueryParams}}{{#queryParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} - {{/queryParams}}{{/hasQueryParams}} - {{#hasFormParams}}{{#formParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} {{/formParams}}{{/hasFormParams}} - - return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); - }); - -{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} - diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/AppServiceProvider.php b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/AppServiceProvider.php deleted file mode 100644 index ddec04694c37..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/AppServiceProvider.php +++ /dev/null @@ -1,18 +0,0 @@ -input('api_token')) { - return User::where('api_token', $request->input('api_token'))->first(); - } - }); - } -} diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/EventServiceProvider.php b/output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/EventServiceProvider.php deleted file mode 100644 index 0b8f3934fb3c..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/app/Providers/EventServiceProvider.php +++ /dev/null @@ -1,19 +0,0 @@ - [ - 'App\Listeners\EventListener', - ], - ]; -} diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/app/User.php b/output/LumenServer/src/main/resources/LumenServerCodegen/app/User.php deleted file mode 100644 index fd4de31172cf..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/app/User.php +++ /dev/null @@ -1,34 +0,0 @@ -make( - 'Illuminate\Contracts\Console\Kernel' -); - -exit($kernel->handle(new ArgvInput, new ConsoleOutput)); diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/bootstrap/app.php b/output/LumenServer/src/main/resources/LumenServerCodegen/bootstrap/app.php deleted file mode 100644 index 9bc334dd8866..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/bootstrap/app.php +++ /dev/null @@ -1,102 +0,0 @@ -load(); -} catch (Dotenv\Exception\InvalidPathException $e) { - // -} - -/* -|-------------------------------------------------------------------------- -| Create The Application -|-------------------------------------------------------------------------- -| -| Here we will load the environment and create the application instance -| that serves as the central piece of this framework. We'll use this -| application as an "IoC" container and router for this framework. -| -*/ - -$app = new Laravel\Lumen\Application( - realpath(__DIR__.'/../') -); - -// $app->withFacades(); - -// $app->withEloquent(); - -/* -|-------------------------------------------------------------------------- -| Register Container Bindings -|-------------------------------------------------------------------------- -| -| Now we will register a few bindings in the service container. We will -| register the exception handler and the console kernel. You may add -| your own bindings here if you like or you can make another file. -| -*/ - -$app->singleton( - Illuminate\Contracts\Debug\ExceptionHandler::class, - App\Exceptions\Handler::class -); - -$app->singleton( - Illuminate\Contracts\Console\Kernel::class, - App\Console\Kernel::class -); - -class_alias('Illuminate\Support\Facades\Request', 'Request'); //to use the Reqesut facade - -/* -|-------------------------------------------------------------------------- -| Register Middleware -|-------------------------------------------------------------------------- -| -| Next, we will register the middleware with the application. These can -| be global middleware that run before and after each request into a -| route or middleware that'll be assigned to some specific routes. -| -*/ - -// $app->middleware([ -// App\Http\Middleware\ExampleMiddleware::class -// ]); - -// $app->routeMiddleware([ -// 'auth' => App\Http\Middleware\Authenticate::class, -// ]); - -/* -|-------------------------------------------------------------------------- -| Register Service Providers -|-------------------------------------------------------------------------- -| -| Here we will register all of the application's service providers which -| are used to bind services into the container. Service providers are -| totally optional, so you are not required to uncomment this line. -| -*/ - -// $app->register(App\Providers\AppServiceProvider::class); -// $app->register(App\Providers\AuthServiceProvider::class); -// $app->register(App\Providers\EventServiceProvider::class); - -/* -|-------------------------------------------------------------------------- -| Load The Application Routes -|-------------------------------------------------------------------------- -| -| Next we will include the routes file so that they can all be added to -| the application. This will provide all of the URLs the application -| can respond to, as well as the controllers that may handle them. -| -*/ - -$app->group(['namespace' => 'App\Http\Controllers'], function ($app) { - require __DIR__.'/../app/Http/routes.php'; -}); - -return $app; diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/composer.json b/output/LumenServer/src/main/resources/LumenServerCodegen/composer.json deleted file mode 100644 index 62df199e76a7..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/composer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "laravel/lumen", - "description": "The Laravel Lumen Framework.", - "keywords": ["framework", "laravel", "lumen"], - "license": "MIT", - "type": "project", - "require": { - "php": ">=5.5.9", - "laravel/lumen-framework": "5.2.*", - "vlucas/phpdotenv": "~2.2" - }, - "autoload": { - "psr-4": { - "App\\": "app/" - } - } -} diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/public/.htaccess b/output/LumenServer/src/main/resources/LumenServerCodegen/public/.htaccess deleted file mode 100644 index 8eb2dd0ddfa5..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/public/.htaccess +++ /dev/null @@ -1,16 +0,0 @@ - - - Options -MultiViews - - - RewriteEngine On - - # Redirect Trailing Slashes If Not A Folder... - RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule ^(.*)/$ /$1 [L,R=301] - - # Handle Front Controller... - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^ index.php [L] - diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/public/index.php b/output/LumenServer/src/main/resources/LumenServerCodegen/public/index.php deleted file mode 100644 index 04aa08688e00..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/public/index.php +++ /dev/null @@ -1,28 +0,0 @@ -run(); diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/readme.md b/output/LumenServer/src/main/resources/LumenServerCodegen/readme.md deleted file mode 100644 index 9605e5f3f459..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/readme.md +++ /dev/null @@ -1,21 +0,0 @@ -## Lumen PHP Framework - -[![Build Status](https://travis-ci.org/laravel/lumen-framework.svg)](https://travis-ci.org/laravel/lumen-framework) -[![Total Downloads](https://poser.pugx.org/laravel/lumen-framework/d/total.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![Latest Stable Version](https://poser.pugx.org/laravel/lumen-framework/v/stable.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![Latest Unstable Version](https://poser.pugx.org/laravel/lumen-framework/v/unstable.svg)](https://packagist.org/packages/laravel/lumen-framework) -[![License](https://poser.pugx.org/laravel/lumen-framework/license.svg)](https://packagist.org/packages/laravel/lumen-framework) - -Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching. - -## Official Documentation - -Documentation for the framework can be found on the [Lumen website](http://lumen.laravel.com/docs). - -## Security Vulnerabilities - -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. - -### License - -The Lumen framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/routes.mustache b/output/LumenServer/src/main/resources/LumenServerCodegen/routes.mustache deleted file mode 100644 index be2fac8d86e5..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/routes.mustache +++ /dev/null @@ -1,28 +0,0 @@ -get('/', function () use ($app) { - return $app->version(); -}); - -{{#apis}}{{#operations}}{{#operation}} -/** - * {{httpMethod}} {{nickname}} - * Summary: {{summary}} - * Notes: {{notes}} -{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}} - */ -Route::{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}}, {{/pathParams}}null) use ($app) { - {{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}} - {{#hasQueryParams}}{{#queryParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} - {{/queryParams}}{{/hasQueryParams}} - {{#hasFormParams}}{{#formParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} {{/formParams}}{{/hasFormParams}} - - return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); - }); - -{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} - diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/storage/app/.gitignore b/output/LumenServer/src/main/resources/LumenServerCodegen/storage/app/.gitignore deleted file mode 100644 index d6b7ef32c847..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/storage/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/storage/framework/views/.gitignore b/output/LumenServer/src/main/resources/LumenServerCodegen/storage/framework/views/.gitignore deleted file mode 100644 index d6b7ef32c847..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/storage/framework/views/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/storage/logs/.gitignore b/output/LumenServer/src/main/resources/LumenServerCodegen/storage/logs/.gitignore deleted file mode 100644 index d6b7ef32c847..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/storage/logs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/tests/ExampleTest.php b/output/LumenServer/src/main/resources/LumenServerCodegen/tests/ExampleTest.php deleted file mode 100644 index 2b206c66173e..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/tests/ExampleTest.php +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $this->assertEquals( - $this->response->getContent(), $this->app->version() - ); - } -} diff --git a/output/LumenServer/src/main/resources/LumenServerCodegen/tests/TestCase.php b/output/LumenServer/src/main/resources/LumenServerCodegen/tests/TestCase.php deleted file mode 100644 index 651d9cbd67f3..000000000000 --- a/output/LumenServer/src/main/resources/LumenServerCodegen/tests/TestCase.php +++ /dev/null @@ -1,14 +0,0 @@ - Date: Wed, 20 Apr 2016 16:52:47 +0800 Subject: [PATCH 21/26] move the lumen generator to corresponding folder --- bin/all-petstore.sh | 1 + bin/lumen-petstore-server.sh | 31 ++ .../codegen/languages/LumenServerCodegen.java | 235 +++++++++++++ .../services/io.swagger.codegen.CodegenConfig | 1 + .../lumen/app/Console/Commands/.gitkeep | 0 .../resources/lumen/app/Console/Kernel.php | 29 ++ .../lumen/app/Exceptions/Handler.php | 50 +++ .../lumen/app/Http/Controllers/Controller.php | 10 + .../Http/Controllers/ExampleController.php | 18 + .../app/Http/Middleware/Authenticate.php | 44 +++ .../app/Http/Middleware/ExampleMiddleware.php | 20 ++ .../resources/lumen/app/Http/routes.mustache | 28 ++ .../app/Providers/AppServiceProvider.php | 18 + .../app/Providers/AuthServiceProvider.php | 40 +++ .../app/Providers/EventServiceProvider.php | 19 ++ .../src/main/resources/lumen/app/User.php | 34 ++ .../src/main/resources/lumen/artisan | 35 ++ .../main/resources/lumen/bootstrap/app.php | 102 ++++++ .../src/main/resources/lumen/composer.json | 17 + .../src/main/resources/lumen/public/.htaccess | 16 + .../src/main/resources/lumen/public/index.php | 28 ++ .../src/main/resources/lumen/readme.md | 21 ++ .../src/main/resources/lumen/routes.mustache | 28 ++ .../resources/lumen/storage/app/.gitignore | 2 + .../lumen/storage/framework/views/.gitignore | 2 + .../resources/lumen/storage/logs/.gitignore | 2 + .../resources/lumen/tests/ExampleTest.php | 20 ++ .../main/resources/lumen/tests/TestCase.php | 14 + .../codegen/lumen/LumenServerOptionsTest.java | 33 ++ .../options/LumenServerOptionsProvider.java | 30 ++ .../online/OnlineGeneratorOptionsTest.java | 2 +- .../lumen/lumen/app/Console/Kernel.php | 29 ++ .../lumen/lumen/app/Exceptions/Handler.php | 50 +++ .../lumen/app/Http/Controllers/Controller.php | 10 + .../Http/Controllers/ExampleController.php | 18 + .../app/Http/Middleware/Authenticate.php | 44 +++ .../app/Http/Middleware/ExampleMiddleware.php | 20 ++ .../petstore/lumen/lumen/app/Http/routes.php | 316 ++++++++++++++++++ .../app/Providers/AppServiceProvider.php | 18 + .../app/Providers/AuthServiceProvider.php | 40 +++ .../app/Providers/EventServiceProvider.php | 19 ++ .../server/petstore/lumen/lumen/app/User.php | 34 ++ samples/server/petstore/lumen/lumen/artisan | 35 ++ .../petstore/lumen/lumen/bootstrap/app.php | 102 ++++++ .../server/petstore/lumen/lumen/composer.json | 17 + .../petstore/lumen/lumen/public/index.php | 28 ++ samples/server/petstore/lumen/lumen/readme.md | 21 ++ 47 files changed, 1730 insertions(+), 1 deletion(-) create mode 100644 bin/lumen-petstore-server.sh create mode 100644 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LumenServerCodegen.java create mode 100644 modules/swagger-codegen/src/main/resources/lumen/app/Console/Commands/.gitkeep create mode 100644 modules/swagger-codegen/src/main/resources/lumen/app/Console/Kernel.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/app/Exceptions/Handler.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/app/Http/Controllers/Controller.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/app/Http/Controllers/ExampleController.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/app/Http/Middleware/Authenticate.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/app/Http/Middleware/ExampleMiddleware.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/app/Http/routes.mustache create mode 100644 modules/swagger-codegen/src/main/resources/lumen/app/Providers/AppServiceProvider.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/app/Providers/AuthServiceProvider.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/app/Providers/EventServiceProvider.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/app/User.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/artisan create mode 100644 modules/swagger-codegen/src/main/resources/lumen/bootstrap/app.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/composer.json create mode 100644 modules/swagger-codegen/src/main/resources/lumen/public/.htaccess create mode 100644 modules/swagger-codegen/src/main/resources/lumen/public/index.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/readme.md create mode 100644 modules/swagger-codegen/src/main/resources/lumen/routes.mustache create mode 100644 modules/swagger-codegen/src/main/resources/lumen/storage/app/.gitignore create mode 100644 modules/swagger-codegen/src/main/resources/lumen/storage/framework/views/.gitignore create mode 100644 modules/swagger-codegen/src/main/resources/lumen/storage/logs/.gitignore create mode 100644 modules/swagger-codegen/src/main/resources/lumen/tests/ExampleTest.php create mode 100644 modules/swagger-codegen/src/main/resources/lumen/tests/TestCase.php create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/lumen/LumenServerOptionsTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/options/LumenServerOptionsProvider.java create mode 100644 samples/server/petstore/lumen/lumen/app/Console/Kernel.php create mode 100644 samples/server/petstore/lumen/lumen/app/Exceptions/Handler.php create mode 100644 samples/server/petstore/lumen/lumen/app/Http/Controllers/Controller.php create mode 100644 samples/server/petstore/lumen/lumen/app/Http/Controllers/ExampleController.php create mode 100644 samples/server/petstore/lumen/lumen/app/Http/Middleware/Authenticate.php create mode 100644 samples/server/petstore/lumen/lumen/app/Http/Middleware/ExampleMiddleware.php create mode 100644 samples/server/petstore/lumen/lumen/app/Http/routes.php create mode 100644 samples/server/petstore/lumen/lumen/app/Providers/AppServiceProvider.php create mode 100644 samples/server/petstore/lumen/lumen/app/Providers/AuthServiceProvider.php create mode 100644 samples/server/petstore/lumen/lumen/app/Providers/EventServiceProvider.php create mode 100644 samples/server/petstore/lumen/lumen/app/User.php create mode 100644 samples/server/petstore/lumen/lumen/artisan create mode 100644 samples/server/petstore/lumen/lumen/bootstrap/app.php create mode 100644 samples/server/petstore/lumen/lumen/composer.json create mode 100644 samples/server/petstore/lumen/lumen/public/index.php create mode 100644 samples/server/petstore/lumen/lumen/readme.md diff --git a/bin/all-petstore.sh b/bin/all-petstore.sh index f1e8ae4b1161..f3f497254f42 100755 --- a/bin/all-petstore.sh +++ b/bin/all-petstore.sh @@ -49,3 +49,4 @@ cd $APP_DIR ./bin/tizen-petstore.sh ./bin/typescript-angular-petstore.sh ./bin/typescript-node-petstore.sh +./bin/lumen-petstore-server.sh \ No newline at end of file diff --git a/bin/lumen-petstore-server.sh b/bin/lumen-petstore-server.sh new file mode 100644 index 000000000000..15acb2fe2bd3 --- /dev/null +++ b/bin/lumen-petstore-server.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/lumen -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l lumen -o samples/server/petstore/lumen" + +java $JAVA_OPTS -jar $executable $ags diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LumenServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LumenServerCodegen.java new file mode 100644 index 000000000000..55e72f793846 --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LumenServerCodegen.java @@ -0,0 +1,235 @@ +package io.swagger.codegen.languages; + +import io.swagger.codegen.*; +import io.swagger.models.properties.*; + +import java.util.*; +import java.io.File; + +public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig { + + // source folder where to write the files + protected String sourceFolder = "src"; + protected String apiVersion = "1.0.0"; + + /** + * Configures the type of generator. + * + * @return the CodegenType for this generator + * @see io.swagger.codegen.CodegenType + */ + public CodegenType getTag() { + return CodegenType.CLIENT; + } + + /** + * Configures a friendly name for the generator. This will be used by the generator + * to select the library with the -l flag. + * + * @return the friendly name for the generator + */ + public String getName() { + return "lumen"; + } + + /** + * Returns human-friendly help for the generator. Provide the consumer with help + * tips, parameters here + * + * @return A string value for the help message + */ + public String getHelp() { + return "Generates a LumenServerCodegen client library."; + } + + public LumenServerCodegen() { + super(); + + // set the output folder here + outputFolder = "generated-code/lumen"; + String packagePath = "lumen"; + + // modelPackage = packagePath + "\\lib\\Models"; + // apiPackage = packagePath + "\\lib"; + // // outputFolder = "generated-code" + File.separator + "slim"; + // modelTemplateFiles.put("model.mustache", ".php"); + + /** + * Models. You can write model files using the modelTemplateFiles map. + * if you want to create one template for file, you can do so here. + * for multiple files for model, just put another entry in the `modelTemplateFiles` with + * a different extension + */ + // modelTemplateFiles.put( + // "model.mustache", // the template to use + // ".sample"); // the extension for each file to write + + /** + * Api classes. You can write classes for each Api file with the apiTemplateFiles map. + * as with models, add multiple entries with different extensions for multiple files per + * class + */ + // apiTemplateFiles.put( + // "api.mustache", // the template to use + // ".sample"); // the extension for each file to write + + + // no api files + apiTemplateFiles.clear(); + + // embeddedTemplateDir = templateDir = "slim"; + + /** + * Template Location. This is the location which templates will be read from. The generator + * will use the resource stream to attempt to read the templates. + */ + templateDir = "lumen"; + + /** + * Api Package. Optional, if needed, this can be used in templates + */ + apiPackage = "io.swagger.client.api"; + + /** + * Model Package. Optional, if needed, this can be used in templates + */ + modelPackage = "io.swagger.client.model"; + + /** + * Reserved words. Override this with reserved words specific to your language + */ + reservedWords = new HashSet ( + Arrays.asList( + "sample1", // replace with static values + "sample2") + ); + + /** + * Additional Properties. These values can be passed to the templates and + * are available in models, apis, and supporting files + */ + additionalProperties.put("apiVersion", apiVersion); + + /** + * Supporting Files. You can write single files for the generator with the + * entire object tree available. If the input file has a suffix of `.mustache + * it will be processed by the template engine. Otherwise, it will be copied + */ + // supportingFiles.add(new SupportingFile("index.mustache", packagePath, "index.php")); + // supportingFiles.add(new SupportingFile("routes.mustache", packagePath, "routes.php")); + + supportingFiles.add(new SupportingFile("composer.json", packagePath, "composer.json")); + supportingFiles.add(new SupportingFile("readme.md", packagePath, "readme.md")); + supportingFiles.add(new SupportingFile("artisan", packagePath, "artisan")); + // supportingFiles.add(new SupportingFile("server.php", packagePath, "server.php")); + + supportingFiles.add(new SupportingFile("bootstrap" + File.separator + "app.php", packagePath + File.separator + "bootstrap", "app.php")); + + supportingFiles.add(new SupportingFile("public" + File.separator + "index.php", packagePath + File.separator + "public", "index.php")); + + supportingFiles.add(new SupportingFile("app" + File.separator + "User.php", packagePath + File.separator + "app", "User.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Console" + File.separator + "Kernel.php", packagePath + File.separator + "app" + File.separator + "Console", "Kernel.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Exceptions" + File.separator + "Handler.php", packagePath + File.separator + "app" + File.separator + "Exceptions", "Handler.php")); + // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Kernel.php", packagePath + File.separator + "app" + File.separator + "Http", "Kernel.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "routes.mustache", packagePath + File.separator + "app" + File.separator + "Http", "routes.php")); + + supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Controller.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "Controller.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "ExampleController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator, "ExampleController.php")); + // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator + "AuthController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator, "AuthController.php")); + // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator + "PasswordController.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Controllers" + File.separator + "Auth" + File.separator, "PasswordController.php")); + + supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "Authenticate.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "Authenticate.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "ExampleMiddleware.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "ExampleMiddleware.php")); + // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "RedirectIfAuthenticated.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "RedirectIfAuthenticated.php")); + // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Middleware" + File.separator + "VerifyCsrfToken.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Middleware" + File.separator, "VerifyCsrfToken.php")); + + // supportingFiles.add(new SupportingFile("app" + File.separator + "Http" + File.separator + "Requests" + File.separator + "Request.php", packagePath + File.separator + "app" + File.separator + "Http" + File.separator + "Requests" + File.separator, "Request.php")); + + supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "AppServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "AppServiceProvider.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "AuthServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "AuthServiceProvider.php")); + supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "EventServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "EventServiceProvider.php")); + // supportingFiles.add(new SupportingFile("app" + File.separator + "Providers" + File.separator + "RouteServiceProvider.php", packagePath + File.separator + "app" + File.separator + "Providers", "RouteServiceProvider.php")); + + // supportingFiles.add(new SupportingFile("config" + File.separator + "app.php", packagePath + File.separator + "config" + File.separator, "app.php")); + + /** + * Language Specific Primitives. These types will not trigger imports by + * the client generator + */ + languageSpecificPrimitives = new HashSet( + Arrays.asList( + "Type1", // replace these with your types + "Type2") + ); + } + + /** + * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping + * those terms here. This logic is only called if a variable matches the reseved words + * + * @return the escaped term + */ + @Override + public String escapeReservedWord(String name) { + return "_" + name; // add an underscore to the name + } + + /** + * Location to write model files. You can use the modelPackage() as defined when the class is + * instantiated + */ + public String modelFileFolder() { + return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar); + } + + /** + * Location to write api files. You can use the apiPackage() as defined when the class is + * instantiated + */ + @Override + public String apiFileFolder() { + return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar); + } + + /** + * Optional - type declaration. This is a String which is used by the templates to instantiate your + * types. There is typically special handling for different property types + * + * @return a string value used as the `dataType` field for model templates, `returnType` for api templates + */ + @Override + public String getTypeDeclaration(Property p) { + if(p instanceof ArrayProperty) { + ArrayProperty ap = (ArrayProperty) p; + Property inner = ap.getItems(); + return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]"; + } + else if (p instanceof MapProperty) { + MapProperty mp = (MapProperty) p; + Property inner = mp.getAdditionalProperties(); + return getSwaggerType(p) + "[String, " + getTypeDeclaration(inner) + "]"; + } + return super.getTypeDeclaration(p); + } + + /** + * Optional - swagger type conversion. This is used to map swagger types in a `Property` into + * either language specific types via `typeMapping` or into complex models if there is not a mapping. + * + * @return a string value of the type or complex model for this property + * @see io.swagger.models.properties.Property + */ + @Override + public String getSwaggerType(Property p) { + String swaggerType = super.getSwaggerType(p); + String type = null; + if(typeMapping.containsKey(swaggerType)) { + type = typeMapping.get(swaggerType); + if(languageSpecificPrimitives.contains(type)) + return toModelName(type); + } + else + type = swaggerType; + return toModelName(type); + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index 070b084fdb62..00822e32b32f 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -40,3 +40,4 @@ io.swagger.codegen.languages.AkkaScalaClientCodegen io.swagger.codegen.languages.CsharpDotNet2ClientCodegen io.swagger.codegen.languages.ClojureClientCodegen io.swagger.codegen.languages.HaskellServantCodegen +io.swagger.codegen.languages.LumenServerCodegen \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Console/Commands/.gitkeep b/modules/swagger-codegen/src/main/resources/lumen/app/Console/Commands/.gitkeep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Console/Kernel.php b/modules/swagger-codegen/src/main/resources/lumen/app/Console/Kernel.php new file mode 100644 index 000000000000..ad6e311cdd04 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/app/Console/Kernel.php @@ -0,0 +1,29 @@ +auth = $auth; + } + + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @param string|null $guard + * @return mixed + */ + public function handle($request, Closure $next, $guard = null) + { + if ($this->auth->guard($guard)->guest()) { + return response('Unauthorized.', 401); + } + + return $next($request); + } +} diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Http/Middleware/ExampleMiddleware.php b/modules/swagger-codegen/src/main/resources/lumen/app/Http/Middleware/ExampleMiddleware.php new file mode 100644 index 000000000000..166581c8e69b --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/app/Http/Middleware/ExampleMiddleware.php @@ -0,0 +1,20 @@ +get('/', function () use ($app) { + return $app->version(); +}); + +{{#apis}}{{#operations}}{{#operation}} +/** + * {{httpMethod}} {{nickname}} + * Summary: {{summary}} + * Notes: {{notes}} +{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}} + */ +$app->{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}}, {{/pathParams}}$null = null) use ($app) { + {{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}} + {{#hasQueryParams}}{{#queryParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} + {{/queryParams}}{{/hasQueryParams}} + {{#hasFormParams}}{{#formParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} {{/formParams}}{{/hasFormParams}} + + return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); + }); + +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Providers/AppServiceProvider.php b/modules/swagger-codegen/src/main/resources/lumen/app/Providers/AppServiceProvider.php new file mode 100644 index 000000000000..ddec04694c37 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/app/Providers/AppServiceProvider.php @@ -0,0 +1,18 @@ +input('api_token')) { + return User::where('api_token', $request->input('api_token'))->first(); + } + }); + } +} diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/Providers/EventServiceProvider.php b/modules/swagger-codegen/src/main/resources/lumen/app/Providers/EventServiceProvider.php new file mode 100644 index 000000000000..0b8f3934fb3c --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/app/Providers/EventServiceProvider.php @@ -0,0 +1,19 @@ + [ + 'App\Listeners\EventListener', + ], + ]; +} diff --git a/modules/swagger-codegen/src/main/resources/lumen/app/User.php b/modules/swagger-codegen/src/main/resources/lumen/app/User.php new file mode 100644 index 000000000000..fd4de31172cf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/app/User.php @@ -0,0 +1,34 @@ +make( + 'Illuminate\Contracts\Console\Kernel' +); + +exit($kernel->handle(new ArgvInput, new ConsoleOutput)); diff --git a/modules/swagger-codegen/src/main/resources/lumen/bootstrap/app.php b/modules/swagger-codegen/src/main/resources/lumen/bootstrap/app.php new file mode 100644 index 000000000000..9bc334dd8866 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/bootstrap/app.php @@ -0,0 +1,102 @@ +load(); +} catch (Dotenv\Exception\InvalidPathException $e) { + // +} + +/* +|-------------------------------------------------------------------------- +| Create The Application +|-------------------------------------------------------------------------- +| +| Here we will load the environment and create the application instance +| that serves as the central piece of this framework. We'll use this +| application as an "IoC" container and router for this framework. +| +*/ + +$app = new Laravel\Lumen\Application( + realpath(__DIR__.'/../') +); + +// $app->withFacades(); + +// $app->withEloquent(); + +/* +|-------------------------------------------------------------------------- +| Register Container Bindings +|-------------------------------------------------------------------------- +| +| Now we will register a few bindings in the service container. We will +| register the exception handler and the console kernel. You may add +| your own bindings here if you like or you can make another file. +| +*/ + +$app->singleton( + Illuminate\Contracts\Debug\ExceptionHandler::class, + App\Exceptions\Handler::class +); + +$app->singleton( + Illuminate\Contracts\Console\Kernel::class, + App\Console\Kernel::class +); + +class_alias('Illuminate\Support\Facades\Request', 'Request'); //to use the Reqesut facade + +/* +|-------------------------------------------------------------------------- +| Register Middleware +|-------------------------------------------------------------------------- +| +| Next, we will register the middleware with the application. These can +| be global middleware that run before and after each request into a +| route or middleware that'll be assigned to some specific routes. +| +*/ + +// $app->middleware([ +// App\Http\Middleware\ExampleMiddleware::class +// ]); + +// $app->routeMiddleware([ +// 'auth' => App\Http\Middleware\Authenticate::class, +// ]); + +/* +|-------------------------------------------------------------------------- +| Register Service Providers +|-------------------------------------------------------------------------- +| +| Here we will register all of the application's service providers which +| are used to bind services into the container. Service providers are +| totally optional, so you are not required to uncomment this line. +| +*/ + +// $app->register(App\Providers\AppServiceProvider::class); +// $app->register(App\Providers\AuthServiceProvider::class); +// $app->register(App\Providers\EventServiceProvider::class); + +/* +|-------------------------------------------------------------------------- +| Load The Application Routes +|-------------------------------------------------------------------------- +| +| Next we will include the routes file so that they can all be added to +| the application. This will provide all of the URLs the application +| can respond to, as well as the controllers that may handle them. +| +*/ + +$app->group(['namespace' => 'App\Http\Controllers'], function ($app) { + require __DIR__.'/../app/Http/routes.php'; +}); + +return $app; diff --git a/modules/swagger-codegen/src/main/resources/lumen/composer.json b/modules/swagger-codegen/src/main/resources/lumen/composer.json new file mode 100644 index 000000000000..62df199e76a7 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/composer.json @@ -0,0 +1,17 @@ +{ + "name": "laravel/lumen", + "description": "The Laravel Lumen Framework.", + "keywords": ["framework", "laravel", "lumen"], + "license": "MIT", + "type": "project", + "require": { + "php": ">=5.5.9", + "laravel/lumen-framework": "5.2.*", + "vlucas/phpdotenv": "~2.2" + }, + "autoload": { + "psr-4": { + "App\\": "app/" + } + } +} diff --git a/modules/swagger-codegen/src/main/resources/lumen/public/.htaccess b/modules/swagger-codegen/src/main/resources/lumen/public/.htaccess new file mode 100644 index 000000000000..8eb2dd0ddfa5 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/public/.htaccess @@ -0,0 +1,16 @@ + + + Options -MultiViews + + + RewriteEngine On + + # Redirect Trailing Slashes If Not A Folder... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)/$ /$1 [L,R=301] + + # Handle Front Controller... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + diff --git a/modules/swagger-codegen/src/main/resources/lumen/public/index.php b/modules/swagger-codegen/src/main/resources/lumen/public/index.php new file mode 100644 index 000000000000..04aa08688e00 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/public/index.php @@ -0,0 +1,28 @@ +run(); diff --git a/modules/swagger-codegen/src/main/resources/lumen/readme.md b/modules/swagger-codegen/src/main/resources/lumen/readme.md new file mode 100644 index 000000000000..9605e5f3f459 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/readme.md @@ -0,0 +1,21 @@ +## Lumen PHP Framework + +[![Build Status](https://travis-ci.org/laravel/lumen-framework.svg)](https://travis-ci.org/laravel/lumen-framework) +[![Total Downloads](https://poser.pugx.org/laravel/lumen-framework/d/total.svg)](https://packagist.org/packages/laravel/lumen-framework) +[![Latest Stable Version](https://poser.pugx.org/laravel/lumen-framework/v/stable.svg)](https://packagist.org/packages/laravel/lumen-framework) +[![Latest Unstable Version](https://poser.pugx.org/laravel/lumen-framework/v/unstable.svg)](https://packagist.org/packages/laravel/lumen-framework) +[![License](https://poser.pugx.org/laravel/lumen-framework/license.svg)](https://packagist.org/packages/laravel/lumen-framework) + +Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching. + +## Official Documentation + +Documentation for the framework can be found on the [Lumen website](http://lumen.laravel.com/docs). + +## Security Vulnerabilities + +If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. + +### License + +The Lumen framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) diff --git a/modules/swagger-codegen/src/main/resources/lumen/routes.mustache b/modules/swagger-codegen/src/main/resources/lumen/routes.mustache new file mode 100644 index 000000000000..be2fac8d86e5 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/routes.mustache @@ -0,0 +1,28 @@ +get('/', function () use ($app) { + return $app->version(); +}); + +{{#apis}}{{#operations}}{{#operation}} +/** + * {{httpMethod}} {{nickname}} + * Summary: {{summary}} + * Notes: {{notes}} +{{#hasProduces}} * Output-Formats: [{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}} + */ +Route::{{httpMethod}}('{{path}}', function({{#pathParams}}${{paramName}}, {{/pathParams}}null) use ($app) { + {{#hasHeaderParams}}$headers = Request::header();{{/hasHeaderParams}} + {{#hasQueryParams}}{{#queryParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} + {{/queryParams}}{{/hasQueryParams}} + {{#hasFormParams}}{{#formParams}}${{paramName}} = Request::input('{{paramName}}');{{newline}} {{/formParams}}{{/hasFormParams}} + + return response('How about implementing {{nickname}} as a {{httpMethod}} method ?'); + }); + +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + diff --git a/modules/swagger-codegen/src/main/resources/lumen/storage/app/.gitignore b/modules/swagger-codegen/src/main/resources/lumen/storage/app/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/storage/app/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/modules/swagger-codegen/src/main/resources/lumen/storage/framework/views/.gitignore b/modules/swagger-codegen/src/main/resources/lumen/storage/framework/views/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/storage/framework/views/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/modules/swagger-codegen/src/main/resources/lumen/storage/logs/.gitignore b/modules/swagger-codegen/src/main/resources/lumen/storage/logs/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/storage/logs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/modules/swagger-codegen/src/main/resources/lumen/tests/ExampleTest.php b/modules/swagger-codegen/src/main/resources/lumen/tests/ExampleTest.php new file mode 100644 index 000000000000..2b206c66173e --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/tests/ExampleTest.php @@ -0,0 +1,20 @@ +get('/'); + + $this->assertEquals( + $this->response->getContent(), $this->app->version() + ); + } +} diff --git a/modules/swagger-codegen/src/main/resources/lumen/tests/TestCase.php b/modules/swagger-codegen/src/main/resources/lumen/tests/TestCase.php new file mode 100644 index 000000000000..651d9cbd67f3 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lumen/tests/TestCase.php @@ -0,0 +1,14 @@ + createOptions() { + ImmutableMap.Builder builder = new ImmutableMap.Builder(); + return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE) + .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) + .build(); + } + + @Override + public boolean isServer() { + return true; + } +} diff --git a/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java index 2ae76374adb1..9a50c9481f69 100644 --- a/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java +++ b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java @@ -56,7 +56,7 @@ public class OnlineGeneratorOptionsTest { {new StaticHtmlOptionsProvider()}, {new SwaggerOptionsProvider()}, {new SwaggerYamlOptionsProvider()}, {new SwiftOptionsProvider()}, {new TizenClientOptionsProvider()}, {new TypeScriptAngularClientOptionsProvider()}, - {new TypeScriptNodeClientOptionsProvider()} + {new TypeScriptNodeClientOptionsProvider()}, {new LumenServerOptionsProvider()} }; } diff --git a/samples/server/petstore/lumen/lumen/app/Console/Kernel.php b/samples/server/petstore/lumen/lumen/app/Console/Kernel.php new file mode 100644 index 000000000000..ad6e311cdd04 --- /dev/null +++ b/samples/server/petstore/lumen/lumen/app/Console/Kernel.php @@ -0,0 +1,29 @@ +auth = $auth; + } + + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @param string|null $guard + * @return mixed + */ + public function handle($request, Closure $next, $guard = null) + { + if ($this->auth->guard($guard)->guest()) { + return response('Unauthorized.', 401); + } + + return $next($request); + } +} diff --git a/samples/server/petstore/lumen/lumen/app/Http/Middleware/ExampleMiddleware.php b/samples/server/petstore/lumen/lumen/app/Http/Middleware/ExampleMiddleware.php new file mode 100644 index 000000000000..166581c8e69b --- /dev/null +++ b/samples/server/petstore/lumen/lumen/app/Http/Middleware/ExampleMiddleware.php @@ -0,0 +1,20 @@ +get('/', function () use ($app) { + return $app->version(); +}); + + +/** + * POST addPet + * Summary: Add a new pet to the store + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/pet', function($null = null) use ($app) { + + + + + return response('How about implementing addPet as a POST method ?'); + }); + + +/** + * DELETE deletePet + * Summary: Deletes a pet + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->DELETE('/pet/{petId}', function($petId, $null = null) use ($app) { + $headers = Request::header(); + + + + return response('How about implementing deletePet as a DELETE method ?'); + }); + + +/** + * GET findPetsByStatus + * Summary: Finds Pets by status + * Notes: Multiple status values can be provided with comma separated strings + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/pet/findByStatus', function($null = null) use ($app) { + + $status = Request::input('status'); + + + + return response('How about implementing findPetsByStatus as a GET method ?'); + }); + + +/** + * GET findPetsByTags + * Summary: Finds Pets by tags + * Notes: Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/pet/findByTags', function($null = null) use ($app) { + + $tags = Request::input('tags'); + + + + return response('How about implementing findPetsByTags as a GET method ?'); + }); + + +/** + * GET getPetById + * Summary: Find pet by ID + * Notes: Returns a single pet + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/pet/{petId}', function($petId, $null = null) use ($app) { + + + + + return response('How about implementing getPetById as a GET method ?'); + }); + + +/** + * PUT updatePet + * Summary: Update an existing pet + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->PUT('/pet', function($null = null) use ($app) { + + + + + return response('How about implementing updatePet as a PUT method ?'); + }); + + +/** + * POST updatePetWithForm + * Summary: Updates a pet in the store with form data + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/pet/{petId}', function($petId, $null = null) use ($app) { + + + $name = Request::input('name'); $status = Request::input('status'); + + return response('How about implementing updatePetWithForm as a POST method ?'); + }); + + +/** + * POST uploadFile + * Summary: uploads an image + * Notes: + * Output-Formats: [application/json] + */ +$app->POST('/pet/{petId}/uploadImage', function($petId, $null = null) use ($app) { + + + $additionalMetadata = Request::input('additionalMetadata'); $file = Request::input('file'); + + return response('How about implementing uploadFile as a POST method ?'); + }); + + +/** + * DELETE deleteOrder + * Summary: Delete purchase order by ID + * Notes: For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors + * Output-Formats: [application/xml, application/json] + */ +$app->DELETE('/store/order/{orderId}', function($orderId, $null = null) use ($app) { + + + + + return response('How about implementing deleteOrder as a DELETE method ?'); + }); + + +/** + * GET getInventory + * Summary: Returns pet inventories by status + * Notes: Returns a map of status codes to quantities + * Output-Formats: [application/json] + */ +$app->GET('/store/inventory', function($null = null) use ($app) { + + + + + return response('How about implementing getInventory as a GET method ?'); + }); + + +/** + * GET getOrderById + * Summary: Find purchase order by ID + * Notes: For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/store/order/{orderId}', function($orderId, $null = null) use ($app) { + + + + + return response('How about implementing getOrderById as a GET method ?'); + }); + + +/** + * POST placeOrder + * Summary: Place an order for a pet + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/store/order', function($null = null) use ($app) { + + + + + return response('How about implementing placeOrder as a POST method ?'); + }); + + +/** + * POST createUser + * Summary: Create user + * Notes: This can only be done by the logged in user. + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/user', function($null = null) use ($app) { + + + + + return response('How about implementing createUser as a POST method ?'); + }); + + +/** + * POST createUsersWithArrayInput + * Summary: Creates list of users with given input array + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/user/createWithArray', function($null = null) use ($app) { + + + + + return response('How about implementing createUsersWithArrayInput as a POST method ?'); + }); + + +/** + * POST createUsersWithListInput + * Summary: Creates list of users with given input array + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->POST('/user/createWithList', function($null = null) use ($app) { + + + + + return response('How about implementing createUsersWithListInput as a POST method ?'); + }); + + +/** + * DELETE deleteUser + * Summary: Delete user + * Notes: This can only be done by the logged in user. + * Output-Formats: [application/xml, application/json] + */ +$app->DELETE('/user/{username}', function($username, $null = null) use ($app) { + + + + + return response('How about implementing deleteUser as a DELETE method ?'); + }); + + +/** + * GET getUserByName + * Summary: Get user by user name + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/user/{username}', function($username, $null = null) use ($app) { + + + + + return response('How about implementing getUserByName as a GET method ?'); + }); + + +/** + * GET loginUser + * Summary: Logs user into the system + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/user/login', function($null = null) use ($app) { + + $username = Request::input('username'); + $password = Request::input('password'); + + + + return response('How about implementing loginUser as a GET method ?'); + }); + + +/** + * GET logoutUser + * Summary: Logs out current logged in user session + * Notes: + * Output-Formats: [application/xml, application/json] + */ +$app->GET('/user/logout', function($null = null) use ($app) { + + + + + return response('How about implementing logoutUser as a GET method ?'); + }); + + +/** + * PUT updateUser + * Summary: Updated user + * Notes: This can only be done by the logged in user. + * Output-Formats: [application/xml, application/json] + */ +$app->PUT('/user/{username}', function($username, $null = null) use ($app) { + + + + + return response('How about implementing updateUser as a PUT method ?'); + }); + + + diff --git a/samples/server/petstore/lumen/lumen/app/Providers/AppServiceProvider.php b/samples/server/petstore/lumen/lumen/app/Providers/AppServiceProvider.php new file mode 100644 index 000000000000..ddec04694c37 --- /dev/null +++ b/samples/server/petstore/lumen/lumen/app/Providers/AppServiceProvider.php @@ -0,0 +1,18 @@ +input('api_token')) { + return User::where('api_token', $request->input('api_token'))->first(); + } + }); + } +} diff --git a/samples/server/petstore/lumen/lumen/app/Providers/EventServiceProvider.php b/samples/server/petstore/lumen/lumen/app/Providers/EventServiceProvider.php new file mode 100644 index 000000000000..0b8f3934fb3c --- /dev/null +++ b/samples/server/petstore/lumen/lumen/app/Providers/EventServiceProvider.php @@ -0,0 +1,19 @@ + [ + 'App\Listeners\EventListener', + ], + ]; +} diff --git a/samples/server/petstore/lumen/lumen/app/User.php b/samples/server/petstore/lumen/lumen/app/User.php new file mode 100644 index 000000000000..fd4de31172cf --- /dev/null +++ b/samples/server/petstore/lumen/lumen/app/User.php @@ -0,0 +1,34 @@ +make( + 'Illuminate\Contracts\Console\Kernel' +); + +exit($kernel->handle(new ArgvInput, new ConsoleOutput)); diff --git a/samples/server/petstore/lumen/lumen/bootstrap/app.php b/samples/server/petstore/lumen/lumen/bootstrap/app.php new file mode 100644 index 000000000000..9bc334dd8866 --- /dev/null +++ b/samples/server/petstore/lumen/lumen/bootstrap/app.php @@ -0,0 +1,102 @@ +load(); +} catch (Dotenv\Exception\InvalidPathException $e) { + // +} + +/* +|-------------------------------------------------------------------------- +| Create The Application +|-------------------------------------------------------------------------- +| +| Here we will load the environment and create the application instance +| that serves as the central piece of this framework. We'll use this +| application as an "IoC" container and router for this framework. +| +*/ + +$app = new Laravel\Lumen\Application( + realpath(__DIR__.'/../') +); + +// $app->withFacades(); + +// $app->withEloquent(); + +/* +|-------------------------------------------------------------------------- +| Register Container Bindings +|-------------------------------------------------------------------------- +| +| Now we will register a few bindings in the service container. We will +| register the exception handler and the console kernel. You may add +| your own bindings here if you like or you can make another file. +| +*/ + +$app->singleton( + Illuminate\Contracts\Debug\ExceptionHandler::class, + App\Exceptions\Handler::class +); + +$app->singleton( + Illuminate\Contracts\Console\Kernel::class, + App\Console\Kernel::class +); + +class_alias('Illuminate\Support\Facades\Request', 'Request'); //to use the Reqesut facade + +/* +|-------------------------------------------------------------------------- +| Register Middleware +|-------------------------------------------------------------------------- +| +| Next, we will register the middleware with the application. These can +| be global middleware that run before and after each request into a +| route or middleware that'll be assigned to some specific routes. +| +*/ + +// $app->middleware([ +// App\Http\Middleware\ExampleMiddleware::class +// ]); + +// $app->routeMiddleware([ +// 'auth' => App\Http\Middleware\Authenticate::class, +// ]); + +/* +|-------------------------------------------------------------------------- +| Register Service Providers +|-------------------------------------------------------------------------- +| +| Here we will register all of the application's service providers which +| are used to bind services into the container. Service providers are +| totally optional, so you are not required to uncomment this line. +| +*/ + +// $app->register(App\Providers\AppServiceProvider::class); +// $app->register(App\Providers\AuthServiceProvider::class); +// $app->register(App\Providers\EventServiceProvider::class); + +/* +|-------------------------------------------------------------------------- +| Load The Application Routes +|-------------------------------------------------------------------------- +| +| Next we will include the routes file so that they can all be added to +| the application. This will provide all of the URLs the application +| can respond to, as well as the controllers that may handle them. +| +*/ + +$app->group(['namespace' => 'App\Http\Controllers'], function ($app) { + require __DIR__.'/../app/Http/routes.php'; +}); + +return $app; diff --git a/samples/server/petstore/lumen/lumen/composer.json b/samples/server/petstore/lumen/lumen/composer.json new file mode 100644 index 000000000000..62df199e76a7 --- /dev/null +++ b/samples/server/petstore/lumen/lumen/composer.json @@ -0,0 +1,17 @@ +{ + "name": "laravel/lumen", + "description": "The Laravel Lumen Framework.", + "keywords": ["framework", "laravel", "lumen"], + "license": "MIT", + "type": "project", + "require": { + "php": ">=5.5.9", + "laravel/lumen-framework": "5.2.*", + "vlucas/phpdotenv": "~2.2" + }, + "autoload": { + "psr-4": { + "App\\": "app/" + } + } +} diff --git a/samples/server/petstore/lumen/lumen/public/index.php b/samples/server/petstore/lumen/lumen/public/index.php new file mode 100644 index 000000000000..04aa08688e00 --- /dev/null +++ b/samples/server/petstore/lumen/lumen/public/index.php @@ -0,0 +1,28 @@ +run(); diff --git a/samples/server/petstore/lumen/lumen/readme.md b/samples/server/petstore/lumen/lumen/readme.md new file mode 100644 index 000000000000..9605e5f3f459 --- /dev/null +++ b/samples/server/petstore/lumen/lumen/readme.md @@ -0,0 +1,21 @@ +## Lumen PHP Framework + +[![Build Status](https://travis-ci.org/laravel/lumen-framework.svg)](https://travis-ci.org/laravel/lumen-framework) +[![Total Downloads](https://poser.pugx.org/laravel/lumen-framework/d/total.svg)](https://packagist.org/packages/laravel/lumen-framework) +[![Latest Stable Version](https://poser.pugx.org/laravel/lumen-framework/v/stable.svg)](https://packagist.org/packages/laravel/lumen-framework) +[![Latest Unstable Version](https://poser.pugx.org/laravel/lumen-framework/v/unstable.svg)](https://packagist.org/packages/laravel/lumen-framework) +[![License](https://poser.pugx.org/laravel/lumen-framework/license.svg)](https://packagist.org/packages/laravel/lumen-framework) + +Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching. + +## Official Documentation + +Documentation for the framework can be found on the [Lumen website](http://lumen.laravel.com/docs). + +## Security Vulnerabilities + +If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. + +### License + +The Lumen framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) From 8eb3f8a448ce7e6494f5d4ea3088ef69c9a21cbe Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 20 Apr 2016 22:12:09 +0800 Subject: [PATCH 22/26] fix python property name --- bin/lumen-petstore-server.sh | 0 .../languages/PythonClientCodegen.java | 2 ++ ...ith-fake-endpoints-models-for-testing.yaml | 2 ++ samples/client/petstore/python/README.md | 2 +- samples/client/petstore/python/docs/Name.md | 1 + .../python/swagger_client/models/name.py | 29 +++++++++++++++++-- 6 files changed, 33 insertions(+), 3 deletions(-) mode change 100644 => 100755 bin/lumen-petstore-server.sh diff --git a/bin/lumen-petstore-server.sh b/bin/lumen-petstore-server.sh old mode 100644 new mode 100755 diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index d560a9462143..a1e3d6f93563 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -69,6 +69,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig // local variable name used in API methods (endpoints) "all_params", "resource_path", "path_params", "query_params", "header_params", "form_params", "local_var_files", "body_params", "auth_settings", + // @property + "property", // python reserved words "and", "del", "from", "not", "while", "as", "elif", "global", "or", "with", "assert", "else", "if", "pass", "yield", "break", "except", "import", diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml index bf84cf9c38cb..01c0be8c9a32 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -717,6 +717,8 @@ definitions: readOnly: true type: integer format: int32 + property: + type: string xml: name: Name 200_response: diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 309ae5d6374b..79eef5803264 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https:// - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-19T21:05:59.494+01:00 +- Build date: 2016-04-20T22:11:45.927+08:00 - Build package: class io.swagger.codegen.languages.PythonClientCodegen ## Requirements. diff --git a/samples/client/petstore/python/docs/Name.md b/samples/client/petstore/python/docs/Name.md index 905680a7d30c..a472a529a0fe 100644 --- a/samples/client/petstore/python/docs/Name.md +++ b/samples/client/petstore/python/docs/Name.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **int** | | **snake_case** | **int** | | [optional] +**_property** | **str** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/swagger_client/models/name.py b/samples/client/petstore/python/swagger_client/models/name.py index 068bca97eea3..4fbf1a03211c 100644 --- a/samples/client/petstore/python/swagger_client/models/name.py +++ b/samples/client/petstore/python/swagger_client/models/name.py @@ -38,16 +38,19 @@ class Name(object): """ self.swagger_types = { 'name': 'int', - 'snake_case': 'int' + 'snake_case': 'int', + '_property': 'str' } self.attribute_map = { 'name': 'name', - 'snake_case': 'snake_case' + 'snake_case': 'snake_case', + '_property': 'property' } self._name = None self._snake_case = None + self.__property = None @property def name(self): @@ -93,6 +96,28 @@ class Name(object): """ self._snake_case = snake_case + @property + def _property(self): + """ + Gets the _property of this Name. + + + :return: The _property of this Name. + :rtype: str + """ + return self.__property + + @_property.setter + def _property(self, _property): + """ + Sets the _property of this Name. + + + :param _property: The _property of this Name. + :type: str + """ + self.__property = _property + def to_dict(self): """ Returns the model properties as a dict From 7eebf17f5800e252b2c5e4cbe1eabf595187e12e Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 21 Apr 2016 14:34:48 +0800 Subject: [PATCH 23/26] add getting started section --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 94a5e6999741..ba0720fb5e7c 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Check out [Swagger-Spec](https://github.com/OAI/OpenAPI-Specification) for addit - [Run docker in Vagrant](#run-docker-in-vagrant) - [Public Docker image](#public-docker-image) - [Homebrew](#homebrew) + - [Getting Started](#getting-started) - Generators - [To generate a sample client library](#to-generate-a-sample-client-library) - [Generating libraries from your server](#generating-libraries-from-your-server) @@ -141,7 +142,27 @@ Here is an example usage: ``` swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -l ruby -o /tmp/test/ ``` +## Getting Started +To generate a PHP client for http://petstore.swagger.io/v2/swagger.json, please run the following +```sh +git clone https://github.com/swagger-api/swagger-codegen +cd swagger-codegen +mvn clean package +java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ + -i http://petstore.swagger.io/v2/swagger.json \ + -l php \ + -o /var/tmp/php_api_client +``` +(if you're on Windows, replace the last command with `java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client`) + +You can also download the JAR (latest relesae) directlry from [maven.org]( http://central.maven.org/maven2/io/swagger/swagger-codegen/2.1.6/swagger-codegen-2.1.6.jar) + +To get a list of **general** options available, please run `java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar help generate` + +To get a list of PHP specified options (which can be passed to the generator with a config file via the `-c` option), please run `java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l php` + +## Generators ### To generate a sample client library You can build a client against the swagger sample [petstore](http://petstore.swagger.io) API as follows: @@ -150,7 +171,7 @@ You can build a client against the swagger sample [petstore](http://petstore.swa ./bin/java-petstore.sh ``` -(On Windows, run `./bin/windows/java-petstore.bat` instead) +(On Windows, run `.\bin\windows\java-petstore.bat` instead) This will run the generator with this command: From a54720a58656c25210cc41aeb84f64e44dab99f3 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 21 Apr 2016 14:36:17 +0800 Subject: [PATCH 24/26] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ba0720fb5e7c..1d97c7675d8c 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ ``` (if you're on Windows, replace the last command with `java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client`) -You can also download the JAR (latest relesae) directlry from [maven.org]( http://central.maven.org/maven2/io/swagger/swagger-codegen/2.1.6/swagger-codegen-2.1.6.jar) +You can also download the JAR (latest relesae) directly from [maven.org]( http://central.maven.org/maven2/io/swagger/swagger-codegen/2.1.6/swagger-codegen-2.1.6.jar) To get a list of **general** options available, please run `java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar help generate` From 6075f078b69bbab566787b3a0e3d28f152352f13 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 21 Apr 2016 17:18:44 +0800 Subject: [PATCH 25/26] minor fix to constructor --- .../src/main/resources/csharp/model.mustache | 2 +- .../Lib/SwaggerClient.Test/NameTests.cs | 8 ++++++++ .../Lib/SwaggerClient/README.md | 10 ++++++---- .../Lib/SwaggerClient/docs/Animal.md | 3 ++- .../Lib/SwaggerClient/docs/ApiResponse.md | 3 ++- .../Lib/SwaggerClient/docs/Cat.md | 3 ++- .../Lib/SwaggerClient/docs/Category.md | 3 ++- .../Lib/SwaggerClient/docs/Dog.md | 3 ++- .../Lib/SwaggerClient/docs/FormatTest.md | 3 ++- .../Lib/SwaggerClient/docs/Model200Response.md | 3 ++- .../Lib/SwaggerClient/docs/ModelReturn.md | 3 ++- .../Lib/SwaggerClient/docs/Name.md | 4 +++- .../Lib/SwaggerClient/docs/Order.md | 3 ++- .../Lib/SwaggerClient/docs/Pet.md | 3 ++- .../Lib/SwaggerClient/docs/PetApi.md | 16 ++++++++++++++++ .../Lib/SwaggerClient/docs/SpecialModelName.md | 3 ++- .../Lib/SwaggerClient/docs/StoreApi.md | 8 ++++++++ .../Lib/SwaggerClient/docs/Tag.md | 3 ++- .../Lib/SwaggerClient/docs/User.md | 3 ++- .../Lib/SwaggerClient/docs/UserApi.md | 16 ++++++++++++++++ .../src/main/csharp/IO/Swagger/Model/Name.cs | 18 +++++++++++++++++- ...rClientTest.csproj.FilesWrittenAbsolute.txt | 6 +++--- 22 files changed, 104 insertions(+), 23 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/csharp/model.mustache b/modules/swagger-codegen/src/main/resources/csharp/model.mustache index 3626da0f1c45..6d0878958471 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/model.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/model.mustache @@ -41,7 +41,7 @@ namespace {{packageName}}.Model /// {{#vars}}{{^isReadOnly}} /// {{#description}}{{description}}{{/description}}{{^description}}{{name}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{defaultValue}}){{/defaultValue}}. {{/isReadOnly}}{{/vars}} - public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatypeWithEnum}}} {{name}} = null{{#hasMoreNonReadOnly}}, {{/hasMoreNonReadOnly}}{{/isReadOnly}}{{/vars}}) + public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatypeWithEnum}}} {{name}} = null{{/isReadOnly}}{{#hasMoreNonReadOnly}}, {{/hasMoreNonReadOnly}}{{/vars}}) { {{#vars}}{{^isReadOnly}}{{#required}}// to ensure "{{name}}" is required (not null) if ({{name}} == null) diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs index 896cb8f12bff..c6c68253ca0e 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient.Test/NameTests.cs @@ -66,6 +66,14 @@ namespace IO.Swagger.Test { // TODO: unit test for the property 'SnakeCase' } + /// + /// Test the property 'Property' + /// + [Test] + public void PropertyTest() + { + // TODO: unit test for the property 'Property' + } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.md index a73dec9973a4..81bd746a9b94 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.md @@ -1,11 +1,12 @@ # IO.Swagger - the C# library for the Swagger Petstore + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. This C# SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: 1.0.0 -- Package version: 1.0.0 -- Build date: 2016-04-17T23:54:21.676+08:00 +- SDK version: 1.0.0 +- Build date: 2016-04-21T17:03:44.297+08:00 - Build package: class io.swagger.codegen.languages.CSharpClientCodegen ## Frameworks supported @@ -29,10 +30,11 @@ Run the following command to generate the DLL - [Mac/Linux] `/bin/sh compile-mono.sh` - [Windows] `compile.bat` -Then include the DLL (under the `bin` folder) in the C# project, and import the packages: +Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces: ```csharp using IO.Swagger.Api; using IO.Swagger.Client; +using IO.Swagger.Model; ``` ## Getting Started @@ -42,7 +44,7 @@ using System; using System.Diagnostics; using IO.Swagger.Api; using IO.Swagger.Client; - +using IO.Swagger.Model; namespace Example { diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Animal.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Animal.md index ef6727b89c4a..46eb96c05f42 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Animal.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Animal.md @@ -1,8 +1,9 @@ # IO.Swagger.Model.Animal - ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **ClassName** | **string** | | +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/ApiResponse.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/ApiResponse.md index 4a551f439987..3e4b4c5e9cbb 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/ApiResponse.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/ApiResponse.md @@ -1,5 +1,4 @@ # IO.Swagger.Model.ApiResponse - ## Properties Name | Type | Description | Notes @@ -8,3 +7,5 @@ Name | Type | Description | Notes **Type** | **string** | | [optional] **Message** | **string** | | [optional] +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Cat.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Cat.md index 0acd66d65304..e0034d4ab5d0 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Cat.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Cat.md @@ -1,5 +1,4 @@ # IO.Swagger.Model.Cat - ## Properties Name | Type | Description | Notes @@ -7,3 +6,5 @@ Name | Type | Description | Notes **ClassName** | **string** | | **Declawed** | **bool?** | | [optional] +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Category.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Category.md index d0ebf1a1ec7e..20b56b1728c1 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Category.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Category.md @@ -1,5 +1,4 @@ # IO.Swagger.Model.Category - ## Properties Name | Type | Description | Notes @@ -7,3 +6,5 @@ Name | Type | Description | Notes **Id** | **long?** | | [optional] **Name** | **string** | | [optional] +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Dog.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Dog.md index 12949333e192..0acf4182d942 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Dog.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Dog.md @@ -1,5 +1,4 @@ # IO.Swagger.Model.Dog - ## Properties Name | Type | Description | Notes @@ -7,3 +6,5 @@ Name | Type | Description | Notes **ClassName** | **string** | | **Breed** | **string** | | [optional] +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/FormatTest.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/FormatTest.md index b32763555077..d29dc6b5d795 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/FormatTest.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/FormatTest.md @@ -1,5 +1,4 @@ # IO.Swagger.Model.FormatTest - ## Properties Name | Type | Description | Notes @@ -17,3 +16,5 @@ Name | Type | Description | Notes **DateTime** | **DateTime?** | | [optional] **Password** | **string** | | [optional] +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Model200Response.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Model200Response.md index 647d981bc529..5cd7e66ea7ea 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Model200Response.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Model200Response.md @@ -1,8 +1,9 @@ # IO.Swagger.Model.Model200Response - ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Name** | **int?** | | [optional] +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/ModelReturn.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/ModelReturn.md index 859f217de9d4..9895ccde2b0c 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/ModelReturn.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/ModelReturn.md @@ -1,8 +1,9 @@ # IO.Swagger.Model.ModelReturn - ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_Return** | **int?** | | [optional] +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Name.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Name.md index a2b0df80869c..6cb961b6fcf9 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Name.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Name.md @@ -1,9 +1,11 @@ # IO.Swagger.Model.Name - ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_Name** | **int?** | | **SnakeCase** | **int?** | | [optional] +**Property** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Order.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Order.md index b4ffb22e6bb2..32aeab388e52 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Order.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Order.md @@ -1,5 +1,4 @@ # IO.Swagger.Model.Order - ## Properties Name | Type | Description | Notes @@ -11,3 +10,5 @@ Name | Type | Description | Notes **Status** | **string** | Order Status | [optional] **Complete** | **bool?** | | [optional] [default to false] +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Pet.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Pet.md index 74d7b6caca77..e83933d1c60a 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Pet.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Pet.md @@ -1,5 +1,4 @@ # IO.Swagger.Model.Pet - ## Properties Name | Type | Description | Notes @@ -11,3 +10,5 @@ Name | Type | Description | Notes **Tags** | [**List<Tag>**](Tag.md) | | [optional] **Status** | **string** | pet status in the store | [optional] +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md index 46b1d566ba12..22255f593624 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md @@ -75,6 +75,8 @@ void (empty response body) - **Content-Type**: application/json, application/xml - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **DeletePet** > void DeletePet (long? petId, string apiKey = null) @@ -138,6 +140,8 @@ void (empty response body) - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **FindPetsByStatus** > List FindPetsByStatus (List status) @@ -200,6 +204,8 @@ Name | Type | Description | Notes - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **FindPetsByTags** > List FindPetsByTags (List tags) @@ -262,6 +268,8 @@ Name | Type | Description | Notes - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **GetPetById** > Pet GetPetById (long? petId) @@ -326,6 +334,8 @@ Name | Type | Description | Notes - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **UpdatePet** > void UpdatePet (Pet body) @@ -387,6 +397,8 @@ void (empty response body) - **Content-Type**: application/json, application/xml - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **UpdatePetWithForm** > void UpdatePetWithForm (long? petId, string name = null, string status = null) @@ -452,6 +464,8 @@ void (empty response body) - **Content-Type**: application/x-www-form-urlencoded - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **UploadFile** > ApiResponse UploadFile (long? petId, string additionalMetadata = null, System.IO.Stream file = null) @@ -518,3 +532,5 @@ Name | Type | Description | Notes - **Content-Type**: multipart/form-data - **Accept**: application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/SpecialModelName.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/SpecialModelName.md index 1d6f2f252de8..ee1bc3168353 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/SpecialModelName.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/SpecialModelName.md @@ -1,8 +1,9 @@ # IO.Swagger.Model.SpecialModelName - ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **SpecialPropertyName** | **long?** | | [optional] +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md index 382e56160ebe..5b12c672a359 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md @@ -68,6 +68,8 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **GetInventory** > Dictionary GetInventory () @@ -128,6 +130,8 @@ This endpoint does not need any parameter. - **Content-Type**: Not defined - **Accept**: application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **GetOrderById** > Order GetOrderById (long? orderId) @@ -187,6 +191,8 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **PlaceOrder** > Order PlaceOrder (Order body) @@ -246,3 +252,5 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Tag.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Tag.md index a68cd6f0ecc5..64c5e6bdc720 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Tag.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/Tag.md @@ -1,5 +1,4 @@ # IO.Swagger.Model.Tag - ## Properties Name | Type | Description | Notes @@ -7,3 +6,5 @@ Name | Type | Description | Notes **Id** | **long?** | | [optional] **Name** | **string** | | [optional] +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/User.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/User.md index 54485476d2f3..fbea33c48b92 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/User.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/User.md @@ -1,5 +1,4 @@ # IO.Swagger.Model.User - ## Properties Name | Type | Description | Notes @@ -13,3 +12,5 @@ Name | Type | Description | Notes **Phone** | **string** | | [optional] **UserStatus** | **int?** | User Status | [optional] +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md index 11061b7a1e2c..0ba0d6357ec9 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md @@ -72,6 +72,8 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **CreateUsersWithArrayInput** > void CreateUsersWithArrayInput (List body) @@ -130,6 +132,8 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **CreateUsersWithListInput** > void CreateUsersWithListInput (List body) @@ -188,6 +192,8 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **DeleteUser** > void DeleteUser (string username) @@ -246,6 +252,8 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **GetUserByName** > User GetUserByName (string username) @@ -305,6 +313,8 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **LoginUser** > string LoginUser (string username, string password) @@ -366,6 +376,8 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **LogoutUser** > void LogoutUser () @@ -420,6 +432,8 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **UpdateUser** > void UpdateUser (string username, User body) @@ -480,3 +494,5 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/xml, application/json +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs index f9138390e3e2..fe9c89588c98 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs @@ -23,8 +23,9 @@ namespace IO.Swagger.Model /// Initializes a new instance of the class. /// /// _Name (required). + /// Property. - public Name(int? _Name = null) + public Name(int? _Name = null, string Property = null) { // to ensure "_Name" is required (not null) if (_Name == null) @@ -35,6 +36,7 @@ namespace IO.Swagger.Model { this._Name = _Name; } + this.Property = Property; } @@ -51,6 +53,12 @@ namespace IO.Swagger.Model [DataMember(Name="snake_case", EmitDefaultValue=false)] public int? SnakeCase { get; private set; } + /// + /// Gets or Sets Property + /// + [DataMember(Name="property", EmitDefaultValue=false)] + public string Property { get; set; } + /// /// Returns the string presentation of the object /// @@ -61,6 +69,7 @@ namespace IO.Swagger.Model sb.Append("class Name {\n"); sb.Append(" _Name: ").Append(_Name).Append("\n"); sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n"); + sb.Append(" Property: ").Append(Property).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -106,6 +115,11 @@ namespace IO.Swagger.Model this.SnakeCase == other.SnakeCase || this.SnakeCase != null && this.SnakeCase.Equals(other.SnakeCase) + ) && + ( + this.Property == other.Property || + this.Property != null && + this.Property.Equals(other.Property) ); } @@ -124,6 +138,8 @@ namespace IO.Swagger.Model hash = hash * 59 + this._Name.GetHashCode(); if (this.SnakeCase != null) hash = hash * 59 + this.SnakeCase.GetHashCode(); + if (this.Property != null) + hash = hash * 59 + this.Property.GetHashCode(); return hash; } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt index 0991d15f1187..323cad108c6b 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt +++ b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt @@ -1,9 +1,9 @@ /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.swagger-logo.png -/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll -/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll -/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb +/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll +/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll +/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll From c4b32f24cf762091c2d82b23cd0e33d531295edf Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 21 Apr 2016 17:23:36 +0800 Subject: [PATCH 26/26] remove trailing space --- .../src/main/resources/csharp/api_doc.mustache | 2 +- .../Lib/SwaggerClient/README.md | 2 +- .../Lib/SwaggerClient/docs/PetApi.md | 16 ++++++++-------- .../Lib/SwaggerClient/docs/StoreApi.md | 8 ++++---- .../Lib/SwaggerClient/docs/UserApi.md | 16 ++++++++-------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache b/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache index f1b3c15e6161..e445191085a3 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache @@ -17,7 +17,7 @@ Method | HTTP request | Description {{{notes}}}{{/notes}} -### Example +### Example ```csharp using System; using System.Diagnostics; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.md index 81bd746a9b94..a5c2cd333598 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/README.md @@ -6,7 +6,7 @@ This C# SDK is automatically generated by the [Swagger Codegen](https://github.c - API version: 1.0.0 - SDK version: 1.0.0 -- Build date: 2016-04-21T17:03:44.297+08:00 +- Build date: 2016-04-21T17:22:44.115+08:00 - Build package: class io.swagger.codegen.languages.CSharpClientCodegen ## Frameworks supported diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md index 22255f593624..6d05169a4ccf 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md @@ -21,7 +21,7 @@ Add a new pet to the store -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -84,7 +84,7 @@ Deletes a pet -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -149,7 +149,7 @@ Finds Pets by status Multiple status values can be provided with comma separated strings -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -213,7 +213,7 @@ Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -277,7 +277,7 @@ Find pet by ID Returns a single pet -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -343,7 +343,7 @@ Update an existing pet -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -406,7 +406,7 @@ Updates a pet in the store with form data -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -473,7 +473,7 @@ uploads an image -### Example +### Example ```csharp using System; using System.Diagnostics; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md index 5b12c672a359..f558166ecb04 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md @@ -17,7 +17,7 @@ Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -77,7 +77,7 @@ Returns pet inventories by status Returns a map of status codes to quantities -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -139,7 +139,7 @@ Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -200,7 +200,7 @@ Place an order for a pet -### Example +### Example ```csharp using System; using System.Diagnostics; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md index 0ba0d6357ec9..65c22f9f072c 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md @@ -21,7 +21,7 @@ Create user This can only be done by the logged in user. -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -81,7 +81,7 @@ Creates list of users with given input array -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -141,7 +141,7 @@ Creates list of users with given input array -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -201,7 +201,7 @@ Delete user This can only be done by the logged in user. -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -261,7 +261,7 @@ Get user by user name -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -322,7 +322,7 @@ Logs user into the system -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -385,7 +385,7 @@ Logs out current logged in user session -### Example +### Example ```csharp using System; using System.Diagnostics; @@ -441,7 +441,7 @@ Updated user This can only be done by the logged in user. -### Example +### Example ```csharp using System; using System.Diagnostics;