diff --git a/README.md b/README.md index b49bf4994ffe..3fccbaff1f02 100644 --- a/README.md +++ b/README.md @@ -799,6 +799,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you - [Plexxi](http://www.plexxi.com) - [Pixoneye](http://www.pixoneye.com/) - [PostAffiliatePro](https://www.postaffiliatepro.com/) +- [Prill Tecnologia](http://www.prill.com.br) - [QAdept](http://qadept.com/) - [QuantiModo](https://quantimo.do/) - [Rapid7](https://rapid7.com/) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/examples/ExampleGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/examples/ExampleGenerator.java index 228e5afb90de..26a4422f071b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/examples/ExampleGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/examples/ExampleGenerator.java @@ -93,7 +93,7 @@ public class ExampleGenerator { }; } } else if (property instanceof DateProperty) { - return "2000-01-23T04:56:07.000+00:00"; + return "2000-01-23"; } else if (property instanceof DateTimeProperty) { return "2000-01-23T04:56:07.000+00:00"; } else if (property instanceof DecimalProperty) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/examples/XmlExampleGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/examples/XmlExampleGenerator.java index 3b7700115e18..ed9ab1233547 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/examples/XmlExampleGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/examples/XmlExampleGenerator.java @@ -180,7 +180,7 @@ public class XmlExampleGenerator { if (property.getExample() != null) { return property.getExample().toString(); } else { - return "2000-01-23T04:56:07.000Z"; + return "2000-01-23"; } } else if (property instanceof IntegerProperty) { if (property.getExample() != null) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java index 5f08cebcdf9d..4fb1660db46b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AndroidClientCodegen.java @@ -390,7 +390,6 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi // need to put back serializableModel (boolean) into additionalProperties as value in additionalProperties is string additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel); - LOGGER.info("CodegenConstants.SERIALIZABLE_MODEL = " + additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL)); //make api and model doc path available in mustache template additionalProperties.put( "apiDocPath", apiDocPath ); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CsharpDotNet2ClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CsharpDotNet2ClientCodegen.java index 9537b7abc2c5..dbcf9d70613f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CsharpDotNet2ClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CsharpDotNet2ClientCodegen.java @@ -21,6 +21,9 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege protected String packageVersion = "1.0.0"; protected String clientPackage = "IO.Swagger.Client"; protected String sourceFolder = "src" + File.separator + "main" + File.separator + "CsharpDotNet2"; + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; + public CsharpDotNet2ClientCodegen() { super(); @@ -35,6 +38,8 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege embeddedTemplateDir = templateDir = "CsharpDotNet2"; apiPackage = "IO.Swagger.Api"; modelPackage = "IO.Swagger.Model"; + modelDocTemplateFiles.put("model_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); setReservedWordsLowerCase( Arrays.asList( @@ -122,6 +127,9 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege additionalProperties.put(CLIENT_PACKAGE, clientPackage); } + additionalProperties.put("apiDocPath", apiDocPath); + additionalProperties.put("modelDocPath", modelDocPath); + supportingFiles.add(new SupportingFile("Configuration.mustache", sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "Configuration.cs")); supportingFiles.add(new SupportingFile("ApiClient.mustache", @@ -130,7 +138,7 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "ApiException.cs")); supportingFiles.add(new SupportingFile("packages.config.mustache", "vendor", "packages.config")); supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "compile-mono.sh")); - supportingFiles.add(new SupportingFile("README.md", "", "README.md")); + supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); } @@ -292,4 +300,14 @@ public class CsharpDotNet2ClientCodegen extends DefaultCodegen implements Codege return input.replace("*/", "*_/").replace("/*", "/_*"); } + @Override + public String apiDocFileFolder() { + return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar); + } + + @Override + public String modelDocFileFolder() { + return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); + } + } diff --git a/modules/swagger-codegen/src/main/resources/CsharpDotNet2/README.md b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/README.md deleted file mode 100644 index 5fe03fcb316f..000000000000 --- a/modules/swagger-codegen/src/main/resources/CsharpDotNet2/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Csharp-DotNet2 - -This generator creates C# code targeting the .Net 2.0 framework. The resulting DLLs can be used in places where .Net 2.0 is the maximum supported version, such as in the Unity3d. - -## Dependencies -- Mono compiler -- Note: NuGet is downloaded by the mono compilation script and packages are installed with it. No dependency DLLs are bundled with this generator. - - - diff --git a/modules/swagger-codegen/src/main/resources/CsharpDotNet2/README.mustache b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/README.mustache new file mode 100644 index 000000000000..6056d800a240 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/README.mustache @@ -0,0 +1,153 @@ +# {{packageName}} - the C# library for the {{appName}} + +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +This C# SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: {{appVersion}} +- SDK version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} + For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + + +## Frameworks supported +{{^supportUWP}} +- .NET 2.0 +{{/supportUWP}} +{{#supportUWP}} +- UWP +{{/supportUWP}} + + +## Dependencies +- Mono compiler +- Newtonsoft.Json.7.0.1 +- RestSharp.Net2.1.1.11 + +Note: NuGet is downloaded by the mono compilation script and packages are installed with it. No dependency DLLs are bundled with this generator + + +## Installation +Run the following command to generate the DLL +- [Mac/Linux] `/bin/sh compile-mono.sh` +- [Windows] TODO + +Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces: +```csharp +using {{packageName}}.{{apiPackage}}; +using {{packageName}}.Client; +using {{packageName}}.{{modelPackage}}; +``` + +## Getting Started + +```csharp +using System; +using System.Diagnostics; +using {{apiPackage}}; +using {{packageName}}.Client; +using {{modelPackage}}; + +namespace Example +{ + public class {{operationId}}Example + { + public void main() + { + {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} + // Configure HTTP basic authorization: {{{name}}} + Configuration.Default.Username = "YOUR_USERNAME"; + Configuration.Default.Password = "YOUR_PASSWORD";{{/isBasic}}{{#isApiKey}} + // Configure API key authorization: {{{name}}} + Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");{{/isApiKey}}{{#isOAuth}} + // Configure OAuth2 access token for authorization: {{{name}}} + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";{{/isOAuth}}{{/authMethods}} + {{/hasAuthMethods}} + + var apiInstance = new {{classname}}(); + {{#allParams}} + {{#isPrimitiveType}} + var {{paramName}} = {{example}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/isPrimitiveType}} + {{^isPrimitiveType}} + var {{paramName}} = new {{{dataType}}}(); // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/isPrimitiveType}} + {{/allParams}} + + try + { + {{#summary}} + // {{{.}}} + {{/summary}} + {{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + Debug.WriteLine(result);{{/returnType}} + } + catch (Exception e) + { + Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message ); + } + } + } +}{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + + +## Documentation for API Endpoints + +All URIs are relative to *{{{basePath}}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{{summary}}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + + +## Documentation for Models + +{{#modelPackage}} +{{#models}}{{#model}} - [{{{modelPackage}}}.{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} +{{/modelPackage}} +{{^modelPackage}} +No model defined in this package +{{/modelPackage}} + + +## Documentation for Authorization + +{{^authMethods}} +All endpoints do not require authorization. +{{/authMethods}} +{{#authMethods}} +{{#last}} +Authentication schemes defined for the API: +{{/last}} +{{/authMethods}} +{{#authMethods}} + +### {{name}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{keyParamName}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{flow}} +- **Authorization URL**: {{authorizationUrl}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - {{scope}}: {{description}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} diff --git a/modules/swagger-codegen/src/main/resources/CsharpDotNet2/api_doc.mustache b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/api_doc.mustache new file mode 100644 index 000000000000..c61043bf1ea1 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/api_doc.mustache @@ -0,0 +1,97 @@ +# {{packageName}}.{{apiPackage}}.{{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{{basePath}}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} + +# **{{{operationId}}}** +> {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{{summary}}}{{#notes}} + +{{{notes}}}{{/notes}} + +### Example +```csharp +using System; +using System.Diagnostics; +using {{packageName}}.Api; +using {{packageName}}.Client; +using {{modelPackage}}; + +namespace Example +{ + public class {{operationId}}Example + { + public void main() + { + {{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} + // Configure HTTP basic authorization: {{{name}}} + Configuration.Default.Username = "YOUR_USERNAME"; + Configuration.Default.Password = "YOUR_PASSWORD";{{/isBasic}}{{#isApiKey}} + // Configure API key authorization: {{{name}}} + Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");{{/isApiKey}}{{#isOAuth}} + // Configure OAuth2 access token for authorization: {{{name}}} + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";{{/isOAuth}}{{/authMethods}} + {{/hasAuthMethods}} + + var apiInstance = new {{classname}}(); + {{#allParams}} + {{#isPrimitiveType}} + var {{paramName}} = {{example}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/isPrimitiveType}} + {{^isPrimitiveType}} + var {{paramName}} = new {{{dataType}}}(); // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/isPrimitiveType}} + {{/allParams}} + + try + { + {{#summary}} + // {{{.}}} + {{/summary}} + {{#returnType}}{{returnType}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + Debug.WriteLine(result);{{/returnType}} + } + catch (Exception e) + { + Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message ); + } + } + } +} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isFile}}**{{{dataType}}}**{{/isFile}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{{dataType}}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +[[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) + +{{/operation}} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/CsharpDotNet2/model_doc.mustache b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/model_doc.mustache new file mode 100644 index 000000000000..aff3e7e0d1e4 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/model_doc.mustache @@ -0,0 +1,14 @@ +{{#models}} +{{#model}} +# {{{packageName}}}.Model.{{{classname}}} +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{/vars}} + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + +{{/model}} +{{/models}} 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 7fbcc9cea4d1..47062c394d2e 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache @@ -37,7 +37,7 @@ public interface {{classname}} { @Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }) {{/hasProduces}} @ApiOperation(value = "{{summary}}", tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} }) - public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + public {{>returnTypes}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); {{/operation}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache index ee5d82699555..70f5f4f37ded 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache @@ -28,7 +28,7 @@ import org.springframework.stereotype.Service; public class {{classname}}ServiceImpl implements {{classname}} { {{#operations}} {{#operation}} - public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}} {{nickname}}({{#allParams}}{{>queryParamsImpl}}{{>pathParamsImpl}}{{>headerParamsImpl}}{{>bodyParams}}{{>formParamsImpl}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { + public {{>returnTypes}} {{nickname}}({{#allParams}}{{>queryParamsImpl}}{{>pathParamsImpl}}{{>headerParamsImpl}}{{>bodyParams}}{{>formParamsImpl}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { // TODO: Implement... {{^vendorExtensions.x-java-is-response-void}}return null;{{/vendorExtensions.x-java-is-response-void}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api_test.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api_test.mustache index 34308df43140..919e7d38206b 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api_test.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api_test.mustache @@ -103,7 +103,7 @@ public class {{classname}}Test { {{#allParams}} {{^isFile}}{{{dataType}}} {{paramName}} = null;{{/isFile}}{{#isFile}}org.apache.cxf.jaxrs.ext.multipart.Attachment {{paramName}} = null;{{/isFile}} {{/allParams}} - //{{^vendorExtensions.x-java-is-response-void}}{{{returnType}}} response = {{/vendorExtensions.x-java-is-response-void}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + //{{^vendorExtensions.x-java-is-response-void}}{{>returnTypes}} response = {{/vendorExtensions.x-java-is-response-void}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); {{^vendorExtensions.x-java-is-response-void}}//assertNotNull(response);{{/vendorExtensions.x-java-is-response-void}} // TODO: test validations diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/returnTypes.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/returnTypes.mustache new file mode 100644 index 000000000000..c8f7a56938aa --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/returnTypes.mustache @@ -0,0 +1 @@ +{{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List<{{{returnType}}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/android/enum_outer_doc.mustache b/modules/swagger-codegen/src/main/resources/android/enum_outer_doc.mustache new file mode 100644 index 000000000000..20c512aaeae4 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/android/enum_outer_doc.mustache @@ -0,0 +1,7 @@ +# {{classname}} + +## Enum + +{{#allowableValues}}{{#enumVars}} +* `{{name}}` (value: `{{{value}}}`) +{{/enumVars}}{{/allowableValues}} diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/Pair.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/Pair.mustache index 60e15c94ed49..442f9c7a811b 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/Pair.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/Pair.mustache @@ -2,38 +2,38 @@ package {{invokerPackage}}; public class Pair { - private String name = ""; - private String value = ""; + private String name = ""; + private String value = ""; - public Pair(String name, String value) { - setName(name); - setValue(value); - } + public Pair(String name, String value) { + setName(name); + setValue(value); + } - private void setName(String name) { - if (!isValidString(name)) return; + private void setName(String name) { + if (!isValidString(name)) return; - this.name = name; - } + this.name = name; + } - private void setValue(String value) { - if (!isValidString(value)) return; + private void setValue(String value) { + if (!isValidString(value)) return; - this.value = value; - } + this.value = value; + } - public String getName() { - return this.name; - } + public String getName() { + return this.name; + } - public String getValue() { - return this.value; - } + public String getValue() { + return this.value; + } - private boolean isValidString(String arg) { - if (arg == null) return false; - if (arg.trim().isEmpty()) return false; + private boolean isValidString(String arg) { + if (arg == null) return false; + if (arg.trim().isEmpty()) return false; - return true; - } + return true; + } } diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache index 0d18ad5572e1..288408ab26c3 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache @@ -54,83 +54,89 @@ public class {{classname}} { {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; - {{#allParams}}{{#required}} - // verify the required parameter '{{paramName}}' is set - if ({{paramName}} == null) { + Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; + {{#allParams}} + {{#required}} + // verify the required parameter '{{paramName}}' is set + if ({{paramName}} == null) { VolleyError error = new VolleyError("Missing the required parameter '{{paramName}}' when calling {{nickname}}", - new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{nickname}}")); - } - {{/required}}{{/allParams}} + new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{nickname}}")); + } + {{/required}} + {{/allParams}} - // create path and map variables - String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{baseName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}}; + // create path and map variables + String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{baseName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}}; - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + {{#queryParams}} + queryParams.addAll(ApiInvoker.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); + {{/queryParams}} + {{#headerParams}} + headerParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}})); + {{/headerParams}} + String[] contentTypes = { + {{#consumes}} + "{{{mediaType}}}"{{#hasMore}},{{/hasMore}} + {{/consumes}} + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - {{#queryParams}} - queryParams.addAll(ApiInvoker.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); - {{/queryParams}} - - {{#headerParams}} - headerParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}})); - {{/headerParams}} - - String[] contentTypes = { - {{#consumes}}"{{{mediaType}}}"{{#hasMore}},{{/hasMore}}{{/consumes}} - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - {{#formParams}}{{#notFile}} - if ({{paramName}} != null) { - localVarBuilder.addTextBody("{{baseName}}", ApiInvoker.parameterToString({{paramName}}), ApiInvoker.TEXT_PLAIN_UTF8); - } - {{/notFile}}{{#isFile}} - if ({{paramName}} != null) { - localVarBuilder.addBinaryBody("{{baseName}}", {{paramName}}); - } - {{/isFile}}{{/formParams}} - + {{#formParams}} + {{^isFile}} + if ({{paramName}} != null) { + localVarBuilder.addTextBody("{{baseName}}", ApiInvoker.parameterToString({{paramName}}), ApiInvoker.TEXT_PLAIN_UTF8); + } + {{/isFile}} + {{#isFile}} + if ({{paramName}} != null) { + localVarBuilder.addBinaryBody("{{baseName}}", {{paramName}}); + } + {{/isFile}} + {{/formParams}} HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - {{#formParams}}{{#notFile}}formParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}}));{{/notFile}} - {{/formParams}} + {{#formParams}} + {{^isFile}} + formParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}})); + {{/isFile}} + {{/formParams}} + } + + String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; + + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "{{httpMethod}}", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return {{#returnType}}({{{returnType}}}) ApiInvoker.deserialize(localVarResponse, "{{returnContainer}}", {{returnBaseType}}.class){{/returnType}}; + } else { + return {{#returnType}}null{{/returnType}}; } - - String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; - - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "{{httpMethod}}", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return {{#returnType}}({{{returnType}}}) ApiInvoker.deserialize(localVarResponse, "{{returnContainer}}", {{returnBaseType}}.class){{/returnType}}; - } else { - return {{#returnType}}null{{/returnType}}; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); } - throw ex; - } catch (TimeoutException ex) { - throw ex; - } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiException.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiException.mustache index 8d9da2fbe5d8..381af8fb4b04 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiException.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiException.mustache @@ -12,18 +12,38 @@ public class ApiException extends Exception { this.message = message; } + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ public int getCode() { return code; } + /** + * Set the HTTP status code. + * + * @param code HTTP status code. + */ public void setCode(int code) { this.code = code; } + /** + * Get the error message. + * + * @return Error message. + */ public String getMessage() { return message; } + /** + * Set the error messages. + * + * @param message Error message. + */ public void setMessage(String message) { this.message = message; } diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache index d57d8bb058f9..09e2b177fab9 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache @@ -179,48 +179,48 @@ public class ApiInvoker { } public static void initializeInstance() { - initializeInstance(null); + initializeInstance(null); } public static void initializeInstance(Cache cache) { - initializeInstance(cache, null, 0, null, 30); + initializeInstance(cache, null, 0, null, 30); } public static void initializeInstance(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery, int connectionTimeout) { - INSTANCE = new ApiInvoker(cache, network, threadPoolSize, delivery, connectionTimeout); - setUserAgent("{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{artifactVersion}}}/android{{/httpUserAgent}}"); + INSTANCE = new ApiInvoker(cache, network, threadPoolSize, delivery, connectionTimeout); + setUserAgent("{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{artifactVersion}}}/android{{/httpUserAgent}}"); - // Setup authentications (key: authentication name, value: authentication). - INSTANCE.authentications = new HashMap(); - {{#authMethods}} - {{#isApiKey}} - INSTANCE.authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}")); - {{/isApiKey}} - {{#isBasic}} - INSTANCE.authentications.put("{{name}}", new HttpBasicAuth()); - {{/isBasic}} - {{#isOAuth}} - // TODO: comment out below as OAuth does not exist - //INSTANCE.authentications.put("{{name}}", new OAuth()); - {{/isOAuth}} - {{/authMethods}} - // Prevent the authentications from being modified. - INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications); + // Setup authentications (key: authentication name, value: authentication). + INSTANCE.authentications = new HashMap(); + {{#authMethods}} + {{#isApiKey}} + INSTANCE.authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}")); + {{/isApiKey}} + {{#isBasic}} + INSTANCE.authentications.put("{{name}}", new HttpBasicAuth()); + {{/isBasic}} + {{#isOAuth}} + // TODO: comment out below as OAuth does not exist + //INSTANCE.authentications.put("{{name}}", new OAuth()); + {{/isOAuth}} + {{/authMethods}} + // Prevent the authentications from being modified. + INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications); } private ApiInvoker(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery, int connectionTimeout) { - if(cache == null) cache = new NoCache(); - if(network == null) { - HttpStack stack = new HurlStack(); - network = new BasicNetwork(stack); - } + if(cache == null) cache = new NoCache(); + if(network == null) { + HttpStack stack = new HurlStack(); + network = new BasicNetwork(stack); + } - if(delivery == null) { - initConnectionRequest(cache, network); - } else { - initConnectionRequest(cache, network, threadPoolSize, delivery); - } - this.connectionTimeout = connectionTimeout; + if(delivery == null) { + initConnectionRequest(cache, network); + } else { + initConnectionRequest(cache, network, threadPoolSize, delivery); + } + this.connectionTimeout = connectionTimeout; } public static ApiInvoker getInstance() { @@ -273,25 +273,25 @@ public class ApiInvoker { } /** - * Get authentications (key: authentication name, value: authentication). - */ + * Get authentications (key: authentication name, value: authentication). + */ public Map getAuthentications() { return authentications; } /** - * Get authentication for the given name. - * - * @param authName The authentication name - * @return The authentication, null if not found - */ + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ public Authentication getAuthentication(String authName) { return authentications.get(authName); } /** - * Helper method to set username for the first HTTP basic authentication. - */ + * Helper method to set username for the first HTTP basic authentication. + */ public void setUsername(String username) { for (Authentication auth : authentications.values()) { if (auth instanceof HttpBasicAuth) { @@ -303,21 +303,21 @@ public class ApiInvoker { } /** - * Helper method to set password for the first HTTP basic authentication. - */ + * Helper method to set password for the first HTTP basic authentication. + */ public void setPassword(String password) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setPassword(password); - return; - } - } - throw new RuntimeException("No HTTP basic authentication configured!"); + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); } /** - * Helper method to set API key value for the first API key authentication. - */ + * Helper method to set API key value for the first API key authentication. + */ public void setApiKey(String apiKey) { for (Authentication auth : authentications.values()) { if (auth instanceof ApiKeyAuth) { @@ -329,8 +329,8 @@ public class ApiInvoker { } /** - * Helper method to set API key prefix for the first API key authentication. - */ + * Helper method to set API key prefix for the first API key authentication. + */ public void setApiKeyPrefix(String apiKeyPrefix) { for (Authentication auth : authentications.values()) { if (auth instanceof ApiKeyAuth) { @@ -342,18 +342,18 @@ public class ApiInvoker { } public void setConnectionTimeout(int connectionTimeout){ - this.connectionTimeout = connectionTimeout; + this.connectionTimeout = connectionTimeout; } public int getConnectionTimeout() { - return connectionTimeout; + return connectionTimeout; } /** - * Update query and header parameters based on authentication settings. - * - * @param authNames The authentications to apply - */ + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + */ private void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams) { for (String authName : authNames) { Authentication auth = authentications.get(authName); @@ -363,17 +363,21 @@ public class ApiInvoker { } public String invokeAPI(String host, String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String contentType, String[] authNames) throws ApiException, InterruptedException, ExecutionException, TimeoutException { - RequestFuture future = RequestFuture.newFuture(); - Request request = createRequest(host, path, method, queryParams, body, headerParams, formParams, contentType, authNames, future, future); - if(request != null) { - mRequestQueue.add(request); - return future.get(connectionTimeout, TimeUnit.SECONDS); - } else return "no data"; + RequestFuture future = RequestFuture.newFuture(); + Request request = createRequest(host, path, method, queryParams, body, headerParams, formParams, contentType, authNames, future, future); + if(request != null) { + mRequestQueue.add(request); + return future.get(connectionTimeout, TimeUnit.SECONDS); + } else { + return "no data"; + } } public void invokeAPI(String host, String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String contentType, String[] authNames, Response.Listener stringRequest, Response.ErrorListener errorListener) throws ApiException { - Request request = createRequest(host, path, method, queryParams, body, headerParams, formParams, contentType, authNames, stringRequest, errorListener); - if (request != null) mRequestQueue.add(request); + Request request = createRequest(host, path, method, queryParams, body, headerParams, formParams, contentType, authNames, stringRequest, errorListener); + if (request != null) { + mRequestQueue.add(request); + } } public Request createRequest(String host, String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String contentType, String[] authNames, Response.Listener stringRequest, Response.ErrorListener errorListener) throws ApiException { @@ -503,16 +507,16 @@ public class ApiInvoker { } private void initConnectionRequest(Cache cache, Network network) { - mRequestQueue = new RequestQueue(cache, network); - mRequestQueue.start(); + mRequestQueue = new RequestQueue(cache, network); + mRequestQueue.start(); } private void initConnectionRequest(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery) { - mRequestQueue = new RequestQueue(cache, network, threadPoolSize, delivery); - mRequestQueue.start(); + mRequestQueue = new RequestQueue(cache, network, threadPoolSize, delivery); + mRequestQueue.start(); } public void stopQueue() { - mRequestQueue.stop(); + mRequestQueue.stop(); } } diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/apikeyauth.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/apikeyauth.mustache index 2208935ee42b..9f5c6dcbaa2c 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/apikeyauth.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/apikeyauth.mustache @@ -46,7 +46,7 @@ public class ApiKeyAuth implements Authentication { public void applyToParams(List queryParams, Map headerParams) { String value; if (apiKey == null) { - return; + return; } if (apiKeyPrefix != null) { value = apiKeyPrefix + " " + apiKey; diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/httpbasicauth.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/httpbasicauth.mustache index 51017997ed41..f4f9a1a0bc09 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/httpbasicauth.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/httpbasicauth.mustache @@ -9,28 +9,28 @@ import java.util.Map; import java.util.List; public class HttpBasicAuth implements Authentication { - private String username; - private String password; + private String username; + private String password; - public String getUsername() { - return username; - } + public String getUsername() { + return username; + } - public void setUsername(String username) { - this.username = username; - } + public void setUsername(String username) { + this.username = username; + } - public String getPassword() { - return password; - } + public String getPassword() { + return password; + } - public void setPassword(String password) { - this.password = password; - } + public void setPassword(String password) { + this.password = password; + } - @Override - public void applyToParams(List queryParams, Map headerParams) { - String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); - headerParams.put("Authorization", "Basic " + Base64.encodeToString(str.getBytes(), Base64.DEFAULT)); - } + @Override + public void applyToParams(List queryParams, Map headerParams) { + String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); + headerParams.put("Authorization", "Basic " + Base64.encodeToString(str.getBytes(), Base64.DEFAULT)); + } } diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/oauth.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/oauth.mustache index 72b5e0baab89..1839e96bf08b 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/oauth.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/auth/oauth.mustache @@ -7,8 +7,8 @@ import java.util.Map; import java.util.List; public class OAuth implements Authentication { - @Override - public void applyToParams(List queryParams, Map headerParams) { - // TODO stub - } + @Override + public void applyToParams(List queryParams, Map headerParams) { + // TODO stub + } } diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache index 7dcc613d0f00..90956e791dcf 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/deleterequest.mustache @@ -19,75 +19,75 @@ import java.util.Map; public class DeleteRequest extends Request { - HttpEntity entity; + HttpEntity entity; - private final Response.Listener mListener; + private final Response.Listener mListener; - String contentType; - Map apiHeaders; - public DeleteRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { - super(Method.DELETE, url, errorListener); - mListener = listener; - this.entity = entity; - this.contentType = contentType; - this.apiHeaders = apiHeaders; + String contentType; + Map apiHeaders; + public DeleteRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { + super(Method.DELETE, url, errorListener); + mListener = listener; + this.entity = entity; + this.contentType = contentType; + this.apiHeaders = apiHeaders; + } + + @Override + public String getBodyContentType() { + if(entity == null) { + return null; + } + return entity.getContentType().getValue(); + } + + @Override + public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + entity.writeTo(bos); + } + catch (IOException e) { + VolleyLog.e("IOException writing to ByteArrayOutputStream"); + } + return bos.toByteArray(); + } + + @Override + protected Response parseNetworkResponse(NetworkResponse response) { + String parsed; + try { + parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); + } catch (UnsupportedEncodingException e) { + parsed = new String(response.data); + } + return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); + } + + @Override + protected void deliverResponse(String response) { + mListener.onResponse(response); + } + + /* (non-Javadoc) + * @see com.android.volley.Request#getHeaders() + */ + @Override + public Map getHeaders() throws AuthFailureError { + Map headers = super.getHeaders(); + if (headers == null || headers.equals(Collections.emptyMap())) { + headers = new HashMap(); + } + if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { + headers.putAll(apiHeaders); + } + if(contentType != null) { + headers.put("Content-Type", contentType); } - @Override - public String getBodyContentType() { - if(entity == null) { - return null; - } - return entity.getContentType().getValue(); - } - - @Override - public byte[] getBody() throws AuthFailureError { - if(entity == null) { - return null; - } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - entity.writeTo(bos); - } - catch (IOException e) { - VolleyLog.e("IOException writing to ByteArrayOutputStream"); - } - return bos.toByteArray(); - } - - @Override - protected Response parseNetworkResponse(NetworkResponse response) { - String parsed; - try { - parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); - } catch (UnsupportedEncodingException e) { - parsed = new String(response.data); - } - return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); - } - - @Override - protected void deliverResponse(String response) { - mListener.onResponse(response); - } - - /* (non-Javadoc) - * @see com.android.volley.Request#getHeaders() - */ - @Override - public Map getHeaders() throws AuthFailureError { - Map headers = super.getHeaders(); - if (headers == null || headers.equals(Collections.emptyMap())) { - headers = new HashMap(); - } - if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { - headers.putAll(apiHeaders); - } - if(contentType != null) { - headers.put("Content-Type", contentType); - } - - return headers; - } + return headers; + } } diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache index 5415ab602a24..b9a7fed67050 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/patchrequest.mustache @@ -19,75 +19,75 @@ import java.util.Map; public class PatchRequest extends Request { - HttpEntity entity; + HttpEntity entity; - private final Response.Listener mListener; + private final Response.Listener mListener; - String contentType; - Map apiHeaders; - public PatchRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { - super(Method.PATCH, url, errorListener); - mListener = listener; - this.entity = entity; - this.contentType = contentType; - this.apiHeaders = apiHeaders; + String contentType; + Map apiHeaders; + public PatchRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { + super(Method.PATCH, url, errorListener); + mListener = listener; + this.entity = entity; + this.contentType = contentType; + this.apiHeaders = apiHeaders; + } + + @Override + public String getBodyContentType() { + if(entity == null) { + return null; + } + return entity.getContentType().getValue(); + } + + @Override + public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + entity.writeTo(bos); + } + catch (IOException e) { + VolleyLog.e("IOException writing to ByteArrayOutputStream"); + } + return bos.toByteArray(); + } + + @Override + protected Response parseNetworkResponse(NetworkResponse response) { + String parsed; + try { + parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); + } catch (UnsupportedEncodingException e) { + parsed = new String(response.data); + } + return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); + } + + @Override + protected void deliverResponse(String response) { + mListener.onResponse(response); + } + + /* (non-Javadoc) + * @see com.android.volley.Request#getHeaders() + */ + @Override + public Map getHeaders() throws AuthFailureError { + Map headers = super.getHeaders(); + if (headers == null || headers.equals(Collections.emptyMap())) { + headers = new HashMap(); + } + if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { + headers.putAll(apiHeaders); + } + if(contentType != null) { + headers.put("Content-Type", contentType); } - @Override - public String getBodyContentType() { - if(entity == null) { - return null; - } - return entity.getContentType().getValue(); - } - - @Override - public byte[] getBody() throws AuthFailureError { - if(entity == null) { - return null; - } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - entity.writeTo(bos); - } - catch (IOException e) { - VolleyLog.e("IOException writing to ByteArrayOutputStream"); - } - return bos.toByteArray(); - } - - @Override - protected Response parseNetworkResponse(NetworkResponse response) { - String parsed; - try { - parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); - } catch (UnsupportedEncodingException e) { - parsed = new String(response.data); - } - return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); - } - - @Override - protected void deliverResponse(String response) { - mListener.onResponse(response); - } - - /* (non-Javadoc) - * @see com.android.volley.Request#getHeaders() - */ - @Override - public Map getHeaders() throws AuthFailureError { - Map headers = super.getHeaders(); - if (headers == null || headers.equals(Collections.emptyMap())) { - headers = new HashMap(); - } - if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { - headers.putAll(apiHeaders); - } - if(contentType != null) { - headers.put("Content-Type", contentType); - } - - return headers; - } + return headers; + } } diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache index 183fe15b9b53..2349b51a3186 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/postrequest.mustache @@ -19,75 +19,75 @@ import java.util.Map; public class PostRequest extends Request { - HttpEntity entity; + HttpEntity entity; - private final Response.Listener mListener; + private final Response.Listener mListener; - String contentType; - Map apiHeaders; - public PostRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { - super(Method.POST, url, errorListener); - mListener = listener; - this.entity = entity; - this.contentType = contentType; - this.apiHeaders = apiHeaders; + String contentType; + Map apiHeaders; + public PostRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { + super(Method.POST, url, errorListener); + mListener = listener; + this.entity = entity; + this.contentType = contentType; + this.apiHeaders = apiHeaders; + } + + @Override + public String getBodyContentType() { + if(entity == null) { + return null; + } + return entity.getContentType().getValue(); + } + + @Override + public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + entity.writeTo(bos); + } + catch (IOException e) { + VolleyLog.e("IOException writing to ByteArrayOutputStream"); + } + return bos.toByteArray(); + } + + @Override + protected Response parseNetworkResponse(NetworkResponse response) { + String parsed; + try { + parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); + } catch (UnsupportedEncodingException e) { + parsed = new String(response.data); + } + return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); + } + + @Override + protected void deliverResponse(String response) { + mListener.onResponse(response); + } + + /* (non-Javadoc) + * @see com.android.volley.Request#getHeaders() + */ + @Override + public Map getHeaders() throws AuthFailureError { + Map headers = super.getHeaders(); + if (headers == null || headers.equals(Collections.emptyMap())) { + headers = new HashMap(); + } + if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { + headers.putAll(apiHeaders); + } + if(contentType != null) { + headers.put("Content-Type", contentType); } - @Override - public String getBodyContentType() { - if(entity == null) { - return null; - } - return entity.getContentType().getValue(); - } - - @Override - public byte[] getBody() throws AuthFailureError { - if(entity == null) { - return null; - } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - entity.writeTo(bos); - } - catch (IOException e) { - VolleyLog.e("IOException writing to ByteArrayOutputStream"); - } - return bos.toByteArray(); - } - - @Override - protected Response parseNetworkResponse(NetworkResponse response) { - String parsed; - try { - parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); - } catch (UnsupportedEncodingException e) { - parsed = new String(response.data); - } - return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); - } - - @Override - protected void deliverResponse(String response) { - mListener.onResponse(response); - } - - /* (non-Javadoc) - * @see com.android.volley.Request#getHeaders() - */ - @Override - public Map getHeaders() throws AuthFailureError { - Map headers = super.getHeaders(); - if (headers == null || headers.equals(Collections.emptyMap())) { - headers = new HashMap(); - } - if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { - headers.putAll(apiHeaders); - } - if(contentType != null) { - headers.put("Content-Type", contentType); - } - - return headers; - } + return headers; + } } diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache index 88cf2edce8ee..6773fb4da7f1 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/request/putrequest.mustache @@ -19,75 +19,75 @@ import java.util.Map; public class PutRequest extends Request { - HttpEntity entity; + HttpEntity entity; - private final Response.Listener mListener; + private final Response.Listener mListener; - String contentType; - Map apiHeaders; - public PutRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { - super(Method.PUT, url, errorListener); - mListener = listener; - this.entity = entity; - this.contentType = contentType; - this.apiHeaders = apiHeaders; + String contentType; + Map apiHeaders; + public PutRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { + super(Method.PUT, url, errorListener); + mListener = listener; + this.entity = entity; + this.contentType = contentType; + this.apiHeaders = apiHeaders; + } + + @Override + public String getBodyContentType() { + if(entity == null) { + return null; + } + return entity.getContentType().getValue(); + } + + @Override + public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + entity.writeTo(bos); + } + catch (IOException e) { + VolleyLog.e("IOException writing to ByteArrayOutputStream"); + } + return bos.toByteArray(); + } + + @Override + protected Response parseNetworkResponse(NetworkResponse response) { + String parsed; + try { + parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); + } catch (UnsupportedEncodingException e) { + parsed = new String(response.data); + } + return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); + } + + @Override + protected void deliverResponse(String response) { + mListener.onResponse(response); + } + + /* (non-Javadoc) + * @see com.android.volley.Request#getHeaders() + */ + @Override + public Map getHeaders() throws AuthFailureError { + Map headers = super.getHeaders(); + if (headers == null || headers.equals(Collections.emptyMap())) { + headers = new HashMap(); + } + if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { + headers.putAll(apiHeaders); + } + if(contentType != null) { + headers.put("Content-Type", contentType); } - @Override - public String getBodyContentType() { - if(entity == null) { - return null; - } - return entity.getContentType().getValue(); - } - - @Override - public byte[] getBody() throws AuthFailureError { - if(entity == null) { - return null; - } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - entity.writeTo(bos); - } - catch (IOException e) { - VolleyLog.e("IOException writing to ByteArrayOutputStream"); - } - return bos.toByteArray(); - } - - @Override - protected Response parseNetworkResponse(NetworkResponse response) { - String parsed; - try { - parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); - } catch (UnsupportedEncodingException e) { - parsed = new String(response.data); - } - return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); - } - - @Override - protected void deliverResponse(String response) { - mListener.onResponse(response); - } - - /* (non-Javadoc) - * @see com.android.volley.Request#getHeaders() - */ - @Override - public Map getHeaders() throws AuthFailureError { - Map headers = super.getHeaders(); - if (headers == null || headers.equals(Collections.emptyMap())) { - headers = new HashMap(); - } - if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { - headers.putAll(apiHeaders); - } - if(contentType != null) { - headers.put("Content-Type", contentType); - } - - return headers; - } + return headers; + } } diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/configuration.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/configuration.mustache index dd8d4be97288..a566a180e4eb 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/configuration.mustache @@ -2,5 +2,5 @@ export class Configuration { apiKey: string; username: string; password: string; - accessToken: string | () => string; + accessToken: string | (() => string); } \ No newline at end of file diff --git a/samples/client/petstore-security-test/typescript-angular2/configuration.ts b/samples/client/petstore-security-test/typescript-angular2/configuration.ts index dd8d4be97288..a566a180e4eb 100644 --- a/samples/client/petstore-security-test/typescript-angular2/configuration.ts +++ b/samples/client/petstore-security-test/typescript-angular2/configuration.ts @@ -2,5 +2,5 @@ export class Configuration { apiKey: string; username: string; password: string; - accessToken: string | () => string; + accessToken: string | (() => string); } \ No newline at end of file diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiException.java index 60e7a3d92c9e..7ccb9a47f481 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiException.java @@ -23,18 +23,38 @@ public class ApiException extends Exception { this.message = message; } + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ public int getCode() { return code; } + /** + * Set the HTTP status code. + * + * @param code HTTP status code. + */ public void setCode(int code) { this.code = code; } + /** + * Get the error message. + * + * @return Error message. + */ public String getMessage() { return message; } + /** + * Set the error messages. + * + * @param message Error message. + */ public void setMessage(String message) { this.message = message; } diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java index e9a7d1b1624e..5791dbfd072d 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java @@ -190,39 +190,39 @@ public class ApiInvoker { } public static void initializeInstance() { - initializeInstance(null); + initializeInstance(null); } public static void initializeInstance(Cache cache) { - initializeInstance(cache, null, 0, null, 30); + initializeInstance(cache, null, 0, null, 30); } public static void initializeInstance(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery, int connectionTimeout) { - INSTANCE = new ApiInvoker(cache, network, threadPoolSize, delivery, connectionTimeout); - setUserAgent("Swagger-Codegen/1.0.0/android"); + INSTANCE = new ApiInvoker(cache, network, threadPoolSize, delivery, connectionTimeout); + setUserAgent("Swagger-Codegen/1.0.0/android"); - // Setup authentications (key: authentication name, value: authentication). - INSTANCE.authentications = new HashMap(); - INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key")); - // TODO: comment out below as OAuth does not exist - //INSTANCE.authentications.put("petstore_auth", new OAuth()); - // Prevent the authentications from being modified. - INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications); + // Setup authentications (key: authentication name, value: authentication). + INSTANCE.authentications = new HashMap(); + INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key")); + // TODO: comment out below as OAuth does not exist + //INSTANCE.authentications.put("petstore_auth", new OAuth()); + // Prevent the authentications from being modified. + INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications); } private ApiInvoker(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery, int connectionTimeout) { - if(cache == null) cache = new NoCache(); - if(network == null) { - HttpStack stack = new HurlStack(); - network = new BasicNetwork(stack); - } + if(cache == null) cache = new NoCache(); + if(network == null) { + HttpStack stack = new HurlStack(); + network = new BasicNetwork(stack); + } - if(delivery == null) { - initConnectionRequest(cache, network); - } else { - initConnectionRequest(cache, network, threadPoolSize, delivery); - } - this.connectionTimeout = connectionTimeout; + if(delivery == null) { + initConnectionRequest(cache, network); + } else { + initConnectionRequest(cache, network, threadPoolSize, delivery); + } + this.connectionTimeout = connectionTimeout; } public static ApiInvoker getInstance() { @@ -275,25 +275,25 @@ public class ApiInvoker { } /** - * Get authentications (key: authentication name, value: authentication). - */ + * Get authentications (key: authentication name, value: authentication). + */ public Map getAuthentications() { return authentications; } /** - * Get authentication for the given name. - * - * @param authName The authentication name - * @return The authentication, null if not found - */ + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ public Authentication getAuthentication(String authName) { return authentications.get(authName); } /** - * Helper method to set username for the first HTTP basic authentication. - */ + * Helper method to set username for the first HTTP basic authentication. + */ public void setUsername(String username) { for (Authentication auth : authentications.values()) { if (auth instanceof HttpBasicAuth) { @@ -305,21 +305,21 @@ public class ApiInvoker { } /** - * Helper method to set password for the first HTTP basic authentication. - */ + * Helper method to set password for the first HTTP basic authentication. + */ public void setPassword(String password) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setPassword(password); - return; - } - } - throw new RuntimeException("No HTTP basic authentication configured!"); + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); } /** - * Helper method to set API key value for the first API key authentication. - */ + * Helper method to set API key value for the first API key authentication. + */ public void setApiKey(String apiKey) { for (Authentication auth : authentications.values()) { if (auth instanceof ApiKeyAuth) { @@ -331,8 +331,8 @@ public class ApiInvoker { } /** - * Helper method to set API key prefix for the first API key authentication. - */ + * Helper method to set API key prefix for the first API key authentication. + */ public void setApiKeyPrefix(String apiKeyPrefix) { for (Authentication auth : authentications.values()) { if (auth instanceof ApiKeyAuth) { @@ -344,18 +344,18 @@ public class ApiInvoker { } public void setConnectionTimeout(int connectionTimeout){ - this.connectionTimeout = connectionTimeout; + this.connectionTimeout = connectionTimeout; } public int getConnectionTimeout() { - return connectionTimeout; + return connectionTimeout; } /** - * Update query and header parameters based on authentication settings. - * - * @param authNames The authentications to apply - */ + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + */ private void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams) { for (String authName : authNames) { Authentication auth = authentications.get(authName); @@ -365,17 +365,21 @@ public class ApiInvoker { } public String invokeAPI(String host, String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String contentType, String[] authNames) throws ApiException, InterruptedException, ExecutionException, TimeoutException { - RequestFuture future = RequestFuture.newFuture(); - Request request = createRequest(host, path, method, queryParams, body, headerParams, formParams, contentType, authNames, future, future); - if(request != null) { - mRequestQueue.add(request); - return future.get(connectionTimeout, TimeUnit.SECONDS); - } else return "no data"; + RequestFuture future = RequestFuture.newFuture(); + Request request = createRequest(host, path, method, queryParams, body, headerParams, formParams, contentType, authNames, future, future); + if(request != null) { + mRequestQueue.add(request); + return future.get(connectionTimeout, TimeUnit.SECONDS); + } else { + return "no data"; + } } public void invokeAPI(String host, String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String contentType, String[] authNames, Response.Listener stringRequest, Response.ErrorListener errorListener) throws ApiException { - Request request = createRequest(host, path, method, queryParams, body, headerParams, formParams, contentType, authNames, stringRequest, errorListener); - if (request != null) mRequestQueue.add(request); + Request request = createRequest(host, path, method, queryParams, body, headerParams, formParams, contentType, authNames, stringRequest, errorListener); + if (request != null) { + mRequestQueue.add(request); + } } public Request createRequest(String host, String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String contentType, String[] authNames, Response.Listener stringRequest, Response.ErrorListener errorListener) throws ApiException { @@ -505,16 +509,16 @@ public class ApiInvoker { } private void initConnectionRequest(Cache cache, Network network) { - mRequestQueue = new RequestQueue(cache, network); - mRequestQueue.start(); + mRequestQueue = new RequestQueue(cache, network); + mRequestQueue.start(); } private void initConnectionRequest(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery) { - mRequestQueue = new RequestQueue(cache, network, threadPoolSize, delivery); - mRequestQueue.start(); + mRequestQueue = new RequestQueue(cache, network, threadPoolSize, delivery); + mRequestQueue.start(); } public void stopQueue() { - mRequestQueue.stop(); + mRequestQueue.stop(); } } diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/Pair.java index d83f3053c713..df9d3f03908c 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/Pair.java @@ -13,38 +13,38 @@ package io.swagger.client; public class Pair { - private String name = ""; - private String value = ""; + private String name = ""; + private String value = ""; - public Pair(String name, String value) { - setName(name); - setValue(value); - } + public Pair(String name, String value) { + setName(name); + setValue(value); + } - private void setName(String name) { - if (!isValidString(name)) return; + private void setName(String name) { + if (!isValidString(name)) return; - this.name = name; - } + this.name = name; + } - private void setValue(String value) { - if (!isValidString(value)) return; + private void setValue(String value) { + if (!isValidString(value)) return; - this.value = value; - } + this.value = value; + } - public String getName() { - return this.name; - } + public String getName() { + return this.name; + } - public String getValue() { - return this.value; - } + public String getValue() { + return this.value; + } - private boolean isValidString(String arg) { - if (arg == null) return false; - if (arg.trim().isEmpty()) return false; + private boolean isValidString(String arg) { + if (arg == null) return false; + if (arg.trim().isEmpty()) return false; - return true; - } + return true; + } } diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/PetApi.java index 02291b27fd24..644a15c5da30 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/PetApi.java @@ -63,61 +63,56 @@ public class PetApi { * @return void */ public void addPet (Pet body) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = body; - + Object postBody = body; - // create path and map variables - String path = "/pet".replaceAll("\\{format\\}","json"); + // create path and map variables + String path = "/pet".replaceAll("\\{format\\}","json"); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + "application/json", + "application/xml" + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - "application/json","application/xml" - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { "petstore_auth" }; + String[] authNames = new String[] { "petstore_auth" }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return ; - } else { - return ; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return ; + } else { + return ; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -185,68 +180,60 @@ public class PetApi { * @return void */ public void deletePet (Long petId, String apiKey) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { + Object postBody = null; + // verify the required parameter 'petId' is set + if (petId == null) { VolleyError error = new VolleyError("Missing the required parameter 'petId' when calling deletePet", - new ApiException(400, "Missing the required parameter 'petId' when calling deletePet")); - } - + new ApiException(400, "Missing the required parameter 'petId' when calling deletePet")); + } - // create path and map variables - String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); + // create path and map variables + String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + headerParams.put("api_key", ApiInvoker.parameterToString(apiKey)); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - headerParams.put("api_key", ApiInvoker.parameterToString(apiKey)); - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { "petstore_auth" }; + String[] authNames = new String[] { "petstore_auth" }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return ; - } else { - return ; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return ; + } else { + return ; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -320,62 +307,55 @@ public class PetApi { * @return List */ public List findPetsByStatus (List status) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - + Object postBody = null; - // create path and map variables - String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); + // create path and map variables + String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + queryParams.addAll(ApiInvoker.parameterToPairs("multi", "status", status)); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - queryParams.addAll(ApiInvoker.parameterToPairs("multi", "status", status)); - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { "petstore_auth" }; + String[] authNames = new String[] { "petstore_auth" }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return (List) ApiInvoker.deserialize(localVarResponse, "array", Pet.class); - } else { - return null; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return (List) ApiInvoker.deserialize(localVarResponse, "array", Pet.class); + } else { + return null; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -447,62 +427,55 @@ public class PetApi { * @return List */ public List findPetsByTags (List tags) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - + Object postBody = null; - // create path and map variables - String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); + // create path and map variables + String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + queryParams.addAll(ApiInvoker.parameterToPairs("multi", "tags", tags)); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - queryParams.addAll(ApiInvoker.parameterToPairs("multi", "tags", tags)); - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { "petstore_auth" }; + String[] authNames = new String[] { "petstore_auth" }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return (List) ApiInvoker.deserialize(localVarResponse, "array", Pet.class); - } else { - return null; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return (List) ApiInvoker.deserialize(localVarResponse, "array", Pet.class); + } else { + return null; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -574,67 +547,59 @@ public class PetApi { * @return Pet */ public Pet getPetById (Long petId) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { + Object postBody = null; + // verify the required parameter 'petId' is set + if (petId == null) { VolleyError error = new VolleyError("Missing the required parameter 'petId' when calling getPetById", - new ApiException(400, "Missing the required parameter 'petId' when calling getPetById")); - } - + new ApiException(400, "Missing the required parameter 'petId' when calling getPetById")); + } - // create path and map variables - String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); + // create path and map variables + String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { "api_key", "petstore_auth" }; + String[] authNames = new String[] { "api_key", "petstore_auth" }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return (Pet) ApiInvoker.deserialize(localVarResponse, "", Pet.class); - } else { - return null; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return (Pet) ApiInvoker.deserialize(localVarResponse, "", Pet.class); + } else { + return null; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -711,61 +676,56 @@ public class PetApi { * @return void */ public void updatePet (Pet body) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = body; - + Object postBody = body; - // create path and map variables - String path = "/pet".replaceAll("\\{format\\}","json"); + // create path and map variables + String path = "/pet".replaceAll("\\{format\\}","json"); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + "application/json", + "application/xml" + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - "application/json","application/xml" - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { "petstore_auth" }; + String[] authNames = new String[] { "petstore_auth" }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "PUT", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return ; - } else { - return ; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "PUT", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return ; + } else { + return ; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -834,77 +794,68 @@ public class PetApi { * @return void */ public void updatePetWithForm (String petId, String name, String status) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { + Object postBody = null; + // verify the required parameter 'petId' is set + if (petId == null) { VolleyError error = new VolleyError("Missing the required parameter 'petId' when calling updatePetWithForm", - new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm")); - } - + new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm")); + } - // create path and map variables - String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); + // create path and map variables + String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + "application/x-www-form-urlencoded" + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - "application/x-www-form-urlencoded" - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - if (name != null) { - localVarBuilder.addTextBody("name", ApiInvoker.parameterToString(name), ApiInvoker.TEXT_PLAIN_UTF8); - } - - if (status != null) { - localVarBuilder.addTextBody("status", ApiInvoker.parameterToString(status), ApiInvoker.TEXT_PLAIN_UTF8); - } - - + if (name != null) { + localVarBuilder.addTextBody("name", ApiInvoker.parameterToString(name), ApiInvoker.TEXT_PLAIN_UTF8); + } + if (status != null) { + localVarBuilder.addTextBody("status", ApiInvoker.parameterToString(status), ApiInvoker.TEXT_PLAIN_UTF8); + } HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - formParams.put("name", ApiInvoker.parameterToString(name)); -formParams.put("status", ApiInvoker.parameterToString(status)); + formParams.put("name", ApiInvoker.parameterToString(name)); + formParams.put("status", ApiInvoker.parameterToString(status)); + } + + String[] authNames = new String[] { "petstore_auth" }; + + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return ; + } else { + return ; } - - String[] authNames = new String[] { "petstore_auth" }; - - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return ; - } else { - return ; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); } - throw ex; - } catch (TimeoutException ex) { - throw ex; - } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -989,77 +940,67 @@ formParams.put("status", ApiInvoker.parameterToString(status)); * @return void */ public void uploadFile (Long petId, String additionalMetadata, File file) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { + Object postBody = null; + // verify the required parameter 'petId' is set + if (petId == null) { VolleyError error = new VolleyError("Missing the required parameter 'petId' when calling uploadFile", - new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile")); - } - + new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile")); + } - // create path and map variables - String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); + // create path and map variables + String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString())); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + "multipart/form-data" + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - "multipart/form-data" - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - if (additionalMetadata != null) { - localVarBuilder.addTextBody("additionalMetadata", ApiInvoker.parameterToString(additionalMetadata), ApiInvoker.TEXT_PLAIN_UTF8); - } - - if (file != null) { - localVarBuilder.addBinaryBody("file", file); - } - - + if (additionalMetadata != null) { + localVarBuilder.addTextBody("additionalMetadata", ApiInvoker.parameterToString(additionalMetadata), ApiInvoker.TEXT_PLAIN_UTF8); + } + if (file != null) { + localVarBuilder.addBinaryBody("file", file); + } HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - formParams.put("additionalMetadata", ApiInvoker.parameterToString(additionalMetadata)); + formParams.put("additionalMetadata", ApiInvoker.parameterToString(additionalMetadata)); + } + String[] authNames = new String[] { "petstore_auth" }; + + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return ; + } else { + return ; } - - String[] authNames = new String[] { "petstore_auth" }; - - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return ; - } else { - return ; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); } - throw ex; - } catch (TimeoutException ex) { - throw ex; - } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/StoreApi.java index bc3646d399ae..1aac5e84fa5e 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/StoreApi.java @@ -63,67 +63,59 @@ public class StoreApi { * @return void */ public void deleteOrder (String orderId) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - - // verify the required parameter 'orderId' is set - if (orderId == null) { + Object postBody = null; + // verify the required parameter 'orderId' is set + if (orderId == null) { VolleyError error = new VolleyError("Missing the required parameter 'orderId' when calling deleteOrder", - new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder")); - } - + new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder")); + } - // create path and map variables - String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); + // create path and map variables + String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { }; + String[] authNames = new String[] { }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return ; - } else { - return ; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return ; + } else { + return ; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -195,61 +187,54 @@ public class StoreApi { * @return Map */ public Map getInventory () throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - + Object postBody = null; - // create path and map variables - String path = "/store/inventory".replaceAll("\\{format\\}","json"); + // create path and map variables + String path = "/store/inventory".replaceAll("\\{format\\}","json"); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "api_key" }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return (Map) ApiInvoker.deserialize(localVarResponse, "map", Map.class); - } else { - return null; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return (Map) ApiInvoker.deserialize(localVarResponse, "map", Map.class); + } else { + return null; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -320,67 +305,59 @@ public class StoreApi { * @return Order */ public Order getOrderById (String orderId) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - - // verify the required parameter 'orderId' is set - if (orderId == null) { + Object postBody = null; + // verify the required parameter 'orderId' is set + if (orderId == null) { VolleyError error = new VolleyError("Missing the required parameter 'orderId' when calling getOrderById", - new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById")); - } - + new ApiException(400, "Missing the required parameter 'orderId' when calling getOrderById")); + } - // create path and map variables - String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); + // create path and map variables + String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString())); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { }; + String[] authNames = new String[] { }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return (Order) ApiInvoker.deserialize(localVarResponse, "", Order.class); - } else { - return null; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return (Order) ApiInvoker.deserialize(localVarResponse, "", Order.class); + } else { + return null; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -457,61 +434,54 @@ public class StoreApi { * @return Order */ public Order placeOrder (Order body) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = body; - + Object postBody = body; - // create path and map variables - String path = "/store/order".replaceAll("\\{format\\}","json"); + // create path and map variables + String path = "/store/order".replaceAll("\\{format\\}","json"); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { }; + String[] authNames = new String[] { }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return (Order) ApiInvoker.deserialize(localVarResponse, "", Order.class); - } else { - return null; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return (Order) ApiInvoker.deserialize(localVarResponse, "", Order.class); + } else { + return null; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/UserApi.java index 9e9dcb6853c9..0857956f749c 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/UserApi.java @@ -63,61 +63,54 @@ public class UserApi { * @return void */ public void createUser (User body) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = body; - + Object postBody = body; - // create path and map variables - String path = "/user".replaceAll("\\{format\\}","json"); + // create path and map variables + String path = "/user".replaceAll("\\{format\\}","json"); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { }; + String[] authNames = new String[] { }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return ; - } else { - return ; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return ; + } else { + return ; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -184,61 +177,54 @@ public class UserApi { * @return void */ public void createUsersWithArrayInput (List body) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = body; - + Object postBody = body; - // create path and map variables - String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); + // create path and map variables + String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { }; + String[] authNames = new String[] { }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return ; - } else { - return ; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return ; + } else { + return ; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -305,61 +291,54 @@ public class UserApi { * @return void */ public void createUsersWithListInput (List body) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = body; - + Object postBody = body; - // create path and map variables - String path = "/user/createWithList".replaceAll("\\{format\\}","json"); + // create path and map variables + String path = "/user/createWithList".replaceAll("\\{format\\}","json"); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { }; + String[] authNames = new String[] { }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return ; - } else { - return ; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return ; + } else { + return ; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -426,67 +405,59 @@ public class UserApi { * @return void */ public void deleteUser (String username) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - - // verify the required parameter 'username' is set - if (username == null) { + Object postBody = null; + // verify the required parameter 'username' is set + if (username == null) { VolleyError error = new VolleyError("Missing the required parameter 'username' when calling deleteUser", - new ApiException(400, "Missing the required parameter 'username' when calling deleteUser")); - } - + new ApiException(400, "Missing the required parameter 'username' when calling deleteUser")); + } - // create path and map variables - String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); + // create path and map variables + String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { }; + String[] authNames = new String[] { }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return ; - } else { - return ; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return ; + } else { + return ; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -559,67 +530,59 @@ public class UserApi { * @return User */ public User getUserByName (String username) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - - // verify the required parameter 'username' is set - if (username == null) { + Object postBody = null; + // verify the required parameter 'username' is set + if (username == null) { VolleyError error = new VolleyError("Missing the required parameter 'username' when calling getUserByName", - new ApiException(400, "Missing the required parameter 'username' when calling getUserByName")); - } - + new ApiException(400, "Missing the required parameter 'username' when calling getUserByName")); + } - // create path and map variables - String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); + // create path and map variables + String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { }; + String[] authNames = new String[] { }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return (User) ApiInvoker.deserialize(localVarResponse, "", User.class); - } else { - return null; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return (User) ApiInvoker.deserialize(localVarResponse, "", User.class); + } else { + return null; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -697,63 +660,56 @@ public class UserApi { * @return String */ public String loginUser (String username, String password) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - + Object postBody = null; - // create path and map variables - String path = "/user/login".replaceAll("\\{format\\}","json"); + // create path and map variables + String path = "/user/login".replaceAll("\\{format\\}","json"); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + queryParams.addAll(ApiInvoker.parameterToPairs("", "username", username)); + queryParams.addAll(ApiInvoker.parameterToPairs("", "password", password)); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - queryParams.addAll(ApiInvoker.parameterToPairs("", "username", username)); - queryParams.addAll(ApiInvoker.parameterToPairs("", "password", password)); - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { }; + String[] authNames = new String[] { }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return (String) ApiInvoker.deserialize(localVarResponse, "", String.class); - } else { - return null; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return (String) ApiInvoker.deserialize(localVarResponse, "", String.class); + } else { + return null; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -825,61 +781,54 @@ public class UserApi { * @return void */ public void logoutUser () throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = null; - + Object postBody = null; - // create path and map variables - String path = "/user/logout".replaceAll("\\{format\\}","json"); + // create path and map variables + String path = "/user/logout".replaceAll("\\{format\\}","json"); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { }; + String[] authNames = new String[] { }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return ; - } else { - return ; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return ; + } else { + return ; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** @@ -947,67 +896,59 @@ public class UserApi { * @return void */ public void updateUser (String username, User body) throws TimeoutException, ExecutionException, InterruptedException, ApiException { - Object postBody = body; - - // verify the required parameter 'username' is set - if (username == null) { + Object postBody = body; + // verify the required parameter 'username' is set + if (username == null) { VolleyError error = new VolleyError("Missing the required parameter 'username' when calling updateUser", - new ApiException(400, "Missing the required parameter 'username' when calling updateUser")); - } - + new ApiException(400, "Missing the required parameter 'username' when calling updateUser")); + } - // create path and map variables - String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); + // create path and map variables + String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); - // query params - List queryParams = new ArrayList(); - // header params - Map headerParams = new HashMap(); - // form params - Map formParams = new HashMap(); + // query params + List queryParams = new ArrayList(); + // header params + Map headerParams = new HashMap(); + // form params + Map formParams = new HashMap(); + String[] contentTypes = { + }; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - - String[] contentTypes = { - - }; - String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - - if (contentType.startsWith("multipart/form-data")) { + if (contentType.startsWith("multipart/form-data")) { // file uploading MultipartEntityBuilder localVarBuilder = MultipartEntityBuilder.create(); - - HttpEntity httpEntity = localVarBuilder.build(); postBody = httpEntity; - } else { + } else { // normal form params - } + } - String[] authNames = new String[] { }; + String[] authNames = new String[] { }; - try { - String localVarResponse = apiInvoker.invokeAPI (basePath, path, "PUT", queryParams, postBody, headerParams, formParams, contentType, authNames); - if(localVarResponse != null){ - return ; - } else { - return ; - } - } catch (ApiException ex) { - throw ex; - } catch (InterruptedException ex) { - throw ex; - } catch (ExecutionException ex) { - if(ex.getCause() instanceof VolleyError) { - VolleyError volleyError = (VolleyError)ex.getCause(); - if (volleyError.networkResponse != null) { - throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); - } - } - throw ex; - } catch (TimeoutException ex) { - throw ex; + try { + String localVarResponse = apiInvoker.invokeAPI (basePath, path, "PUT", queryParams, postBody, headerParams, formParams, contentType, authNames); + if (localVarResponse != null) { + return ; + } else { + return ; } + } catch (ApiException ex) { + throw ex; + } catch (InterruptedException ex) { + throw ex; + } catch (ExecutionException ex) { + if (ex.getCause() instanceof VolleyError) { + VolleyError volleyError = (VolleyError)ex.getCause(); + if (volleyError.networkResponse != null) { + throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage()); + } + } + throw ex; + } catch (TimeoutException ex) { + throw ex; + } } /** diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index ff48bc72ecdb..58a3022c0415 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -57,7 +57,7 @@ public class ApiKeyAuth implements Authentication { public void applyToParams(List queryParams, Map headerParams) { String value; if (apiKey == null) { - return; + return; } if (apiKeyPrefix != null) { value = apiKeyPrefix + " " + apiKey; diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index aa2e467321a1..21019099056d 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -20,28 +20,28 @@ import java.util.Map; import java.util.List; public class HttpBasicAuth implements Authentication { - private String username; - private String password; + private String username; + private String password; - public String getUsername() { - return username; - } + public String getUsername() { + return username; + } - public void setUsername(String username) { - this.username = username; - } + public void setUsername(String username) { + this.username = username; + } - public String getPassword() { - return password; - } + public String getPassword() { + return password; + } - public void setPassword(String password) { - this.password = password; - } + public void setPassword(String password) { + this.password = password; + } - @Override - public void applyToParams(List queryParams, Map headerParams) { - String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); - headerParams.put("Authorization", "Basic " + Base64.encodeToString(str.getBytes(), Base64.DEFAULT)); - } + @Override + public void applyToParams(List queryParams, Map headerParams) { + String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); + headerParams.put("Authorization", "Basic " + Base64.encodeToString(str.getBytes(), Base64.DEFAULT)); + } } diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/DeleteRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/DeleteRequest.java index 13240eaa65e6..e957462d9638 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/DeleteRequest.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/DeleteRequest.java @@ -30,75 +30,75 @@ import java.util.Map; public class DeleteRequest extends Request { - HttpEntity entity; + HttpEntity entity; - private final Response.Listener mListener; + private final Response.Listener mListener; - String contentType; - Map apiHeaders; - public DeleteRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { - super(Method.DELETE, url, errorListener); - mListener = listener; - this.entity = entity; - this.contentType = contentType; - this.apiHeaders = apiHeaders; + String contentType; + Map apiHeaders; + public DeleteRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { + super(Method.DELETE, url, errorListener); + mListener = listener; + this.entity = entity; + this.contentType = contentType; + this.apiHeaders = apiHeaders; + } + + @Override + public String getBodyContentType() { + if(entity == null) { + return null; + } + return entity.getContentType().getValue(); + } + + @Override + public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + entity.writeTo(bos); + } + catch (IOException e) { + VolleyLog.e("IOException writing to ByteArrayOutputStream"); + } + return bos.toByteArray(); + } + + @Override + protected Response parseNetworkResponse(NetworkResponse response) { + String parsed; + try { + parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); + } catch (UnsupportedEncodingException e) { + parsed = new String(response.data); + } + return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); + } + + @Override + protected void deliverResponse(String response) { + mListener.onResponse(response); + } + + /* (non-Javadoc) + * @see com.android.volley.Request#getHeaders() + */ + @Override + public Map getHeaders() throws AuthFailureError { + Map headers = super.getHeaders(); + if (headers == null || headers.equals(Collections.emptyMap())) { + headers = new HashMap(); + } + if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { + headers.putAll(apiHeaders); + } + if(contentType != null) { + headers.put("Content-Type", contentType); } - @Override - public String getBodyContentType() { - if(entity == null) { - return null; - } - return entity.getContentType().getValue(); - } - - @Override - public byte[] getBody() throws AuthFailureError { - if(entity == null) { - return null; - } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - entity.writeTo(bos); - } - catch (IOException e) { - VolleyLog.e("IOException writing to ByteArrayOutputStream"); - } - return bos.toByteArray(); - } - - @Override - protected Response parseNetworkResponse(NetworkResponse response) { - String parsed; - try { - parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); - } catch (UnsupportedEncodingException e) { - parsed = new String(response.data); - } - return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); - } - - @Override - protected void deliverResponse(String response) { - mListener.onResponse(response); - } - - /* (non-Javadoc) - * @see com.android.volley.Request#getHeaders() - */ - @Override - public Map getHeaders() throws AuthFailureError { - Map headers = super.getHeaders(); - if (headers == null || headers.equals(Collections.emptyMap())) { - headers = new HashMap(); - } - if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { - headers.putAll(apiHeaders); - } - if(contentType != null) { - headers.put("Content-Type", contentType); - } - - return headers; - } + return headers; + } } diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PatchRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PatchRequest.java index 877e2e44e253..844d49c81f98 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PatchRequest.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PatchRequest.java @@ -30,75 +30,75 @@ import java.util.Map; public class PatchRequest extends Request { - HttpEntity entity; + HttpEntity entity; - private final Response.Listener mListener; + private final Response.Listener mListener; - String contentType; - Map apiHeaders; - public PatchRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { - super(Method.PATCH, url, errorListener); - mListener = listener; - this.entity = entity; - this.contentType = contentType; - this.apiHeaders = apiHeaders; + String contentType; + Map apiHeaders; + public PatchRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { + super(Method.PATCH, url, errorListener); + mListener = listener; + this.entity = entity; + this.contentType = contentType; + this.apiHeaders = apiHeaders; + } + + @Override + public String getBodyContentType() { + if(entity == null) { + return null; + } + return entity.getContentType().getValue(); + } + + @Override + public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + entity.writeTo(bos); + } + catch (IOException e) { + VolleyLog.e("IOException writing to ByteArrayOutputStream"); + } + return bos.toByteArray(); + } + + @Override + protected Response parseNetworkResponse(NetworkResponse response) { + String parsed; + try { + parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); + } catch (UnsupportedEncodingException e) { + parsed = new String(response.data); + } + return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); + } + + @Override + protected void deliverResponse(String response) { + mListener.onResponse(response); + } + + /* (non-Javadoc) + * @see com.android.volley.Request#getHeaders() + */ + @Override + public Map getHeaders() throws AuthFailureError { + Map headers = super.getHeaders(); + if (headers == null || headers.equals(Collections.emptyMap())) { + headers = new HashMap(); + } + if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { + headers.putAll(apiHeaders); + } + if(contentType != null) { + headers.put("Content-Type", contentType); } - @Override - public String getBodyContentType() { - if(entity == null) { - return null; - } - return entity.getContentType().getValue(); - } - - @Override - public byte[] getBody() throws AuthFailureError { - if(entity == null) { - return null; - } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - entity.writeTo(bos); - } - catch (IOException e) { - VolleyLog.e("IOException writing to ByteArrayOutputStream"); - } - return bos.toByteArray(); - } - - @Override - protected Response parseNetworkResponse(NetworkResponse response) { - String parsed; - try { - parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); - } catch (UnsupportedEncodingException e) { - parsed = new String(response.data); - } - return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); - } - - @Override - protected void deliverResponse(String response) { - mListener.onResponse(response); - } - - /* (non-Javadoc) - * @see com.android.volley.Request#getHeaders() - */ - @Override - public Map getHeaders() throws AuthFailureError { - Map headers = super.getHeaders(); - if (headers == null || headers.equals(Collections.emptyMap())) { - headers = new HashMap(); - } - if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { - headers.putAll(apiHeaders); - } - if(contentType != null) { - headers.put("Content-Type", contentType); - } - - return headers; - } + return headers; + } } diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PostRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PostRequest.java index 66383b7d054c..85e537bb0aa5 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PostRequest.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PostRequest.java @@ -30,75 +30,75 @@ import java.util.Map; public class PostRequest extends Request { - HttpEntity entity; + HttpEntity entity; - private final Response.Listener mListener; + private final Response.Listener mListener; - String contentType; - Map apiHeaders; - public PostRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { - super(Method.POST, url, errorListener); - mListener = listener; - this.entity = entity; - this.contentType = contentType; - this.apiHeaders = apiHeaders; + String contentType; + Map apiHeaders; + public PostRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { + super(Method.POST, url, errorListener); + mListener = listener; + this.entity = entity; + this.contentType = contentType; + this.apiHeaders = apiHeaders; + } + + @Override + public String getBodyContentType() { + if(entity == null) { + return null; + } + return entity.getContentType().getValue(); + } + + @Override + public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + entity.writeTo(bos); + } + catch (IOException e) { + VolleyLog.e("IOException writing to ByteArrayOutputStream"); + } + return bos.toByteArray(); + } + + @Override + protected Response parseNetworkResponse(NetworkResponse response) { + String parsed; + try { + parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); + } catch (UnsupportedEncodingException e) { + parsed = new String(response.data); + } + return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); + } + + @Override + protected void deliverResponse(String response) { + mListener.onResponse(response); + } + + /* (non-Javadoc) + * @see com.android.volley.Request#getHeaders() + */ + @Override + public Map getHeaders() throws AuthFailureError { + Map headers = super.getHeaders(); + if (headers == null || headers.equals(Collections.emptyMap())) { + headers = new HashMap(); + } + if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { + headers.putAll(apiHeaders); + } + if(contentType != null) { + headers.put("Content-Type", contentType); } - @Override - public String getBodyContentType() { - if(entity == null) { - return null; - } - return entity.getContentType().getValue(); - } - - @Override - public byte[] getBody() throws AuthFailureError { - if(entity == null) { - return null; - } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - entity.writeTo(bos); - } - catch (IOException e) { - VolleyLog.e("IOException writing to ByteArrayOutputStream"); - } - return bos.toByteArray(); - } - - @Override - protected Response parseNetworkResponse(NetworkResponse response) { - String parsed; - try { - parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); - } catch (UnsupportedEncodingException e) { - parsed = new String(response.data); - } - return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); - } - - @Override - protected void deliverResponse(String response) { - mListener.onResponse(response); - } - - /* (non-Javadoc) - * @see com.android.volley.Request#getHeaders() - */ - @Override - public Map getHeaders() throws AuthFailureError { - Map headers = super.getHeaders(); - if (headers == null || headers.equals(Collections.emptyMap())) { - headers = new HashMap(); - } - if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { - headers.putAll(apiHeaders); - } - if(contentType != null) { - headers.put("Content-Type", contentType); - } - - return headers; - } + return headers; + } } diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PutRequest.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PutRequest.java index 80a54c978687..bd7f9dad7427 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PutRequest.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/request/PutRequest.java @@ -30,75 +30,75 @@ import java.util.Map; public class PutRequest extends Request { - HttpEntity entity; + HttpEntity entity; - private final Response.Listener mListener; + private final Response.Listener mListener; - String contentType; - Map apiHeaders; - public PutRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { - super(Method.PUT, url, errorListener); - mListener = listener; - this.entity = entity; - this.contentType = contentType; - this.apiHeaders = apiHeaders; + String contentType; + Map apiHeaders; + public PutRequest(String url, Map apiHeaders, String contentType, HttpEntity entity, Response.Listener listener, Response.ErrorListener errorListener) { + super(Method.PUT, url, errorListener); + mListener = listener; + this.entity = entity; + this.contentType = contentType; + this.apiHeaders = apiHeaders; + } + + @Override + public String getBodyContentType() { + if(entity == null) { + return null; + } + return entity.getContentType().getValue(); + } + + @Override + public byte[] getBody() throws AuthFailureError { + if(entity == null) { + return null; + } + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + entity.writeTo(bos); + } + catch (IOException e) { + VolleyLog.e("IOException writing to ByteArrayOutputStream"); + } + return bos.toByteArray(); + } + + @Override + protected Response parseNetworkResponse(NetworkResponse response) { + String parsed; + try { + parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); + } catch (UnsupportedEncodingException e) { + parsed = new String(response.data); + } + return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); + } + + @Override + protected void deliverResponse(String response) { + mListener.onResponse(response); + } + + /* (non-Javadoc) + * @see com.android.volley.Request#getHeaders() + */ + @Override + public Map getHeaders() throws AuthFailureError { + Map headers = super.getHeaders(); + if (headers == null || headers.equals(Collections.emptyMap())) { + headers = new HashMap(); + } + if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { + headers.putAll(apiHeaders); + } + if(contentType != null) { + headers.put("Content-Type", contentType); } - @Override - public String getBodyContentType() { - if(entity == null) { - return null; - } - return entity.getContentType().getValue(); - } - - @Override - public byte[] getBody() throws AuthFailureError { - if(entity == null) { - return null; - } - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - entity.writeTo(bos); - } - catch (IOException e) { - VolleyLog.e("IOException writing to ByteArrayOutputStream"); - } - return bos.toByteArray(); - } - - @Override - protected Response parseNetworkResponse(NetworkResponse response) { - String parsed; - try { - parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); - } catch (UnsupportedEncodingException e) { - parsed = new String(response.data); - } - return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); - } - - @Override - protected void deliverResponse(String response) { - mListener.onResponse(response); - } - - /* (non-Javadoc) - * @see com.android.volley.Request#getHeaders() - */ - @Override - public Map getHeaders() throws AuthFailureError { - Map headers = super.getHeaders(); - if (headers == null || headers.equals(Collections.emptyMap())) { - headers = new HashMap(); - } - if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) { - headers.putAll(apiHeaders); - } - if(contentType != null) { - headers.put("Content-Type", contentType); - } - - return headers; - } + return headers; + } } diff --git a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/.swagger-codegen-ignore b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/.swagger-codegen-ignore new file mode 100644 index 000000000000..c5fa491b4c55 --- /dev/null +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/README.md b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/README.md index 5fe03fcb316f..6cd17fe5c761 100644 --- a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/README.md +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/README.md @@ -1,10 +1,132 @@ -# Csharp-DotNet2 +# IO.Swagger - the C# library for the Swagger Petstore -This generator creates C# code targeting the .Net 2.0 framework. The resulting DLLs can be used in places where .Net 2.0 is the maximum supported version, such as in the Unity3d. +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. +This C# SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: 1.0.0 +- SDK version: 1.0.0 +- Build date: 2016-12-09T16:46:08.135+08:00 +- Build package: class io.swagger.codegen.languages.CsharpDotNet2ClientCodegen + + +## Frameworks supported +- .NET 2.0 + + ## Dependencies - Mono compiler -- Note: NuGet is downloaded by the mono compilation script and packages are installed with it. No dependency DLLs are bundled with this generator. +- Newtonsoft.Json.7.0.1 +- RestSharp.Net2.1.1.11 + +Note: NuGet is downloaded by the mono compilation script and packages are installed with it. No dependency DLLs are bundled with this generator + + +## Installation +Run the following command to generate the DLL +- [Mac/Linux] `/bin/sh compile-mono.sh` +- [Windows] TODO + +Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces: +```csharp +using IO.Swagger.IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.IO.Swagger.Model; +``` + +## Getting Started + +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class Example + { + public void main() + { + + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var body = new Pet(); // Pet | Pet object that needs to be added to the store + + try + { + // Add a new pet to the store + apiInstance.AddPet(body); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.AddPet: " + e.Message ); + } + } + } +} +``` + + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**AddPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**DeletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**FindPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**FindPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**GetPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**UpdatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**PlaceOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**CreateUser**](docs/UserApi.md#createuser) | **POST** /user | Create user +*UserApi* | [**CreateUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**CreateUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**DeleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**GetUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*UserApi* | [**LoginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*UserApi* | [**LogoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**UpdateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + +## Documentation for Models + + - [IO.Swagger.Model.ApiResponse](docs/ApiResponse.md) + - [IO.Swagger.Model.Category](docs/Category.md) + - [IO.Swagger.Model.Order](docs/Order.md) + - [IO.Swagger.Model.Pet](docs/Pet.md) + - [IO.Swagger.Model.Tag](docs/Tag.md) + - [IO.Swagger.Model.User](docs/User.md) + + + +## Documentation for Authorization + + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + + +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **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/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/ApiResponse.md b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/ApiResponse.md new file mode 100644 index 000000000000..6da90f0a55d6 --- /dev/null +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/ApiResponse.md @@ -0,0 +1,11 @@ +# IO.Swagger.Model.ApiResponse +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **int?** | | [optional] [default to null] +**Type** | **string** | | [optional] [default to null] +**Message** | **string** | | [optional] [default to null] + +[[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-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/Category.md b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/Category.md new file mode 100644 index 000000000000..14f993459253 --- /dev/null +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/Category.md @@ -0,0 +1,10 @@ +# IO.Swagger.Model.Category +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long?** | | [optional] [default to null] +**Name** | **string** | | [optional] [default to null] + +[[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-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/Order.md b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/Order.md new file mode 100644 index 000000000000..029b93a4fcf4 --- /dev/null +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/Order.md @@ -0,0 +1,14 @@ +# IO.Swagger.Model.Order +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long?** | | [optional] [default to null] +**PetId** | **long?** | | [optional] [default to null] +**Quantity** | **int?** | | [optional] [default to null] +**ShipDate** | **DateTime?** | | [optional] [default to null] +**Status** | **string** | Order Status | [optional] [default to null] +**Complete** | **bool?** | | [optional] [default to null] + +[[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-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/Pet.md b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/Pet.md new file mode 100644 index 000000000000..0cfae6a37765 --- /dev/null +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/Pet.md @@ -0,0 +1,14 @@ +# IO.Swagger.Model.Pet +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long?** | | [optional] [default to null] +**Category** | [**Category**](Category.md) | | [optional] [default to null] +**Name** | **string** | | [default to null] +**PhotoUrls** | **List<string>** | | [default to null] +**Tags** | [**List<Tag>**](Tag.md) | | [optional] [default to null] +**Status** | **string** | pet status in the store | [optional] [default to null] + +[[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-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md new file mode 100644 index 000000000000..2487b1e5fdda --- /dev/null +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/PetApi.md @@ -0,0 +1,544 @@ +# IO.Swagger..PetApi + +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 +[**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 +[**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 + + + +# **AddPet** +> void AddPet (Pet body) + +Add a new pet to the store + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class AddPetExample + { + public void main() + { + + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var body = new Pet(); // Pet | Pet object that needs to be added to the store + + try + { + // Add a new pet to the store + apiInstance.AddPet(body); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.AddPet: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **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) + +Deletes a pet + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class DeletePetExample + { + public void main() + { + + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var petId = 789; // long? | Pet id to delete + var apiKey = apiKey_example; // string | (optional) + + try + { + // Deletes a pet + apiInstance.DeletePet(petId, apiKey); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.DeletePet: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **long?**| Pet id to delete | + **apiKey** | **string**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **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) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class FindPetsByStatusExample + { + public void main() + { + + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var status = new List(); // List | Status values that need to be considered for filter + + try + { + // Finds Pets by status + List<Pet> result = apiInstance.FindPetsByStatus(status); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.FindPetsByStatus: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**List**](string.md)| Status values that need to be considered for filter | + +### Return type + +[**List**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **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) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class FindPetsByTagsExample + { + public void main() + { + + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var tags = new List(); // List | Tags to filter by + + try + { + // Finds Pets by tags + List<Pet> result = apiInstance.FindPetsByTags(tags); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.FindPetsByTags: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**List**](string.md)| Tags to filter by | + +### Return type + +[**List**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **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) + +Find pet by ID + +Returns a single pet + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class GetPetByIdExample + { + public void main() + { + + // Configure API key authorization: api_key + Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); + + var apiInstance = new PetApi(); + var petId = 789; // long? | ID of pet to return + + try + { + // Find pet by ID + Pet result = apiInstance.GetPetById(petId); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.GetPetById: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **long?**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **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) + +Update an existing pet + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class UpdatePetExample + { + public void main() + { + + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var body = new Pet(); // Pet | Pet object that needs to be added to the store + + try + { + // Update an existing pet + apiInstance.UpdatePet(body); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.UpdatePet: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **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, string status) + +Updates a pet in the store with form data + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class UpdatePetWithFormExample + { + public void main() + { + + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var petId = 789; // long? | ID of pet that needs to be updated + var name = name_example; // string | Updated name of the pet (optional) + var status = status_example; // string | Updated status of the pet (optional) + + try + { + // Updates a pet in the store with form data + apiInstance.UpdatePetWithForm(petId, name, status); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.UpdatePetWithForm: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **long?**| ID of pet that needs to be updated | + **name** | **string**| Updated name of the pet | [optional] + **status** | **string**| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **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, System.IO.Stream file) + +uploads an image + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class UploadFileExample + { + public void main() + { + + // Configure OAuth2 access token for authorization: petstore_auth + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + + var apiInstance = new PetApi(); + var petId = 789; // long? | ID of pet to update + var additionalMetadata = additionalMetadata_example; // string | Additional data to pass to server (optional) + var file = new System.IO.Stream(); // System.IO.Stream | file to upload (optional) + + try + { + // uploads an image + ApiResponse result = apiInstance.UploadFile(petId, additionalMetadata, file); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling PetApi.UploadFile: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **long?**| ID of pet to update | + **additionalMetadata** | **string**| Additional data to pass to server | [optional] + **file** | **System.IO.Stream**| file to upload | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **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-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md new file mode 100644 index 000000000000..bed83b157f1e --- /dev/null +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/StoreApi.md @@ -0,0 +1,260 @@ +# IO.Swagger..StoreApi + +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 +[**GetInventory**](StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +[**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 + + + +# **DeleteOrder** +> void DeleteOrder (string orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class DeleteOrderExample + { + public void main() + { + + var apiInstance = new StoreApi(); + var orderId = orderId_example; // string | ID of the order that needs to be deleted + + try + { + // Delete purchase order by ID + apiInstance.DeleteOrder(orderId); + } + catch (Exception e) + { + Debug.Print("Exception when calling StoreApi.DeleteOrder: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **string**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **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 () + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class GetInventoryExample + { + public void main() + { + + // Configure API key authorization: api_key + Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); + + var apiInstance = new StoreApi(); + + try + { + // Returns pet inventories by status + Dictionary<String, int?> result = apiInstance.GetInventory(); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling StoreApi.GetInventory: " + e.Message ); + } + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**Dictionary** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **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) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class GetOrderByIdExample + { + public void main() + { + + var apiInstance = new StoreApi(); + var orderId = 789; // long? | ID of pet that needs to be fetched + + try + { + // Find purchase order by ID + Order result = apiInstance.GetOrderById(orderId); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling StoreApi.GetOrderById: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **long?**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **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) + +Place an order for a pet + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class PlaceOrderExample + { + public void main() + { + + var apiInstance = new StoreApi(); + var body = new Order(); // Order | order placed for purchasing the pet + + try + { + // Place an order for a pet + Order result = apiInstance.PlaceOrder(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling StoreApi.PlaceOrder: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **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-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/Tag.md b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/Tag.md new file mode 100644 index 000000000000..f5ebda46b8cc --- /dev/null +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/Tag.md @@ -0,0 +1,10 @@ +# IO.Swagger.Model.Tag +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long?** | | [optional] [default to null] +**Name** | **string** | | [optional] [default to null] + +[[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-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/User.md b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/User.md new file mode 100644 index 000000000000..fdf2b4020dc2 --- /dev/null +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/User.md @@ -0,0 +1,16 @@ +# IO.Swagger.Model.User +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **long?** | | [optional] [default to null] +**Username** | **string** | | [optional] [default to null] +**FirstName** | **string** | | [optional] [default to null] +**LastName** | **string** | | [optional] [default to null] +**Email** | **string** | | [optional] [default to null] +**Password** | **string** | | [optional] [default to null] +**Phone** | **string** | | [optional] [default to null] +**UserStatus** | **int?** | User Status | [optional] [default to null] + +[[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-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md new file mode 100644 index 000000000000..6b14a5a4373f --- /dev/null +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/docs/UserApi.md @@ -0,0 +1,506 @@ +# IO.Swagger..UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**CreateUser**](UserApi.md#createuser) | **POST** /user | Create user +[**CreateUsersWithArrayInput**](UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +[**CreateUsersWithListInput**](UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +[**DeleteUser**](UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +[**GetUserByName**](UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +[**LoginUser**](UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +[**LogoutUser**](UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +[**UpdateUser**](UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + + +# **CreateUser** +> void CreateUser (User body) + +Create user + +This can only be done by the logged in user. + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class CreateUserExample + { + public void main() + { + + var apiInstance = new UserApi(); + var body = new User(); // User | Created user object + + try + { + // Create user + apiInstance.CreateUser(body); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.CreateUser: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **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) + +Creates list of users with given input array + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class CreateUsersWithArrayInputExample + { + public void main() + { + + var apiInstance = new UserApi(); + var body = new List(); // List | List of user object + + try + { + // Creates list of users with given input array + apiInstance.CreateUsersWithArrayInput(body); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.CreateUsersWithArrayInput: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **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) + +Creates list of users with given input array + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class CreateUsersWithListInputExample + { + public void main() + { + + var apiInstance = new UserApi(); + var body = new List(); // List | List of user object + + try + { + // Creates list of users with given input array + apiInstance.CreateUsersWithListInput(body); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.CreateUsersWithListInput: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **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) + +Delete user + +This can only be done by the logged in user. + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class DeleteUserExample + { + public void main() + { + + var apiInstance = new UserApi(); + var username = username_example; // string | The name that needs to be deleted + + try + { + // Delete user + apiInstance.DeleteUser(username); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.DeleteUser: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **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) + +Get user by user name + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class GetUserByNameExample + { + public void main() + { + + var apiInstance = new UserApi(); + var username = username_example; // string | The name that needs to be fetched. Use user1 for testing. + + try + { + // Get user by user name + User result = apiInstance.GetUserByName(username); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.GetUserByName: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **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) + +Logs user into the system + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class LoginUserExample + { + public void main() + { + + var apiInstance = new UserApi(); + var username = username_example; // string | The user name for login + var password = password_example; // string | The password for login in clear text + + try + { + // Logs user into the system + string result = apiInstance.LoginUser(username, password); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.LoginUser: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The user name for login | + **password** | **string**| The password for login in clear text | + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **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 () + +Logs out current logged in user session + + + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class LogoutUserExample + { + public void main() + { + + var apiInstance = new UserApi(); + + try + { + // Logs out current logged in user session + apiInstance.LogoutUser(); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.LogoutUser: " + e.Message ); + } + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **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) + +Updated user + +This can only be done by the logged in user. + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class UpdateUserExample + { + public void main() + { + + var apiInstance = new UserApi(); + var username = username_example; // string | name that need to be deleted + var body = new User(); // User | Updated user object + + try + { + // Updated user + apiInstance.UpdateUser(username, body); + } + catch (Exception e) + { + Debug.Print("Exception when calling UserApi.UpdateUser: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **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-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Client/ApiClient.cs b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Client/ApiClient.cs index 4f55f1301341..b832ff1d0f94 100644 --- a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Client/ApiClient.cs +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Client/ApiClient.cs @@ -257,13 +257,13 @@ namespace IO.Swagger.Client // determine which one to use switch(auth) { - case "petstore_auth": - - //TODO support oauth - break; case "api_key": headerParams["api_key"] = GetApiKeyWithPrefix("api_key"); + break; + case "petstore_auth": + + //TODO support oauth break; default: //TODO show warning about security definition not found diff --git a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/ApiResponse.cs b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/ApiResponse.cs index 42e259da68a2..ee748fc96b11 100644 --- a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/ApiResponse.cs @@ -8,7 +8,7 @@ using Newtonsoft.Json; namespace IO.Swagger.Model { /// - /// + /// Describes the result of uploading an image resource /// [DataContract] public class ApiResponse { diff --git a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Category.cs b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Category.cs index 3e2508259dbe..1cfd58f9873a 100644 --- a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Category.cs +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Category.cs @@ -8,7 +8,7 @@ using Newtonsoft.Json; namespace IO.Swagger.Model { /// - /// + /// A category for a pet /// [DataContract] public class Category { diff --git a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Order.cs b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Order.cs index 0f667d9c46d5..cce83477933a 100644 --- a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Order.cs +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Order.cs @@ -8,7 +8,7 @@ using Newtonsoft.Json; namespace IO.Swagger.Model { /// - /// + /// An order for a pets from the pet store /// [DataContract] public class Order { diff --git a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Pet.cs b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Pet.cs index 27ab53d3767d..01f8229ec05f 100644 --- a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Pet.cs +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Pet.cs @@ -8,7 +8,7 @@ using Newtonsoft.Json; namespace IO.Swagger.Model { /// - /// + /// A pet for sale in the pet store /// [DataContract] public class Pet { diff --git a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Tag.cs b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Tag.cs index 639e1d79eafd..558fb7c5d263 100644 --- a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Tag.cs +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/Tag.cs @@ -8,7 +8,7 @@ using Newtonsoft.Json; namespace IO.Swagger.Model { /// - /// + /// A tag for a pet /// [DataContract] public class Tag { diff --git a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/User.cs b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/User.cs index f3367f341b96..0da312eb0f44 100644 --- a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/User.cs +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/src/main/CsharpDotNet2/IO/Swagger/Model/User.cs @@ -8,7 +8,7 @@ using Newtonsoft.Json; namespace IO.Swagger.Model { /// - /// + /// A User who is purchasing from the pet store /// [DataContract] public class User { diff --git a/samples/client/petstore/typescript-angular2/default/configuration.ts b/samples/client/petstore/typescript-angular2/default/configuration.ts index dd8d4be97288..a566a180e4eb 100644 --- a/samples/client/petstore/typescript-angular2/default/configuration.ts +++ b/samples/client/petstore/typescript-angular2/default/configuration.ts @@ -2,5 +2,5 @@ export class Configuration { apiKey: string; username: string; password: string; - accessToken: string | () => string; + accessToken: string | (() => string); } \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java index 608b51f96d84..4ef2db0e2049 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/PetApi.java @@ -1,8 +1,8 @@ package io.swagger.api; -import io.swagger.model.Pet; -import io.swagger.model.ModelApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; +import io.swagger.model.Pet; import java.io.InputStream; import java.io.OutputStream; @@ -18,8 +18,6 @@ import io.swagger.annotations.ApiOperation; @Path("/") @Api(value = "/", description = "") -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) public interface PetApi { @POST @@ -27,51 +25,51 @@ public interface PetApi { @Consumes({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Add a new pet to the store", tags={ "pet", }) - public void addPet(Pet body); + public void addPet(Pet body); @DELETE @Path("/pet/{petId}") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Deletes a pet", tags={ "pet", }) - public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey); + public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey); @GET @Path("/pet/findByStatus") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Finds Pets by status", tags={ "pet", }) - public Pet findPetsByStatus(@QueryParam("status")List status); + public List findPetsByStatus(@QueryParam("status")List status); @GET @Path("/pet/findByTags") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Finds Pets by tags", tags={ "pet", }) - public Pet findPetsByTags(@QueryParam("tags")List tags); + public List findPetsByTags(@QueryParam("tags")List tags); @GET @Path("/pet/{petId}") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Find pet by ID", tags={ "pet", }) - public Pet getPetById(@PathParam("petId") Long petId); + public Pet getPetById(@PathParam("petId") Long petId); @PUT @Path("/pet") @Consumes({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Update an existing pet", tags={ "pet", }) - public void updatePet(Pet body); + public void updatePet(Pet body); @POST @Path("/pet/{petId}") @Consumes({ "application/x-www-form-urlencoded" }) @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Updates a pet in the store with form data", tags={ "pet", }) - public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status); + public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status); @POST @Path("/pet/{petId}/uploadImage") @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) @ApiOperation(value = "uploads an image", tags={ "pet" }) - public ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment fileDetail); + public ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment fileDetail); } diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java index 87a583b8712f..e26c47769b4e 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/StoreApi.java @@ -17,32 +17,30 @@ import io.swagger.annotations.ApiOperation; @Path("/") @Api(value = "/", description = "") -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) public interface StoreApi { @DELETE @Path("/store/order/{orderId}") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Delete purchase order by ID", tags={ "store", }) - public void deleteOrder(@PathParam("orderId") String orderId); + public void deleteOrder(@PathParam("orderId") String orderId); @GET @Path("/store/inventory") @Produces({ "application/json" }) @ApiOperation(value = "Returns pet inventories by status", tags={ "store", }) - public Integer getInventory(); + public Map getInventory(); @GET @Path("/store/order/{orderId}") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Find purchase order by ID", tags={ "store", }) - public Order getOrderById(@PathParam("orderId") Long orderId); + public Order getOrderById(@PathParam("orderId") Long orderId); @POST @Path("/store/order") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Place an order for a pet", tags={ "store" }) - public Order placeOrder(Order body); + public Order placeOrder(Order body); } diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java index 528af584f46e..a51b1fe0c70d 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/UserApi.java @@ -1,7 +1,7 @@ package io.swagger.api; -import io.swagger.model.User; import java.util.List; +import io.swagger.model.User; import java.io.InputStream; import java.io.OutputStream; @@ -17,56 +17,54 @@ import io.swagger.annotations.ApiOperation; @Path("/") @Api(value = "/", description = "") -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) public interface UserApi { @POST @Path("/user") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Create user", tags={ "user", }) - public void createUser(User body); + public void createUser(User body); @POST @Path("/user/createWithArray") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) - public void createUsersWithArrayInput(List body); + public void createUsersWithArrayInput(List body); @POST @Path("/user/createWithList") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Creates list of users with given input array", tags={ "user", }) - public void createUsersWithListInput(List body); + public void createUsersWithListInput(List body); @DELETE @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Delete user", tags={ "user", }) - public void deleteUser(@PathParam("username") String username); + public void deleteUser(@PathParam("username") String username); @GET @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Get user by user name", tags={ "user", }) - public User getUserByName(@PathParam("username") String username); + public User getUserByName(@PathParam("username") String username); @GET @Path("/user/login") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Logs user into the system", tags={ "user", }) - public String loginUser(@QueryParam("username")String username, @QueryParam("password")String password); + public String loginUser(@QueryParam("username")String username, @QueryParam("password")String password); @GET @Path("/user/logout") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Logs out current logged in user session", tags={ "user", }) - public void logoutUser(); + public void logoutUser(); @PUT @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) @ApiOperation(value = "Updated user", tags={ "user" }) - public void updateUser(@PathParam("username") String username, User body); + public void updateUser(@PathParam("username") String username, User body); } diff --git a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java index 9c9528200704..d9b9345d3396 100644 --- a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java @@ -1,9 +1,9 @@ package io.swagger.api.impl; import io.swagger.api.*; -import io.swagger.model.Pet; -import io.swagger.model.ModelApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; +import io.swagger.model.Pet; import java.io.InputStream; import java.io.OutputStream; @@ -19,49 +19,49 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; public class PetApiServiceImpl implements PetApi { - public void addPet(Pet body) { + public void addPet(Pet body) { // TODO: Implement... } - public void deletePet(Long petId, String apiKey) { + public void deletePet(Long petId, String apiKey) { // TODO: Implement... } - public Pet findPetsByStatus(List status) { + public List findPetsByStatus(List status) { // TODO: Implement... return null; } - public Pet findPetsByTags(List tags) { + public List findPetsByTags(List tags) { // TODO: Implement... return null; } - public Pet getPetById(Long petId) { + public Pet getPetById(Long petId) { // TODO: Implement... return null; } - public void updatePet(Pet body) { + public void updatePet(Pet body) { // TODO: Implement... } - public void updatePetWithForm(Long petId, String name, String status) { + public void updatePetWithForm(Long petId, String name, String status) { // TODO: Implement... } - public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Attachment fileDetail) { + public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Attachment fileDetail) { // TODO: Implement... return null; diff --git a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java index cbcc2de9e2a7..3f791097b6b1 100644 --- a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java @@ -18,25 +18,25 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; public class StoreApiServiceImpl implements StoreApi { - public void deleteOrder(String orderId) { + public void deleteOrder(String orderId) { // TODO: Implement... } - public Integer getInventory() { + public Map getInventory() { // TODO: Implement... return null; } - public Order getOrderById(Long orderId) { + public Order getOrderById(Long orderId) { // TODO: Implement... return null; } - public Order placeOrder(Order body) { + public Order placeOrder(Order body) { // TODO: Implement... return null; diff --git a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java index 8fac5414a23f..861273cfb7b4 100644 --- a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java @@ -1,8 +1,8 @@ package io.swagger.api.impl; import io.swagger.api.*; -import io.swagger.model.User; import java.util.List; +import io.swagger.model.User; import java.io.InputStream; import java.io.OutputStream; @@ -18,49 +18,49 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; public class UserApiServiceImpl implements UserApi { - public void createUser(User body) { + public void createUser(User body) { // TODO: Implement... } - public void createUsersWithArrayInput(List body) { + public void createUsersWithArrayInput(List body) { // TODO: Implement... } - public void createUsersWithListInput(List body) { + public void createUsersWithListInput(List body) { // TODO: Implement... } - public void deleteUser(String username) { + public void deleteUser(String username) { // TODO: Implement... } - public User getUserByName(String username) { + public User getUserByName(String username) { // TODO: Implement... return null; } - public String loginUser(String username, String password) { + public String loginUser(String username, String password) { // TODO: Implement... return null; } - public void logoutUser() { + public void logoutUser() { // TODO: Implement... } - public void updateUser(String username, User body) { + public void updateUser(String username, User body) { // TODO: Implement...