From 36f14ab757883bf1566ac1814804f131e4f59f71 Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 20 Oct 2017 22:16:41 +0800 Subject: [PATCH 01/28] update JS petstore samples --- .../client/petstore/javascript-es6/README.md | 1 + .../petstore/javascript-es6/docs/FakeApi.md | 46 ++++++++++++++++ .../petstore/javascript-es6/src/ApiClient.js | 11 ++++ .../javascript-es6/src/api/FakeApi.js | 44 ++++++++++++++++ .../petstore/javascript-promise-es6/README.md | 1 + .../javascript-promise-es6/docs/FakeApi.md | 44 ++++++++++++++++ .../javascript-promise-es6/src/ApiClient.js | 11 ++++ .../javascript-promise-es6/src/api/FakeApi.js | 50 ++++++++++++++++++ .../petstore/javascript-promise/README.md | 1 + .../javascript-promise/docs/FakeApi.md | 44 ++++++++++++++++ .../javascript-promise/src/ApiClient.js | 10 ++++ .../javascript-promise/src/api/FakeApi.js | 52 +++++++++++++++++++ samples/client/petstore/javascript/README.md | 1 + .../petstore/javascript/docs/FakeApi.md | 47 +++++++++++++++++ .../petstore/javascript/src/ApiClient.js | 10 ++++ .../petstore/javascript/src/api/FakeApi.js | 46 ++++++++++++++++ 16 files changed, 419 insertions(+) diff --git a/samples/client/petstore/javascript-es6/README.md b/samples/client/petstore/javascript-es6/README.md index 7d74305e7ce2..bbf7a369ff4c 100644 --- a/samples/client/petstore/javascript-es6/README.md +++ b/samples/client/petstore/javascript-es6/README.md @@ -100,6 +100,7 @@ Class | Method | HTTP request | Description *SwaggerPetstore.FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model *SwaggerPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *SwaggerPetstore.FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +*SwaggerPetstore.FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *SwaggerPetstore.FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data *SwaggerPetstore.FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *SwaggerPetstore.PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store diff --git a/samples/client/petstore/javascript-es6/docs/FakeApi.md b/samples/client/petstore/javascript-es6/docs/FakeApi.md index 037f5a2a9b0c..cafe836d687e 100644 --- a/samples/client/petstore/javascript-es6/docs/FakeApi.md +++ b/samples/client/petstore/javascript-es6/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -385,6 +386,51 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```javascript +import SwaggerPetstore from 'swagger_petstore'; + +let apiInstance = new SwaggerPetstore.FakeApi(); + +let param = null; // Object | request body + + +apiInstance.testInlineAdditionalProperties(param, (error, data, response) => { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/javascript-es6/src/ApiClient.js b/samples/client/petstore/javascript-es6/src/ApiClient.js index a2556b62caa2..11497febbe96 100644 --- a/samples/client/petstore/javascript-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-es6/src/ApiClient.js @@ -83,6 +83,12 @@ export default class ApiClient { if (typeof window === 'undefined') { this.agent = new superagent.agent(); } + + /* + * Allow user to override superagent agent + */ + this.requestAgent = null; + } /** @@ -398,6 +404,11 @@ export default class ApiClient { // set header parameters request.set(this.defaultHeaders).set(this.normalizeParams(headerParams)); + // set requestAgent if it is set by user + if (this.requestAgent) { + request.agent(this.requestAgent); + } + // set request timeout request.timeout(this.timeout); diff --git a/samples/client/petstore/javascript-es6/src/api/FakeApi.js b/samples/client/petstore/javascript-es6/src/api/FakeApi.js index 99741813c03f..1a5f16e94bc6 100644 --- a/samples/client/petstore/javascript-es6/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-es6/src/api/FakeApi.js @@ -391,6 +391,50 @@ export default class FakeApi { ); } + /** + * Callback function to receive the result of the testInlineAdditionalProperties operation. + * @callback module:api/FakeApi~testInlineAdditionalPropertiesCallback + * @param {String} error Error message, if any. + * @param data This operation does not return a value. + * @param {String} response The complete HTTP response. + */ + + /** + * test inline additionalProperties + * + * @param {Object} param request body + * @param {module:api/FakeApi~testInlineAdditionalPropertiesCallback} callback The callback function, accepting three arguments: error, data, response + */ + testInlineAdditionalProperties(param, callback) { + let postBody = param; + + // verify the required parameter 'param' is set + if (param === undefined || param === null) { + throw new Error("Missing the required parameter 'param' when calling testInlineAdditionalProperties"); + } + + + let pathParams = { + }; + let queryParams = { + }; + let headerParams = { + }; + let formParams = { + }; + + let authNames = []; + let contentTypes = ['application/json']; + let accepts = []; + let returnType = null; + + return this.apiClient.callApi( + '/fake/inline-additionalProperties', 'POST', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + } + /** * Callback function to receive the result of the testJsonFormData operation. * @callback module:api/FakeApi~testJsonFormDataCallback diff --git a/samples/client/petstore/javascript-promise-es6/README.md b/samples/client/petstore/javascript-promise-es6/README.md index c668dfd721ff..67af003b88dc 100644 --- a/samples/client/petstore/javascript-promise-es6/README.md +++ b/samples/client/petstore/javascript-promise-es6/README.md @@ -97,6 +97,7 @@ Class | Method | HTTP request | Description *SwaggerPetstore.FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model *SwaggerPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *SwaggerPetstore.FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +*SwaggerPetstore.FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *SwaggerPetstore.FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data *SwaggerPetstore.FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *SwaggerPetstore.PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store diff --git a/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md b/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md index 41d3591a9bbb..366f5ff7bed8 100644 --- a/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md +++ b/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -371,6 +372,49 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```javascript +import SwaggerPetstore from 'swagger_petstore'; + +let apiInstance = new SwaggerPetstore.FakeApi(); + +let param = null; // Object | request body + +apiInstance.testInlineAdditionalProperties(param).then(() => { + console.log('API called successfully.'); +}, (error) => { + console.error(error); +}); + +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js index b68c90555467..a6a1dddd8ef4 100644 --- a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js @@ -83,6 +83,12 @@ export default class ApiClient { if (typeof window === 'undefined') { this.agent = new superagent.agent(); } + + /* + * Allow user to override superagent agent + */ + this.requestAgent = null; + } /** @@ -391,6 +397,11 @@ export default class ApiClient { // set header parameters request.set(this.defaultHeaders).set(this.normalizeParams(headerParams)); + // set requestAgent if it is set by user + if (this.requestAgent) { + request.agent(this.requestAgent); + } + // set request timeout request.timeout(this.timeout); diff --git a/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js b/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js index 9bcf6796fa31..0b0b8a1a816b 100644 --- a/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js @@ -451,6 +451,56 @@ export default class FakeApi { } + /** + * test inline additionalProperties + * + * @param {Object} param request body + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response + */ + testInlineAdditionalPropertiesWithHttpInfo(param) { + let postBody = param; + + // verify the required parameter 'param' is set + if (param === undefined || param === null) { + throw new Error("Missing the required parameter 'param' when calling testInlineAdditionalProperties"); + } + + + let pathParams = { + }; + let queryParams = { + }; + let headerParams = { + }; + let formParams = { + }; + + let authNames = []; + let contentTypes = ['application/json']; + let accepts = []; + let returnType = null; + + return this.apiClient.callApi( + '/fake/inline-additionalProperties', 'POST', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType + ); + } + + /** + * test inline additionalProperties + * + * @param {Object} param request body + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + testInlineAdditionalProperties(param) { + return this.testInlineAdditionalPropertiesWithHttpInfo(param) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + + /** * test json serialization of form data * diff --git a/samples/client/petstore/javascript-promise/README.md b/samples/client/petstore/javascript-promise/README.md index 35942f17ef6a..3dbc2e674d85 100644 --- a/samples/client/petstore/javascript-promise/README.md +++ b/samples/client/petstore/javascript-promise/README.md @@ -122,6 +122,7 @@ Class | Method | HTTP request | Description *SwaggerPetstore.FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model *SwaggerPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *SwaggerPetstore.FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +*SwaggerPetstore.FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *SwaggerPetstore.FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data *SwaggerPetstore.FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *SwaggerPetstore.PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store diff --git a/samples/client/petstore/javascript-promise/docs/FakeApi.md b/samples/client/petstore/javascript-promise/docs/FakeApi.md index 52969139d4bd..8fd0dc0a6d95 100644 --- a/samples/client/petstore/javascript-promise/docs/FakeApi.md +++ b/samples/client/petstore/javascript-promise/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -371,6 +372,49 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```javascript +var SwaggerPetstore = require('swagger_petstore'); + +var apiInstance = new SwaggerPetstore.FakeApi(); + +var param = null; // Object | request body + +apiInstance.testInlineAdditionalProperties(param).then(function() { + console.log('API called successfully.'); +}, function(error) { + console.error(error); +}); + +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index 0d8ec3e50075..691f409db9eb 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -98,6 +98,10 @@ this.agent = new superagent.agent(); } + /* + * Allow user to override superagent agent + */ + this.requestAgent = null; }; /** @@ -406,6 +410,12 @@ // set header parameters request.set(this.defaultHeaders).set(this.normalizeParams(headerParams)); + + // set requestAgent if it is set by user + if (this.requestAgent) { + request.agent(this.requestAgent); + } + // set request timeout request.timeout(this.timeout); diff --git a/samples/client/petstore/javascript-promise/src/api/FakeApi.js b/samples/client/petstore/javascript-promise/src/api/FakeApi.js index 0b3b9c24e2f1..0f06c046e0e7 100644 --- a/samples/client/petstore/javascript-promise/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-promise/src/api/FakeApi.js @@ -478,6 +478,58 @@ } + /** + * test inline additionalProperties + * + * @param {Object} param request body + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response + */ + this.testInlineAdditionalPropertiesWithHttpInfo = function(param) { + var postBody = param; + + // verify the required parameter 'param' is set + if (param === undefined || param === null) { + throw new Error("Missing the required parameter 'param' when calling testInlineAdditionalProperties"); + } + + + var pathParams = { + }; + var queryParams = { + }; + var collectionQueryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = []; + var contentTypes = ['application/json']; + var accepts = []; + var returnType = null; + + return this.apiClient.callApi( + '/fake/inline-additionalProperties', 'POST', + pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType + ); + } + + /** + * test inline additionalProperties + * + * @param {Object} param request body + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.testInlineAdditionalProperties = function(param) { + return this.testInlineAdditionalPropertiesWithHttpInfo(param) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + + /** * test json serialization of form data * diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md index 402689f894a2..556caa6e87b8 100644 --- a/samples/client/petstore/javascript/README.md +++ b/samples/client/petstore/javascript/README.md @@ -125,6 +125,7 @@ Class | Method | HTTP request | Description *SwaggerPetstore.FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model *SwaggerPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *SwaggerPetstore.FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +*SwaggerPetstore.FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *SwaggerPetstore.FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data *SwaggerPetstore.FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *SwaggerPetstore.PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store diff --git a/samples/client/petstore/javascript/docs/FakeApi.md b/samples/client/petstore/javascript/docs/FakeApi.md index a4e995f4333a..f9b086c52d54 100644 --- a/samples/client/petstore/javascript/docs/FakeApi.md +++ b/samples/client/petstore/javascript/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -392,6 +393,52 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```javascript +var SwaggerPetstore = require('swagger_petstore'); + +var apiInstance = new SwaggerPetstore.FakeApi(); + +var param = null; // Object | request body + + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +apiInstance.testInlineAdditionalProperties(param, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index 5ea521843858..246500eb3e4a 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -98,6 +98,10 @@ this.agent = new superagent.agent(); } + /* + * Allow user to override superagent agent + */ + this.requestAgent = null; }; /** @@ -415,6 +419,12 @@ // set header parameters request.set(this.defaultHeaders).set(this.normalizeParams(headerParams)); + + // set requestAgent if it is set by user + if (this.requestAgent) { + request.agent(this.requestAgent); + } + // set request timeout request.timeout(this.timeout); diff --git a/samples/client/petstore/javascript/src/api/FakeApi.js b/samples/client/petstore/javascript/src/api/FakeApi.js index f7621dc00c93..81ac51959d84 100644 --- a/samples/client/petstore/javascript/src/api/FakeApi.js +++ b/samples/client/petstore/javascript/src/api/FakeApi.js @@ -418,6 +418,52 @@ ); } + /** + * Callback function to receive the result of the testInlineAdditionalProperties operation. + * @callback module:api/FakeApi~testInlineAdditionalPropertiesCallback + * @param {String} error Error message, if any. + * @param data This operation does not return a value. + * @param {String} response The complete HTTP response. + */ + + /** + * test inline additionalProperties + * + * @param {Object} param request body + * @param {module:api/FakeApi~testInlineAdditionalPropertiesCallback} callback The callback function, accepting three arguments: error, data, response + */ + this.testInlineAdditionalProperties = function(param, callback) { + var postBody = param; + + // verify the required parameter 'param' is set + if (param === undefined || param === null) { + throw new Error("Missing the required parameter 'param' when calling testInlineAdditionalProperties"); + } + + + var pathParams = { + }; + var queryParams = { + }; + var collectionQueryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = []; + var contentTypes = ['application/json']; + var accepts = []; + var returnType = null; + + return this.apiClient.callApi( + '/fake/inline-additionalProperties', 'POST', + pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + } + /** * Callback function to receive the result of the testJsonFormData operation. * @callback module:api/FakeApi~testJsonFormDataCallback From 4d994a2045a0b596b6b5e5d110fcb2f308d66db9 Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 20 Oct 2017 22:17:09 +0800 Subject: [PATCH 02/28] update ruby petstore samples --- samples/client/petstore/ruby/README.md | 14 +- .../petstore/ruby/docs/AnotherFakeApi.md | 56 ++++++++ .../client/petstore/ruby/docs/DefaultApi.md | 93 +++++++++++++ samples/client/petstore/ruby/docs/FakeApi.md | 47 +++++++ samples/client/petstore/ruby/lib/petstore.rb | 1 + .../ruby/lib/petstore/api/another_fake_api.rb | 78 +++++++++++ .../ruby/lib/petstore/api/default_api.rb | 126 ++++++++++++++++++ .../ruby/lib/petstore/api/fake_api.rb | 52 ++++++++ .../ruby/spec/api/another_fake_api_spec.rb | 47 +++++++ .../ruby/spec/api/default_api_spec.rb | 58 ++++++++ 10 files changed, 566 insertions(+), 6 deletions(-) create mode 100644 samples/client/petstore/ruby/docs/AnotherFakeApi.md create mode 100644 samples/client/petstore/ruby/docs/DefaultApi.md create mode 100644 samples/client/petstore/ruby/lib/petstore/api/another_fake_api.rb create mode 100644 samples/client/petstore/ruby/lib/petstore/api/default_api.rb create mode 100644 samples/client/petstore/ruby/spec/api/another_fake_api_spec.rb create mode 100644 samples/client/petstore/ruby/spec/api/default_api_spec.rb diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 4903f7624708..84d01e186c4a 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -54,17 +54,17 @@ Please follow the [installation](#installation) procedure and then run the follo # Load the gem require 'petstore' -api_instance = Petstore::FakeApi.new +api_instance = Petstore::AnotherFakeApi.new + +body = Petstore::Client.new # Client | client model -opts = { - body: Petstore::OuterBoolean.new # OuterBoolean | Input boolean as post body -} begin - result = api_instance.fake_outer_boolean_serialize(opts) + #To test special tags + result = api_instance.test_special_tags(body) p result rescue Petstore::ApiError => e - puts "Exception when calling FakeApi->fake_outer_boolean_serialize: #{e}" + puts "Exception when calling AnotherFakeApi->test_special_tags: #{e}" end ``` @@ -75,6 +75,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*Petstore::AnotherFakeApi* | [**test_special_tags**](docs/AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags *Petstore::FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean | *Petstore::FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite | *Petstore::FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | @@ -82,6 +83,7 @@ Class | Method | HTTP request | Description *Petstore::FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model *Petstore::FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *Petstore::FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters +*Petstore::FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *Petstore::FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data *Petstore::FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case *Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store diff --git a/samples/client/petstore/ruby/docs/AnotherFakeApi.md b/samples/client/petstore/ruby/docs/AnotherFakeApi.md new file mode 100644 index 000000000000..a198df230eba --- /dev/null +++ b/samples/client/petstore/ruby/docs/AnotherFakeApi.md @@ -0,0 +1,56 @@ +# Petstore::AnotherFakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**test_special_tags**](AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags + + +# **test_special_tags** +> Client test_special_tags(body) + +To test special tags + +To test special tags + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::AnotherFakeApi.new + +body = Petstore::Client.new # Client | client model + + +begin + #To test special tags + result = api_instance.test_special_tags(body) + p result +rescue Petstore::ApiError => e + puts "Exception when calling AnotherFakeApi->test_special_tags: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + + diff --git a/samples/client/petstore/ruby/docs/DefaultApi.md b/samples/client/petstore/ruby/docs/DefaultApi.md new file mode 100644 index 000000000000..0790d1278a16 --- /dev/null +++ b/samples/client/petstore/ruby/docs/DefaultApi.md @@ -0,0 +1,93 @@ +# Petstore::DefaultApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**get_xml_features**](DefaultApi.md#get_xml_features) | **GET** /fake/xmlFeatures | Get some XML +[**post_xml_features**](DefaultApi.md#post_xml_features) | **POST** /fake/xmlFeatures | Post some xml + + +# **get_xml_features** +> XmlObject get_xml_features + +Get some XML + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::DefaultApi.new + +begin + #Get some XML + result = api_instance.get_xml_features + p result +rescue Petstore::ApiError => e + puts "Exception when calling DefaultApi->get_xml_features: #{e}" +end +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**XmlObject**](XmlObject.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/xml + - **Accept**: application/xml + + + +# **post_xml_features** +> post_xml_features(xml_object) + +Post some xml + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::DefaultApi.new + +xml_object = Petstore::XmlObject.new # XmlObject | + + +begin + #Post some xml + api_instance.post_xml_features(xml_object) +rescue Petstore::ApiError => e + puts "Exception when calling DefaultApi->post_xml_features: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **xml_object** | [**XmlObject**](XmlObject.md)| | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/xml + - **Accept**: application/xml + + + diff --git a/samples/client/petstore/ruby/docs/FakeApi.md b/samples/client/petstore/ruby/docs/FakeApi.md index 97c2efb11c2c..72aaf8460e4f 100644 --- a/samples/client/petstore/ruby/docs/FakeApi.md +++ b/samples/client/petstore/ruby/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters +[**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data @@ -393,6 +394,52 @@ No authorization required +# **test_inline_additional_properties** +> test_inline_additional_properties(param) + +test inline additionalProperties + + + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new + +param = nil # Object | request body + + +begin + #test inline additionalProperties + api_instance.test_inline_additional_properties(param) +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->test_inline_additional_properties: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + + # **test_json_form_data** > test_json_form_data(param, param2) diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index 605e44333dd3..e2cafdbe706e 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -55,6 +55,7 @@ require 'petstore/models/cat' require 'petstore/models/dog' # APIs +require 'petstore/api/another_fake_api' require 'petstore/api/fake_api' require 'petstore/api/fake_classname_tags123_api' require 'petstore/api/pet_api' diff --git a/samples/client/petstore/ruby/lib/petstore/api/another_fake_api.rb b/samples/client/petstore/ruby/lib/petstore/api/another_fake_api.rb new file mode 100644 index 000000000000..5c93e4521c80 --- /dev/null +++ b/samples/client/petstore/ruby/lib/petstore/api/another_fake_api.rb @@ -0,0 +1,78 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.3.0-SNAPSHOT + +=end + +require "uri" + +module Petstore + class AnotherFakeApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + + # To test special tags + # To test special tags + # @param body client model + # @param [Hash] opts the optional parameters + # @return [Client] + def test_special_tags(body, opts = {}) + data, _status_code, _headers = test_special_tags_with_http_info(body, opts) + return data + end + + # To test special tags + # To test special tags + # @param body client model + # @param [Hash] opts the optional parameters + # @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers + def test_special_tags_with_http_info(body, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: AnotherFakeApi.test_special_tags ..." + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling AnotherFakeApi.test_special_tags" + end + # resource path + local_var_path = "/another-fake/dummy" + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(body) + auth_names = [] + data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'Client') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: AnotherFakeApi#test_special_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/samples/client/petstore/ruby/lib/petstore/api/default_api.rb b/samples/client/petstore/ruby/lib/petstore/api/default_api.rb new file mode 100644 index 000000000000..1d542fe75480 --- /dev/null +++ b/samples/client/petstore/ruby/lib/petstore/api/default_api.rb @@ -0,0 +1,126 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.3.0-SNAPSHOT + +=end + +require "uri" + +module Petstore + class DefaultApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + + # Get some XML + # + # @param [Hash] opts the optional parameters + # @return [XmlObject] + def get_xml_features(opts = {}) + data, _status_code, _headers = get_xml_features_with_http_info(opts) + return data + end + + # Get some XML + # + # @param [Hash] opts the optional parameters + # @return [Array<(XmlObject, Fixnum, Hash)>] XmlObject data, response status code and response headers + def get_xml_features_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: DefaultApi.get_xml_features ..." + end + # resource path + local_var_path = "/fake/xmlFeatures" + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/xml']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/xml']) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = [] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'XmlObject') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: DefaultApi#get_xml_features\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Post some xml + # + # @param xml_object + # @param [Hash] opts the optional parameters + # @return [nil] + def post_xml_features(xml_object, opts = {}) + post_xml_features_with_http_info(xml_object, opts) + return nil + end + + # Post some xml + # + # @param xml_object + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def post_xml_features_with_http_info(xml_object, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: DefaultApi.post_xml_features ..." + end + # verify the required parameter 'xml_object' is set + if @api_client.config.client_side_validation && xml_object.nil? + fail ArgumentError, "Missing the required parameter 'xml_object' when calling DefaultApi.post_xml_features" + end + # resource path + local_var_path = "/fake/xmlFeatures" + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/xml']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/xml']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(xml_object) + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: DefaultApi#post_xml_features\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb b/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb index 7951ac39df87..56e68e4422b0 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb @@ -517,6 +517,58 @@ module Petstore return data, status_code, headers end + # test inline additionalProperties + # + # @param param request body + # @param [Hash] opts the optional parameters + # @return [nil] + def test_inline_additional_properties(param, opts = {}) + test_inline_additional_properties_with_http_info(param, opts) + return nil + end + + # test inline additionalProperties + # + # @param param request body + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def test_inline_additional_properties_with_http_info(param, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: FakeApi.test_inline_additional_properties ..." + end + # verify the required parameter 'param' is set + if @api_client.config.client_side_validation && param.nil? + fail ArgumentError, "Missing the required parameter 'param' when calling FakeApi.test_inline_additional_properties" + end + # resource path + local_var_path = "/fake/inline-additionalProperties" + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(param) + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_inline_additional_properties\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # test json serialization of form data # # @param param field1 diff --git a/samples/client/petstore/ruby/spec/api/another_fake_api_spec.rb b/samples/client/petstore/ruby/spec/api/another_fake_api_spec.rb new file mode 100644 index 000000000000..269359233163 --- /dev/null +++ b/samples/client/petstore/ruby/spec/api/another_fake_api_spec.rb @@ -0,0 +1,47 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.3.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' + +# Unit tests for Petstore::AnotherFakeApi +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'AnotherFakeApi' do + before do + # run before each test + @instance = Petstore::AnotherFakeApi.new + end + + after do + # run after each test + end + + describe 'test an instance of AnotherFakeApi' do + it 'should create an instance of AnotherFakeApi' do + expect(@instance).to be_instance_of(Petstore::AnotherFakeApi) + end + end + + # unit tests for test_special_tags + # To test special tags + # To test special tags + # @param body client model + # @param [Hash] opts the optional parameters + # @return [Client] + describe 'test_special_tags test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/client/petstore/ruby/spec/api/default_api_spec.rb b/samples/client/petstore/ruby/spec/api/default_api_spec.rb new file mode 100644 index 000000000000..714609b99004 --- /dev/null +++ b/samples/client/petstore/ruby/spec/api/default_api_spec.rb @@ -0,0 +1,58 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.3.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' + +# Unit tests for Petstore::DefaultApi +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'DefaultApi' do + before do + # run before each test + @instance = Petstore::DefaultApi.new + end + + after do + # run after each test + end + + describe 'test an instance of DefaultApi' do + it 'should create an instance of DefaultApi' do + expect(@instance).to be_instance_of(Petstore::DefaultApi) + end + end + + # unit tests for get_xml_features + # Get some XML + # + # @param [Hash] opts the optional parameters + # @return [XmlObject] + describe 'get_xml_features test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for post_xml_features + # Post some xml + # + # @param xml_object + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'post_xml_features test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end From af2089777d9cea7525a26e8b0ccd7a1ec4f7925c Mon Sep 17 00:00:00 2001 From: Giulio Pulina Date: Sat, 21 Oct 2017 17:57:43 +0200 Subject: [PATCH 03/28] Fixed link to open issues (correct label is 'help wanted') (#6779) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8f432b095f4d..a727baf58725 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project) [![PR Stats](http://issuestats.com/github/swagger-api/swagger-codegen/badge/pr)](http://issuestats.com/github/swagger-api/swagger-codegen) [![Issue Stats](http://issuestats.com/github/swagger-api/swagger-codegen/badge/issue)](http://issuestats.com/github/swagger-api/swagger-codegen) -:star::star::star: If you would like to contribute, please refer to [guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md) and a list of [open tasks](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22Need+community+contribution%22).:star::star::star: +:star::star::star: If you would like to contribute, please refer to [guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md) and a list of [open tasks](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22).:star::star::star: :notebook_with_decorative_cover: For more information, please refer to the [Wiki page](https://github.com/swagger-api/swagger-codegen/wiki) and [FAQ](https://github.com/swagger-api/swagger-codegen/wiki/FAQ) :notebook_with_decorative_cover: @@ -1032,7 +1032,7 @@ Here is a list of template creators: Here are the requirements to become a core team member: - rank within top 50 in https://github.com/swagger-api/swagger-codegen/graphs/contributors - - to contribute, here are some good [starting points](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22Need+community+contribution%22) + - to contribute, here are some good [starting points](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) - regular contributions to the project - about 3 hours per week - for contribution, it can be addressing issues, reviewing PRs submitted by others, submitting PR to fix bugs or make enhancements, etc From d2eb7cb35bb273880aa562f12b94dcec5b24d420 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 22 Oct 2017 22:09:50 +0800 Subject: [PATCH 04/28] remove unused files from Ruby petstore client --- .../client/petstore/ruby/docs/DefaultApi.md | 93 ------------- .../ruby/lib/petstore/api/default_api.rb | 126 ------------------ .../ruby/spec/api/default_api_spec.rb | 58 -------- 3 files changed, 277 deletions(-) delete mode 100644 samples/client/petstore/ruby/docs/DefaultApi.md delete mode 100644 samples/client/petstore/ruby/lib/petstore/api/default_api.rb delete mode 100644 samples/client/petstore/ruby/spec/api/default_api_spec.rb diff --git a/samples/client/petstore/ruby/docs/DefaultApi.md b/samples/client/petstore/ruby/docs/DefaultApi.md deleted file mode 100644 index 0790d1278a16..000000000000 --- a/samples/client/petstore/ruby/docs/DefaultApi.md +++ /dev/null @@ -1,93 +0,0 @@ -# Petstore::DefaultApi - -All URIs are relative to *http://petstore.swagger.io:80/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**get_xml_features**](DefaultApi.md#get_xml_features) | **GET** /fake/xmlFeatures | Get some XML -[**post_xml_features**](DefaultApi.md#post_xml_features) | **POST** /fake/xmlFeatures | Post some xml - - -# **get_xml_features** -> XmlObject get_xml_features - -Get some XML - -### Example -```ruby -# load the gem -require 'petstore' - -api_instance = Petstore::DefaultApi.new - -begin - #Get some XML - result = api_instance.get_xml_features - p result -rescue Petstore::ApiError => e - puts "Exception when calling DefaultApi->get_xml_features: #{e}" -end -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -[**XmlObject**](XmlObject.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/xml - - **Accept**: application/xml - - - -# **post_xml_features** -> post_xml_features(xml_object) - -Post some xml - -### Example -```ruby -# load the gem -require 'petstore' - -api_instance = Petstore::DefaultApi.new - -xml_object = Petstore::XmlObject.new # XmlObject | - - -begin - #Post some xml - api_instance.post_xml_features(xml_object) -rescue Petstore::ApiError => e - puts "Exception when calling DefaultApi->post_xml_features: #{e}" -end -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **xml_object** | [**XmlObject**](XmlObject.md)| | - -### Return type - -nil (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/xml - - **Accept**: application/xml - - - diff --git a/samples/client/petstore/ruby/lib/petstore/api/default_api.rb b/samples/client/petstore/ruby/lib/petstore/api/default_api.rb deleted file mode 100644 index 1d542fe75480..000000000000 --- a/samples/client/petstore/ruby/lib/petstore/api/default_api.rb +++ /dev/null @@ -1,126 +0,0 @@ -=begin -#Swagger Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 2.3.0-SNAPSHOT - -=end - -require "uri" - -module Petstore - class DefaultApi - attr_accessor :api_client - - def initialize(api_client = ApiClient.default) - @api_client = api_client - end - - # Get some XML - # - # @param [Hash] opts the optional parameters - # @return [XmlObject] - def get_xml_features(opts = {}) - data, _status_code, _headers = get_xml_features_with_http_info(opts) - return data - end - - # Get some XML - # - # @param [Hash] opts the optional parameters - # @return [Array<(XmlObject, Fixnum, Hash)>] XmlObject data, response status code and response headers - def get_xml_features_with_http_info(opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: DefaultApi.get_xml_features ..." - end - # resource path - local_var_path = "/fake/xmlFeatures" - - # query parameters - query_params = {} - - # header parameters - header_params = {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/xml']) - # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/xml']) - - # form parameters - form_params = {} - - # http body (model) - post_body = nil - auth_names = [] - data, status_code, headers = @api_client.call_api(:GET, local_var_path, - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names, - :return_type => 'XmlObject') - if @api_client.config.debugging - @api_client.config.logger.debug "API called: DefaultApi#get_xml_features\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Post some xml - # - # @param xml_object - # @param [Hash] opts the optional parameters - # @return [nil] - def post_xml_features(xml_object, opts = {}) - post_xml_features_with_http_info(xml_object, opts) - return nil - end - - # Post some xml - # - # @param xml_object - # @param [Hash] opts the optional parameters - # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers - def post_xml_features_with_http_info(xml_object, opts = {}) - if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: DefaultApi.post_xml_features ..." - end - # verify the required parameter 'xml_object' is set - if @api_client.config.client_side_validation && xml_object.nil? - fail ArgumentError, "Missing the required parameter 'xml_object' when calling DefaultApi.post_xml_features" - end - # resource path - local_var_path = "/fake/xmlFeatures" - - # query parameters - query_params = {} - - # header parameters - header_params = {} - # HTTP header 'Accept' (if needed) - header_params['Accept'] = @api_client.select_header_accept(['application/xml']) - # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/xml']) - - # form parameters - form_params = {} - - # http body (model) - post_body = @api_client.object_to_http_body(xml_object) - auth_names = [] - data, status_code, headers = @api_client.call_api(:POST, local_var_path, - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: DefaultApi#post_xml_features\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - end -end diff --git a/samples/client/petstore/ruby/spec/api/default_api_spec.rb b/samples/client/petstore/ruby/spec/api/default_api_spec.rb deleted file mode 100644 index 714609b99004..000000000000 --- a/samples/client/petstore/ruby/spec/api/default_api_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -=begin -#Swagger Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 2.3.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' - -# Unit tests for Petstore::DefaultApi -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) -# Please update as you see appropriate -describe 'DefaultApi' do - before do - # run before each test - @instance = Petstore::DefaultApi.new - end - - after do - # run after each test - end - - describe 'test an instance of DefaultApi' do - it 'should create an instance of DefaultApi' do - expect(@instance).to be_instance_of(Petstore::DefaultApi) - end - end - - # unit tests for get_xml_features - # Get some XML - # - # @param [Hash] opts the optional parameters - # @return [XmlObject] - describe 'get_xml_features test' do - it "should work" do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - # unit tests for post_xml_features - # Post some xml - # - # @param xml_object - # @param [Hash] opts the optional parameters - # @return [nil] - describe 'post_xml_features test' do - it "should work" do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end From 7cbd36e75be360da1dd44a6a8c9db48ba802916c Mon Sep 17 00:00:00 2001 From: Gustavo Paz <32820138+gustavoapaz@users.noreply.github.com> Date: Sun, 22 Oct 2017 10:00:48 -0500 Subject: [PATCH 05/28] [Java][JAXRS-CXF] Improve API documentation in the CXF Server stub and Client generation (#6708) * Inclusion of API documentation in CXF Server stub generation * Inclusion of API documentation in CXF client generation * Update of the Petstore CXF server sample * Update of the Petstore CXF client sample * Update of the Petstore CXF server annotated base path sample * Update of the Petstore CXF server non spring application sample * Changed {{{appDescription}}} to {{appDescription}} to use the HTML-escaped value in handling special characters like <, > in the description following the correction made by @wing328 * Update of the Petstore CXF samples --- .../main/resources/JavaJaxRS/cxf/api.mustache | 20 +++++++ .../JavaJaxRS/cxf/apiServiceImpl.mustache | 20 +++++++ .../resources/JavaJaxRS/cxf/api_test.mustache | 14 ++++- .../resources/JavaJaxRS/cxf/pojo.mustache | 8 +++ .../main/resources/JavaJaxRS/cxf/pom.mustache | 3 ++ .../JavaJaxRS/cxf/server/pom.mustache | 3 ++ .../client/petstore/jaxrs-cxf-client/pom.xml | 1 + .../src/gen/java/io/swagger/api/PetApi.java | 54 +++++++++++++++++++ .../src/gen/java/io/swagger/api/StoreApi.java | 30 +++++++++++ .../src/gen/java/io/swagger/api/UserApi.java | 54 +++++++++++++++++++ .../gen/java/io/swagger/model/Category.java | 3 ++ .../io/swagger/model/ModelApiResponse.java | 3 ++ .../src/gen/java/io/swagger/model/Order.java | 6 +++ .../src/gen/java/io/swagger/model/Pet.java | 6 +++ .../src/gen/java/io/swagger/model/Tag.java | 3 ++ .../src/gen/java/io/swagger/model/User.java | 6 +++ .../jaxrs-cxf-annotated-base-path/pom.xml | 1 + .../src/gen/java/io/swagger/api/PetApi.java | 54 +++++++++++++++++++ .../src/gen/java/io/swagger/api/StoreApi.java | 30 +++++++++++ .../src/gen/java/io/swagger/api/UserApi.java | 54 +++++++++++++++++++ .../gen/java/io/swagger/model/Category.java | 3 ++ .../io/swagger/model/ModelApiResponse.java | 3 ++ .../src/gen/java/io/swagger/model/Order.java | 6 +++ .../src/gen/java/io/swagger/model/Pet.java | 6 +++ .../src/gen/java/io/swagger/model/Tag.java | 3 ++ .../src/gen/java/io/swagger/model/User.java | 6 +++ .../swagger/api/impl/PetApiServiceImpl.java | 54 +++++++++++++++++++ .../swagger/api/impl/StoreApiServiceImpl.java | 30 +++++++++++ .../swagger/api/impl/UserApiServiceImpl.java | 54 +++++++++++++++++++ .../petstore/jaxrs-cxf-non-spring-app/pom.xml | 1 + .../src/gen/java/io/swagger/api/PetApi.java | 54 +++++++++++++++++++ .../src/gen/java/io/swagger/api/StoreApi.java | 30 +++++++++++ .../src/gen/java/io/swagger/api/UserApi.java | 54 +++++++++++++++++++ .../gen/java/io/swagger/model/Category.java | 3 ++ .../io/swagger/model/ModelApiResponse.java | 3 ++ .../src/gen/java/io/swagger/model/Order.java | 6 +++ .../src/gen/java/io/swagger/model/Pet.java | 6 +++ .../src/gen/java/io/swagger/model/Tag.java | 3 ++ .../src/gen/java/io/swagger/model/User.java | 6 +++ .../swagger/api/impl/PetApiServiceImpl.java | 54 +++++++++++++++++++ .../swagger/api/impl/StoreApiServiceImpl.java | 30 +++++++++++ .../swagger/api/impl/UserApiServiceImpl.java | 54 +++++++++++++++++++ samples/server/petstore/jaxrs-cxf/pom.xml | 3 +- .../java/io/swagger/api/AnotherFakeApi.java | 12 +++++ .../src/gen/java/io/swagger/api/FakeApi.java | 30 +++++++++++ .../swagger/api/FakeClassnameTags123Api.java | 10 ++++ .../src/gen/java/io/swagger/api/PetApi.java | 54 +++++++++++++++++++ .../src/gen/java/io/swagger/api/StoreApi.java | 30 +++++++++++ .../src/gen/java/io/swagger/api/UserApi.java | 54 +++++++++++++++++++ .../java/io/swagger/model/Capitalization.java | 3 ++ .../gen/java/io/swagger/model/ClassModel.java | 3 ++ .../io/swagger/model/Model200Response.java | 3 ++ .../java/io/swagger/model/ModelReturn.java | 3 ++ .../src/gen/java/io/swagger/model/Name.java | 3 ++ .../src/gen/java/io/swagger/model/Order.java | 3 ++ .../src/gen/java/io/swagger/model/Pet.java | 3 ++ .../src/gen/java/io/swagger/model/User.java | 3 ++ .../api/impl/AnotherFakeApiServiceImpl.java | 12 +++++ .../swagger/api/impl/FakeApiServiceImpl.java | 30 +++++++++++ .../FakeClassnameTags123ApiServiceImpl.java | 10 ++++ .../swagger/api/impl/PetApiServiceImpl.java | 54 +++++++++++++++++++ .../swagger/api/impl/StoreApiServiceImpl.java | 30 +++++++++++ .../swagger/api/impl/UserApiServiceImpl.java | 54 +++++++++++++++++++ 63 files changed, 1247 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache index 5e33aefc1d32..8bc7a22fd768 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/api.mustache @@ -22,6 +22,16 @@ import javax.validation.constraints.*; import javax.validation.Valid; {{/useBeanValidation}} +{{#appName}} +/** + * {{{appName}}} + * + {{#appDescription}} + *

{{{appDescription}}} + * + {{/appDescription}} + */ +{{/appName}} @Path("{{^useAnnotatedBasePath}}/{{/useAnnotatedBasePath}}{{#useAnnotatedBasePath}}{{contextPath}}{{/useAnnotatedBasePath}}") @Api(value = "/", description = "{{description}}") {{#addConsumesProducesJson}} @@ -32,6 +42,16 @@ public interface {{classname}} { {{#operations}} {{#operation}} + {{#summary}} + /** + * {{summary}} + * + {{#notes}} + * {{notes}} + * + {{/notes}} + */ + {{/summary}} @{{httpMethod}} {{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}} {{#hasConsumes}} 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 d216ed025388..f677e3a835e5 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/apiServiceImpl.mustache @@ -25,9 +25,29 @@ import org.springframework.stereotype.Service; {{/useSpringAnnotationConfig}} {{#description}} {{/description}} +{{#appName}} +/** + * {{{appName}}} + * + {{#appDescription}} + *

{{{appDescription}}} + {{/appDescription}} + * + */ +{{/appName}} public class {{classname}}ServiceImpl implements {{classname}} { {{#operations}} {{#operation}} + {{#summary}} + /** + * {{summary}} + * + {{#notes}} + * {{notes}} + * + {{/notes}} + */ + {{/summary}} public {{>returnTypes}} {{nickname}}({{#allParams}}{{>queryParamsImpl}}{{>pathParamsImpl}}{{>headerParamsImpl}}{{>bodyParamsImpl}}{{>formParamsImpl}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { // TODO: Implement... 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 d32c2e3a9644..67a7db053867 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 @@ -42,7 +42,15 @@ import org.springframework.test.context.web.WebAppConfiguration; /** - * API tests for {{classname}} + {{#appName}} + * {{{appName}}} + * + {{/appName}} + {{#appDescription}} + *

{{{appDescription}}} + * + {{/appDescription}} + * API tests for {{classname}} */ {{#generateSpringBootApplication}} @RunWith(SpringJUnit4ClassRunner.class) @@ -91,10 +99,14 @@ public class {{classname}}Test { {{#operations}}{{#operation}} /** + {{#summary}} * {{summary}} * + {{#notes}} * {{notes}} * + {{/notes}} + {{/summary}} * @throws ApiException * if the Api call fails */ diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache index 0412381d5349..eb53f2248cf3 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pojo.mustache @@ -17,6 +17,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; {{^parent}}@XmlRootElement(name="{{classname}}"){{/parent}} {{/withXml}} {{#description}} +/** + * {{{description}}} + **/ @ApiModel(description="{{{description}}}") {{/description}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { @@ -29,6 +32,11 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { @XmlElement(name="{{baseName}}"{{#required}}, required = {{required}}{{/required}}) {{/withXml}} @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") +{{#description}} + /** + * {{{description}}} + **/ +{{/description}} private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}} {{#vars}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pom.mustache index df7a5a3bcb40..02c853a75592 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/pom.mustache @@ -4,6 +4,9 @@ {{artifactId}} jar {{artifactId}} + {{#appDescription}} + {{appDescription}} + {{/appDescription}} {{artifactVersion}} src/main/java diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/server/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/server/pom.mustache index 2bc2739b1fe3..c7be1d0b1728 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/server/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/server/pom.mustache @@ -4,6 +4,9 @@ {{artifactId}} war {{artifactId}} + {{#appDescription}} + {{appDescription}} + {{/appDescription}} {{artifactVersion}} src/main/java diff --git a/samples/client/petstore/jaxrs-cxf-client/pom.xml b/samples/client/petstore/jaxrs-cxf-client/pom.xml index 0c5cec231013..e2be3c4f26bd 100644 --- a/samples/client/petstore/jaxrs-cxf-client/pom.xml +++ b/samples/client/petstore/jaxrs-cxf-client/pom.xml @@ -4,6 +4,7 @@ jaxrs-cxf-petstore-client war jaxrs-cxf-petstore-client + 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. 1.0.0 src/main/java diff --git a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/api/PetApi.java b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/api/PetApi.java index 93a82ed4f6c8..f8b8a10d2886 100644 --- a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/api/PetApi.java @@ -21,10 +21,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ @Path("/") @Api(value = "/", description = "") public interface PetApi { + /** + * Add a new pet to the store + * + * + * + */ @POST @Path("/pet") @Consumes({ "application/json", "application/xml" }) @@ -34,6 +46,12 @@ public interface PetApi { @ApiResponse(code = 405, message = "Invalid input") }) public void addPet(@Valid Pet body); + /** + * Deletes a pet + * + * + * + */ @DELETE @Path("/pet/{petId}") @Produces({ "application/xml", "application/json" }) @@ -42,6 +60,12 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid pet value") }) public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey); + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + */ @GET @Path("/pet/findByStatus") @Produces({ "application/xml", "application/json" }) @@ -51,6 +75,12 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid status value") }) public List findPetsByStatus(@QueryParam("status") @NotNull List status); + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + */ @GET @Path("/pet/findByTags") @Produces({ "application/xml", "application/json" }) @@ -60,6 +90,12 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid tag value") }) public List findPetsByTags(@QueryParam("tags") @NotNull List tags); + /** + * Find pet by ID + * + * Returns a single pet + * + */ @GET @Path("/pet/{petId}") @Produces({ "application/xml", "application/json" }) @@ -70,6 +106,12 @@ public interface PetApi { @ApiResponse(code = 404, message = "Pet not found") }) public Pet getPetById(@PathParam("petId") Long petId); + /** + * Update an existing pet + * + * + * + */ @PUT @Path("/pet") @Consumes({ "application/json", "application/xml" }) @@ -81,6 +123,12 @@ public interface PetApi { @ApiResponse(code = 405, message = "Validation exception") }) public void updatePet(@Valid Pet body); + /** + * Updates a pet in the store with form data + * + * + * + */ @POST @Path("/pet/{petId}") @Consumes({ "application/x-www-form-urlencoded" }) @@ -90,6 +138,12 @@ public interface PetApi { @ApiResponse(code = 405, message = "Invalid input") }) public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status); + /** + * uploads an image + * + * + * + */ @POST @Path("/pet/{petId}/uploadImage") @Consumes({ "multipart/form-data" }) diff --git a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/api/StoreApi.java b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/api/StoreApi.java index 8ddeb8f3deab..72508ea286ab 100644 --- a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/api/StoreApi.java @@ -20,10 +20,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ @Path("/") @Api(value = "/", description = "") public interface StoreApi { + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + */ @DELETE @Path("/store/order/{orderId}") @Produces({ "application/xml", "application/json" }) @@ -33,6 +45,12 @@ public interface StoreApi { @ApiResponse(code = 404, message = "Order not found") }) public void deleteOrder(@PathParam("orderId") String orderId); + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + */ @GET @Path("/store/inventory") @Produces({ "application/json" }) @@ -41,6 +59,12 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) public Map getInventory(); + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + */ @GET @Path("/store/order/{orderId}") @Produces({ "application/xml", "application/json" }) @@ -51,6 +75,12 @@ public interface StoreApi { @ApiResponse(code = 404, message = "Order not found") }) public Order getOrderById(@PathParam("orderId") @Min(1) @Max(5) Long orderId); + /** + * Place an order for a pet + * + * + * + */ @POST @Path("/store/order") @Produces({ "application/xml", "application/json" }) diff --git a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/api/UserApi.java b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/api/UserApi.java index 5588dddf74f7..7aba6911b466 100644 --- a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/api/UserApi.java @@ -20,10 +20,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ @Path("/") @Api(value = "/", description = "") public interface UserApi { + /** + * Create user + * + * This can only be done by the logged in user. + * + */ @POST @Path("/user") @Produces({ "application/xml", "application/json" }) @@ -32,6 +44,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void createUser(@Valid User body); + /** + * Creates list of users with given input array + * + * + * + */ @POST @Path("/user/createWithArray") @Produces({ "application/xml", "application/json" }) @@ -40,6 +58,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void createUsersWithArrayInput(@Valid List body); + /** + * Creates list of users with given input array + * + * + * + */ @POST @Path("/user/createWithList") @Produces({ "application/xml", "application/json" }) @@ -48,6 +72,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void createUsersWithListInput(@Valid List body); + /** + * Delete user + * + * This can only be done by the logged in user. + * + */ @DELETE @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) @@ -57,6 +87,12 @@ public interface UserApi { @ApiResponse(code = 404, message = "User not found") }) public void deleteUser(@PathParam("username") String username); + /** + * Get user by user name + * + * + * + */ @GET @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) @@ -67,6 +103,12 @@ public interface UserApi { @ApiResponse(code = 404, message = "User not found") }) public User getUserByName(@PathParam("username") String username); + /** + * Logs user into the system + * + * + * + */ @GET @Path("/user/login") @Produces({ "application/xml", "application/json" }) @@ -76,6 +118,12 @@ public interface UserApi { @ApiResponse(code = 400, message = "Invalid username/password supplied") }) public String loginUser(@QueryParam("username") @NotNull String username, @QueryParam("password") @NotNull String password); + /** + * Logs out current logged in user session + * + * + * + */ @GET @Path("/user/logout") @Produces({ "application/xml", "application/json" }) @@ -84,6 +132,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void logoutUser(); + /** + * Updated user + * + * This can only be done by the logged in user. + * + */ @PUT @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) diff --git a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Category.java b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Category.java index 2e1f5c0c2a89..9a1956aae8cf 100644 --- a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Category.java +++ b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Category.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * A category for a pet + **/ @ApiModel(description="A category for a pet") public class Category { diff --git a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/ModelApiResponse.java b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/ModelApiResponse.java index c6dc9cbecf68..51ffbeff6da6 100644 --- a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/ModelApiResponse.java +++ b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Describes the result of uploading an image resource + **/ @ApiModel(description="Describes the result of uploading an image resource") public class ModelApiResponse { diff --git a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Order.java b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Order.java index f3083f274948..4b438955a291 100644 --- a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Order.java +++ b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Order.java @@ -14,6 +14,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * An order for a pets from the pet store + **/ @ApiModel(description="An order for a pets from the pet store") public class Order { @@ -59,6 +62,9 @@ public enum StatusEnum { } @ApiModelProperty(value = "Order Status") + /** + * Order Status + **/ private StatusEnum status = null; @ApiModelProperty(value = "") private Boolean complete = false; diff --git a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Pet.java b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Pet.java index 0776e03a9080..826a0b31bcaf 100644 --- a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Pet.java +++ b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Pet.java @@ -17,6 +17,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * A pet for sale in the pet store + **/ @ApiModel(description="A pet for sale in the pet store") public class Pet { @@ -64,6 +67,9 @@ public enum StatusEnum { } @ApiModelProperty(value = "pet status in the store") + /** + * pet status in the store + **/ private StatusEnum status = null; /** diff --git a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Tag.java b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Tag.java index 1e80911874f1..24fd1d55d2ae 100644 --- a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Tag.java +++ b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/Tag.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * A tag for a pet + **/ @ApiModel(description="A tag for a pet") public class Tag { diff --git a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/User.java b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/User.java index a0f42ad1ce72..858e8e14268a 100644 --- a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/User.java +++ b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/io/swagger/model/User.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * A User who is purchasing from the pet store + **/ @ApiModel(description="A User who is purchasing from the pet store") public class User { @@ -31,6 +34,9 @@ public class User { @ApiModelProperty(value = "") private String phone = null; @ApiModelProperty(value = "User Status") + /** + * User Status + **/ private Integer userStatus = null; /** diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/pom.xml b/samples/server/petstore/jaxrs-cxf-annotated-base-path/pom.xml index edaf8d0eeb7c..0136d8f0a768 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/pom.xml +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/pom.xml @@ -4,6 +4,7 @@ swagger-cxf-annotated-basepath war swagger-cxf-annotated-basepath + 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. 1.0.0 src/main/java diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/api/PetApi.java index f6551d8cc375..c576178bcc01 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/api/PetApi.java @@ -21,10 +21,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ @Path("/v2") @Api(value = "/", description = "") public interface PetApi { + /** + * Add a new pet to the store + * + * + * + */ @POST @Path("/pet") @Consumes({ "application/json", "application/xml" }) @@ -34,6 +46,12 @@ public interface PetApi { @ApiResponse(code = 405, message = "Invalid input") }) public void addPet(@Valid Pet body); + /** + * Deletes a pet + * + * + * + */ @DELETE @Path("/pet/{petId}") @Produces({ "application/xml", "application/json" }) @@ -42,6 +60,12 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid pet value") }) public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey); + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + */ @GET @Path("/pet/findByStatus") @Produces({ "application/xml", "application/json" }) @@ -51,6 +75,12 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid status value") }) public List findPetsByStatus(@QueryParam("status") @NotNull List status); + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + */ @GET @Path("/pet/findByTags") @Produces({ "application/xml", "application/json" }) @@ -60,6 +90,12 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid tag value") }) public List findPetsByTags(@QueryParam("tags") @NotNull List tags); + /** + * Find pet by ID + * + * Returns a single pet + * + */ @GET @Path("/pet/{petId}") @Produces({ "application/xml", "application/json" }) @@ -70,6 +106,12 @@ public interface PetApi { @ApiResponse(code = 404, message = "Pet not found") }) public Pet getPetById(@PathParam("petId") Long petId); + /** + * Update an existing pet + * + * + * + */ @PUT @Path("/pet") @Consumes({ "application/json", "application/xml" }) @@ -81,6 +123,12 @@ public interface PetApi { @ApiResponse(code = 405, message = "Validation exception") }) public void updatePet(@Valid Pet body); + /** + * Updates a pet in the store with form data + * + * + * + */ @POST @Path("/pet/{petId}") @Consumes({ "application/x-www-form-urlencoded" }) @@ -90,6 +138,12 @@ public interface PetApi { @ApiResponse(code = 405, message = "Invalid input") }) public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status); + /** + * uploads an image + * + * + * + */ @POST @Path("/pet/{petId}/uploadImage") @Consumes({ "multipart/form-data" }) diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/api/StoreApi.java index 0b00a353bc12..5e18529e1b50 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/api/StoreApi.java @@ -20,10 +20,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ @Path("/v2") @Api(value = "/", description = "") public interface StoreApi { + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + */ @DELETE @Path("/store/order/{orderId}") @Produces({ "application/xml", "application/json" }) @@ -33,6 +45,12 @@ public interface StoreApi { @ApiResponse(code = 404, message = "Order not found") }) public void deleteOrder(@PathParam("orderId") String orderId); + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + */ @GET @Path("/store/inventory") @Produces({ "application/json" }) @@ -41,6 +59,12 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) public Map getInventory(); + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + */ @GET @Path("/store/order/{orderId}") @Produces({ "application/xml", "application/json" }) @@ -51,6 +75,12 @@ public interface StoreApi { @ApiResponse(code = 404, message = "Order not found") }) public Order getOrderById(@PathParam("orderId") @Min(1) @Max(5) Long orderId); + /** + * Place an order for a pet + * + * + * + */ @POST @Path("/store/order") @Produces({ "application/xml", "application/json" }) diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/api/UserApi.java index 36a62cf2a0a9..a5fd5adf01c7 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/api/UserApi.java @@ -20,10 +20,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ @Path("/v2") @Api(value = "/", description = "") public interface UserApi { + /** + * Create user + * + * This can only be done by the logged in user. + * + */ @POST @Path("/user") @Produces({ "application/xml", "application/json" }) @@ -32,6 +44,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void createUser(@Valid User body); + /** + * Creates list of users with given input array + * + * + * + */ @POST @Path("/user/createWithArray") @Produces({ "application/xml", "application/json" }) @@ -40,6 +58,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void createUsersWithArrayInput(@Valid List body); + /** + * Creates list of users with given input array + * + * + * + */ @POST @Path("/user/createWithList") @Produces({ "application/xml", "application/json" }) @@ -48,6 +72,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void createUsersWithListInput(@Valid List body); + /** + * Delete user + * + * This can only be done by the logged in user. + * + */ @DELETE @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) @@ -57,6 +87,12 @@ public interface UserApi { @ApiResponse(code = 404, message = "User not found") }) public void deleteUser(@PathParam("username") String username); + /** + * Get user by user name + * + * + * + */ @GET @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) @@ -67,6 +103,12 @@ public interface UserApi { @ApiResponse(code = 404, message = "User not found") }) public User getUserByName(@PathParam("username") String username); + /** + * Logs user into the system + * + * + * + */ @GET @Path("/user/login") @Produces({ "application/xml", "application/json" }) @@ -76,6 +118,12 @@ public interface UserApi { @ApiResponse(code = 400, message = "Invalid username/password supplied") }) public String loginUser(@QueryParam("username") @NotNull String username, @QueryParam("password") @NotNull String password); + /** + * Logs out current logged in user session + * + * + * + */ @GET @Path("/user/logout") @Produces({ "application/xml", "application/json" }) @@ -84,6 +132,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void logoutUser(); + /** + * Updated user + * + * This can only be done by the logged in user. + * + */ @PUT @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Category.java index 2e1f5c0c2a89..9a1956aae8cf 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Category.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * A category for a pet + **/ @ApiModel(description="A category for a pet") public class Category { diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/ModelApiResponse.java index c6dc9cbecf68..51ffbeff6da6 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/ModelApiResponse.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Describes the result of uploading an image resource + **/ @ApiModel(description="Describes the result of uploading an image resource") public class ModelApiResponse { diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Order.java index f3083f274948..4b438955a291 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Order.java @@ -14,6 +14,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * An order for a pets from the pet store + **/ @ApiModel(description="An order for a pets from the pet store") public class Order { @@ -59,6 +62,9 @@ public enum StatusEnum { } @ApiModelProperty(value = "Order Status") + /** + * Order Status + **/ private StatusEnum status = null; @ApiModelProperty(value = "") private Boolean complete = false; diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Pet.java index 0776e03a9080..826a0b31bcaf 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Pet.java @@ -17,6 +17,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * A pet for sale in the pet store + **/ @ApiModel(description="A pet for sale in the pet store") public class Pet { @@ -64,6 +67,9 @@ public enum StatusEnum { } @ApiModelProperty(value = "pet status in the store") + /** + * pet status in the store + **/ private StatusEnum status = null; /** diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Tag.java index 1e80911874f1..24fd1d55d2ae 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/Tag.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * A tag for a pet + **/ @ApiModel(description="A tag for a pet") public class Tag { diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/User.java index a0f42ad1ce72..858e8e14268a 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/gen/java/io/swagger/model/User.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * A User who is purchasing from the pet store + **/ @ApiModel(description="A User who is purchasing from the pet store") public class User { @@ -31,6 +34,9 @@ public class User { @ApiModelProperty(value = "") private String phone = null; @ApiModelProperty(value = "User Status") + /** + * User Status + **/ private Integer userStatus = null; /** diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java index d9b9345d3396..0f19eb3098d4 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java @@ -18,49 +18,103 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ public class PetApiServiceImpl implements PetApi { + /** + * Add a new pet to the store + * + * + * + */ public void addPet(Pet body) { // TODO: Implement... } + /** + * Deletes a pet + * + * + * + */ public void deletePet(Long petId, String apiKey) { // TODO: Implement... } + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + */ public List findPetsByStatus(List status) { // TODO: Implement... return null; } + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + */ public List findPetsByTags(List tags) { // TODO: Implement... return null; } + /** + * Find pet by ID + * + * Returns a single pet + * + */ public Pet getPetById(Long petId) { // TODO: Implement... return null; } + /** + * Update an existing pet + * + * + * + */ public void updatePet(Pet body) { // TODO: Implement... } + /** + * Updates a pet in the store with form data + * + * + * + */ public void updatePetWithForm(Long petId, String name, String status) { // TODO: Implement... } + /** + * uploads an image + * + * + * + */ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Attachment fileDetail) { // TODO: Implement... diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java index 3f791097b6b1..9d3f93f8c3d0 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java @@ -17,25 +17,55 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ public class StoreApiServiceImpl implements StoreApi { + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + */ public void deleteOrder(String orderId) { // TODO: Implement... } + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + */ public Map getInventory() { // TODO: Implement... return null; } + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + */ public Order getOrderById(Long orderId) { // TODO: Implement... return null; } + /** + * Place an order for a pet + * + * + * + */ public Order placeOrder(Order body) { // TODO: Implement... diff --git a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java index 861273cfb7b4..c569dbf5c15e 100644 --- a/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf-annotated-base-path/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java @@ -17,49 +17,103 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ public class UserApiServiceImpl implements UserApi { + /** + * Create user + * + * This can only be done by the logged in user. + * + */ public void createUser(User body) { // TODO: Implement... } + /** + * Creates list of users with given input array + * + * + * + */ public void createUsersWithArrayInput(List body) { // TODO: Implement... } + /** + * Creates list of users with given input array + * + * + * + */ public void createUsersWithListInput(List body) { // TODO: Implement... } + /** + * Delete user + * + * This can only be done by the logged in user. + * + */ public void deleteUser(String username) { // TODO: Implement... } + /** + * Get user by user name + * + * + * + */ public User getUserByName(String username) { // TODO: Implement... return null; } + /** + * Logs user into the system + * + * + * + */ public String loginUser(String username, String password) { // TODO: Implement... return null; } + /** + * Logs out current logged in user session + * + * + * + */ public void logoutUser() { // TODO: Implement... } + /** + * Updated user + * + * This can only be done by the logged in user. + * + */ public void updateUser(String username, User body) { // TODO: Implement... diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/pom.xml b/samples/server/petstore/jaxrs-cxf-non-spring-app/pom.xml index df55fcf56671..1c116b94ad13 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/pom.xml +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/pom.xml @@ -4,6 +4,7 @@ swagger-cxf-server-non-spring war swagger-cxf-server-non-spring + 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. 1.0.0 src/main/java diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/api/PetApi.java index 93a82ed4f6c8..f8b8a10d2886 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/api/PetApi.java @@ -21,10 +21,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ @Path("/") @Api(value = "/", description = "") public interface PetApi { + /** + * Add a new pet to the store + * + * + * + */ @POST @Path("/pet") @Consumes({ "application/json", "application/xml" }) @@ -34,6 +46,12 @@ public interface PetApi { @ApiResponse(code = 405, message = "Invalid input") }) public void addPet(@Valid Pet body); + /** + * Deletes a pet + * + * + * + */ @DELETE @Path("/pet/{petId}") @Produces({ "application/xml", "application/json" }) @@ -42,6 +60,12 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid pet value") }) public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey); + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + */ @GET @Path("/pet/findByStatus") @Produces({ "application/xml", "application/json" }) @@ -51,6 +75,12 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid status value") }) public List findPetsByStatus(@QueryParam("status") @NotNull List status); + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + */ @GET @Path("/pet/findByTags") @Produces({ "application/xml", "application/json" }) @@ -60,6 +90,12 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid tag value") }) public List findPetsByTags(@QueryParam("tags") @NotNull List tags); + /** + * Find pet by ID + * + * Returns a single pet + * + */ @GET @Path("/pet/{petId}") @Produces({ "application/xml", "application/json" }) @@ -70,6 +106,12 @@ public interface PetApi { @ApiResponse(code = 404, message = "Pet not found") }) public Pet getPetById(@PathParam("petId") Long petId); + /** + * Update an existing pet + * + * + * + */ @PUT @Path("/pet") @Consumes({ "application/json", "application/xml" }) @@ -81,6 +123,12 @@ public interface PetApi { @ApiResponse(code = 405, message = "Validation exception") }) public void updatePet(@Valid Pet body); + /** + * Updates a pet in the store with form data + * + * + * + */ @POST @Path("/pet/{petId}") @Consumes({ "application/x-www-form-urlencoded" }) @@ -90,6 +138,12 @@ public interface PetApi { @ApiResponse(code = 405, message = "Invalid input") }) public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status); + /** + * uploads an image + * + * + * + */ @POST @Path("/pet/{petId}/uploadImage") @Consumes({ "multipart/form-data" }) diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/api/StoreApi.java index 8ddeb8f3deab..72508ea286ab 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/api/StoreApi.java @@ -20,10 +20,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ @Path("/") @Api(value = "/", description = "") public interface StoreApi { + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + */ @DELETE @Path("/store/order/{orderId}") @Produces({ "application/xml", "application/json" }) @@ -33,6 +45,12 @@ public interface StoreApi { @ApiResponse(code = 404, message = "Order not found") }) public void deleteOrder(@PathParam("orderId") String orderId); + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + */ @GET @Path("/store/inventory") @Produces({ "application/json" }) @@ -41,6 +59,12 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) public Map getInventory(); + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + */ @GET @Path("/store/order/{orderId}") @Produces({ "application/xml", "application/json" }) @@ -51,6 +75,12 @@ public interface StoreApi { @ApiResponse(code = 404, message = "Order not found") }) public Order getOrderById(@PathParam("orderId") @Min(1) @Max(5) Long orderId); + /** + * Place an order for a pet + * + * + * + */ @POST @Path("/store/order") @Produces({ "application/xml", "application/json" }) diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/api/UserApi.java index 5588dddf74f7..7aba6911b466 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/api/UserApi.java @@ -20,10 +20,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ @Path("/") @Api(value = "/", description = "") public interface UserApi { + /** + * Create user + * + * This can only be done by the logged in user. + * + */ @POST @Path("/user") @Produces({ "application/xml", "application/json" }) @@ -32,6 +44,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void createUser(@Valid User body); + /** + * Creates list of users with given input array + * + * + * + */ @POST @Path("/user/createWithArray") @Produces({ "application/xml", "application/json" }) @@ -40,6 +58,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void createUsersWithArrayInput(@Valid List body); + /** + * Creates list of users with given input array + * + * + * + */ @POST @Path("/user/createWithList") @Produces({ "application/xml", "application/json" }) @@ -48,6 +72,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void createUsersWithListInput(@Valid List body); + /** + * Delete user + * + * This can only be done by the logged in user. + * + */ @DELETE @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) @@ -57,6 +87,12 @@ public interface UserApi { @ApiResponse(code = 404, message = "User not found") }) public void deleteUser(@PathParam("username") String username); + /** + * Get user by user name + * + * + * + */ @GET @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) @@ -67,6 +103,12 @@ public interface UserApi { @ApiResponse(code = 404, message = "User not found") }) public User getUserByName(@PathParam("username") String username); + /** + * Logs user into the system + * + * + * + */ @GET @Path("/user/login") @Produces({ "application/xml", "application/json" }) @@ -76,6 +118,12 @@ public interface UserApi { @ApiResponse(code = 400, message = "Invalid username/password supplied") }) public String loginUser(@QueryParam("username") @NotNull String username, @QueryParam("password") @NotNull String password); + /** + * Logs out current logged in user session + * + * + * + */ @GET @Path("/user/logout") @Produces({ "application/xml", "application/json" }) @@ -84,6 +132,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void logoutUser(); + /** + * Updated user + * + * This can only be done by the logged in user. + * + */ @PUT @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Category.java index 2e1f5c0c2a89..9a1956aae8cf 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Category.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * A category for a pet + **/ @ApiModel(description="A category for a pet") public class Category { diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/ModelApiResponse.java index c6dc9cbecf68..51ffbeff6da6 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/ModelApiResponse.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Describes the result of uploading an image resource + **/ @ApiModel(description="Describes the result of uploading an image resource") public class ModelApiResponse { diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Order.java index f3083f274948..4b438955a291 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Order.java @@ -14,6 +14,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * An order for a pets from the pet store + **/ @ApiModel(description="An order for a pets from the pet store") public class Order { @@ -59,6 +62,9 @@ public enum StatusEnum { } @ApiModelProperty(value = "Order Status") + /** + * Order Status + **/ private StatusEnum status = null; @ApiModelProperty(value = "") private Boolean complete = false; diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Pet.java index 0776e03a9080..826a0b31bcaf 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Pet.java @@ -17,6 +17,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * A pet for sale in the pet store + **/ @ApiModel(description="A pet for sale in the pet store") public class Pet { @@ -64,6 +67,9 @@ public enum StatusEnum { } @ApiModelProperty(value = "pet status in the store") + /** + * pet status in the store + **/ private StatusEnum status = null; /** diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Tag.java index 1e80911874f1..24fd1d55d2ae 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/Tag.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * A tag for a pet + **/ @ApiModel(description="A tag for a pet") public class Tag { diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/User.java index a0f42ad1ce72..858e8e14268a 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/gen/java/io/swagger/model/User.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * A User who is purchasing from the pet store + **/ @ApiModel(description="A User who is purchasing from the pet store") public class User { @@ -31,6 +34,9 @@ public class User { @ApiModelProperty(value = "") private String phone = null; @ApiModelProperty(value = "User Status") + /** + * User Status + **/ private Integer userStatus = null; /** diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java index d9b9345d3396..0f19eb3098d4 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java @@ -18,49 +18,103 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ public class PetApiServiceImpl implements PetApi { + /** + * Add a new pet to the store + * + * + * + */ public void addPet(Pet body) { // TODO: Implement... } + /** + * Deletes a pet + * + * + * + */ public void deletePet(Long petId, String apiKey) { // TODO: Implement... } + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + */ public List findPetsByStatus(List status) { // TODO: Implement... return null; } + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + */ public List findPetsByTags(List tags) { // TODO: Implement... return null; } + /** + * Find pet by ID + * + * Returns a single pet + * + */ public Pet getPetById(Long petId) { // TODO: Implement... return null; } + /** + * Update an existing pet + * + * + * + */ public void updatePet(Pet body) { // TODO: Implement... } + /** + * Updates a pet in the store with form data + * + * + * + */ public void updatePetWithForm(Long petId, String name, String status) { // TODO: Implement... } + /** + * uploads an image + * + * + * + */ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Attachment fileDetail) { // TODO: Implement... diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java index 3f791097b6b1..9d3f93f8c3d0 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java @@ -17,25 +17,55 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ public class StoreApiServiceImpl implements StoreApi { + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + */ public void deleteOrder(String orderId) { // TODO: Implement... } + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + */ public Map getInventory() { // TODO: Implement... return null; } + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + */ public Order getOrderById(Long orderId) { // TODO: Implement... return null; } + /** + * Place an order for a pet + * + * + * + */ public Order placeOrder(Order body) { // TODO: Implement... diff --git a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java index 861273cfb7b4..c569dbf5c15e 100644 --- a/samples/server/petstore/jaxrs-cxf-non-spring-app/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf-non-spring-app/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java @@ -17,49 +17,103 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +/** + * Swagger Petstore + * + *

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + */ public class UserApiServiceImpl implements UserApi { + /** + * Create user + * + * This can only be done by the logged in user. + * + */ public void createUser(User body) { // TODO: Implement... } + /** + * Creates list of users with given input array + * + * + * + */ public void createUsersWithArrayInput(List body) { // TODO: Implement... } + /** + * Creates list of users with given input array + * + * + * + */ public void createUsersWithListInput(List body) { // TODO: Implement... } + /** + * Delete user + * + * This can only be done by the logged in user. + * + */ public void deleteUser(String username) { // TODO: Implement... } + /** + * Get user by user name + * + * + * + */ public User getUserByName(String username) { // TODO: Implement... return null; } + /** + * Logs user into the system + * + * + * + */ public String loginUser(String username, String password) { // TODO: Implement... return null; } + /** + * Logs out current logged in user session + * + * + * + */ public void logoutUser() { // TODO: Implement... } + /** + * Updated user + * + * This can only be done by the logged in user. + * + */ public void updateUser(String username, User body) { // TODO: Implement... diff --git a/samples/server/petstore/jaxrs-cxf/pom.xml b/samples/server/petstore/jaxrs-cxf/pom.xml index 3d7d56c8519b..1ab755791006 100644 --- a/samples/server/petstore/jaxrs-cxf/pom.xml +++ b/samples/server/petstore/jaxrs-cxf/pom.xml @@ -4,6 +4,7 @@ swagger-cxf-server war swagger-cxf-server + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ 1.0.0 src/main/java @@ -32,7 +33,7 @@ 8079 stopit - 8080 + 80 60000 diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/AnotherFakeApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/AnotherFakeApi.java index 3accd4f023e4..c05c51bee513 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/AnotherFakeApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/AnotherFakeApi.java @@ -19,10 +19,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + */ @Path("/") @Api(value = "/", description = "") public interface AnotherFakeApi { + /** + * To test special tags + * + * To test special tags + * + */ @PATCH @Path("/another-fake/dummy") @Consumes({ "application/json" }) diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeApi.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeApi.java index 1e201b5f14dc..190aceb4a5ea 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeApi.java @@ -23,6 +23,12 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + */ @Path("/") @Api(value = "/", description = "") public interface FakeApi { @@ -55,6 +61,12 @@ public interface FakeApi { @ApiResponse(code = 200, message = "Output string", response = String.class) }) public String fakeOuterStringSerialize(@Valid String body); + /** + * To test \"client\" model + * + * To test \"client\" model + * + */ @PATCH @Path("/fake") @Consumes({ "application/json" }) @@ -64,6 +76,12 @@ public interface FakeApi { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) public Client testClientModel(@Valid Client body); + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + */ @POST @Path("/fake") @Consumes({ "application/xml; charset=utf-8", "application/json; charset=utf-8" }) @@ -74,6 +92,12 @@ public interface FakeApi { @ApiResponse(code = 404, message = "User not found") }) public void testEndpointParameters(@Multipart(value = "number") BigDecimal number, @Multipart(value = "double") Double _double, @Multipart(value = "pattern_without_delimiter") String patternWithoutDelimiter, @Multipart(value = "byte") byte[] _byte, @Multipart(value = "integer", required = false) Integer integer, @Multipart(value = "int32", required = false) Integer int32, @Multipart(value = "int64", required = false) Long int64, @Multipart(value = "float", required = false) Float _float, @Multipart(value = "string", required = false) String string, @Multipart(value = "binary", required = false) byte[] binary, @Multipart(value = "date", required = false) LocalDate date, @Multipart(value = "dateTime", required = false) Date dateTime, @Multipart(value = "password", required = false) String password, @Multipart(value = "callback", required = false) String paramCallback); + /** + * To test enum parameters + * + * To test enum parameters + * + */ @GET @Path("/fake") @Consumes({ "*/*" }) @@ -84,6 +108,12 @@ public interface FakeApi { @ApiResponse(code = 404, message = "Not found") }) public void testEnumParameters(@Multipart(value = "enum_form_string_array", required = false) List enumFormStringArray, @Multipart(value = "enum_form_string", required = false) String enumFormString, @HeaderParam("enum_header_string_array") List enumHeaderStringArray, @HeaderParam("enum_header_string") String enumHeaderString, @QueryParam("enum_query_string_array") List enumQueryStringArray, @QueryParam("enum_query_string") @DefaultValue("-efg") String enumQueryString, @QueryParam("enum_query_integer") Integer enumQueryInteger, @Multipart(value = "enum_query_double", required = false) Double enumQueryDouble); + /** + * test json serialization of form data + * + * + * + */ @GET @Path("/fake/jsonFormData") @Consumes({ "application/json" }) diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeClassnameTags123Api.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeClassnameTags123Api.java index 021e7eeb91f6..63de6839dc1d 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeClassnameTags123Api.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/api/FakeClassnameTags123Api.java @@ -19,10 +19,20 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + */ @Path("/") @Api(value = "/", description = "") public interface FakeClassnameTags123Api { + /** + * To test class name in snake case + * + */ @PATCH @Path("/fake_classname_test") @Consumes({ "application/json" }) 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 93a82ed4f6c8..20fab16db0ce 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 @@ -21,10 +21,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + */ @Path("/") @Api(value = "/", description = "") public interface PetApi { + /** + * Add a new pet to the store + * + * + * + */ @POST @Path("/pet") @Consumes({ "application/json", "application/xml" }) @@ -34,6 +46,12 @@ public interface PetApi { @ApiResponse(code = 405, message = "Invalid input") }) public void addPet(@Valid Pet body); + /** + * Deletes a pet + * + * + * + */ @DELETE @Path("/pet/{petId}") @Produces({ "application/xml", "application/json" }) @@ -42,6 +60,12 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid pet value") }) public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey); + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + */ @GET @Path("/pet/findByStatus") @Produces({ "application/xml", "application/json" }) @@ -51,6 +75,12 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid status value") }) public List findPetsByStatus(@QueryParam("status") @NotNull List status); + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + */ @GET @Path("/pet/findByTags") @Produces({ "application/xml", "application/json" }) @@ -60,6 +90,12 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid tag value") }) public List findPetsByTags(@QueryParam("tags") @NotNull List tags); + /** + * Find pet by ID + * + * Returns a single pet + * + */ @GET @Path("/pet/{petId}") @Produces({ "application/xml", "application/json" }) @@ -70,6 +106,12 @@ public interface PetApi { @ApiResponse(code = 404, message = "Pet not found") }) public Pet getPetById(@PathParam("petId") Long petId); + /** + * Update an existing pet + * + * + * + */ @PUT @Path("/pet") @Consumes({ "application/json", "application/xml" }) @@ -81,6 +123,12 @@ public interface PetApi { @ApiResponse(code = 405, message = "Validation exception") }) public void updatePet(@Valid Pet body); + /** + * Updates a pet in the store with form data + * + * + * + */ @POST @Path("/pet/{petId}") @Consumes({ "application/x-www-form-urlencoded" }) @@ -90,6 +138,12 @@ public interface PetApi { @ApiResponse(code = 405, message = "Invalid input") }) public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status); + /** + * uploads an image + * + * + * + */ @POST @Path("/pet/{petId}/uploadImage") @Consumes({ "multipart/form-data" }) 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 2698ca445e67..065420cf3572 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 @@ -20,10 +20,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + */ @Path("/") @Api(value = "/", description = "") public interface StoreApi { + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + */ @DELETE @Path("/store/order/{order_id}") @Produces({ "application/xml", "application/json" }) @@ -33,6 +45,12 @@ public interface StoreApi { @ApiResponse(code = 404, message = "Order not found") }) public void deleteOrder(@PathParam("order_id") String orderId); + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + */ @GET @Path("/store/inventory") @Produces({ "application/json" }) @@ -41,6 +59,12 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) public Map getInventory(); + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + */ @GET @Path("/store/order/{order_id}") @Produces({ "application/xml", "application/json" }) @@ -51,6 +75,12 @@ public interface StoreApi { @ApiResponse(code = 404, message = "Order not found") }) public Order getOrderById(@PathParam("order_id") @Min(1) @Max(5) Long orderId); + /** + * Place an order for a pet + * + * + * + */ @POST @Path("/store/order") @Produces({ "application/xml", "application/json" }) 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 5588dddf74f7..3e0d63506238 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 @@ -20,10 +20,22 @@ import io.swagger.jaxrs.PATCH; import javax.validation.constraints.*; import javax.validation.Valid; +/** + * Swagger Petstore + * + *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + */ @Path("/") @Api(value = "/", description = "") public interface UserApi { + /** + * Create user + * + * This can only be done by the logged in user. + * + */ @POST @Path("/user") @Produces({ "application/xml", "application/json" }) @@ -32,6 +44,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void createUser(@Valid User body); + /** + * Creates list of users with given input array + * + * + * + */ @POST @Path("/user/createWithArray") @Produces({ "application/xml", "application/json" }) @@ -40,6 +58,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void createUsersWithArrayInput(@Valid List body); + /** + * Creates list of users with given input array + * + * + * + */ @POST @Path("/user/createWithList") @Produces({ "application/xml", "application/json" }) @@ -48,6 +72,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void createUsersWithListInput(@Valid List body); + /** + * Delete user + * + * This can only be done by the logged in user. + * + */ @DELETE @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) @@ -57,6 +87,12 @@ public interface UserApi { @ApiResponse(code = 404, message = "User not found") }) public void deleteUser(@PathParam("username") String username); + /** + * Get user by user name + * + * + * + */ @GET @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) @@ -67,6 +103,12 @@ public interface UserApi { @ApiResponse(code = 404, message = "User not found") }) public User getUserByName(@PathParam("username") String username); + /** + * Logs user into the system + * + * + * + */ @GET @Path("/user/login") @Produces({ "application/xml", "application/json" }) @@ -76,6 +118,12 @@ public interface UserApi { @ApiResponse(code = 400, message = "Invalid username/password supplied") }) public String loginUser(@QueryParam("username") @NotNull String username, @QueryParam("password") @NotNull String password); + /** + * Logs out current logged in user session + * + * + * + */ @GET @Path("/user/logout") @Produces({ "application/xml", "application/json" }) @@ -84,6 +132,12 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation") }) public void logoutUser(); + /** + * Updated user + * + * This can only be done by the logged in user. + * + */ @PUT @Path("/user/{username}") @Produces({ "application/xml", "application/json" }) diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Capitalization.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Capitalization.java index ce100b223004..89278c7c2983 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Capitalization.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Capitalization.java @@ -25,6 +25,9 @@ public class Capitalization { @ApiModelProperty(value = "") private String scAETHFlowPoints = null; @ApiModelProperty(value = "Name of the pet ") + /** + * Name of the pet + **/ private String ATT_NAME = null; /** diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ClassModel.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ClassModel.java index 6cc8af52fc6f..fcdc0f570542 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ClassModel.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ClassModel.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Model for testing model with \"_class\" property + **/ @ApiModel(description="Model for testing model with \"_class\" property") public class ClassModel { diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Model200Response.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Model200Response.java index 8fe54f0a2589..4a5621e30be4 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Model200Response.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Model200Response.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Model for testing model name starting with number + **/ @ApiModel(description="Model for testing model name starting with number") public class Model200Response { diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelReturn.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelReturn.java index df4149c5d4d2..0c514b23b5c2 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelReturn.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/ModelReturn.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Model for testing reserved words + **/ @ApiModel(description="Model for testing reserved words") public class ModelReturn { diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Name.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Name.java index 47a8c83f2fb0..8743ac35dbb0 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Name.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Name.java @@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Model for testing model name same as property name + **/ @ApiModel(description="Model for testing model name same as property name") public class Name { diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java index faf953439157..985634c955d0 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Order.java @@ -57,6 +57,9 @@ public enum StatusEnum { } @ApiModelProperty(value = "Order Status") + /** + * Order Status + **/ private StatusEnum status = null; @ApiModelProperty(value = "") private Boolean complete = false; diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java index 5db1a052b8fe..28db37fa0b90 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/Pet.java @@ -62,6 +62,9 @@ public enum StatusEnum { } @ApiModelProperty(value = "pet status in the store") + /** + * pet status in the store + **/ private StatusEnum status = null; /** diff --git a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java index 54f54896d13d..44509b594beb 100644 --- a/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-cxf/src/gen/java/io/swagger/model/User.java @@ -29,6 +29,9 @@ public class User { @ApiModelProperty(value = "") private String phone = null; @ApiModelProperty(value = "User Status") + /** + * User Status + **/ private Integer userStatus = null; /** diff --git a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/AnotherFakeApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/AnotherFakeApiServiceImpl.java index 5de97453193b..a162ec64ee72 100644 --- a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/AnotherFakeApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/AnotherFakeApiServiceImpl.java @@ -16,7 +16,19 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +/** + * Swagger Petstore + * + *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + */ public class AnotherFakeApiServiceImpl implements AnotherFakeApi { + /** + * To test special tags + * + * To test special tags + * + */ public Client testSpecialTags(Client body) { // TODO: Implement... diff --git a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java index b170bddee2d3..5e47422edf4f 100644 --- a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java @@ -20,6 +20,12 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +/** + * Swagger Petstore + * + *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + */ public class FakeApiServiceImpl implements FakeApi { public Boolean fakeOuterBooleanSerialize(Boolean body) { // TODO: Implement... @@ -45,24 +51,48 @@ public class FakeApiServiceImpl implements FakeApi { return null; } + /** + * To test \"client\" model + * + * To test \"client\" model + * + */ public Client testClientModel(Client body) { // TODO: Implement... return null; } + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + */ public void testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, Date dateTime, String password, String paramCallback) { // TODO: Implement... } + /** + * To test enum parameters + * + * To test enum parameters + * + */ public void testEnumParameters(List enumFormStringArray, String enumFormString, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble) { // TODO: Implement... } + /** + * test json serialization of form data + * + * + * + */ public void testJsonFormData(String param, String param2) { // TODO: Implement... diff --git a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/FakeClassnameTags123ApiServiceImpl.java b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/FakeClassnameTags123ApiServiceImpl.java index 539edc610d96..ad3f555af97d 100644 --- a/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/FakeClassnameTags123ApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-cxf/src/main/java/io/swagger/api/impl/FakeClassnameTags123ApiServiceImpl.java @@ -16,7 +16,17 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +/** + * Swagger Petstore + * + *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + */ public class FakeClassnameTags123ApiServiceImpl implements FakeClassnameTags123Api { + /** + * To test class name in snake case + * + */ public Client testClassname(Client body) { // TODO: Implement... 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 d9b9345d3396..439daacb1b25 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 @@ -18,49 +18,103 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +/** + * Swagger Petstore + * + *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + */ public class PetApiServiceImpl implements PetApi { + /** + * Add a new pet to the store + * + * + * + */ public void addPet(Pet body) { // TODO: Implement... } + /** + * Deletes a pet + * + * + * + */ public void deletePet(Long petId, String apiKey) { // TODO: Implement... } + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + * + */ public List findPetsByStatus(List status) { // TODO: Implement... return null; } + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + */ public List findPetsByTags(List tags) { // TODO: Implement... return null; } + /** + * Find pet by ID + * + * Returns a single pet + * + */ public Pet getPetById(Long petId) { // TODO: Implement... return null; } + /** + * Update an existing pet + * + * + * + */ public void updatePet(Pet body) { // TODO: Implement... } + /** + * Updates a pet in the store with form data + * + * + * + */ public void updatePetWithForm(Long petId, String name, String status) { // TODO: Implement... } + /** + * uploads an image + * + * + * + */ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, Attachment fileDetail) { // TODO: Implement... 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 3f791097b6b1..546d096399bb 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 @@ -17,25 +17,55 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +/** + * Swagger Petstore + * + *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + */ public class StoreApiServiceImpl implements StoreApi { + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + */ public void deleteOrder(String orderId) { // TODO: Implement... } + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + * + */ public Map getInventory() { // TODO: Implement... return null; } + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + */ public Order getOrderById(Long orderId) { // TODO: Implement... return null; } + /** + * Place an order for a pet + * + * + * + */ public Order placeOrder(Order body) { // TODO: Implement... 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 861273cfb7b4..363a42dad0e3 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 @@ -17,49 +17,103 @@ import org.apache.cxf.jaxrs.ext.multipart.*; import io.swagger.annotations.Api; +/** + * Swagger Petstore + * + *

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + */ public class UserApiServiceImpl implements UserApi { + /** + * Create user + * + * This can only be done by the logged in user. + * + */ public void createUser(User body) { // TODO: Implement... } + /** + * Creates list of users with given input array + * + * + * + */ public void createUsersWithArrayInput(List body) { // TODO: Implement... } + /** + * Creates list of users with given input array + * + * + * + */ public void createUsersWithListInput(List body) { // TODO: Implement... } + /** + * Delete user + * + * This can only be done by the logged in user. + * + */ public void deleteUser(String username) { // TODO: Implement... } + /** + * Get user by user name + * + * + * + */ public User getUserByName(String username) { // TODO: Implement... return null; } + /** + * Logs user into the system + * + * + * + */ public String loginUser(String username, String password) { // TODO: Implement... return null; } + /** + * Logs out current logged in user session + * + * + * + */ public void logoutUser() { // TODO: Implement... } + /** + * Updated user + * + * This can only be done by the logged in user. + * + */ public void updateUser(String username, User body) { // TODO: Implement... From c71aa9da496d2fcb056fa175d600fcea4f4d262a Mon Sep 17 00:00:00 2001 From: Benjamin Gill Date: Sun, 22 Oct 2017 17:39:33 +0100 Subject: [PATCH 06/28] Add Metaswitch to list of companies (#6773) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a727baf58725..d51813633118 100644 --- a/README.md +++ b/README.md @@ -793,6 +793,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you - [LXL Tech](http://lxltech.com) - [Lyft](https://www.lyft.com/developers) - [MailMojo](https://mailmojo.no/) +- [Metaswitch](https://www.metaswitch.com/) - [Mindera](http://mindera.com/) - [Mporium](http://mporium.com/) - [Neverfail](https://neverfail.com/) From 18b16c7fe699da5561b5e7208e8c5ce1372fc3f8 Mon Sep 17 00:00:00 2001 From: kinok Date: Mon, 23 Oct 2017 11:46:12 +0200 Subject: [PATCH 07/28] Update README.md (#6783) Add my company to `Companies/Projects using Swagger Codegen` --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d51813633118..cbef495af554 100644 --- a/README.md +++ b/README.md @@ -730,6 +730,7 @@ Please refer to this [page](https://github.com/swagger-api/swagger-codegen/blob/ Companies/Projects using Swagger Codegen ---------------------------------------- Here are some companies/projects using Swagger Codegen in production. To add your company/project to the list, please visit [README.md](https://github.com/swagger-api/swagger-codegen/blob/master/README.md) and click on the icon to edit the page. +- [Accengage](https://www.accengage.com/) - [Activehours](https://www.activehours.com/) - [Acunetix](https://www.acunetix.com/) - [Atlassian](https://www.atlassian.com/) From c6b6249f1c792be804b2fb991cd0e104ce169536 Mon Sep 17 00:00:00 2001 From: Edward Wells Date: Mon, 23 Oct 2017 06:44:37 -0400 Subject: [PATCH 08/28] Fixed Python client docstrings (#6780) * Updated api_client and configuration docstrings ApiClient: Removed host param, added configuration and cookie param Configuration: Docstrings are only read from the @property decorated function, not the setter, moved the more descriptive docstrings from the setters to property functions * Ran bin/python-petstore.sh --- .../main/resources/python/api_client.mustache | 14 ++- .../resources/python/configuration.mustache | 44 +++++---- samples/client/petstore/python/README.md | 1 + .../client/petstore/python/docs/FakeApi.md | 48 ++++++++++ .../python/petstore_api/api_client.py | 14 ++- .../python/petstore_api/apis/fake_api.py | 94 +++++++++++++++++++ .../python/petstore_api/configuration.py | 44 +++++---- 7 files changed, 203 insertions(+), 56 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index 5372dea0592f..576ff74c1460 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -36,9 +36,12 @@ class ApiClient(object): Ref: https://github.com/swagger-api/swagger-codegen Do not edit the class manually. - :param host: The base path for the server to call. + :param configuration: .Configuration object for this client :param header_name: a header to pass when making calls to the API. - :param header_value: a header value to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API """ PRIMITIVE_TYPES = (float, bool, bytes, text_type) + integer_types @@ -73,16 +76,11 @@ class ApiClient(object): @property def user_agent(self): - """ - Gets user agent. - """ + """User agent for this API client""" return self.default_headers['User-Agent'] @user_agent.setter def user_agent(self, value): - """ - Sets user agent. - """ self.default_headers['User-Agent'] = value def set_default_header(self, header_name, header_value): diff --git a/modules/swagger-codegen/src/main/resources/python/configuration.mustache b/modules/swagger-codegen/src/main/resources/python/configuration.mustache index 744b277455a1..076f7401b57d 100644 --- a/modules/swagger-codegen/src/main/resources/python/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/python/configuration.mustache @@ -100,15 +100,19 @@ class Configuration(with_metaclass(TypeWithDefault, object)): @property def logger_file(self): - """ - Gets the logger_file. + """The logger file. + + If the logger_file is None, then add stream handler and remove file handler. + Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str """ return self.__logger_file @logger_file.setter def logger_file(self, value): - """ - Sets the logger_file. + """The logger file. If the logger_file is None, then add stream handler and remove file handler. Otherwise, add file handler and remove stream handler. @@ -138,15 +142,16 @@ class Configuration(with_metaclass(TypeWithDefault, object)): @property def debug(self): - """ - Gets the debug status. + """Debug status + + :param value: The debug status, True or False. + :type: bool """ return self.__debug @debug.setter def debug(self, value): - """ - Sets the debug status. + """Debug status :param value: The debug status, True or False. :type: bool @@ -168,15 +173,18 @@ class Configuration(with_metaclass(TypeWithDefault, object)): @property def logger_format(self): - """ - Gets the logger_format. + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str """ return self.__logger_format @logger_format.setter def logger_format(self, value): - """ - Sets the logger_format. + """The logger format. The logger_formatter will be updated when sets logger_format. @@ -187,8 +195,7 @@ class Configuration(with_metaclass(TypeWithDefault, object)): self.logger_formatter = logging.Formatter(self.__logger_format) def get_api_key_with_prefix(self, identifier): - """ - Gets API key (with prefix if set). + """Gets API key (with prefix if set). :param identifier: The identifier of apiKey. :return: The token for api key authentication. @@ -199,8 +206,7 @@ class Configuration(with_metaclass(TypeWithDefault, object)): return self.api_key[identifier] def get_basic_auth_token(self): - """ - Gets HTTP basic authentication header (string). + """Gets HTTP basic authentication header (string). :return: The token for basic HTTP authentication. """ @@ -208,8 +214,7 @@ class Configuration(with_metaclass(TypeWithDefault, object)): .get('authorization') def auth_settings(self): - """ - Gets Auth Settings dict for api client. + """Gets Auth Settings dict for api client. :return: The Auth Settings information dict. """ @@ -244,8 +249,7 @@ class Configuration(with_metaclass(TypeWithDefault, object)): } def to_debug_report(self): - """ - Gets the essential information for debugging. + """Gets the essential information for debugging. :return: The report for debugging. """ diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 87f80990fc56..a49d99c556cd 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -77,6 +77,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model *FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters +*FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data *FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store diff --git a/samples/client/petstore/python/docs/FakeApi.md b/samples/client/petstore/python/docs/FakeApi.md index eb669540e538..eb651a109a7f 100644 --- a/samples/client/petstore/python/docs/FakeApi.md +++ b/samples/client/petstore/python/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters +[**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data @@ -389,6 +390,53 @@ No authorization required [[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) +# **test_inline_additional_properties** +> test_inline_additional_properties(param) + +test inline additionalProperties + + + +### Example +```python +from __future__ import print_function +import time +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# create an instance of the API class +api_instance = petstore_api.FakeApi() +param = NULL # object | request body + +try: + # test inline additionalProperties + api_instance.test_inline_additional_properties(param) +except ApiException as e: + print("Exception when calling FakeApi->test_inline_additional_properties: %s\n" % e) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **object**| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[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) + # **test_json_form_data** > test_json_form_data(param, param2) diff --git a/samples/client/petstore/python/petstore_api/api_client.py b/samples/client/petstore/python/petstore_api/api_client.py index ff29a063d8c3..00347369b7c2 100644 --- a/samples/client/petstore/python/petstore_api/api_client.py +++ b/samples/client/petstore/python/petstore_api/api_client.py @@ -42,9 +42,12 @@ class ApiClient(object): Ref: https://github.com/swagger-api/swagger-codegen Do not edit the class manually. - :param host: The base path for the server to call. + :param configuration: .Configuration object for this client :param header_name: a header to pass when making calls to the API. - :param header_value: a header value to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API """ PRIMITIVE_TYPES = (float, bool, bytes, text_type) + integer_types @@ -79,16 +82,11 @@ class ApiClient(object): @property def user_agent(self): - """ - Gets user agent. - """ + """User agent for this API client""" return self.default_headers['User-Agent'] @user_agent.setter def user_agent(self, value): - """ - Sets user agent. - """ self.default_headers['User-Agent'] = value def set_default_header(self, header_name, header_value): diff --git a/samples/client/petstore/python/petstore_api/apis/fake_api.py b/samples/client/petstore/python/petstore_api/apis/fake_api.py index 46fb22f72908..cadbc20004c9 100644 --- a/samples/client/petstore/python/petstore_api/apis/fake_api.py +++ b/samples/client/petstore/python/petstore_api/apis/fake_api.py @@ -784,6 +784,100 @@ class FakeApi(object): _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) + def test_inline_additional_properties(self, param, **kwargs): + """ + test inline additionalProperties + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async=True + >>> thread = api.test_inline_additional_properties(param, async=True) + >>> result = thread.get() + + :param async bool + :param object param: request body (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async'): + return self.test_inline_additional_properties_with_http_info(param, **kwargs) + else: + (data) = self.test_inline_additional_properties_with_http_info(param, **kwargs) + return data + + def test_inline_additional_properties_with_http_info(self, param, **kwargs): + """ + test inline additionalProperties + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async=True + >>> thread = api.test_inline_additional_properties_with_http_info(param, async=True) + >>> result = thread.get() + + :param async bool + :param object param: request body (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['param'] + all_params.append('async') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method test_inline_additional_properties" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'param' is set + if ('param' not in params) or (params['param'] is None): + raise ValueError("Missing the required parameter `param` when calling `test_inline_additional_properties`") + + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'param' in params: + body_params = params['param'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type(['application/json']) + + # Authentication setting + auth_settings = [] + + return self.api_client.call_api('/fake/inline-additionalProperties', 'POST', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, + auth_settings=auth_settings, + async=params.get('async'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + def test_json_form_data(self, param, param2, **kwargs): """ test json serialization of form data diff --git a/samples/client/petstore/python/petstore_api/configuration.py b/samples/client/petstore/python/petstore_api/configuration.py index 29bf22034aa7..8410a94f57b6 100644 --- a/samples/client/petstore/python/petstore_api/configuration.py +++ b/samples/client/petstore/python/petstore_api/configuration.py @@ -109,15 +109,19 @@ class Configuration(with_metaclass(TypeWithDefault, object)): @property def logger_file(self): - """ - Gets the logger_file. + """The logger file. + + If the logger_file is None, then add stream handler and remove file handler. + Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str """ return self.__logger_file @logger_file.setter def logger_file(self, value): - """ - Sets the logger_file. + """The logger file. If the logger_file is None, then add stream handler and remove file handler. Otherwise, add file handler and remove stream handler. @@ -147,15 +151,16 @@ class Configuration(with_metaclass(TypeWithDefault, object)): @property def debug(self): - """ - Gets the debug status. + """Debug status + + :param value: The debug status, True or False. + :type: bool """ return self.__debug @debug.setter def debug(self, value): - """ - Sets the debug status. + """Debug status :param value: The debug status, True or False. :type: bool @@ -177,15 +182,18 @@ class Configuration(with_metaclass(TypeWithDefault, object)): @property def logger_format(self): - """ - Gets the logger_format. + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str """ return self.__logger_format @logger_format.setter def logger_format(self, value): - """ - Sets the logger_format. + """The logger format. The logger_formatter will be updated when sets logger_format. @@ -196,8 +204,7 @@ class Configuration(with_metaclass(TypeWithDefault, object)): self.logger_formatter = logging.Formatter(self.__logger_format) def get_api_key_with_prefix(self, identifier): - """ - Gets API key (with prefix if set). + """Gets API key (with prefix if set). :param identifier: The identifier of apiKey. :return: The token for api key authentication. @@ -208,8 +215,7 @@ class Configuration(with_metaclass(TypeWithDefault, object)): return self.api_key[identifier] def get_basic_auth_token(self): - """ - Gets HTTP basic authentication header (string). + """Gets HTTP basic authentication header (string). :return: The token for basic HTTP authentication. """ @@ -217,8 +223,7 @@ class Configuration(with_metaclass(TypeWithDefault, object)): .get('authorization') def auth_settings(self): - """ - Gets Auth Settings dict for api client. + """Gets Auth Settings dict for api client. :return: The Auth Settings information dict. """ @@ -256,8 +261,7 @@ class Configuration(with_metaclass(TypeWithDefault, object)): } def to_debug_report(self): - """ - Gets the essential information for debugging. + """Gets the essential information for debugging. :return: The report for debugging. """ From a63e3f14f58cdce57be0f1091905d8653eb26626 Mon Sep 17 00:00:00 2001 From: Steve Harrigan Date: Mon, 23 Oct 2017 09:40:50 -0400 Subject: [PATCH 09/28] [TypeScript-Angular] Path URI Encoding Update (#6769) * Replaced the method for updating path to prep for URL encoding. The new method will switch TypeScript-Angular variables from snake_case to camelCase in the URL generation. Imported StringBuffer, Matcher, and Pattern, since the new solution needs them. Some extra whitespace on blank lines was removed. * Since these were not up to date with the current master, I ran them and am commiting them here. This way, the changes are shown here instead of after future commits. * Simplified the code for the path conversion A LOT. New version is much simpler to follow, and very efficient - only one iteration through the length of the string. Removed regex Matcher and Pattern classes, since they weren't needed anymore. --- .../TypeScriptAngularClientCodegen.java | 57 +++++++++++++++++-- .../npm/model/apiResponse.ts | 2 + .../npm/model/category.ts | 2 + .../npm/model/order.ts | 8 +-- .../typescript-angular-v4.3/npm/model/pet.ts | 8 +-- .../typescript-angular-v4.3/npm/model/tag.ts | 2 + .../typescript-angular-v4.3/npm/model/user.ts | 2 + 7 files changed, 66 insertions(+), 15 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java index cab99599846b..fefbf143b0c7 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngularClientCodegen.java @@ -1,6 +1,7 @@ package io.swagger.codegen.languages; import java.io.File; +import java.lang.StringBuffer; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -82,7 +83,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts")); supportingFiles.add(new SupportingFile("index.mustache", getIndexDirectory(), "index.ts")); supportingFiles.add(new SupportingFile("api.module.mustache", getIndexDirectory(), "api.module.ts")); - supportingFiles.add(new SupportingFile("rxjs-operators.mustache", getIndexDirectory(), "rxjs-operators.ts")); + supportingFiles.add(new SupportingFile("rxjs-operators.mustache", getIndexDirectory(), "rxjs-operators.ts")); supportingFiles.add(new SupportingFile("configuration.mustache", getIndexDirectory(), "configuration.ts")); supportingFiles.add(new SupportingFile("variables.mustache", getIndexDirectory(), "variables.ts")); supportingFiles.add(new SupportingFile("encoder.mustache", getIndexDirectory(), "encoder.ts")); @@ -149,7 +150,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode public boolean isDataTypeFile(final String dataType) { return dataType != null && dataType.equals("Blob"); } - + @Override public String getTypeDeclaration(Property p) { Property inner; @@ -247,8 +248,54 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode } } - // Convert path to TypeScript template string, applying URI encoding - op.path = op.path.replaceAll("\\{(.*?)\\}", "\\$\\{encodeURIComponent(String($1))\\}"); + // Prep a string buffer where we're going to set up our new version of the string. + StringBuffer pathBuffer = new StringBuffer(); + + // Set up other variables for tracking the current state of the string. + int insideCurly = 0; + boolean foundUnderscore = false; + + // Iterate through existing string, one character at a time. + for(int i = 0; i < op.path.length(); i++) { + switch(op.path.charAt(i)) { + case '{': + // We entered curly braces, so track that. + insideCurly++; + + // Add the more complicated component instead of just the brace. + pathBuffer.append("${encodeURIComponent(String("); + break; + case '}': + // We exited curly braces, so track that. + insideCurly--; + + // Add the more complicated component instead of just the brace. + pathBuffer.append("))}"); + break; + case '_': + // If we're inside the curly brace, the following character will need to be uppercase. + // Otherwise, just add the character. + if (insideCurly > 0) { + foundUnderscore = true; + } else { + pathBuffer.append(op.path.charAt(i)); + } + break; + default: + // If we previously found an underscore, we need an uppercase letter. + // Otherwise, just add the character. + if (foundUnderscore) { + pathBuffer.append(Character.toUpperCase(op.path.charAt(i))); + foundUnderscore = false; + } else { + pathBuffer.append(op.path.charAt(i)); + } + break; + } + } + + // Overwrite path to TypeScript template string, after applying everything we just did. + op.path = pathBuffer.toString(); } // Add additional filename information for model imports in the services @@ -272,7 +319,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode CodegenModel cm = (CodegenModel) mo.get("model"); mo.put("tsImports", toTsImports(cm,cm.imports)); } - + return result; } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts index 3af781cf5804..e79fabe8c8cf 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts @@ -23,3 +23,5 @@ export interface ApiResponse { message?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts index d09f8d7b265f..56608731f956 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts @@ -21,3 +21,5 @@ export interface Category { name?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts index 402a86689c82..84b59f1b09a6 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts @@ -33,9 +33,7 @@ export interface Order { } export namespace Order { - export enum StatusEnum { - Placed = 'placed', - Approved = 'approved', - Delivered = 'delivered' - } + export type StatusEnum = 'placed' | 'approved' | 'delivered'; } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts index 0d6137d02cf2..c0fc942934c3 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts @@ -35,9 +35,7 @@ export interface Pet { } export namespace Pet { - export enum StatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' - } + export type StatusEnum = 'available' | 'pending' | 'sold'; } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts index 3ed1eeff8f32..dbfa473f538a 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts @@ -21,3 +21,5 @@ export interface Tag { name?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts index f4914ae26080..4dfad607c515 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts @@ -36,3 +36,5 @@ export interface User { userStatus?: number; } + + From b034e4446abc458357b3e59551174351a53d18a1 Mon Sep 17 00:00:00 2001 From: naelrashdeen Date: Mon, 23 Oct 2017 16:50:56 +0200 Subject: [PATCH 10/28] [PHP][Symfony] Enhancements (#6615) * Removed commented code * Input validation is now supported as strict JSON validation * [PHP][Symfony] Improve the implementation Closes #6614 * Generated code is tested to assure it compiles and updated README to dynamically load dependencies via composer * Updated shell script because shippable tests were failing --- .gitignore | 5 + bin/php-symfony-petstore.sh | 41 + .../languages/SymfonyServerCodegen.java | 82 +- .../resources/php-symfony/Controller.mustache | 312 +++---- .../php-symfony/ModelInterface.mustache | 55 -- .../php-symfony/ModelSerializer.mustache | 174 ---- .../resources/php-symfony/README.mustache | 26 +- .../main/resources/php-symfony/api.mustache | 16 +- .../php-symfony/api_controller.mustache | 166 ++-- .../php-symfony/api_input_validation.mustache | 88 ++ .../resources/php-symfony/api_test.mustache | 77 -- .../resources/php-symfony/composer.mustache | 6 +- .../main/resources/php-symfony/model.mustache | 9 +- .../php-symfony/model_generic.mustache | 327 +------ .../php-symfony/model_variables.mustache | 91 ++ .../resources/php-symfony/routing.mustache | 24 +- .../serialization/JmsSerializer.mustache | 91 ++ .../SerializerInterface.mustache | 27 + .../StrictJsonDeserializationVisitor.mustache | 72 ++ .../TypeMismatchException.mustache | 52 ++ .../resources/php-symfony/services.mustache | 24 + .../php-symfony/testing/AppKernel.php | 21 + .../php-symfony/testing/api_test.mustache | 116 +++ .../{ => testing}/model_test.mustache | 3 +- .../{ => testing}/phpunit.xml.mustache | 4 + .../resources/php-symfony/testing/pom.xml | 57 ++ .../php-symfony/testing/test_config.yml | 8 + .../validation/SymfonyValidator.mustache | 20 + .../validation/ValidatorInterface.mustache | 25 + .../php-symfony/.swagger-codegen-ignore | 23 + .../php-symfony/.swagger-codegen/VERSION | 1 + .../php-symfony/SymfonyBundle-php/.php_cs | 18 + .../php-symfony/SymfonyBundle-php/.travis.yml | 10 + .../SymfonyBundle-php/Api/ApiServer.php | 80 ++ .../SymfonyBundle-php/Api/PetApiInterface.php | 172 ++++ .../Api/StoreApiInterface.php | 106 +++ .../Api/UserApiInterface.php | 145 ++++ .../Controller/Controller.php | 182 ++++ .../Controller/PetController.php | 799 ++++++++++++++++++ .../Controller/StoreController.php | 368 ++++++++ .../Controller/UserController.php | 720 ++++++++++++++++ .../Compiler/SwaggerServerApiPass.php | 70 ++ .../SwaggerServerExtension.php | 57 ++ .../SymfonyBundle-php/Model/ApiResponse.php | 154 ++++ .../SymfonyBundle-php/Model/Category.php | 121 +++ .../SymfonyBundle-php/Model/Order.php | 256 ++++++ .../SymfonyBundle-php/Model/Pet.php | 262 ++++++ .../SymfonyBundle-php/Model/Tag.php | 121 +++ .../SymfonyBundle-php/Model/User.php | 321 +++++++ .../php-symfony/SymfonyBundle-php/README.md | 182 ++++ .../Resources/config/routing.yml | 145 ++++ .../Resources/config/services.yml | 42 + .../Resources/docs/Api/PetApiInterface.md | 529 ++++++++++++ .../Resources/docs/Api/StoreApiInterface.md | 245 ++++++ .../Resources/docs/Api/UserApiInterface.md | 459 ++++++++++ .../Resources/docs/Model/ApiResponse.md | 12 + .../Resources/docs/Model/Category.md | 11 + .../Resources/docs/Model/Order.md | 15 + .../Resources/docs/Model/Pet.md | 15 + .../Resources/docs/Model/Tag.md | 11 + .../Resources/docs/Model/User.md | 17 + .../Service/JmsSerializer.php | 91 ++ .../Service/SerializerInterface.php | 27 + .../StrictJsonDeserializationVisitor.php | 72 ++ .../Service/SymfonyValidator.php | 20 + .../Service/TypeMismatchException.php | 52 ++ .../Service/ValidatorInterface.php | 25 + .../SymfonyBundle-php/SwaggerServerBundle.php | 50 ++ .../Tests/Api/PetApiInterfaceTest.php | 217 +++++ .../Tests/Api/StoreApiInterfaceTest.php | 151 ++++ .../Tests/Api/UserApiInterfaceTest.php | 214 +++++ .../SymfonyBundle-php/Tests/AppKernel.php | 21 + .../Tests/Model/ApiResponseTest.php | 101 +++ .../Tests/Model/CategoryTest.php | 94 +++ .../Tests/Model/OrderTest.php | 122 +++ .../SymfonyBundle-php/Tests/Model/PetTest.php | 122 +++ .../SymfonyBundle-php/Tests/Model/TagTest.php | 94 +++ .../Tests/Model/UserTest.php | 136 +++ .../SymfonyBundle-php/Tests/test_config.yml | 8 + .../SymfonyBundle-php/autoload.php | 54 ++ .../SymfonyBundle-php/composer.json | 38 + .../php-symfony/SymfonyBundle-php/git_push.sh | 52 ++ .../SymfonyBundle-php/phpunit.xml.dist | 25 + .../php-symfony/SymfonyBundle-php/pom.xml | 57 ++ 84 files changed, 8575 insertions(+), 956 deletions(-) create mode 100755 bin/php-symfony-petstore.sh delete mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/ModelInterface.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/ModelSerializer.mustache create mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/api_input_validation.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/api_test.mustache create mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/model_variables.mustache create mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/serialization/JmsSerializer.mustache create mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/serialization/SerializerInterface.mustache create mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/serialization/StrictJsonDeserializationVisitor.mustache create mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/serialization/TypeMismatchException.mustache create mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/testing/AppKernel.php create mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/testing/api_test.mustache rename modules/swagger-codegen/src/main/resources/php-symfony/{ => testing}/model_test.mustache (95%) rename modules/swagger-codegen/src/main/resources/php-symfony/{ => testing}/phpunit.xml.mustache (90%) create mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/testing/pom.xml create mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/testing/test_config.yml create mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/validation/SymfonyValidator.mustache create mode 100644 modules/swagger-codegen/src/main/resources/php-symfony/validation/ValidatorInterface.mustache create mode 100644 samples/server/petstore/php-symfony/.swagger-codegen-ignore create mode 100644 samples/server/petstore/php-symfony/.swagger-codegen/VERSION create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/.php_cs create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/.travis.yml create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Api/ApiServer.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Api/PetApiInterface.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Api/StoreApiInterface.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Api/UserApiInterface.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/Controller.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/PetController.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/StoreController.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/UserController.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/DependencyInjection/Compiler/SwaggerServerApiPass.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/DependencyInjection/SwaggerServerExtension.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Model/ApiResponse.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Category.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Order.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Pet.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Tag.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Model/User.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/README.md create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/config/routing.yml create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/config/services.yml create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Api/PetApiInterface.md create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Api/StoreApiInterface.md create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Api/UserApiInterface.md create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/ApiResponse.md create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/Category.md create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/Order.md create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/Pet.md create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/Tag.md create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/User.md create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Service/JmsSerializer.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Service/SerializerInterface.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Service/StrictJsonDeserializationVisitor.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Service/SymfonyValidator.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Service/TypeMismatchException.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Service/ValidatorInterface.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/SwaggerServerBundle.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Api/PetApiInterfaceTest.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Api/StoreApiInterfaceTest.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Api/UserApiInterfaceTest.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/AppKernel.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/ApiResponseTest.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/CategoryTest.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/OrderTest.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/PetTest.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/TagTest.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/UserTest.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/test_config.yml create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/autoload.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/composer.json create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/git_push.sh create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/phpunit.xml.dist create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/pom.xml diff --git a/.gitignore b/.gitignore index cce9df3dcfd4..c31b8389c196 100644 --- a/.gitignore +++ b/.gitignore @@ -90,6 +90,11 @@ samples/client/petstore/silex/SwaggerServer/venodr/ **/vendor/ **/composer.lock +#PHP-Symfony +samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/cache/ +samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/logs/ + + # Perl samples/client/petstore/perl/deep_module_test/ diff --git a/bin/php-symfony-petstore.sh b/bin/php-symfony-petstore.sh new file mode 100755 index 000000000000..17d9418b3861 --- /dev/null +++ b/bin/php-symfony-petstore.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +# Make sure that the working directory is the root dir +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd "${SCRIPT_DIR}/../" + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +# Make sure that we are regenerating the sample by removing any existing target directory +TARGET_DIR="$SCRIPT_DIR/../samples/server/petstore/php-symfony" +if [ -d "$TARGET_DIR" ]; then + rm -rf $TARGET_DIR +fi + +executable="$SCRIPT_DIR/../modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="generate -t $SCRIPT_DIR/../modules/swagger-codegen/src/main/resources/php-symfony -i $SCRIPT_DIR/../modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l php-symfony -o $TARGET_DIR $@" + +java $JAVA_OPTS -jar $executable $ags diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SymfonyServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SymfonyServerCodegen.java index 87ce66f16a70..ae9cbd81fdff 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SymfonyServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SymfonyServerCodegen.java @@ -32,7 +32,9 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC protected String bundleExtensionName; protected String bundleAlias; protected String controllerDirName = "Controller"; + protected String serviceDirName = "Service"; protected String controllerPackage; + protected String servicePackage; protected Boolean phpLegacySupport = Boolean.TRUE; protected HashSet typeHintable; @@ -74,7 +76,9 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC modelDocPath = docsBasePath + File.separator + modelDirName; outputFolder = "generated-code" + File.separator + "php"; apiTemplateFiles.put("api_controller.mustache", ".php"); - modelTestTemplateFiles.put("model_test.mustache", ".php"); + modelTestTemplateFiles.put("testing/model_test.mustache", ".php"); + apiTestTemplateFiles = new HashMap(); + apiTestTemplateFiles.put("testing/api_test.mustache", ".php"); embeddedTemplateDir = templateDir = "php-symfony"; setReservedWordsLowerCase( @@ -105,13 +109,10 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC ) ); - //instantiationTypes.put("array", "array"); - //instantiationTypes.put("map", "map"); - defaultIncludes = new HashSet( Arrays.asList( "\\DateTime", - "\\SplFileObject" + "UploadedFile" ) ); @@ -135,7 +136,7 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC typeMapping.put("boolean", "bool"); typeMapping.put("Date", "\\DateTime"); typeMapping.put("DateTime", "\\DateTime"); - typeMapping.put("file", "\\SplFileObject"); + typeMapping.put("file", "UploadedFile"); typeMapping.put("map", "array"); typeMapping.put("array", "array"); typeMapping.put("list", "array"); @@ -242,6 +243,7 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\")); additionalProperties.put("controllerPackage", controllerPackage); + additionalProperties.put("servicePackage", servicePackage); additionalProperties.put("apiTestsPackage", apiTestsPackage); additionalProperties.put("modelTestsPackage", modelTestsPackage); @@ -275,14 +277,28 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC supportingFiles.add(new SupportingFile("Extension.mustache", dependencyInjectionDir, bundleExtensionName + ".php")); supportingFiles.add(new SupportingFile("ApiPass.mustache", dependencyInjectionDir + File.separator + "Compiler", bundleName + "ApiPass.php")); supportingFiles.add(new SupportingFile("ApiServer.mustache", toPackagePath(apiPackage, srcBasePath), "ApiServer.php")); - supportingFiles.add(new SupportingFile("ModelSerializer.mustache", toPackagePath(modelPackage, srcBasePath), "ModelSerializer.php")); - supportingFiles.add(new SupportingFile("ModelInterface.mustache", toPackagePath(modelPackage, srcBasePath), "ModelInterface.php")); + + // Serialization components + supportingFiles.add(new SupportingFile("serialization/SerializerInterface.mustache", toPackagePath(servicePackage, srcBasePath), "SerializerInterface.php")); + supportingFiles.add(new SupportingFile("serialization/JmsSerializer.mustache", toPackagePath(servicePackage, srcBasePath), "JmsSerializer.php")); + supportingFiles.add(new SupportingFile("serialization/StrictJsonDeserializationVisitor.mustache", toPackagePath(servicePackage, srcBasePath), "StrictJsonDeserializationVisitor.php")); + supportingFiles.add(new SupportingFile("serialization/TypeMismatchException.mustache", toPackagePath(servicePackage, srcBasePath), "TypeMismatchException.php")); + // Validation components + supportingFiles.add(new SupportingFile("validation/ValidatorInterface.mustache", toPackagePath(servicePackage, srcBasePath), "ValidatorInterface.php")); + supportingFiles.add(new SupportingFile("validation/SymfonyValidator.mustache", toPackagePath(servicePackage, srcBasePath), "SymfonyValidator.php")); + + // Testing components + supportingFiles.add(new SupportingFile("testing/phpunit.xml.mustache", getPackagePath(), "phpunit.xml.dist")); + supportingFiles.add(new SupportingFile("testing/pom.xml", getPackagePath(), "pom.xml")); + supportingFiles.add(new SupportingFile("testing/AppKernel.php", toPackagePath(testsPackage, srcBasePath), "AppKernel.php")); + supportingFiles.add(new SupportingFile("testing/test_config.yml", toPackagePath(testsPackage, srcBasePath), "test_config.yml")); + supportingFiles.add(new SupportingFile("routing.mustache", configDir, "routing.yml")); supportingFiles.add(new SupportingFile("services.mustache", configDir, "services.yml")); supportingFiles.add(new SupportingFile("composer.mustache", getPackagePath(), "composer.json")); supportingFiles.add(new SupportingFile("autoload.mustache", getPackagePath(), "autoload.php")); supportingFiles.add(new SupportingFile("README.mustache", getPackagePath(), "README.md")); - supportingFiles.add(new SupportingFile("phpunit.xml.mustache", getPackagePath(), "phpunit.xml.dist")); + supportingFiles.add(new SupportingFile(".travis.yml", getPackagePath(), ".travis.yml")); supportingFiles.add(new SupportingFile(".php_cs", getPackagePath(), ".php_cs")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", getPackagePath(), "git_push.sh")); @@ -329,6 +345,14 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC if (!typeHint.isEmpty()) { param.vendorExtensions.put("x-parameterType", typeHint); } + + // Quote default values for strings + // @todo: The default values for headers, forms and query params are handled + // in DefaultCodegen fromParameter with no real possibility to override + // the functionality. Thus we are handling quoting of string values here + if (param.dataType.equals("string") && param.defaultValue != null && !param.defaultValue.isEmpty()) { + param.defaultValue = "'"+param.defaultValue+"'"; + } } for (CodegenResponse response : op.responses) { @@ -340,9 +364,6 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC if (response.dataType != null) { final String dataType = extractSimpleName(response.dataType); response.vendorExtensions.put("x-simpleName", dataType); - // if (!typeMapping.containsValue(dataType)) { - // imports.add(response.dataType.replaceFirst("\\[\\]$", "")); - // } } } @@ -364,19 +385,15 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC ArrayList modelsArray = (ArrayList) objs.get("models"); Map models = (Map) modelsArray.get(0); CodegenModel model = (CodegenModel) models.get("model"); - HashSet imports = new HashSet<>(); // Simplify model var type for (CodegenProperty var : model.vars) { if (var.datatype != null) { - final String importType = var.datatype.replaceFirst("\\[\\]$", ""); - final String dataType = extractSimpleName(var.datatype); - final boolean isScalarType = typeMapping.containsValue(importType); - var.vendorExtensions.put("x-fullType", var.datatype); - if (!isScalarType) { - var.vendorExtensions.put("x-typeAnnotation", dataType.endsWith("[]") ? "array" : dataType); - imports.add(importType); - var.datatype = dataType; + // Determine if the paramter type is supported as a type hint and make it available + // to the templating engine + String typeHint = getTypeHint(var.datatype); + if (!typeHint.isEmpty()) { + var.vendorExtensions.put("x-parameterType", typeHint); } if (var.isBoolean) { @@ -385,8 +402,6 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC } } - objs.put("useStatements", new ArrayList<>(imports)); - return objs; } @@ -425,6 +440,7 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC apiTestsPackage = testsPackage + "\\" + apiDirName; modelTestsPackage = testsPackage + "\\" + modelDirName; controllerPackage = invokerPackage + "\\" + controllerDirName; + servicePackage = invokerPackage + "\\" + serviceDirName; } @Override @@ -485,6 +501,26 @@ public class SymfonyServerCodegen extends AbstractPhpCodegen implements CodegenC } } + @Override + public String toEnumValue(String value, String datatype) { + if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) { + return value; + } else { + return "\"" + escapeText(value) + "\""; + } + } + + /** + * Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33) + * + * @param pattern the pattern (regular expression) + * @return properly-escaped pattern + */ + @Override + public String toRegularExpression(String pattern) { + return escapeText(pattern); + } + public String toApiName(String name) { if (name.isEmpty()) { return "DefaultApiInterface"; diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/Controller.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/Controller.mustache index af937c7d99fe..c1adc2f64a40 100644 --- a/modules/swagger-codegen/src/main/resources/php-symfony/Controller.mustache +++ b/modules/swagger-codegen/src/main/resources/php-symfony/Controller.mustache @@ -19,9 +19,10 @@ namespace {{controllerPackage}}; -use Symfony\Bundle\FrameworkBundle\Controller\Controller as BaseController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\HttpException; +use {{servicePackage}}\SerializerInterface; +use {{servicePackage}}\ValidatorInterface; /** * Controller Class Doc Comment @@ -31,212 +32,141 @@ use Symfony\Component\HttpKernel\Exception\HttpException; * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class Controller extends BaseController +class Controller { + protected $validator; + protected $serializer; + protected $apiServer; - /** - * This will return a response with code 400. Usage example: - * return $this->createBadRequestResponse('Unable to access this page!'); - * - * @param string $message A message - * - * @return Response - */ - public function createBadRequestResponse($message = 'Bad Request.') - { - return new Response($message, 400); - } + public function setValidator(ValidatorInterface $validator) + { + $this->validator = $validator; + } - /** - * This will return an error response. Usage example: - * return $this->createErrorResponse(new UnauthorizedHttpException()); - * - * @param HttpException $exception An HTTP exception - * - * @return Response - */ - public function createErrorResponse(HttpException $exception) - { - $statusCode = $exception->getStatusCode(); - $headers = array_merge($exception->getHeaders(), ['Content-Type' => 'application/json']); + public function setSerializer(SerializerInterface $serializer) + { + $this->serializer = $serializer; + } - $json = $this->exceptionToArray($exception); - $json['statusCode'] = $statusCode; + public function setApiServer($server) + { + $this->apiServer = $server; + } - return new Response(json_encode($json, 15, 512), $statusCode, $headers); - } + /** + * This will return a response with code 400. Usage example: + * return $this->createBadRequestResponse('Unable to access this page!'); + * + * @param string $message A message + * + * @return Response + */ + public function createBadRequestResponse($message = 'Bad Request.') + { + return new Response($message, 400); + } - /** - * Serializes data to a given type format. - * - * @param mixed $data The data to serialize. - * @param string $class The source data class. - * @param string $format The target serialization format. - * - * @return string A serialized data string. - */ - public function serialize($data, $format) - { - return $this->get('{{bundleAlias}}.model.model_serializer')->serialize($data, $format); - } + /** + * This will return an error response. Usage example: + * return $this->createErrorResponse(new UnauthorizedHttpException()); + * + * @param HttpException $exception An HTTP exception + * + * @return Response + */ + public function createErrorResponse(HttpException $exception) + { + $statusCode = $exception->getStatusCode(); + $headers = array_merge($exception->getHeaders(), ['Content-Type' => 'application/json']); - /** - * Deserializes data from a given type format. - * - * @param string $data The data to deserialize. - * @param string $class The target data class. - * @param string $format The source serialization format. - * - * @return mixed A deserialized data. - */ - public function deserialize($data, $class, $format) - { - return $this->get('{{bundleAlias}}.model.model_serializer')->deserialize($data, $class, $format); - } + $json = $this->exceptionToArray($exception); + $json['statusCode'] = $statusCode; - /** - * Decodes a string value. - * - * @param string $string The string value to decode. - * @param string $dataType The data type of the parameter. - * - * @return mixed The decoded value. - */ - public function fromString($string, $dataType) - { - if ($dataType === 'integer' || $dataType === 'number') { - return $this->toNumber($string); - } - if ($dataType === 'bool') { - return $this->toBoolean($string); - } - if ($dataType === '\DateTime') { - return $this->toDateTime($string); - } + return new Response(json_encode($json, 15, 512), $statusCode, $headers); + } - return $string; - } + /** + * Serializes data to a given type format. + * + * @param mixed $data The data to serialize. + * @param string $class The source data class. + * @param string $format The target serialization format. + * + * @return string A serialized data string. + */ + protected function serialize($data, $format) + { + return $this->serializer->serialize($data, $format); + } - /** - * Decodes a header value. - * - * @param string $header The header value to decode. - * @param string $dataType The data type of the parameter. - * - * @return mixed The decoded value. - */ - public function fromHeader($header, $dataType) - { - return $this->fromString($header, $dataType); - } + /** + * Deserializes data from a given type format. + * + * @param string $data The data to deserialize. + * @param string $class The target data class. + * @param string $format The source serialization format. + * + * @return mixed A deserialized data. + */ + protected function deserialize($data, $class, $format) + { + return $this->serializer->deserialize($data, $class, $format); + } - /** - * Decodes a query value. - * - * @param string $query The query value to decode. - * @param string $dataType The data type of the parameter. - * - * @return mixed The decoded value. - */ - public function fromQuery($query, $dataType) - { - return $this->fromString($query, $dataType); - } + protected function validate($data, $asserts = null) + { + $errors = $this->validator->validate($data, $asserts); - /** - * Decodes a path value. - * - * @param string $path The path value to decode. - * @param string $dataType The data type of the parameter. - * - * @return mixed The decoded value. - */ - public function fromPath($path, $dataType) - { - return $this->fromString($path, $dataType); - } + if (count($errors) > 0) { + $errorsString = (string)$errors; + return $this->createBadRequestResponse($errorsString); + } + } - /** - * Decodes a form value. - * - * @param string $form The form value to decode. - * @param string $dataType The data type of the parameter. - * - * @return mixed The decoded value. - */ - public function fromForm($form, $dataType) - { - return $this->fromString($form, $dataType); - } + /** + * Converts an exception to a serializable array. + * + * @param \Exception|null $exception + * + * @return array + */ + private function exceptionToArray(\Exception $exception = null) + { + if (null === $exception) { + return null; + } - /** - * Decoded a string to a number. - * - * @param string $string The string to decode. - * - * @return number|null A decoded number, or null, if not a valid string. - */ - private function toNumber($string) - { - if (is_numeric($string)) { - return $string + 0; - } + return [ + 'message' => $exception->getMessage(), + 'type' => get_class($exception), + 'previous' => $this->exceptionToArray($exception->getPrevious()), + ]; + } - return null; - } + protected function getOutputFormat($accept, array $produced) + { + // Figure out what the client accepts + $accept = preg_split("/[\s,]+/", $accept); + + if (in_array('*/*', $accept) || in_array('application/*', $accept)) { + // Prefer JSON if the client has no preference + if (in_array('application/json', $produced)) { + return 'application/json'; + } + if (in_array('application/xml', $produced)) { + return 'application/xml'; + } + } - /** - * Decoded a string to a boolean. - * - * @param string $string The string to decode. - * - * @return boolean|null A decoded boolean, or null, if not a valid string. - */ - private function toBoolean($string) - { - if ($string === 'true') { - return true; - } - if ($string === 'false') { - return false; - } + if (in_array('application/json', $accept) && in_array('application/json', $produced)) { + return 'application/json'; + } - return null; - } + if (in_array('application/xml', $accept) && in_array('application/xml', $produced)) { + return 'application/xml'; + } - /** - * Decoded a string to a date time. - * - * @param string $string The string to decode. - * - * @return \DateTime|null A decoded date time, or null, if not a valid string. - */ - private function toDateTime($string) - { - if ($dateTime = date_create($string)) { - return $dateTime; - } - - return null; - } - - /** - * Converts an exception to a serializable array. - * - * @param \Exception|null $exception - * - * @return array - */ - private function exceptionToArray(\Exception $exception = null) - { - if (null === $exception) { - return null; - } - - return [ - 'message' => $exception->getMessage(), - 'type' => get_class($exception), - 'previous' => $this->exceptionToArray($exception->getPrevious()), - ]; - } + // If we reach this point, we don't have a common ground between server and client + return null; + } } diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/ModelInterface.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/ModelInterface.mustache deleted file mode 100644 index a568374d6d38..000000000000 --- a/modules/swagger-codegen/src/main/resources/php-symfony/ModelInterface.mustache +++ /dev/null @@ -1,55 +0,0 @@ -partial_header}} -/** - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. - */ - -namespace {{modelPackage}}; - -/** - * Interface abstracting model access. - * - * @package {{modelPackage}} - * @author Swagger Codegen team - */ -interface ModelInterface -{ - - /** - * The original name of the model. - * - * @return string - */ - public function modelName(); - - /** - * Array of property to mappings. - * - * @return array[] - */ - public function modelAttributes(); - - /** - * Validate all the properties in the model - * - * Return true if all passed. - * - * @return bool True if all properties are valid - */ - public function isValid(); -} - - diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/ModelSerializer.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/ModelSerializer.mustache deleted file mode 100644 index c2064b60a8d2..000000000000 --- a/modules/swagger-codegen/src/main/resources/php-symfony/ModelSerializer.mustache +++ /dev/null @@ -1,174 +0,0 @@ -partial_header}} -/** - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. - */ - -namespace {{modelPackage}}; - -/** - * ModelSerializer Class Doc Comment - * - * @category Class - * @package {{modelPackage}} - * @author Swagger Codegen team - * @link https://github.com/swagger-api/swagger-codegen - */ -class ModelSerializer -{ - - /** - * Serializes data to a given type format. - * - * @param mixed $data The data to serialize. - * @param string $format The target serialization format. - * - * @return string A serialized data string. - * @throws \InvalidArgumentException When invalid serialization format was used. - */ - public function serialize($data, $format) - { - $normalized = $this->normalize($data); - if ($format === 'json') { - return json_encode($normalized, 15, 512); - } - - throw new \InvalidArgumentException('Unsupported serialization format: '.$format); - } - - /** - * Deserializes data from a given type format. - * - * @param string $data The data to deserialize. - * @param string $class The target class to deserialize to. - * @param string $format The source serialization format. - * - * @return mixed A deserialized value. - * @throws \InvalidArgumentException When invalid serialization format was used. - */ - public function deserialize($data, $class, $format) - { - switch ($format) { - case 'json': - $normalized = json_decode($data, true, 512, 15); - break; - default: - throw new \InvalidArgumentException('Unsupported serialization format: '.$format); - } - - return $this->denormalize($normalized, $class); - } - - public function normalize($data, $format = null) - { - if (is_scalar($data) || null === $data) { - return $data; - } - - if (is_array($data)) { - return array_map(function ($value) use ($format) { - return $this->normalize($value, $format); - }, $data); - } - - if ($data instanceof \DateTime) { - return ($format === 'date') ? $data->format('Y-m-d') : $data->format(\DateTime::ATOM); - } - - if ($data instanceof ModelInterface) { - $values = []; - foreach ($data->modelAttributes() as $name => $attribute) { - list($baseName, , $format, , $getter) = $attribute; - $value = $this->normalize($data->$getter(), $format); - if ($value !== null && method_exists($data, 'getAllowableEnumValues') - && !in_array($value, $data::getAllowableEnumValues())) { - $imploded = implode("', '", $data::getAllowableEnumValues()); - throw new \InvalidArgumentException("Invalid value for enum '$data', must be one of: '$imploded'"); - } - - if ($value !== null) { - $values[$baseName] = $value; - } - } - - return $values; - } - - return (string) $data; - } - - public function denormalize($data, $class, $format = null) - { - if ($data === null) { - return null; - } - - if (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { - settype($data, $class); - return $data; - } - - // Denormalize array - if (substr($class, -2) === '[]') { - $innerClass = substr($class, 0, -2); - return array_map(function ($value) use ($format, $innerClass) { - return $this->denormalize($value, $innerClass, $format); - }, $data); - } - - if (!class_exists($class)) { - return $data; - } - - // Denormalize enum - if (method_exists($class, 'getAllowableEnumValues')) { - if (!in_array($data, $class::getAllowableEnumValues())) { - $imploded = implode("', '", $class::getAllowableEnumValues()); - throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); - } - - return $data; - } - - // If a discriminator is defined and points to a valid subclass, use it. - $discriminator = $class::DISCRIMINATOR; - if (!empty($discriminator) && isset($data[$discriminator]) && is_string($data[$discriminator])) { - $subclass = '{{modelPackage}}\\'.$data[$discriminator]; - if (is_subclass_of($subclass, $class)) { - $class = $subclass; - } - } - - // Denormalize another model - $values = new $class(); - if ($values instanceof ModelInterface) { - foreach ($values->modelAttributes() as $name => $attribute) { - list($baseName, $innerClass, $format, $setter) = $attribute; - - if (!isset($data[$baseName])) { - continue; - } - - $value = $this->denormalize($data[$baseName], $innerClass, $format); - $values->$setter($value); - } - - return $values; - } - - return $data; - } -} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/README.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/README.mustache index d61acfa1c84d..0b72cf635fac 100644 --- a/modules/swagger-codegen/src/main/resources/php-symfony/README.mustache +++ b/modules/swagger-codegen/src/main/resources/php-symfony/README.mustache @@ -23,28 +23,28 @@ PHP 5.4.0 and later ## Installation & Usage -To install the bindings via [Composer](http://getcomposer.org/), add the following to `composer.json`: +To install the dependencies via [Composer](http://getcomposer.org/), add the following repository to `composer.json` of your Symfony project: -``` +```json { - "repositories": [ - { - "type": "git", - "url": "https://github.com/{{#composerVendorName}}{{.}}{{/composerVendorName}}{{^composerVendorName}}{{gitUserId}}{{/composerVendorName}}/{{#composerProjectName}}{{.}}{{/composerProjectName}}{{^composerProjectName}}{{gitRepoId}}{{/composerProjectName}}.git" - } - ], - "require": { - "{{#composerVendorName}}{{.}}{{/composerVendorName}}{{^composerVendorName}}{{gitUserId}}{{/composerVendorName}}/{{#composerProjectName}}{{.}}{{/composerProjectName}}{{^composerProjectName}}{{gitRepoId}}{{/composerProjectName}}": "*@dev" - } + "repositories": [{ + "type": "path", + "url": "//Path to your generated swagger bundle" + }], } ``` -Then run `composer install` +Then run: +``` +composer require {{#composerVendorName}}{{.}}{{/composerVendorName}}{{^composerVendorName}}{{gitUserId}}{{/composerVendorName}}/{{#composerProjectName}}{{.}}{{/composerProjectName}}{{^composerProjectName}}{{gitRepoId}}{{/composerProjectName}}:dev-master +``` + +to add the generated swagger bundle as a dependency. ## Tests -To run the unit tests: +To run the unit tests for the generated bundle, first navigate to the directory containing the code, then run the following commands: ``` composer install diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/api.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/api.mustache index b3985a9489ac..0e581a1b84de 100644 --- a/modules/swagger-codegen/src/main/resources/php-symfony/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php-symfony/api.mustache @@ -18,6 +18,7 @@ namespace {{apiPackage}}; +use Symfony\Component\HttpFoundation\File\UploadedFile; {{#operations}}{{#imports}}use {{import}}; {{/imports}} @@ -58,18 +59,15 @@ interface {{classname}} {{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} + * @param integer $responseCode The HTTP response code to return + * @param array $responseHeaders Additional HTTP headers to return with the response () * - {{#responses}} - {{#vendorExtensions.x-symfonyExceptionSimple}} - * @throws {{vendorExtensions.x-symfonyExceptionSimple}} {{message}} - {{/vendorExtensions.x-symfonyExceptionSimple}} - {{^vendorExtensions.x-symfonyExceptionSimple}} - * @return {{^dataType}}void{{/dataType}}{{#dataType}}{{dataType}}{{/dataType}} {{message}} + {{#returnType}} + * @return {{{returnType}}} * - {{/vendorExtensions.x-symfonyExceptionSimple}} - {{/responses}} + {{/returnType}} */ - public function {{operationId}}({{#allParams}}{{#vendorExtensions.x-parameterType}}{{vendorExtensions.x-parameterType}} {{/vendorExtensions.x-parameterType}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + public function {{operationId}}({{#allParams}}{{#vendorExtensions.x-parameterType}}{{vendorExtensions.x-parameterType}} {{/vendorExtensions.x-parameterType}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}&$responseCode, array &$responseHeaders); {{/operation}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/api_controller.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/api_controller.mustache index 8fb9efb5ed7c..6f21a082eb59 100644 --- a/modules/swagger-codegen/src/main/resources/php-symfony/api_controller.mustache +++ b/modules/swagger-codegen/src/main/resources/php-symfony/api_controller.mustache @@ -23,6 +23,7 @@ use \Exception; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\HttpException; +use Symfony\Component\Validator\Constraints as Assert; use {{apiPackage}}\{{classname}}; {{#imports}}use {{import}}; {{/imports}} @@ -53,8 +54,28 @@ class {{controllerName}} extends Controller * @param Request $request The Symfony request to handle. * @return Response The Symfony response. */ - public function {{operationId}}Action(Request $request) + public function {{operationId}}Action(Request $request{{#hasPathParams}}{{#pathParams}}, ${{paramName}}{{/pathParams}}{{/hasPathParams}}) { + {{#bodyParams}} + // Make sure that the client is providing something that we can consume + $consumes = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]; + $inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0]; + if (!in_array($inputFormat, $consumes)) { + // We can't consume the content that the client is sending us + return new Response('', 415); + } + + {{/bodyParams}} + // Figure out what data format to return to the client + $produces = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication {{#authMethods}} // Authentication '{{name}}' required {{#isApiKey}} @@ -76,81 +97,58 @@ class {{controllerName}} extends Controller $security{{name}} = $request->headers->get('authorization'); {{/isOAuth}} {{/authMethods}} + + // Read out all input parameter values into variables + {{#allParams}} {{#queryParams}} - // Handle query params - ${{paramName}} = $this->fromQuery($request->query->get('{{paramName}}'), '{{dataType}}'); + ${{paramName}} = $request->query->get('{{paramName}}'); {{/queryParams}} {{#headerParams}} - // Handle header params - ${{paramName}} = $this->fromHeader($request->headers->get('{{paramName}}'), '{{dataType}}'); + ${{paramName}} = $request->headers->get('{{paramName}}'); {{/headerParams}} - {{#pathParams}} - // Handle path params - ${{paramName}} = $this->fromPath($request->attributes->get('{{paramName}}'), '{{dataType}}'); - {{/pathParams}} {{#formParams}} {{#isFile}} - // Handle file params ${{paramName}} = $request->files->get('{{paramName}}'); {{/isFile}} {{^isFile}} - // Handle form params - ${{paramName}} = $this->fromForm($request->request->get('{{paramName}}'), '{{dataType}}'); + ${{paramName}} = $request->request->get('{{paramName}}'); {{/isFile}} {{/formParams}} {{#bodyParams}} - // Handle body params - ${{paramName}} = $this->deserialize($request->getContent(), '{{{dataType}}}', 'json'); + ${{paramName}} = $request->getContent(); {{/bodyParams}} - // Parse incoming parameters - {{#allParams}} - {{#required}} - // Verify the required parameter '{{paramName}}' is set - if (${{paramName}} === null) { - return $this->createBadRequestResponse('Missing the required parameter ${{paramName}} when calling {{operationId}}'); - } + // Use the default value if no value was provided + {{^required}} + {{#isContainer}} + {{#items}} + {{#defaultValue}} + ${{paramName}} = ${{paramName}}?:[{{{defaultValue}}}]; + {{/defaultValue}} + {{/items}} + {{/isContainer}} + {{^isContainer}} + {{#defaultValue}} + ${{paramName}} = ${{paramName}}?:{{{defaultValue}}}; + {{/defaultValue}} + {{/isContainer}} {{/required}} - {{#hasValidation}} - {{#maxLength}} - if ({{^required}}!is_null(${{paramName}}) && {{/required}}(strlen(${{paramName}}) > {{maxLength}})) { - return $this->createBadRequestResponse('Invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.'); - } - {{/maxLength}} - {{#minLength}} - if ({{^required}}!is_null(${{paramName}}) && {{/required}}(strlen(${{paramName}}) < {{minLength}})) { - return $this->createBadRequestResponse('Invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.'); - } - {{/minLength}} - {{#maximum}} - if ({{^required}}!is_null(${{paramName}}) && {{/required}}(${{paramName}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}})) { - return $this->createBadRequestResponse('Invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{maximum}}.'); - } - {{/maximum}} - {{#minimum}} - if ({{^required}}!is_null(${{paramName}}) && {{/required}}(${{paramName}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}})) { - return $this->createBadRequestResponse('Invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{minimum}}.'); - } - {{/minimum}} - {{#pattern}} - if ({{^required}}!is_null(${{paramName}}) && {{/required}}!preg_match("{{{pattern}}}", ${{paramName}})) { - return $this->createBadRequestResponse("Invalid value for \"{{paramName}}\" when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}."); - } - {{/pattern}} - {{#maxItems}} - if ({{^required}}!is_null(${{paramName}}) && {{/required}}(count(${{paramName}}) > {{maxItems}})) { - return $this->createBadRequestResponse('Invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, number of items must be less than or equal to {{maxItems}}.'); - } - {{/maxItems}} - {{#minItems}} - if ({{^required}}!is_null(${{paramName}}) && {{/required}}(count(${{paramName}}) < {{minItems}})) { - return $this->createBadRequestResponse('Invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{minItems}}.'); - } - {{/minItems}} - {{/hasValidation}} + + // Deserialize the input values that needs it + {{^isFile}} + {{#bodyParams}} + + ${{paramName}} = $this->deserialize(${{paramName}}, '{{{dataType}}}', $inputFormat); + {{/bodyParams}} + {{^bodyParams}} + ${{paramName}} = $this->deserialize(${{paramName}}, '{{#isContainer}}array<{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}{{^collectionFormat}}csv{{/collectionFormat}}>{{/isContainer}}{{^isContainer}}{{dataType}}{{/isContainer}}', 'string'); + {{/bodyParams}} + {{/isFile}} {{/allParams}} - // Call the API interface + // Validate the input values +{{>api_input_validation}} + try { $handler = $this->getApiHandler(); @@ -158,31 +156,35 @@ class {{controllerName}} extends Controller // Set authentication method '{{name}}' $handler->set{{name}}($security{{name}}); {{/authMethods}} - {{#returnType}} - // Expecting a return value (exception otherwise) - $result = $handler->{{operationId}}({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + + // Make the call to the business logic + $responseCode = {{#returnType}}200{{/returnType}}{{^returnType}}204{{/returnType}}; + $responseHeaders = []; + $result = $handler->{{operationId}}({{#allParams}}${{paramName}}, {{/allParams}}$responseCode, $responseHeaders); + // Find default response message + $message = '{{#responses}}{{#isDefault}}{{message}}{{/isDefault}}{{/responses}}'; + + // Find a more specific message, if available + switch ($responseCode) { {{#responses}} - {{^vendorExtensions.x-symfonyExceptionSimple}} - // Handle {{code}} response: {{message}} - $content = $this->serialize($result, 'json'); - return new Response($content, {{code}}, [ - 'Content-Type' => 'application/json', - 'X-Swagger-Message' => '{{message}}', - ]); - {{/vendorExtensions.x-symfonyExceptionSimple}} + case {{code}}: + $message = '{{message}}'; + break; {{/responses}} - {{/returnType}} - {{^returnType}} - // No return type expected; return empty response - $handler->{{operationId}}({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); - return new Response('', 204); - {{/returnType}} - {{#responses}} - } catch (HttpException $exception) { - // {{message}} - return $this->createErrorResponse($exception); - {{/responses}} + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); } catch (Exception $fallthrough) { return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); } @@ -195,7 +197,7 @@ class {{controllerName}} extends Controller */ public function getApiHandler() { - return $this->get('{{bundleAlias}}.api.api_server')->getApiHandler('{{pathPrefix}}'); + return $this->apiServer->getApiHandler('{{pathPrefix}}'); } } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/api_input_validation.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/api_input_validation.mustache new file mode 100644 index 000000000000..0bcd30534851 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php-symfony/api_input_validation.mustache @@ -0,0 +1,88 @@ +{{#allParams}} + $asserts = []; +{{#required}} + $asserts[] = new Assert\NotNull(); +{{/required}} +{{#isEnum}} + {{#isContainer}} + $asserts[] = new Assert\All([ + {{#items}} + new Assert\Choice([ {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}} ]) + {{/items}} + ]); + {{/isContainer}} + {{^isContainer}} + $asserts[] = new Assert\Choice([ {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}} ]); + {{/isContainer}} +{{/isEnum}} +{{#isContainer}} + $asserts[] = new Assert\All([ + {{#items}} + new Assert\Type("{{datatype}}") + {{/items}} + ]); +{{/isContainer}} +{{^isContainer}} + {{#isDate}} + $asserts[] = new Assert\Date(); + {{/isDate}} + {{#isDateTime}} + $asserts[] = new Assert\DateTime(); + {{/isDateTime}} + {{^isDate}} + {{^isDateTime}} + {{#isFile}} + $asserts[] = new Assert\File(); + {{/isFile}} + {{^isFile}} + $asserts[] = new Assert\Type("{{dataType}}"); + {{/isFile}} + {{/isDateTime}} + {{/isDate}} +{{/isContainer}} +{{#hasValidation}} + {{#maxLength}} + $asserts[] = new Assert\Length([ + 'max' => {{maxLength}} + ]); + {{/maxLength}} + {{#minLength}} + $asserts[] = new Assert\Length([ + 'min' => {{minLength}} + ]); + {{/minLength}} + {{#minimum}} + {{#exclusiveMinimum}} + $asserts[] = new Assert\GreaterThan({{minimum}}); + {{/exclusiveMinimum}} + {{^exclusiveMinimum}} + $asserts[] = new Assert\GreaterThanOrEqual({{minimum}}); + {{/exclusiveMinimum}} + {{/minimum}} + {{#maximum}} + {{#exclusiveMaximum}} + $asserts[] = new Assert\LessThan({{minimum}}); + {{/exclusiveMaximum}} + {{^exclusiveMaximum}} + $asserts[] = new Assert\LessThanOrEqual({{minimum}}); + {{/exclusiveMaximum}} + {{/maximum}} + {{#pattern}} + $asserts[] = new Assert\Regex("/{{pattern}}/"); + {{/pattern}} + {{#maxItems}} + $asserts[] = new Assert\Count([ + 'max' => {{maxItems}} + ]); + {{/maxItems}} + {{#minItems}} + $asserts[] = new Assert\Count([ + 'min' => {{minItems}} + ]); + {{/minItems}} +{{/hasValidation}} + $response = $this->validate(${{paramName}}, $asserts); + if ($response instanceof Response) { + return $response; + } +{{/allParams}} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/api_test.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/api_test.mustache deleted file mode 100644 index c1f16c70ceab..000000000000 --- a/modules/swagger-codegen/src/main/resources/php-symfony/api_test.mustache +++ /dev/null @@ -1,77 +0,0 @@ -partial_header}} -/** - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen - * Please update the test case below to test the endpoint. - */ - -namespace {{apiTestsPackage}}; - -use \{{invokerPackage}}\Configuration; -use \{{invokerPackage}}\ApiClient; -use \{{invokerPackage}}\ApiException; -use \{{invokerPackage}}\ObjectSerializer; - -/** - * {{classname}}Test Class Doc Comment - * - * @category Class - * @package {{apiTestsPackage}} - * @author Swagger Codegen team - * @link https://github.com/swagger-api/swagger-codegen - */ -{{#operations}}class {{classname}}Test extends \PHPUnit_Framework_TestCase -{ - - /** - * Setup before running any test cases - */ - public static function setUpBeforeClass() - { - } - - /** - * Setup before running each test case - */ - public function setUp() - { - } - - /** - * Clean up after running each test case - */ - public function tearDown() - { - } - - /** - * Clean up after running all test cases - */ - public static function tearDownAfterClass() - { - } - {{#operation}} - - /** - * Test case for {{{operationId}}} - * - * {{{summary}}}. - * - */ - public function test{{operationIdCamelCase}}() - { - } - {{/operation}} -} -{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/composer.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/composer.mustache index eda7618bf65f..5d6156df5504 100644 --- a/modules/swagger-codegen/src/main/resources/php-symfony/composer.mustache +++ b/modules/swagger-codegen/src/main/resources/php-symfony/composer.mustache @@ -23,13 +23,17 @@ "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", + "symfony/validator": "*", + "jms/serializer-bundle": "*", "symfony/framework-bundle": "^2.3|^3.0" }, "require-dev": { "phpunit/phpunit": "~4.8", "satooshi/php-coveralls": "~1.0", "squizlabs/php_codesniffer": "~2.6", - "friendsofphp/php-cs-fixer": "~1.12" + "friendsofphp/php-cs-fixer": "~1.12", + "symfony/browser-kit": "*", + "hoa/regex": "~1.0" }, "autoload": { "psr-4": { "{{escapedInvokerPackage}}\\" : "{{srcBasePath}}/" } diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/model.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/model.mustache index 6e8655780757..02d96acb45fb 100644 --- a/modules/swagger-codegen/src/main/resources/php-symfony/model.mustache +++ b/modules/swagger-codegen/src/main/resources/php-symfony/model.mustache @@ -21,10 +21,9 @@ namespace {{modelPackage}}; -{{^isEnum}} -{{#useStatements}}use {{this}}; -{{/useStatements}} -{{/isEnum}} +use Symfony\Component\Validator\Constraints as Assert; +use JMS\Serializer\Annotation\Type; +use JMS\Serializer\Annotation\SerializedName; /** * Class representing the {{classname}} model. @@ -36,5 +35,5 @@ namespace {{modelPackage}}; * @package {{modelPackage}} * @author Swagger Codegen team */ -{{#isEnum}}{{>model_enum}}{{/isEnum}}{{^isEnum}}{{>model_generic}}{{/isEnum}} +{{>model_generic}} {{/model}}{{/models}} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/model_generic.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/model_generic.mustache index 8e72f968406c..8106055c8548 100644 --- a/modules/swagger-codegen/src/main/resources/php-symfony/model_generic.mustache +++ b/modules/swagger-codegen/src/main/resources/php-symfony/model_generic.mustache @@ -1,49 +1,6 @@ -class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}implements ModelInterface, \ArrayAccess +class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}} { - const DISCRIMINATOR = {{#discriminator}}'{{discriminator}}'{{/discriminator}}{{^discriminator}}null{{/discriminator}}; - - /** - * The original name of the model. - * @var string - */ - protected static $_name = '{{name}}'; - - /** - * Array of property to type mappings. Used for (de)serialization - * @var array[] - */ - protected static $_attributes = [{{#vars}} - '{{name}}' => ['{{baseName}}', '{{{vendorExtensions.x-fullType}}}', {{#dataFormat}}'{{{dataFormat}}}'{{/dataFormat}}{{^dataFormat}}null{{/dataFormat}}, '{{setter}}', '{{getter}}'],{{/vars}} - ]; - {{#vars}}{{#isEnum}} - - /** - * Allowed values of {{name}} - */{{#allowableValues}}{{#enumVars}} - const {{enumName}}_{{{name}}} = {{{value}}};{{/enumVars}}{{/allowableValues}}{{/isEnum}}{{/vars}} - - {{#vars}}{{#isEnum}} - /** - * Gets allowable values of the enum - * @return string[] - */ - public function {{getter}}AllowableValues() - { - return [ - {{#allowableValues}}{{#enumVars}}self::{{enumName}}_{{{name}}},{{^-last}} - {{/-last}}{{/enumVars}}{{/allowableValues}} - ]; - } - {{/isEnum}}{{/vars}} - {{#vars}} - /**{{#description}} - * {{description}} - * - {{/description}} - * @var {{{datatype}}}{{^required}}|null{{/required}} - */ - protected ${{name}}; - + {{#vars}}{{>model_variables}} {{/vars}} /** * Constructor @@ -58,187 +15,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple {{#vars}} $this->{{name}} = isset($data['{{name}}']) ? $data['{{name}}'] : {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}; {{/vars}} - {{#discriminator}} - - // Initialize discriminator property with the model name. - foreach (self::$_attributes as $_name => $attribute) { - list($baseName) = $attribute; - if ('{{discriminator}}' === $baseName) { - $this->$_name = static::$_name; - } - } - {{/discriminator}} } - - /** - * show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - {{#parent}} - $invalid_properties = parent::listInvalidProperties(); - {{/parent}} - {{^parent}} - $invalid_properties = []; - {{/parent}} - - {{#vars}} - {{#required}} - if ($this->{{name}} === null) { - $invalid_properties[] = "'{{name}}' can't be null"; - } - {{/required}} - {{#isEnum}} - {{^isContainer}} - $allowedValues = $this->{{getter}}AllowableValues(); - if (!in_array($this->{{name}}, $allowedValues, true)) { - $invalid_properties[] = sprintf( - "invalid value for '{{name}}', must be one of '%s'", - implode("', '", $allowedValues) - ); - } - - {{/isContainer}} - {{/isEnum}} - {{#hasValidation}} - {{#maxLength}} - if ({{^required}}!is_null($this->{{name}}) && {{/required}}(strlen($this->{{name}}) > {{maxLength}})) { - $invalid_properties[] = "invalid value for '{{name}}', the character length must be smaller than or equal to {{{maxLength}}}."; - } - - {{/maxLength}} - {{#minLength}} - if ({{^required}}!is_null($this->{{name}}) && {{/required}}(strlen($this->{{name}}) < {{minLength}})) { - $invalid_properties[] = "invalid value for '{{name}}', the character length must be bigger than or equal to {{{minLength}}}."; - } - - {{/minLength}} - {{#maximum}} - if ({{^required}}!is_null($this->{{name}}) && {{/required}}($this->{{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}})) { - $invalid_properties[] = "invalid value for '{{name}}', must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{maximum}}."; - } - - {{/maximum}} - {{#minimum}} - if ({{^required}}!is_null($this->{{name}}) && {{/required}}($this->{{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}})) { - $invalid_properties[] = "invalid value for '{{name}}', must be bigger than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{minimum}}."; - } - - {{/minimum}} - {{#pattern}} - if ({{^required}}!is_null($this->{{name}}) && {{/required}}!preg_match("{{{pattern}}}", $this->{{name}})) { - $invalid_properties[] = "invalid value for '{{name}}', must be conform to the pattern {{{pattern}}}."; - } - - {{/pattern}} - {{#maxItems}} - if ({{^required}}!is_null($this->{{name}}) && {{/required}}(count($this->{{name}}) > {{maxItems}})) { - $invalid_properties[] = "invalid value for '{{name}}', number of items must be less than or equal to {{{maxItems}}}."; - } - - {{/maxItems}} - {{#minItems}} - if ({{^required}}!is_null($this->{{name}}) && {{/required}}(count($this->{{name}}) < {{minItems}})) { - $invalid_properties[] = "invalid value for '{{name}}', number of items must be greater than or equal to {{{minItems}}}."; - } - - {{/minItems}} - {{/hasValidation}} - {{/vars}} - return $invalid_properties; - } - - /** - * The original name of the model. - * - * @return string - */ - public function modelName() { - return self::$_name; - } - - /** - * Array of property to mappings. - * - * @return array[] - */ - public function modelAttributes() { - {{#parentSchema}}return array_merge(parent::$_attributes, self::$_attributes);{{/parentSchema}} - {{^parentSchema}}return self::$_attributes;{{/parentSchema}} - } - - /** - * Validate all the properties in the model - * - * Return true if all passed. - * - * @return bool True if all properties are valid - */ - public function isValid() - { - {{#parent}} - if (!parent::isValid()) { - return false; - } - - {{/parent}} - {{#vars}} - {{#required}} - if ($this->{{name}} === null) { - return false; - } - {{/required}} - {{#isEnum}} - {{^isContainer}} - $allowedValues = $this->{{getter}}AllowableValues(); - if (!in_array($this->{{name}}, $allowedValues)) { - return false; - } - {{/isContainer}} - {{/isEnum}} - {{#hasValidation}} - {{#maxLength}} - if (strlen($this->{{name}}) > {{maxLength}}) { - return false; - } - {{/maxLength}} - {{#minLength}} - if (strlen($this->{{name}}) < {{minLength}}) { - return false; - } - {{/minLength}} - {{#maximum}} - if ($this->{{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}) { - return false; - } - {{/maximum}} - {{#minimum}} - if ($this->{{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}) { - return false; - } - {{/minimum}} - {{#pattern}} - if (!preg_match("{{{pattern}}}", $this->{{name}})) { - return false; - } - {{/pattern}} - {{#maxItems}} - if (count($this->{{name}}) > {{maxItems}}) { - return false; - } - {{/maxItems}} - {{#minItems}} - if (count($this->{{name}}) < {{minItems}}) { - return false; - } - {{/minItems}} - {{/hasValidation}} - {{/vars}} - return true; - } - {{#vars}} /** @@ -258,109 +35,11 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple * * @return $this */ - public function {{setter}}({{#vendorExtensions.x-typeAnnotation}}{{vendorExtensions.x-typeAnnotation}} {{/vendorExtensions.x-typeAnnotation}}${{name}}{{^required}} = null{{/required}}) + public function {{setter}}({{#vendorExtensions.x-parameterType}}{{vendorExtensions.x-parameterType}} {{/vendorExtensions.x-parameterType}}${{name}}{{^required}} = null{{/required}}) { - {{#isEnum}} - $allowedValues = $this->{{getter}}AllowableValues(); - {{^isContainer}} - if ({{^required}}${{name}} !== null && {{/required}}!in_array(${{{name}}}, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value for '{{name}}', must be one of '%s'", - implode("', '", $allowedValues) - ) - ); - } - {{/isContainer}} - {{#isContainer}} - if ({{^required}}!is_null(${{name}}) && {{/required}}array_diff(${{{name}}}, $allowedValues)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value for '{{name}}', must be one of '%s'", - implode("', '", $allowedValues) - ) - ); - } - {{/isContainer}} - {{/isEnum}} - {{#hasValidation}} - {{#maxLength}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(strlen(${{name}}) > {{maxLength}})) { - throw new \InvalidArgumentException('invalid length for ${{name}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.'); - }{{/maxLength}} - {{#minLength}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(strlen(${{name}}) < {{minLength}})) { - throw new \InvalidArgumentException('invalid length for ${{name}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.'); - } - {{/minLength}} - {{#maximum}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(${{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}})) { - throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{maximum}}.'); - } - {{/maximum}} - {{#minimum}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(${{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}})) { - throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must be bigger than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{minimum}}.'); - } - {{/minimum}} - {{#pattern}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(!preg_match("{{{pattern}}}", ${{name}}))) { - throw new \InvalidArgumentException("invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}."); - } - {{/pattern}} - {{#maxItems}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(count(${{name}}) > {{maxItems}})) { - throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, number of items must be less than or equal to {{maxItems}}.'); - }{{/maxItems}} - {{#minItems}} - if ({{^required}}!is_null(${{name}}) && {{/required}}(count(${{name}}) < {{minItems}})) { - throw new \InvalidArgumentException('invalid length for ${{name}} when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{minItems}}.'); - } - {{/minItems}} - {{/hasValidation}} $this->{{name}} = ${{name}}; return $this; } {{/vars}} - /** - * Returns true if offset exists. False otherwise. - * @param integer $offset Offset - * @return boolean - */ - public function offsetExists($offset) - { - return isset($this->$offset); - } - - /** - * Gets offset. - * @param integer $offset Offset - * @return mixed - */ - public function offsetGet($offset) - { - return isset($this->$offset) ? $this->$offset : null; - } - - /** - * Sets value based on offset. - * @param string $offset Offset - * @param mixed $value Value to be set - * @return void - */ - public function offsetSet($offset, $value) - { - $this->$offset = $value; - } - - /** - * Unsets offset. - * @param integer $offset Offset - * @return void - */ - public function offsetUnset($offset) - { - $this->$offset = null; - } } diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/model_variables.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/model_variables.mustache new file mode 100644 index 000000000000..d0af5b8579e5 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php-symfony/model_variables.mustache @@ -0,0 +1,91 @@ + /** + {{#description}} + * {{description}} + * + {{/description}} + * @var {{{datatype}}}{{^required}}|null{{/required}} + * @SerializedName("{{baseName}}") +{{#required}} + * @Assert\NotNull() +{{/required}} +{{#isEnum}} + {{#isContainer}} + * @Assert\All({ + {{#items}} + * @Assert\Choice({ {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}} }) + {{/items}} + * }) + {{/isContainer}} + {{^isContainer}} + * @Assert\Choice({ {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}} }) + {{/isContainer}} +{{/isEnum}} +{{#isContainer}} + * @Assert\All({ + {{#items}} + * @Assert\Type("{{datatype}}") + {{/items}} + * }) + {{#items}} + * @Type("array<{{datatype}}>") + {{/items}} +{{/isContainer}} +{{^isContainer}} + {{#isDate}} + * @Assert\Date() + * @Type("DateTime") + {{/isDate}} + {{#isDateTime}} + * @Assert\DateTime() + * @Type("DateTime") + {{/isDateTime}} + {{^isDate}} + {{^isDateTime}} + * @Assert\Type("{{datatype}}") + * @Type("{{datatype}}") + {{/isDateTime}} + {{/isDate}} +{{/isContainer}} +{{#hasValidation}} + {{#maxLength}} + * @Assert\Length( + * max = {{maxLength}} + * ) + {{/maxLength}} + {{#minLength}} + * @Assert\Length( + * min = {{minLength}} + * ) + {{/minLength}} + {{#minimum}} + {{#exclusiveMinimum}} + * @Assert\GreaterThan({{minimum}}) + {{/exclusiveMinimum}} + {{^exclusiveMinimum}} + * @Assert\GreaterThanOrEqual({{minimum}}) + {{/exclusiveMinimum}} + {{/minimum}} + {{#maximum}} + {{#exclusiveMaximum}} + * @Assert\LessThan({{minimum}}) + {{/exclusiveMaximum}} + {{^exclusiveMaximum}} + * @Assert\LessThanOrEqual({{minimum}}) + {{/exclusiveMaximum}} + {{/maximum}} + {{#pattern}} + * @Assert\Regex("/{{pattern}}/") + {{/pattern}} + {{#maxItems}} + * @Assert\Count( + * max = {{maxItems}} + * ) + {{/maxItems}} + {{#minItems}} + * @Assert\Count( + * min = {{minItems}} + * ) + {{/minItems}} +{{/hasValidation}} + */ + protected ${{name}}; diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/routing.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/routing.mustache index e91e9349c06e..e0294a956d17 100644 --- a/modules/swagger-codegen/src/main/resources/php-symfony/routing.mustache +++ b/modules/swagger-codegen/src/main/resources/php-symfony/routing.mustache @@ -11,7 +11,29 @@ path: {{path}} methods: [{{httpMethod}}] defaults: - _controller: {{bundleClassName}}:{{baseName}}:{{operationId}} + _controller: {{bundleAlias}}.controller.{{pathPrefix}}:{{operationId}}Action + {{#hasPathParams}} + requirements: + {{/hasPathParams}} + {{#pathParams}} + {{#pattern}} + {{paramName}}: '{{pattern}}' + {{/pattern}} + {{^pattern}} + {{#isLong}} + {{paramName}}: '\d+' + {{/isLong}} + {{#isInteger}} + {{paramName}}: '\d+' + {{/isInteger}} + {{#isString}} + {{paramName}}: '[a-z0-9]+' + {{/isString}} + {{#isBoolean}} + {{paramName}}: 'true|false' + {{/isBoolean}} + {{/pattern}} + {{/pathParams}} {{/operation}} {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/serialization/JmsSerializer.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/serialization/JmsSerializer.mustache new file mode 100644 index 000000000000..995e71ba0235 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php-symfony/serialization/JmsSerializer.mustache @@ -0,0 +1,91 @@ +serializer = SerializerBuilder::create() + ->setDeserializationVisitor('json', new StrictJsonDeserializationVisitor($naming_strategy)) + ->setDeserializationVisitor('xml', new XmlDeserializationVisitor($naming_strategy)) + ->build(); + } + + public function serialize($data, $format) + { + return SerializerBuilder::create()->build()->serialize($data, $this->convertFormat($format)); + } + + public function deserialize($data, $type, $format) + { + if ($format == 'string') { + return $this->deserializeString($data, $type); + } + + // If we end up here, let JMS serializer handle the deserialization + return $this->serializer->deserialize($data, $type, $this->convertFormat($format)); + } + + private function convertFormat($format) + { + switch ($format) { + case 'application/json': + return 'json'; + case 'application/xml': + return 'xml'; + } + + return null; + } + + private function deserializeString($data, $type) + { + switch ($type) { + case 'int': + case 'integer': + if (is_int($data)) { + return $data; + } + + if (is_numeric($data)) { + return $data + 0; + } + + break; + case 'string': + break; + case 'boolean': + case 'bool': + if (strtolower($data) === 'true') { + return true; + } + + if (strtolower($data) === 'false') { + return false; + } + + break; + case 'array': + return explode(',', $data); + case 'array': + return explode(' ', $data); + case 'array': + return explode("\t", $data); + case 'array': + return explode('|', $data); + } + + // If we end up here, just return data + return $data; + } +} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/serialization/SerializerInterface.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/serialization/SerializerInterface.mustache new file mode 100644 index 000000000000..60ad87246487 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php-symfony/serialization/SerializerInterface.mustache @@ -0,0 +1,27 @@ +getCurrentPath()) > 0) { + $property = sprintf('property "%s" to be ', implode('.', $context->getCurrentPath())); + } else { + $property = ''; + } + + return new static(sprintf( + 'Expected %s%s, but got %s: %s', + $property, + $expected_type, + gettype($actual_value), + json_encode($actual_value) + )); + } +} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/services.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/services.mustache index 89e2bb8a96bc..f6aec0cc2e0a 100644 --- a/modules/swagger-codegen/src/main/resources/php-symfony/services.mustache +++ b/modules/swagger-codegen/src/main/resources/php-symfony/services.mustache @@ -2,9 +2,33 @@ # https://github.com/swagger-api/swagger-codegen # Do not edit the class manually. +parameters: + {{bundleAlias}}.serializer: '{{servicePackage}}\JmsSerializer' + {{bundleAlias}}.validator: '{{servicePackage}}\SymfonyValidator' + services: {{bundleAlias}}.api.api_server: class: {{apiPackage}}\ApiServer {{bundleAlias}}.model.model_serializer: class: {{modelPackage}}\ModelSerializer + + {{bundleAlias}}.service.serializer: + class: %{{bundleAlias}}.serializer% + + {{bundleAlias}}.service.validator: + class: %{{bundleAlias}}.validator% + +{{#apiInfo}} +{{#apis}} +{{#operations}} + {{bundleAlias}}.controller.{{pathPrefix}}: + class: {{controllerPackage}}\{{baseName}}Controller + calls: + - [setSerializer, ['@{{bundleAlias}}.service.serializer']] + - [setValidator, ['@{{bundleAlias}}.service.validator']] + - [setApiServer, ['@{{bundleAlias}}.api.api_server']] + +{{/operations}} +{{/apis}} +{{/apiInfo}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/testing/AppKernel.php b/modules/swagger-codegen/src/main/resources/php-symfony/testing/AppKernel.php new file mode 100644 index 000000000000..631690bc9786 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php-symfony/testing/AppKernel.php @@ -0,0 +1,21 @@ +load(__DIR__.'/test_config.yml'); + } +} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/testing/api_test.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/testing/api_test.mustache new file mode 100644 index 000000000000..d337c1e3df6a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php-symfony/testing/api_test.mustache @@ -0,0 +1,116 @@ +partial_header}} +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Please update the test case below to test the endpoint. + */ + +namespace {{apiTestsPackage}}; + +use {{invokerPackage}}\Configuration; +use {{invokerPackage}}\ApiClient; +use {{invokerPackage}}\ApiException; +use {{invokerPackage}}\ObjectSerializer; +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; + +/** + * {{classname}}Test Class Doc Comment + * + * @category Class + * @package {{apiTestsPackage}} + * @author Swagger Codegen team + * @link https://github.com/swagger-api/swagger-codegen + */ +{{#operations}}class {{classname}}Test extends WebTestCase +{ + + /** + * Setup before running any test cases + */ + public static function setUpBeforeClass() + { + } + + /** + * Setup before running each test case + */ + public function setUp() + { + } + + /** + * Clean up after running each test case + */ + public function tearDown() + { + } + + /** + * Clean up after running all test cases + */ + public static function tearDownAfterClass() + { + } + {{#operation}} + + /** + * Test case for {{{operationId}}} + * + * {{{summary}}}. + * + */ + public function test{{operationIdCamelCase}}() + { + $client = static::createClient(); + + $path = '{{path}}'; + {{#pathParams}} + {{=<% %>=}} + $pattern = '{<%paramName%>}'; + <%={{ }}=%> + {{#pattern}} + $data = $this->genTestData('{{pattern}}'); + {{/pattern}} + {{^pattern}} + {{#isLong}} + $data = $this->genTestData('\d+'); + {{/isLong}} + {{#isInteger}} + $data = $this->genTestData('\d+'); + {{/isInteger}} + {{#isString}} + $data = $this->genTestData('[a-z0-9]+'); + {{/isString}} + {{#isBoolean}} + $data = $this->genTestData('true|false'); + {{/isBoolean}} + {{/pattern}} + $path = str_replace($pattern, $data, $path); + {{/pathParams}} + + $crawler = $client->request('{{httpMethod}}', $path); + } + {{/operation}} + + protected function genTestData($regexp) + { + $grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp'); + $compiler = \Hoa\Compiler\Llk\Llk::load($grammar); + $ast = $compiler->parse($regexp); + $generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random()); + + return $generator->visit($ast); + } +} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/model_test.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/testing/model_test.mustache similarity index 95% rename from modules/swagger-codegen/src/main/resources/php-symfony/model_test.mustache rename to modules/swagger-codegen/src/main/resources/php-symfony/testing/model_test.mustache index 797f9a2af2a6..b4b9cf012a39 100644 --- a/modules/swagger-codegen/src/main/resources/php-symfony/model_test.mustache +++ b/modules/swagger-codegen/src/main/resources/php-symfony/testing/model_test.mustache @@ -19,7 +19,7 @@ * Please update the test case below to test the model. */ -namespace {{modelTestsPackage}}; +namespace {{modelPackage}}; /** * {{classname}}Test Class Doc Comment @@ -67,6 +67,7 @@ class {{classname}}Test extends \PHPUnit_Framework_TestCase */ public function test{{classname}}() { + $test{{classname}} = new {{classname}}(); } {{#vars}} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/phpunit.xml.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/testing/phpunit.xml.mustache similarity index 90% rename from modules/swagger-codegen/src/main/resources/php-symfony/phpunit.xml.mustache rename to modules/swagger-codegen/src/main/resources/php-symfony/testing/phpunit.xml.mustache index 5de6fea575c0..bd5b2978ee04 100644 --- a/modules/swagger-codegen/src/main/resources/php-symfony/phpunit.xml.mustache +++ b/modules/swagger-codegen/src/main/resources/php-symfony/testing/phpunit.xml.mustache @@ -12,6 +12,10 @@ + + + + {{apiSrcPath}} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/testing/pom.xml b/modules/swagger-codegen/src/main/resources/php-symfony/testing/pom.xml new file mode 100644 index 000000000000..614b3d33f98a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php-symfony/testing/pom.xml @@ -0,0 +1,57 @@ + + 4.0.0 + com.penneo + PhpSymfonyPetstoreServerTests + pom + 1.0-SNAPSHOT + PHP Symfony Swagger Petstore Server + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + bundle-install + pre-integration-test + + exec + + + composer + + install + + + + + bundle-test + integration-test + + exec + + + vendor/bin/phpunit + + + + + + + + diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/testing/test_config.yml b/modules/swagger-codegen/src/main/resources/php-symfony/testing/test_config.yml new file mode 100644 index 000000000000..10c88a274c97 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php-symfony/testing/test_config.yml @@ -0,0 +1,8 @@ +imports: + - { resource: "../Resources/config/services.yml" } + +framework: + secret: "testsecret" + test: ~ + router: + resource: "%kernel.root_dir%/../Resources/config/routing.yml" diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/validation/SymfonyValidator.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/validation/SymfonyValidator.mustache new file mode 100644 index 000000000000..3b6c5dd0ef64 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php-symfony/validation/SymfonyValidator.mustache @@ -0,0 +1,20 @@ +validator = Validation::createValidator(); + } + + public function validate($value, $constraints = null, $groups = null) + { + return $this->validator->validate($value, $constraints, $groups); + } +} diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/validation/ValidatorInterface.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/validation/ValidatorInterface.mustache new file mode 100644 index 000000000000..e2a0d9badc5d --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/php-symfony/validation/ValidatorInterface.mustache @@ -0,0 +1,25 @@ +level(Symfony\CS\FixerInterface::PSR2_LEVEL) + ->setUsingCache(true) + ->fixers( + [ + 'ordered_use', + 'phpdoc_order', + 'short_array_syntax', + 'strict', + 'strict_param' + ] + ) + ->finder( + Symfony\CS\Finder\DefaultFinder::create() + ->in(__DIR__) + ); diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/.travis.yml b/samples/server/petstore/php-symfony/SymfonyBundle-php/.travis.yml new file mode 100644 index 000000000000..d77f3825f6fe --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/.travis.yml @@ -0,0 +1,10 @@ +language: php +sudo: false +php: + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - hhvm +before_install: "composer install" +script: "vendor/bin/phpunit" diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/ApiServer.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/ApiServer.php new file mode 100644 index 000000000000..d26918e624f0 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/ApiServer.php @@ -0,0 +1,80 @@ +apis[$api])) { + throw new \InvalidArgumentException('API has already a handler: '.$api); + } + + $this->apis[$api] = $handler; + } + + /** + * Returns an API handler. + * + * @param string $api An API name of the handle + * @return mixed Returns a handler + * @throws \InvalidArgumentException When no such handler exists + */ + public function getApiHandler($api) + { + if (!isset($this->apis[$api])) { + throw new \InvalidArgumentException('No handler for '.$api.' implemented.'); + } + + return $this->apis[$api]; + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/PetApiInterface.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/PetApiInterface.php new file mode 100644 index 000000000000..587f6d813a31 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/PetApiInterface.php @@ -0,0 +1,172 @@ +validator = $validator; + } + + public function setSerializer(SerializerInterface $serializer) + { + $this->serializer = $serializer; + } + + public function setApiServer($server) + { + $this->apiServer = $server; + } + + /** + * This will return a response with code 400. Usage example: + * return $this->createBadRequestResponse('Unable to access this page!'); + * + * @param string $message A message + * + * @return Response + */ + public function createBadRequestResponse($message = 'Bad Request.') + { + return new Response($message, 400); + } + + /** + * This will return an error response. Usage example: + * return $this->createErrorResponse(new UnauthorizedHttpException()); + * + * @param HttpException $exception An HTTP exception + * + * @return Response + */ + public function createErrorResponse(HttpException $exception) + { + $statusCode = $exception->getStatusCode(); + $headers = array_merge($exception->getHeaders(), ['Content-Type' => 'application/json']); + + $json = $this->exceptionToArray($exception); + $json['statusCode'] = $statusCode; + + return new Response(json_encode($json, 15, 512), $statusCode, $headers); + } + + /** + * Serializes data to a given type format. + * + * @param mixed $data The data to serialize. + * @param string $class The source data class. + * @param string $format The target serialization format. + * + * @return string A serialized data string. + */ + protected function serialize($data, $format) + { + return $this->serializer->serialize($data, $format); + } + + /** + * Deserializes data from a given type format. + * + * @param string $data The data to deserialize. + * @param string $class The target data class. + * @param string $format The source serialization format. + * + * @return mixed A deserialized data. + */ + protected function deserialize($data, $class, $format) + { + return $this->serializer->deserialize($data, $class, $format); + } + + protected function validate($data, $asserts = null) + { + $errors = $this->validator->validate($data, $asserts); + + if (count($errors) > 0) { + $errorsString = (string)$errors; + return $this->createBadRequestResponse($errorsString); + } + } + + /** + * Converts an exception to a serializable array. + * + * @param \Exception|null $exception + * + * @return array + */ + private function exceptionToArray(\Exception $exception = null) + { + if (null === $exception) { + return null; + } + + return [ + 'message' => $exception->getMessage(), + 'type' => get_class($exception), + 'previous' => $this->exceptionToArray($exception->getPrevious()), + ]; + } + + protected function getOutputFormat($accept, array $produced) + { + // Figure out what the client accepts + $accept = preg_split("/[\s,]+/", $accept); + + if (in_array('*/*', $accept) || in_array('application/*', $accept)) { + // Prefer JSON if the client has no preference + if (in_array('application/json', $produced)) { + return 'application/json'; + } + if (in_array('application/xml', $produced)) { + return 'application/xml'; + } + } + + if (in_array('application/json', $accept) && in_array('application/json', $produced)) { + return 'application/json'; + } + + if (in_array('application/xml', $accept) && in_array('application/xml', $produced)) { + return 'application/xml'; + } + + // If we reach this point, we don't have a common ground between server and client + return null; + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/PetController.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/PetController.php new file mode 100644 index 000000000000..9362b82b123c --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/PetController.php @@ -0,0 +1,799 @@ +headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0]; + if (!in_array($inputFormat, $consumes)) { + // We can't consume the content that the client is sending us + return new Response('', 415); + } + + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + // Authentication 'petstore_auth' required + // Oauth required + $securitypetstore_auth = $request->headers->get('authorization'); + + // Read out all input parameter values into variables + $body = $request->getContent(); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + + $body = $this->deserialize($body, 'Swagger\Server\Model\Pet', $inputFormat); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("Swagger\Server\Model\Pet"); + $response = $this->validate($body, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + // Set authentication method 'petstore_auth' + $handler->setpetstore_auth($securitypetstore_auth); + + // Make the call to the business logic + $responseCode = 204; + $responseHeaders = []; + $result = $handler->addPet($body, $responseCode, $responseHeaders); + + // Find default response message + $message = ''; + + // Find a more specific message, if available + switch ($responseCode) { + case 405: + $message = 'Invalid input'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation deletePet + * + * Deletes a pet + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function deletePetAction(Request $request, $petId) + { + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + // Authentication 'petstore_auth' required + // Oauth required + $securitypetstore_auth = $request->headers->get('authorization'); + + // Read out all input parameter values into variables + $apiKey = $request->headers->get('apiKey'); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $petId = $this->deserialize($petId, 'int', 'string'); + $apiKey = $request->headers->get('apiKey'); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $apiKey = $this->deserialize($apiKey, 'string', 'string'); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("int"); + $response = $this->validate($petId, $asserts); + if ($response instanceof Response) { + return $response; + } + $asserts = []; + $asserts[] = new Assert\Type("string"); + $response = $this->validate($apiKey, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + // Set authentication method 'petstore_auth' + $handler->setpetstore_auth($securitypetstore_auth); + + // Make the call to the business logic + $responseCode = 204; + $responseHeaders = []; + $result = $handler->deletePet($petId, $apiKey, $responseCode, $responseHeaders); + + // Find default response message + $message = ''; + + // Find a more specific message, if available + switch ($responseCode) { + case 400: + $message = 'Invalid pet value'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation findPetsByStatus + * + * Finds Pets by status + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function findPetsByStatusAction(Request $request) + { + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + // Authentication 'petstore_auth' required + // Oauth required + $securitypetstore_auth = $request->headers->get('authorization'); + + // Read out all input parameter values into variables + $status = $request->query->get('status'); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $status = $this->deserialize($status, 'array', 'string'); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\All([ + new Assert\Choice([ "available", "pending", "sold" ]) + ]); + $asserts[] = new Assert\All([ + new Assert\Type("string") + ]); + $response = $this->validate($status, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + // Set authentication method 'petstore_auth' + $handler->setpetstore_auth($securitypetstore_auth); + + // Make the call to the business logic + $responseCode = 200; + $responseHeaders = []; + $result = $handler->findPetsByStatus($status, $responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 200: + $message = 'successful operation'; + break; + case 400: + $message = 'Invalid status value'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation findPetsByTags + * + * Finds Pets by tags + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function findPetsByTagsAction(Request $request) + { + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + // Authentication 'petstore_auth' required + // Oauth required + $securitypetstore_auth = $request->headers->get('authorization'); + + // Read out all input parameter values into variables + $tags = $request->query->get('tags'); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $tags = $this->deserialize($tags, 'array', 'string'); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\All([ + new Assert\Type("string") + ]); + $response = $this->validate($tags, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + // Set authentication method 'petstore_auth' + $handler->setpetstore_auth($securitypetstore_auth); + + // Make the call to the business logic + $responseCode = 200; + $responseHeaders = []; + $result = $handler->findPetsByTags($tags, $responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 200: + $message = 'successful operation'; + break; + case 400: + $message = 'Invalid tag value'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation getPetById + * + * Find pet by ID + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function getPetByIdAction(Request $request, $petId) + { + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + // Authentication 'api_key' required + // Set key with prefix in header + $securityapi_key = $request->headers->get('api_key'); + + // Read out all input parameter values into variables + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $petId = $this->deserialize($petId, 'int', 'string'); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("int"); + $response = $this->validate($petId, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + // Set authentication method 'api_key' + $handler->setapi_key($securityapi_key); + + // Make the call to the business logic + $responseCode = 200; + $responseHeaders = []; + $result = $handler->getPetById($petId, $responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 200: + $message = 'successful operation'; + break; + case 400: + $message = 'Invalid ID supplied'; + break; + case 404: + $message = 'Pet not found'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation updatePet + * + * Update an existing pet + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function updatePetAction(Request $request) + { + // Make sure that the client is providing something that we can consume + $consumes = ['application/json', 'application/xml']; + $inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0]; + if (!in_array($inputFormat, $consumes)) { + // We can't consume the content that the client is sending us + return new Response('', 415); + } + + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + // Authentication 'petstore_auth' required + // Oauth required + $securitypetstore_auth = $request->headers->get('authorization'); + + // Read out all input parameter values into variables + $body = $request->getContent(); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + + $body = $this->deserialize($body, 'Swagger\Server\Model\Pet', $inputFormat); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("Swagger\Server\Model\Pet"); + $response = $this->validate($body, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + // Set authentication method 'petstore_auth' + $handler->setpetstore_auth($securitypetstore_auth); + + // Make the call to the business logic + $responseCode = 204; + $responseHeaders = []; + $result = $handler->updatePet($body, $responseCode, $responseHeaders); + + // Find default response message + $message = ''; + + // Find a more specific message, if available + switch ($responseCode) { + case 400: + $message = 'Invalid ID supplied'; + break; + case 404: + $message = 'Pet not found'; + break; + case 405: + $message = 'Validation exception'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation updatePetWithForm + * + * Updates a pet in the store with form data + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function updatePetWithFormAction(Request $request, $petId) + { + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + // Authentication 'petstore_auth' required + // Oauth required + $securitypetstore_auth = $request->headers->get('authorization'); + + // Read out all input parameter values into variables + $name = $request->request->get('name'); + $status = $request->request->get('status'); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $petId = $this->deserialize($petId, 'int', 'string'); + $name = $request->request->get('name'); + $status = $request->request->get('status'); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $name = $this->deserialize($name, 'string', 'string'); + $name = $request->request->get('name'); + $status = $request->request->get('status'); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $status = $this->deserialize($status, 'string', 'string'); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("int"); + $response = $this->validate($petId, $asserts); + if ($response instanceof Response) { + return $response; + } + $asserts = []; + $asserts[] = new Assert\Type("string"); + $response = $this->validate($name, $asserts); + if ($response instanceof Response) { + return $response; + } + $asserts = []; + $asserts[] = new Assert\Type("string"); + $response = $this->validate($status, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + // Set authentication method 'petstore_auth' + $handler->setpetstore_auth($securitypetstore_auth); + + // Make the call to the business logic + $responseCode = 204; + $responseHeaders = []; + $result = $handler->updatePetWithForm($petId, $name, $status, $responseCode, $responseHeaders); + + // Find default response message + $message = ''; + + // Find a more specific message, if available + switch ($responseCode) { + case 405: + $message = 'Invalid input'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation uploadFile + * + * uploads an image + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function uploadFileAction(Request $request, $petId) + { + // Figure out what data format to return to the client + $produces = ['application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + // Authentication 'petstore_auth' required + // Oauth required + $securitypetstore_auth = $request->headers->get('authorization'); + + // Read out all input parameter values into variables + $additionalMetadata = $request->request->get('additionalMetadata'); + $file = $request->files->get('file'); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $petId = $this->deserialize($petId, 'int', 'string'); + $additionalMetadata = $request->request->get('additionalMetadata'); + $file = $request->files->get('file'); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $additionalMetadata = $this->deserialize($additionalMetadata, 'string', 'string'); + $additionalMetadata = $request->request->get('additionalMetadata'); + $file = $request->files->get('file'); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("int"); + $response = $this->validate($petId, $asserts); + if ($response instanceof Response) { + return $response; + } + $asserts = []; + $asserts[] = new Assert\Type("string"); + $response = $this->validate($additionalMetadata, $asserts); + if ($response instanceof Response) { + return $response; + } + $asserts = []; + $asserts[] = new Assert\File(); + $response = $this->validate($file, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + // Set authentication method 'petstore_auth' + $handler->setpetstore_auth($securitypetstore_auth); + + // Make the call to the business logic + $responseCode = 200; + $responseHeaders = []; + $result = $handler->uploadFile($petId, $additionalMetadata, $file, $responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 200: + $message = 'successful operation'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Returns the handler for this API controller. + * @return PetApiInterface + */ + public function getApiHandler() + { + return $this->apiServer->getApiHandler('pet'); + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/StoreController.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/StoreController.php new file mode 100644 index 000000000000..304a847c6eb8 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/StoreController.php @@ -0,0 +1,368 @@ +headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + + // Read out all input parameter values into variables + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $orderId = $this->deserialize($orderId, 'string', 'string'); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("string"); + $response = $this->validate($orderId, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + + // Make the call to the business logic + $responseCode = 204; + $responseHeaders = []; + $result = $handler->deleteOrder($orderId, $responseCode, $responseHeaders); + + // Find default response message + $message = ''; + + // Find a more specific message, if available + switch ($responseCode) { + case 400: + $message = 'Invalid ID supplied'; + break; + case 404: + $message = 'Order not found'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation getInventory + * + * Returns pet inventories by status + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function getInventoryAction(Request $request) + { + // Figure out what data format to return to the client + $produces = ['application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + // Authentication 'api_key' required + // Set key with prefix in header + $securityapi_key = $request->headers->get('api_key'); + + // Read out all input parameter values into variables + + // Validate the input values + + + try { + $handler = $this->getApiHandler(); + + // Set authentication method 'api_key' + $handler->setapi_key($securityapi_key); + + // Make the call to the business logic + $responseCode = 200; + $responseHeaders = []; + $result = $handler->getInventory($responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 200: + $message = 'successful operation'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation getOrderById + * + * Find purchase order by ID + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function getOrderByIdAction(Request $request, $orderId) + { + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + + // Read out all input parameter values into variables + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $orderId = $this->deserialize($orderId, 'int', 'string'); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("int"); + $asserts[] = new Assert\GreaterThanOrEqual(1); + $asserts[] = new Assert\LessThanOrEqual(1); + $response = $this->validate($orderId, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + + // Make the call to the business logic + $responseCode = 200; + $responseHeaders = []; + $result = $handler->getOrderById($orderId, $responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 200: + $message = 'successful operation'; + break; + case 400: + $message = 'Invalid ID supplied'; + break; + case 404: + $message = 'Order not found'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation placeOrder + * + * Place an order for a pet + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function placeOrderAction(Request $request) + { + // Make sure that the client is providing something that we can consume + $consumes = []; + $inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0]; + if (!in_array($inputFormat, $consumes)) { + // We can't consume the content that the client is sending us + return new Response('', 415); + } + + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + + // Read out all input parameter values into variables + $body = $request->getContent(); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + + $body = $this->deserialize($body, 'Swagger\Server\Model\Order', $inputFormat); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("Swagger\Server\Model\Order"); + $response = $this->validate($body, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + + // Make the call to the business logic + $responseCode = 200; + $responseHeaders = []; + $result = $handler->placeOrder($body, $responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 200: + $message = 'successful operation'; + break; + case 400: + $message = 'Invalid Order'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Returns the handler for this API controller. + * @return StoreApiInterface + */ + public function getApiHandler() + { + return $this->apiServer->getApiHandler('store'); + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/UserController.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/UserController.php new file mode 100644 index 000000000000..7f182bb1e61c --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/UserController.php @@ -0,0 +1,720 @@ +headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0]; + if (!in_array($inputFormat, $consumes)) { + // We can't consume the content that the client is sending us + return new Response('', 415); + } + + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + + // Read out all input parameter values into variables + $body = $request->getContent(); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + + $body = $this->deserialize($body, 'Swagger\Server\Model\User', $inputFormat); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("Swagger\Server\Model\User"); + $response = $this->validate($body, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + + // Make the call to the business logic + $responseCode = 204; + $responseHeaders = []; + $result = $handler->createUser($body, $responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 0: + $message = 'successful operation'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation createUsersWithArrayInput + * + * Creates list of users with given input array + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function createUsersWithArrayInputAction(Request $request) + { + // Make sure that the client is providing something that we can consume + $consumes = []; + $inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0]; + if (!in_array($inputFormat, $consumes)) { + // We can't consume the content that the client is sending us + return new Response('', 415); + } + + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + + // Read out all input parameter values into variables + $body = $request->getContent(); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + + $body = $this->deserialize($body, 'Swagger\Server\Model\User[]', $inputFormat); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\All([ + new Assert\Type("Swagger\Server\Model\User[]") + ]); + $response = $this->validate($body, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + + // Make the call to the business logic + $responseCode = 204; + $responseHeaders = []; + $result = $handler->createUsersWithArrayInput($body, $responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 0: + $message = 'successful operation'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation createUsersWithListInput + * + * Creates list of users with given input array + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function createUsersWithListInputAction(Request $request) + { + // Make sure that the client is providing something that we can consume + $consumes = []; + $inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0]; + if (!in_array($inputFormat, $consumes)) { + // We can't consume the content that the client is sending us + return new Response('', 415); + } + + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + + // Read out all input parameter values into variables + $body = $request->getContent(); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + + $body = $this->deserialize($body, 'Swagger\Server\Model\User[]', $inputFormat); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\All([ + new Assert\Type("Swagger\Server\Model\User[]") + ]); + $response = $this->validate($body, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + + // Make the call to the business logic + $responseCode = 204; + $responseHeaders = []; + $result = $handler->createUsersWithListInput($body, $responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 0: + $message = 'successful operation'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation deleteUser + * + * Delete user + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function deleteUserAction(Request $request, $username) + { + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + + // Read out all input parameter values into variables + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $username = $this->deserialize($username, 'string', 'string'); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("string"); + $response = $this->validate($username, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + + // Make the call to the business logic + $responseCode = 204; + $responseHeaders = []; + $result = $handler->deleteUser($username, $responseCode, $responseHeaders); + + // Find default response message + $message = ''; + + // Find a more specific message, if available + switch ($responseCode) { + case 400: + $message = 'Invalid username supplied'; + break; + case 404: + $message = 'User not found'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation getUserByName + * + * Get user by user name + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function getUserByNameAction(Request $request, $username) + { + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + + // Read out all input parameter values into variables + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $username = $this->deserialize($username, 'string', 'string'); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("string"); + $response = $this->validate($username, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + + // Make the call to the business logic + $responseCode = 200; + $responseHeaders = []; + $result = $handler->getUserByName($username, $responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 200: + $message = 'successful operation'; + break; + case 400: + $message = 'Invalid username supplied'; + break; + case 404: + $message = 'User not found'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation loginUser + * + * Logs user into the system + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function loginUserAction(Request $request) + { + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + + // Read out all input parameter values into variables + $username = $request->query->get('username'); + $password = $request->query->get('password'); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $username = $this->deserialize($username, 'string', 'string'); + $username = $request->query->get('username'); + $password = $request->query->get('password'); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + $password = $this->deserialize($password, 'string', 'string'); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("string"); + $response = $this->validate($username, $asserts); + if ($response instanceof Response) { + return $response; + } + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("string"); + $response = $this->validate($password, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + + // Make the call to the business logic + $responseCode = 200; + $responseHeaders = []; + $result = $handler->loginUser($username, $password, $responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 200: + $message = 'successful operation'; + break; + case 400: + $message = 'Invalid username/password supplied'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation logoutUser + * + * Logs out current logged in user session + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function logoutUserAction(Request $request) + { + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + + // Read out all input parameter values into variables + + // Validate the input values + + + try { + $handler = $this->getApiHandler(); + + + // Make the call to the business logic + $responseCode = 204; + $responseHeaders = []; + $result = $handler->logoutUser($responseCode, $responseHeaders); + + // Find default response message + $message = 'successful operation'; + + // Find a more specific message, if available + switch ($responseCode) { + case 0: + $message = 'successful operation'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Operation updateUser + * + * Updated user + * + * @param Request $request The Symfony request to handle. + * @return Response The Symfony response. + */ + public function updateUserAction(Request $request, $username) + { + // Make sure that the client is providing something that we can consume + $consumes = []; + $inputFormat = $request->headers->has('Content-Type')?$request->headers->get('Content-Type'):$consumes[0]; + if (!in_array($inputFormat, $consumes)) { + // We can't consume the content that the client is sending us + return new Response('', 415); + } + + // Figure out what data format to return to the client + $produces = ['application/xml', 'application/json']; + // Figure out what the client accepts + $clientAccepts = $request->headers->has('Accept')?$request->headers->get('Accept'):'*/*'; + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); + if ($responseFormat === null) { + return new Response('', 406); + } + + // Handle authentication + + // Read out all input parameter values into variables + $body = $request->getContent(); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + + $body = $this->deserialize($body, 'Swagger\Server\Model\User', $inputFormat); + $body = $request->getContent(); + + // Use the default value if no value was provided + + // Deserialize the input values that needs it + + $body = $this->deserialize($body, 'Swagger\Server\Model\User', $inputFormat); + + // Validate the input values + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("string"); + $response = $this->validate($username, $asserts); + if ($response instanceof Response) { + return $response; + } + $asserts = []; + $asserts[] = new Assert\NotNull(); + $asserts[] = new Assert\Type("Swagger\Server\Model\User"); + $response = $this->validate($body, $asserts); + if ($response instanceof Response) { + return $response; + } + + + try { + $handler = $this->getApiHandler(); + + + // Make the call to the business logic + $responseCode = 204; + $responseHeaders = []; + $result = $handler->updateUser($username, $body, $responseCode, $responseHeaders); + + // Find default response message + $message = ''; + + // Find a more specific message, if available + switch ($responseCode) { + case 400: + $message = 'Invalid user supplied'; + break; + case 404: + $message = 'User not found'; + break; + } + + return new Response( + $result?$this->serialize($result, $responseFormat):'', + $responseCode, + array_merge( + $responseHeaders, + [ + 'Content-Type' => $responseFormat, + 'X-Swagger-Message' => $message + ] + ) + ); + } catch (Exception $fallthrough) { + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); + } + } + + /** + * Returns the handler for this API controller. + * @return UserApiInterface + */ + public function getApiHandler() + { + return $this->apiServer->getApiHandler('user'); + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/DependencyInjection/Compiler/SwaggerServerApiPass.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/DependencyInjection/Compiler/SwaggerServerApiPass.php new file mode 100644 index 000000000000..7ac5898d1432 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/DependencyInjection/Compiler/SwaggerServerApiPass.php @@ -0,0 +1,70 @@ +has('swagger_server.api.api_server')) { + return; + } + + $definition = $container->findDefinition('swagger_server.api.api_server'); + + // find all service IDs with the swagger_server.api tag + $taggedServices = $container->findTaggedServiceIds('swagger_server.api'); + + foreach ($taggedServices as $id => $tags) { + foreach ($tags as $tag) { + // add the transport service to the ChainTransport service + $definition->addMethodCall('addApiHandler', [$tag['api'], new Reference($id)]); + } + } + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/DependencyInjection/SwaggerServerExtension.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/DependencyInjection/SwaggerServerExtension.php new file mode 100644 index 000000000000..2f12f034cce2 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/DependencyInjection/SwaggerServerExtension.php @@ -0,0 +1,57 @@ +load('services.yml'); + } + + public function getAlias() + { + return 'swagger_server'; + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/ApiResponse.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/ApiResponse.php new file mode 100644 index 000000000000..5a00e41be2d5 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/ApiResponse.php @@ -0,0 +1,154 @@ +code = isset($data['code']) ? $data['code'] : null; + $this->type = isset($data['type']) ? $data['type'] : null; + $this->message = isset($data['message']) ? $data['message'] : null; + } + + /** + * Gets code. + * + * @return int|null + */ + public function getCode() + { + return $this->code; + } + + /** + * Sets code. + * + * @param int|null $code + * + * @return $this + */ + public function setCode($code = null) + { + $this->code = $code; + + return $this; + } + + /** + * Gets type. + * + * @return string|null + */ + public function getType() + { + return $this->type; + } + + /** + * Sets type. + * + * @param string|null $type + * + * @return $this + */ + public function setType($type = null) + { + $this->type = $type; + + return $this; + } + + /** + * Gets message. + * + * @return string|null + */ + public function getMessage() + { + return $this->message; + } + + /** + * Sets message. + * + * @param string|null $message + * + * @return $this + */ + public function setMessage($message = null) + { + $this->message = $message; + + return $this; + } +} + + diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Category.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Category.php new file mode 100644 index 000000000000..e59ecdbe7c4d --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Category.php @@ -0,0 +1,121 @@ +id = isset($data['id']) ? $data['id'] : null; + $this->name = isset($data['name']) ? $data['name'] : null; + } + + /** + * Gets id. + * + * @return int|null + */ + public function getId() + { + return $this->id; + } + + /** + * Sets id. + * + * @param int|null $id + * + * @return $this + */ + public function setId($id = null) + { + $this->id = $id; + + return $this; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } +} + + diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Order.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Order.php new file mode 100644 index 000000000000..65a7ead3cf28 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Order.php @@ -0,0 +1,256 @@ +id = isset($data['id']) ? $data['id'] : null; + $this->petId = isset($data['petId']) ? $data['petId'] : null; + $this->quantity = isset($data['quantity']) ? $data['quantity'] : null; + $this->shipDate = isset($data['shipDate']) ? $data['shipDate'] : null; + $this->status = isset($data['status']) ? $data['status'] : null; + $this->complete = isset($data['complete']) ? $data['complete'] : false; + } + + /** + * Gets id. + * + * @return int|null + */ + public function getId() + { + return $this->id; + } + + /** + * Sets id. + * + * @param int|null $id + * + * @return $this + */ + public function setId($id = null) + { + $this->id = $id; + + return $this; + } + + /** + * Gets petId. + * + * @return int|null + */ + public function getPetId() + { + return $this->petId; + } + + /** + * Sets petId. + * + * @param int|null $petId + * + * @return $this + */ + public function setPetId($petId = null) + { + $this->petId = $petId; + + return $this; + } + + /** + * Gets quantity. + * + * @return int|null + */ + public function getQuantity() + { + return $this->quantity; + } + + /** + * Sets quantity. + * + * @param int|null $quantity + * + * @return $this + */ + public function setQuantity($quantity = null) + { + $this->quantity = $quantity; + + return $this; + } + + /** + * Gets shipDate. + * + * @return \DateTime|null + */ + public function getShipDate() + { + return $this->shipDate; + } + + /** + * Sets shipDate. + * + * @param \DateTime|null $shipDate + * + * @return $this + */ + public function setShipDate(\DateTime $shipDate = null) + { + $this->shipDate = $shipDate; + + return $this; + } + + /** + * Gets status. + * + * @return string|null + */ + public function getStatus() + { + return $this->status; + } + + /** + * Sets status. + * + * @param string|null $status Order Status + * + * @return $this + */ + public function setStatus($status = null) + { + $this->status = $status; + + return $this; + } + + /** + * Gets complete. + * + * @return bool|null + */ + public function isComplete() + { + return $this->complete; + } + + /** + * Sets complete. + * + * @param bool|null $complete + * + * @return $this + */ + public function setComplete($complete = null) + { + $this->complete = $complete; + + return $this; + } +} + + diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Pet.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Pet.php new file mode 100644 index 000000000000..ac3fba47a7d1 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Pet.php @@ -0,0 +1,262 @@ +") + */ + protected $photoUrls; + + /** + * @var Swagger\Server\Model\Tag[]|null + * @SerializedName("tags") + * @Assert\All({ + * @Assert\Type("Swagger\Server\Model\Tag") + * }) + * @Type("array") + */ + protected $tags; + + /** + * pet status in the store + * + * @var string|null + * @SerializedName("status") + * @Assert\Choice({ "available", "pending", "sold" }) + * @Assert\Type("string") + * @Type("string") + */ + protected $status; + + /** + * Constructor + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->id = isset($data['id']) ? $data['id'] : null; + $this->category = isset($data['category']) ? $data['category'] : null; + $this->name = isset($data['name']) ? $data['name'] : null; + $this->photoUrls = isset($data['photoUrls']) ? $data['photoUrls'] : null; + $this->tags = isset($data['tags']) ? $data['tags'] : null; + $this->status = isset($data['status']) ? $data['status'] : null; + } + + /** + * Gets id. + * + * @return int|null + */ + public function getId() + { + return $this->id; + } + + /** + * Sets id. + * + * @param int|null $id + * + * @return $this + */ + public function setId($id = null) + { + $this->id = $id; + + return $this; + } + + /** + * Gets category. + * + * @return Swagger\Server\Model\Category|null + */ + public function getCategory() + { + return $this->category; + } + + /** + * Sets category. + * + * @param Swagger\Server\Model\Category|null $category + * + * @return $this + */ + public function setCategory(Category $category = null) + { + $this->category = $category; + + return $this; + } + + /** + * Gets name. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Gets photoUrls. + * + * @return string[] + */ + public function getPhotoUrls() + { + return $this->photoUrls; + } + + /** + * Sets photoUrls. + * + * @param string[] $photoUrls + * + * @return $this + */ + public function setPhotoUrls(array $photoUrls) + { + $this->photoUrls = $photoUrls; + + return $this; + } + + /** + * Gets tags. + * + * @return Swagger\Server\Model\Tag[]|null + */ + public function getTags() + { + return $this->tags; + } + + /** + * Sets tags. + * + * @param Swagger\Server\Model\Tag[]|null $tags + * + * @return $this + */ + public function setTags(array $tags = null) + { + $this->tags = $tags; + + return $this; + } + + /** + * Gets status. + * + * @return string|null + */ + public function getStatus() + { + return $this->status; + } + + /** + * Sets status. + * + * @param string|null $status pet status in the store + * + * @return $this + */ + public function setStatus($status = null) + { + $this->status = $status; + + return $this; + } +} + + diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Tag.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Tag.php new file mode 100644 index 000000000000..ffe2ef4fb4f4 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Tag.php @@ -0,0 +1,121 @@ +id = isset($data['id']) ? $data['id'] : null; + $this->name = isset($data['name']) ? $data['name'] : null; + } + + /** + * Gets id. + * + * @return int|null + */ + public function getId() + { + return $this->id; + } + + /** + * Sets id. + * + * @param int|null $id + * + * @return $this + */ + public function setId($id = null) + { + $this->id = $id; + + return $this; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } +} + + diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/User.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/User.php new file mode 100644 index 000000000000..5f69763a5253 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/User.php @@ -0,0 +1,321 @@ +id = isset($data['id']) ? $data['id'] : null; + $this->username = isset($data['username']) ? $data['username'] : null; + $this->firstName = isset($data['firstName']) ? $data['firstName'] : null; + $this->lastName = isset($data['lastName']) ? $data['lastName'] : null; + $this->email = isset($data['email']) ? $data['email'] : null; + $this->password = isset($data['password']) ? $data['password'] : null; + $this->phone = isset($data['phone']) ? $data['phone'] : null; + $this->userStatus = isset($data['userStatus']) ? $data['userStatus'] : null; + } + + /** + * Gets id. + * + * @return int|null + */ + public function getId() + { + return $this->id; + } + + /** + * Sets id. + * + * @param int|null $id + * + * @return $this + */ + public function setId($id = null) + { + $this->id = $id; + + return $this; + } + + /** + * Gets username. + * + * @return string|null + */ + public function getUsername() + { + return $this->username; + } + + /** + * Sets username. + * + * @param string|null $username + * + * @return $this + */ + public function setUsername($username = null) + { + $this->username = $username; + + return $this; + } + + /** + * Gets firstName. + * + * @return string|null + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * Sets firstName. + * + * @param string|null $firstName + * + * @return $this + */ + public function setFirstName($firstName = null) + { + $this->firstName = $firstName; + + return $this; + } + + /** + * Gets lastName. + * + * @return string|null + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * Sets lastName. + * + * @param string|null $lastName + * + * @return $this + */ + public function setLastName($lastName = null) + { + $this->lastName = $lastName; + + return $this; + } + + /** + * Gets email. + * + * @return string|null + */ + public function getEmail() + { + return $this->email; + } + + /** + * Sets email. + * + * @param string|null $email + * + * @return $this + */ + public function setEmail($email = null) + { + $this->email = $email; + + return $this; + } + + /** + * Gets password. + * + * @return string|null + */ + public function getPassword() + { + return $this->password; + } + + /** + * Sets password. + * + * @param string|null $password + * + * @return $this + */ + public function setPassword($password = null) + { + $this->password = $password; + + return $this; + } + + /** + * Gets phone. + * + * @return string|null + */ + public function getPhone() + { + return $this->phone; + } + + /** + * Sets phone. + * + * @param string|null $phone + * + * @return $this + */ + public function setPhone($phone = null) + { + $this->phone = $phone; + + return $this; + } + + /** + * Gets userStatus. + * + * @return int|null + */ + public function getUserStatus() + { + return $this->userStatus; + } + + /** + * Sets userStatus. + * + * @param int|null $userStatus User Status + * + * @return $this + */ + public function setUserStatus($userStatus = null) + { + $this->userStatus = $userStatus; + + return $this; + } +} + + diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/README.md b/samples/server/petstore/php-symfony/SymfonyBundle-php/README.md new file mode 100644 index 000000000000..d4375c06941f --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/README.md @@ -0,0 +1,182 @@ +# SwaggerServer +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 [Symfony](https://symfony.com/) bundle is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: 1.0.0 +- Build package: io.swagger.codegen.languages.SymfonyServerCodegen + +## Requirements + +PHP 5.4.0 and later + +## Installation & Usage + +To install the dependencies via [Composer](http://getcomposer.org/), add the following repository to `composer.json` of your Symfony project: + +```json +{ + "repositories": [{ + "type": "path", + "url": "//Path to your generated swagger bundle" + }], +} +``` + +Then run: + +``` +composer require swagger/server-bundle:dev-master +``` + +to add the generated swagger bundle as a dependency. + +## Tests + +To run the unit tests for the generated bundle, first navigate to the directory containing the code, then run the following commands: + +``` +composer install +./vendor/bin/phpunit +``` + + +## Getting Started + +Step 1: Please follow the [installation procedure](#installation--usage) first. + +Step 2: Enable the bundle in the kernel: + +```php + addPet($body) + +Add a new pet to the store + + + +### Example Implementation +```php + deletePet($petId, $apiKey) + +Deletes a pet + + + +### Example Implementation +```php + Swagger\Server\Model\Pet[] findPetsByStatus($status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example Implementation +```php + Swagger\Server\Model\Pet[] findPetsByTags($tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example Implementation +```php + Swagger\Server\Model\Pet getPetById($petId) + +Find pet by ID + +Returns a single pet + +### Example Implementation +```php + updatePet($body) + +Update an existing pet + + + +### Example Implementation +```php + updatePetWithForm($petId, $name, $status) + +Updates a pet in the store with form data + + + +### Example Implementation +```php + Swagger\Server\Model\ApiResponse uploadFile($petId, $additionalMetadata, $file) + +uploads an image + + + +### Example Implementation +```php + deleteOrder($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 Implementation +```php + int[] getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example Implementation +```php + Swagger\Server\Model\Order getOrderById($orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example Implementation +```php + Swagger\Server\Model\Order placeOrder($body) + +Place an order for a pet + + + +### Example Implementation +```php + createUser($body) + +Create user + +This can only be done by the logged in user. + +### Example Implementation +```php + createUsersWithArrayInput($body) + +Creates list of users with given input array + + + +### Example Implementation +```php + createUsersWithListInput($body) + +Creates list of users with given input array + + + +### Example Implementation +```php + deleteUser($username) + +Delete user + +This can only be done by the logged in user. + +### Example Implementation +```php + Swagger\Server\Model\User getUserByName($username) + +Get user by user name + + + +### Example Implementation +```php + string loginUser($username, $password) + +Logs user into the system + + + +### Example Implementation +```php + logoutUser() + +Logs out current logged in user session + + + +### Example Implementation +```php + updateUser($username, $body) + +Updated user + +This can only be done by the logged in user. + +### Example Implementation +```php +serializer = SerializerBuilder::create() + ->setDeserializationVisitor('json', new StrictJsonDeserializationVisitor($naming_strategy)) + ->setDeserializationVisitor('xml', new XmlDeserializationVisitor($naming_strategy)) + ->build(); + } + + public function serialize($data, $format) + { + return SerializerBuilder::create()->build()->serialize($data, $this->convertFormat($format)); + } + + public function deserialize($data, $type, $format) + { + if ($format == 'string') { + return $this->deserializeString($data, $type); + } + + // If we end up here, let JMS serializer handle the deserialization + return $this->serializer->deserialize($data, $type, $this->convertFormat($format)); + } + + private function convertFormat($format) + { + switch ($format) { + case 'application/json': + return 'json'; + case 'application/xml': + return 'xml'; + } + + return null; + } + + private function deserializeString($data, $type) + { + switch ($type) { + case 'int': + case 'integer': + if (is_int($data)) { + return $data; + } + + if (is_numeric($data)) { + return $data + 0; + } + + break; + case 'string': + break; + case 'boolean': + case 'bool': + if (strtolower($data) === 'true') { + return true; + } + + if (strtolower($data) === 'false') { + return false; + } + + break; + case 'array': + return explode(',', $data); + case 'array': + return explode(' ', $data); + case 'array': + return explode("\t", $data); + case 'array': + return explode('|', $data); + } + + // If we end up here, just return data + return $data; + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Service/SerializerInterface.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Service/SerializerInterface.php new file mode 100644 index 000000000000..bf8bc1896f66 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Service/SerializerInterface.php @@ -0,0 +1,27 @@ +validator = Validation::createValidator(); + } + + public function validate($value, $constraints = null, $groups = null) + { + return $this->validator->validate($value, $constraints, $groups); + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Service/TypeMismatchException.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Service/TypeMismatchException.php new file mode 100644 index 000000000000..97a8f2e31975 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Service/TypeMismatchException.php @@ -0,0 +1,52 @@ +getCurrentPath()) > 0) { + $property = sprintf('property "%s" to be ', implode('.', $context->getCurrentPath())); + } else { + $property = ''; + } + + return new static(sprintf( + 'Expected %s%s, but got %s: %s', + $property, + $expected_type, + gettype($actual_value), + json_encode($actual_value) + )); + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Service/ValidatorInterface.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Service/ValidatorInterface.php new file mode 100644 index 000000000000..a85241e81f65 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Service/ValidatorInterface.php @@ -0,0 +1,25 @@ +addCompilerPass(new SwaggerServerApiPass()); + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Api/PetApiInterfaceTest.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Api/PetApiInterfaceTest.php new file mode 100644 index 000000000000..ca0c3b8ec263 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Api/PetApiInterfaceTest.php @@ -0,0 +1,217 @@ +request('POST', $path); + } + + /** + * Test case for deletePet + * + * Deletes a pet. + * + */ + public function testDeletePet() + { + $client = static::createClient(); + + $path = '/pet/{petId}'; + $pattern = '{petId}'; + $data = $this->genTestData('\d+'); + $path = str_replace($pattern, $data, $path); + + $crawler = $client->request('DELETE', $path); + } + + /** + * Test case for findPetsByStatus + * + * Finds Pets by status. + * + */ + public function testFindPetsByStatus() + { + $client = static::createClient(); + + $path = '/pet/findByStatus'; + + $crawler = $client->request('GET', $path); + } + + /** + * Test case for findPetsByTags + * + * Finds Pets by tags. + * + */ + public function testFindPetsByTags() + { + $client = static::createClient(); + + $path = '/pet/findByTags'; + + $crawler = $client->request('GET', $path); + } + + /** + * Test case for getPetById + * + * Find pet by ID. + * + */ + public function testGetPetById() + { + $client = static::createClient(); + + $path = '/pet/{petId}'; + $pattern = '{petId}'; + $data = $this->genTestData('\d+'); + $path = str_replace($pattern, $data, $path); + + $crawler = $client->request('GET', $path); + } + + /** + * Test case for updatePet + * + * Update an existing pet. + * + */ + public function testUpdatePet() + { + $client = static::createClient(); + + $path = '/pet'; + + $crawler = $client->request('PUT', $path); + } + + /** + * Test case for updatePetWithForm + * + * Updates a pet in the store with form data. + * + */ + public function testUpdatePetWithForm() + { + $client = static::createClient(); + + $path = '/pet/{petId}'; + $pattern = '{petId}'; + $data = $this->genTestData('\d+'); + $path = str_replace($pattern, $data, $path); + + $crawler = $client->request('POST', $path); + } + + /** + * Test case for uploadFile + * + * uploads an image. + * + */ + public function testUploadFile() + { + $client = static::createClient(); + + $path = '/pet/{petId}/uploadImage'; + $pattern = '{petId}'; + $data = $this->genTestData('\d+'); + $path = str_replace($pattern, $data, $path); + + $crawler = $client->request('POST', $path); + } + + protected function genTestData($regexp) + { + $grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp'); + $compiler = \Hoa\Compiler\Llk\Llk::load($grammar); + $ast = $compiler->parse($regexp); + $generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random()); + + return $generator->visit($ast); + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Api/StoreApiInterfaceTest.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Api/StoreApiInterfaceTest.php new file mode 100644 index 000000000000..2162289d8dde --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Api/StoreApiInterfaceTest.php @@ -0,0 +1,151 @@ +genTestData('[a-z0-9]+'); + $path = str_replace($pattern, $data, $path); + + $crawler = $client->request('DELETE', $path); + } + + /** + * Test case for getInventory + * + * Returns pet inventories by status. + * + */ + public function testGetInventory() + { + $client = static::createClient(); + + $path = '/store/inventory'; + + $crawler = $client->request('GET', $path); + } + + /** + * Test case for getOrderById + * + * Find purchase order by ID. + * + */ + public function testGetOrderById() + { + $client = static::createClient(); + + $path = '/store/order/{orderId}'; + $pattern = '{orderId}'; + $data = $this->genTestData('\d+'); + $path = str_replace($pattern, $data, $path); + + $crawler = $client->request('GET', $path); + } + + /** + * Test case for placeOrder + * + * Place an order for a pet. + * + */ + public function testPlaceOrder() + { + $client = static::createClient(); + + $path = '/store/order'; + + $crawler = $client->request('POST', $path); + } + + protected function genTestData($regexp) + { + $grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp'); + $compiler = \Hoa\Compiler\Llk\Llk::load($grammar); + $ast = $compiler->parse($regexp); + $generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random()); + + return $generator->visit($ast); + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Api/UserApiInterfaceTest.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Api/UserApiInterfaceTest.php new file mode 100644 index 000000000000..9074d020f308 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Api/UserApiInterfaceTest.php @@ -0,0 +1,214 @@ +request('POST', $path); + } + + /** + * Test case for createUsersWithArrayInput + * + * Creates list of users with given input array. + * + */ + public function testCreateUsersWithArrayInput() + { + $client = static::createClient(); + + $path = '/user/createWithArray'; + + $crawler = $client->request('POST', $path); + } + + /** + * Test case for createUsersWithListInput + * + * Creates list of users with given input array. + * + */ + public function testCreateUsersWithListInput() + { + $client = static::createClient(); + + $path = '/user/createWithList'; + + $crawler = $client->request('POST', $path); + } + + /** + * Test case for deleteUser + * + * Delete user. + * + */ + public function testDeleteUser() + { + $client = static::createClient(); + + $path = '/user/{username}'; + $pattern = '{username}'; + $data = $this->genTestData('[a-z0-9]+'); + $path = str_replace($pattern, $data, $path); + + $crawler = $client->request('DELETE', $path); + } + + /** + * Test case for getUserByName + * + * Get user by user name. + * + */ + public function testGetUserByName() + { + $client = static::createClient(); + + $path = '/user/{username}'; + $pattern = '{username}'; + $data = $this->genTestData('[a-z0-9]+'); + $path = str_replace($pattern, $data, $path); + + $crawler = $client->request('GET', $path); + } + + /** + * Test case for loginUser + * + * Logs user into the system. + * + */ + public function testLoginUser() + { + $client = static::createClient(); + + $path = '/user/login'; + + $crawler = $client->request('GET', $path); + } + + /** + * Test case for logoutUser + * + * Logs out current logged in user session. + * + */ + public function testLogoutUser() + { + $client = static::createClient(); + + $path = '/user/logout'; + + $crawler = $client->request('GET', $path); + } + + /** + * Test case for updateUser + * + * Updated user. + * + */ + public function testUpdateUser() + { + $client = static::createClient(); + + $path = '/user/{username}'; + $pattern = '{username}'; + $data = $this->genTestData('[a-z0-9]+'); + $path = str_replace($pattern, $data, $path); + + $crawler = $client->request('PUT', $path); + } + + protected function genTestData($regexp) + { + $grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp'); + $compiler = \Hoa\Compiler\Llk\Llk::load($grammar); + $ast = $compiler->parse($regexp); + $generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random()); + + return $generator->visit($ast); + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/AppKernel.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/AppKernel.php new file mode 100644 index 000000000000..631690bc9786 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/AppKernel.php @@ -0,0 +1,21 @@ +load(__DIR__.'/test_config.yml'); + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/ApiResponseTest.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/ApiResponseTest.php new file mode 100644 index 000000000000..47970cb5c0bb --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/ApiResponseTest.php @@ -0,0 +1,101 @@ +=5.4", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "symfony/validator": "*", + "jms/serializer-bundle": "*", + "symfony/framework-bundle": "^2.3|^3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8", + "satooshi/php-coveralls": "~1.0", + "squizlabs/php_codesniffer": "~2.6", + "friendsofphp/php-cs-fixer": "~1.12", + "symfony/browser-kit": "*", + "hoa/regex": "~1.0" + }, + "autoload": { + "psr-4": { "Swagger\\Server\\" : "./" } + } +} diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/git_push.sh b/samples/server/petstore/php-symfony/SymfonyBundle-php/git_push.sh new file mode 100644 index 000000000000..792320114fbe --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/phpunit.xml.dist b/samples/server/petstore/php-symfony/SymfonyBundle-php/phpunit.xml.dist new file mode 100644 index 000000000000..ec07d2081c9e --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/phpunit.xml.dist @@ -0,0 +1,25 @@ + + + + + ./Tests/Api + ./Tests/Model + + + + + + + + + + ././Api + ././Model + + + diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/pom.xml b/samples/server/petstore/php-symfony/SymfonyBundle-php/pom.xml new file mode 100644 index 000000000000..614b3d33f98a --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/pom.xml @@ -0,0 +1,57 @@ + + 4.0.0 + com.penneo + PhpSymfonyPetstoreServerTests + pom + 1.0-SNAPSHOT + PHP Symfony Swagger Petstore Server + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + bundle-install + pre-integration-test + + exec + + + composer + + install + + + + + bundle-test + integration-test + + exec + + + vendor/bin/phpunit + + + + + + + + From fe5c2e627bc8e63a9b66b4277f4c9d46c35904fd Mon Sep 17 00:00:00 2001 From: tgifford-webfirst Date: Mon, 23 Oct 2017 11:35:11 -0400 Subject: [PATCH 11/28] Allow using help command with run-in-docker.sh (#6706) --- docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 556b6ff2f63e..ca6b8d4e3614 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -11,7 +11,7 @@ codegen="${cli}/target/swagger-codegen-cli.jar" cmdsrc="${cli}/src/main/java/io/swagger/codegen/cmd" pattern="@Command(name = \"$1\"" -if expr "x$1" : 'x[a-z][a-z-]*$' > /dev/null && fgrep -qe "$pattern" "$cmdsrc"/*.java; then +if expr "x$1" : 'x[a-z][a-z-]*$' > /dev/null && fgrep -qe "$pattern" "$cmdsrc"/*.java || expr "$1" = 'help' > /dev/null; then # If ${GEN_DIR} has been mapped elsewhere from default, and that location has not been built if [[ ! -f "${codegen}" ]]; then (cd "${GEN_DIR}" && exec mvn -am -pl "modules/swagger-codegen-cli" -Duser.home=$(dirname MAVEN_CONFIG) package) From f7471add70f1cabdd597aecc304fd131016cae3e Mon Sep 17 00:00:00 2001 From: Keni Steward Date: Mon, 23 Oct 2017 22:42:03 -0400 Subject: [PATCH 12/28] Fixed spacing in model.mustache (#6788) * Added v4/v4.3 to typescript-angular-petsotre-all and renamed from angular2 to angular * refactored typescript-angular-petstore-all.sh * changed profile id for typescript-angularjs to properly have angularjs instead of just angular. * Spacing at end of model template * Corrected backwards compatible enum typing --- ....sh => typescript-angular-petstore-all.sh} | 8 ++ ...at => typescript-angular-petstore-all.bat} | 4 + .../typescript-angular/licenseInfo.mustache | 2 +- .../typescript-angular/modelEnum.mustache | 9 +- .../typescript-angular/modelGeneric.mustache | 11 ++- pom.xml | 2 +- pom.xml.bash | 2 +- pom.xml.circleci | 2 +- pom.xml.shippable | 2 +- .../default/api/pet.service.ts | 1 - .../default/api/store.service.ts | 1 - .../default/api/user.service.ts | 1 - .../default/model/ApiResponse.ts | 4 - .../default/model/category.ts | 3 - .../default/model/order.ts | 12 +-- .../default/model/pet.ts | 12 +-- .../default/model/tag.ts | 3 - .../default/model/user.ts | 9 -- .../npm/api/pet.service.ts | 1 - .../npm/api/store.service.ts | 1 - .../npm/api/user.service.ts | 1 - .../npm/model/ApiResponse.ts | 4 - .../npm/model/category.ts | 3 - .../typescript-angular-v2/npm/model/order.ts | 12 +-- .../typescript-angular-v2/npm/model/pet.ts | 12 +-- .../typescript-angular-v2/npm/model/tag.ts | 3 - .../typescript-angular-v2/npm/model/user.ts | 9 -- .../with-interfaces/README.md | 98 +++++++++++++++++++ .../with-interfaces/api/pet.service.ts | 1 - .../api/pet.serviceInterface.ts | 1 - .../with-interfaces/api/store.service.ts | 1 - .../api/store.serviceInterface.ts | 1 - .../with-interfaces/api/user.service.ts | 1 - .../api/user.serviceInterface.ts | 1 - .../with-interfaces/model/Category.ts | 3 - .../with-interfaces/model/Order.ts | 12 +-- .../with-interfaces/model/Pet.ts | 12 +-- .../with-interfaces/model/Tag.ts | 3 - .../with-interfaces/model/User.ts | 9 -- .../with-interfaces/model/apiResponse.ts | 4 - .../with-interfaces/package.json | 40 ++++++++ .../with-interfaces/tsconfig.json | 25 +++++ .../with-interfaces/typings.json | 5 + .../npm/api/pet.service.ts | 1 - .../npm/api/store.service.ts | 1 - .../npm/api/user.service.ts | 1 - .../npm/model/apiResponse.ts | 4 - .../npm/model/category.ts | 3 - .../npm/model/order.ts | 14 +-- .../typescript-angular-v4.3/npm/model/pet.ts | 14 +-- .../typescript-angular-v4.3/npm/model/tag.ts | 3 - .../typescript-angular-v4.3/npm/model/user.ts | 9 -- .../npm/api/pet.service.ts | 1 - .../npm/api/store.service.ts | 1 - .../npm/api/user.service.ts | 1 - .../npm/model/apiResponse.ts | 4 - .../npm/model/category.ts | 3 - .../typescript-angular-v4/npm/model/order.ts | 12 +-- .../typescript-angular-v4/npm/model/pet.ts | 12 +-- .../typescript-angular-v4/npm/model/tag.ts | 3 - .../typescript-angular-v4/npm/model/user.ts | 9 -- 61 files changed, 251 insertions(+), 196 deletions(-) rename bin/{typescript-angular-v2-petstore-all.sh => typescript-angular-petstore-all.sh} (68%) mode change 100755 => 100644 rename bin/windows/{typescript-angular2-petstore-all.bat => typescript-angular-petstore-all.bat} (58%) mode change 100755 => 100644 create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/README.md create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/package.json create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/tsconfig.json create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/typings.json diff --git a/bin/typescript-angular-v2-petstore-all.sh b/bin/typescript-angular-petstore-all.sh old mode 100755 new mode 100644 similarity index 68% rename from bin/typescript-angular-v2-petstore-all.sh rename to bin/typescript-angular-petstore-all.sh index ae2ae18719f0..c3cdf8ba34fc --- a/bin/typescript-angular-v2-petstore-all.sh +++ b/bin/typescript-angular-petstore-all.sh @@ -38,3 +38,11 @@ java $JAVA_OPTS -jar $executable $ags echo "Typescript Petstore API client (with interfaces generated)" ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular -o samples/client/petstore/typescript-angular-v2/with-interfaces -D withInterfaces=true --additional-properties ngVersion=2" java $JAVA_OPTS -jar $executable $ags + +echo "Typescript Petstore API client (v4 { Adding InjectionToken Over OpaqueToken })" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v4/npm --additional-properties ngVersion=4" +java $JAVA_OPTS -jar $executable $ags + +echo "Typescript Petstore API client (v4.3 { Adding HttpClientModule over HttpModule })" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v4.3/npm --additional-properties ngVersion=4.3" +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/windows/typescript-angular2-petstore-all.bat b/bin/windows/typescript-angular-petstore-all.bat old mode 100755 new mode 100644 similarity index 58% rename from bin/windows/typescript-angular2-petstore-all.bat rename to bin/windows/typescript-angular-petstore-all.bat index 3d1a51792557..dff81b05a62e --- a/bin/windows/typescript-angular2-petstore-all.bat +++ b/bin/windows/typescript-angular-petstore-all.bat @@ -1,3 +1,7 @@ call .\bin\windows\typescript-angular-v2-with-npm.bat call .\bin\windows\typescript-angular-v2-interfaces.bat call .\bin\windows\typescript-angular-v2.bat +call .\bin\windows\typescript-angular-v4-with-npm.bat +call .\bin\windows\typescript-angular-v4.3-with-npm.bat + + diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/licenseInfo.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/licenseInfo.mustache index bbd8742e52a5..7d61c4ee0550 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/licenseInfo.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/licenseInfo.mustache @@ -8,4 +8,4 @@ * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. - */ + */ \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/modelEnum.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/modelEnum.mustache index a32e859196fc..aafd141aa9db 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/modelEnum.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/modelEnum.mustache @@ -1,2 +1,9 @@ -export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}; +export type {{enumName}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}; +export const {{enumName}} = { +{{#allowableValues}} +{{#enumVars}} + {{name}}: {{{value}}} as {{enumName}}{{^-last}},{{/-last}} +{{/enumVars}} +{{/allowableValues}} +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/modelGeneric.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/modelGeneric.mustache index a8b3c80e364c..34e35255d5a9 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/modelGeneric.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/modelGeneric.mustache @@ -10,14 +10,19 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ */ {{/description}} {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; - {{/vars}} }{{#hasEnums}} export namespace {{classname}} { {{#vars}} {{#isEnum}} export type {{enumName}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}; + export const {{enumName}} = { + {{#allowableValues}} + {{#enumVars}} + {{name}}: {{{value}}} as {{enumName}}{{^-last}},{{/-last}} + {{/enumVars}} + {{/allowableValues}} + } {{/isEnum}} {{/vars}} -}{{/hasEnums}} - +}{{/hasEnums}} \ No newline at end of file diff --git a/pom.xml b/pom.xml index d063b8780d4e..16a8e0e3578c 100644 --- a/pom.xml +++ b/pom.xml @@ -685,7 +685,7 @@ - typescript-angular-client + typescript-angularjs-client env diff --git a/pom.xml.bash b/pom.xml.bash index 6d43fe6829d0..02cd49a802ac 100644 --- a/pom.xml.bash +++ b/pom.xml.bash @@ -685,7 +685,7 @@ - typescript-angular-client + typescript-angularjs-client env diff --git a/pom.xml.circleci b/pom.xml.circleci index d1b7b94572c6..0f4f98791459 100644 --- a/pom.xml.circleci +++ b/pom.xml.circleci @@ -656,7 +656,7 @@ - typescript-angular-client + typescript-angularjs-client env diff --git a/pom.xml.shippable b/pom.xml.shippable index a73d38ae9aa6..3b033834d4f3 100644 --- a/pom.xml.shippable +++ b/pom.xml.shippable @@ -685,7 +685,7 @@ - typescript-angular-client + typescript-angularjs-client env diff --git a/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts index 11a1b603831e..c2899427ea6e 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts b/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts index 393d291ba3d1..24cf96b4136b 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts b/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts index f495f1f9d39d..5bd7cdbac655 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts b/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts index 3af781cf5804..eac4208f022a 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts @@ -11,15 +11,11 @@ */ - /** * Describes the result of uploading an image resource */ export interface ApiResponse { code?: number; - type?: string; - message?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/default/model/category.ts b/samples/client/petstore/typescript-angular-v2/default/model/category.ts index d09f8d7b265f..5040d1db915b 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/category.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/category.ts @@ -11,13 +11,10 @@ */ - /** * A category for a pet */ export interface Category { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/default/model/order.ts b/samples/client/petstore/typescript-angular-v2/default/model/order.ts index 4639b8c2949e..33b60bb6e163 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/order.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/order.ts @@ -11,27 +11,25 @@ */ - /** * An order for a pets from the pet store */ export interface Order { id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - /** * Order Status */ status?: Order.StatusEnum; - complete?: boolean; - } export namespace Order { export type StatusEnum = 'placed' | 'approved' | 'delivered'; + export const StatusEnum = { + Placed: 'placed' as StatusEnum, + Approved: 'approved' as StatusEnum, + Delivered: 'delivered' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v2/default/model/pet.ts b/samples/client/petstore/typescript-angular-v2/default/model/pet.ts index ce6c535b867c..342ab5f8e752 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/pet.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Category } from './category'; import { Tag } from './tag'; @@ -19,21 +18,20 @@ import { Tag } from './tag'; */ export interface Pet { id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - /** * pet status in the store */ status?: Pet.StatusEnum; - } export namespace Pet { export type StatusEnum = 'available' | 'pending' | 'sold'; + export const StatusEnum = { + Available: 'available' as StatusEnum, + Pending: 'pending' as StatusEnum, + Sold: 'sold' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v2/default/model/tag.ts b/samples/client/petstore/typescript-angular-v2/default/model/tag.ts index 3ed1eeff8f32..c75240003572 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/tag.ts @@ -11,13 +11,10 @@ */ - /** * A tag for a pet */ export interface Tag { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/default/model/user.ts b/samples/client/petstore/typescript-angular-v2/default/model/user.ts index f4914ae26080..a0261a6f37d2 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/user.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/user.ts @@ -11,28 +11,19 @@ */ - /** * A User who is purchasing from the pet store */ export interface User { id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - /** * User Status */ userStatus?: number; - } diff --git a/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts index 11a1b603831e..c2899427ea6e 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts index 393d291ba3d1..24cf96b4136b 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts index f495f1f9d39d..5bd7cdbac655 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts b/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts index 3af781cf5804..eac4208f022a 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts @@ -11,15 +11,11 @@ */ - /** * Describes the result of uploading an image resource */ export interface ApiResponse { code?: number; - type?: string; - message?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/category.ts b/samples/client/petstore/typescript-angular-v2/npm/model/category.ts index d09f8d7b265f..5040d1db915b 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/category.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/category.ts @@ -11,13 +11,10 @@ */ - /** * A category for a pet */ export interface Category { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/order.ts b/samples/client/petstore/typescript-angular-v2/npm/model/order.ts index 4639b8c2949e..33b60bb6e163 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/order.ts @@ -11,27 +11,25 @@ */ - /** * An order for a pets from the pet store */ export interface Order { id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - /** * Order Status */ status?: Order.StatusEnum; - complete?: boolean; - } export namespace Order { export type StatusEnum = 'placed' | 'approved' | 'delivered'; + export const StatusEnum = { + Placed: 'placed' as StatusEnum, + Approved: 'approved' as StatusEnum, + Delivered: 'delivered' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts index ce6c535b867c..342ab5f8e752 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Category } from './category'; import { Tag } from './tag'; @@ -19,21 +18,20 @@ import { Tag } from './tag'; */ export interface Pet { id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - /** * pet status in the store */ status?: Pet.StatusEnum; - } export namespace Pet { export type StatusEnum = 'available' | 'pending' | 'sold'; + export const StatusEnum = { + Available: 'available' as StatusEnum, + Pending: 'pending' as StatusEnum, + Sold: 'sold' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts b/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts index 3ed1eeff8f32..c75240003572 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts @@ -11,13 +11,10 @@ */ - /** * A tag for a pet */ export interface Tag { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/user.ts b/samples/client/petstore/typescript-angular-v2/npm/model/user.ts index f4914ae26080..a0261a6f37d2 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/user.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/user.ts @@ -11,28 +11,19 @@ */ - /** * A User who is purchasing from the pet store */ export interface User { id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - /** * User Status */ userStatus?: number; - } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md b/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md new file mode 100644 index 000000000000..038fd51491ce --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md @@ -0,0 +1,98 @@ +## @swagger/angular2-typescript-petstore@0.0.1 + +### Building + +To build an compile the typescript sources to javascript use: +``` +npm install +npm run build +``` + +### publishing + +First build the package than run ```npm publish``` + +### consuming + +navigate to the folder of your consuming project and run one of next commando's. + +_published:_ + +``` +npm install @swagger/angular2-typescript-petstore@0.0.1 --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save +``` + +_using `npm link`:_ + +In PATH_TO_GENERATED_PACKAGE: +``` +npm link +``` + +In your project: +``` +npm link @swagger/angular2-typescript-petstore@0.0.1 +``` + +In your angular2 project: + +``` +import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api'; +@NgModule({ + imports: [], + declarations: [], + exports: [], + providers: [AppModule] +}) +export class CoreModule {} +``` +``` +import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api'; + +export class AppComponent { + constructor(private apiGateway: DefaultApi) { } +} +``` + +### Set service base path +If different than the generated base path, during app bootstrap, you can provide the base path to your service. + +``` +import { BASE_PATH } from './path-to-swagger-gen-service/index'; + +bootstrap(AppComponent, [ + { provide: BASE_PATH, useValue: 'https://your-web-service.com' }, +]); +``` + +#### Using @angular/cli +First extend your `src/environments/*.ts` files by adding the corresponding base path: + +``` +export const environment = { + production: false, + API_BASE_PATH: 'http://127.0.0.1:8080' +}; +``` + +In the src/app/app.module.ts: +``` +import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; +import { environment } from '../environments/environment'; + +@NgModule({ + declarations: [ + AppComponent, + ], + imports: [ ], + providers: [{ provide: BASE_PATH, useValue: useValue: environment.API_BASE_PATH }], + bootstrap: [AppComponent] +}) +export class AppModule { } +``` \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts index 8ff5eda659db..8d6285d29e19 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.serviceInterface.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.serviceInterface.ts index 5ee39b3ab696..968ed61c846d 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.serviceInterface.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.serviceInterface.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Headers } from '@angular/http'; import { Observable } from 'rxjs/Observable'; diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts index 1297e638d439..af8cc47369bf 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.serviceInterface.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.serviceInterface.ts index a40dcc47b83d..f7fdf5fb0d95 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.serviceInterface.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.serviceInterface.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Headers } from '@angular/http'; import { Observable } from 'rxjs/Observable'; diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts index 480d00b3bb60..54752a85503d 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.serviceInterface.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.serviceInterface.ts index 3cab3a9c64b7..f68e221df9a8 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.serviceInterface.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.serviceInterface.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Headers } from '@angular/http'; import { Observable } from 'rxjs/Observable'; diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts index d09f8d7b265f..5040d1db915b 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts @@ -11,13 +11,10 @@ */ - /** * A category for a pet */ export interface Category { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts index 4639b8c2949e..33b60bb6e163 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts @@ -11,27 +11,25 @@ */ - /** * An order for a pets from the pet store */ export interface Order { id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - /** * Order Status */ status?: Order.StatusEnum; - complete?: boolean; - } export namespace Order { export type StatusEnum = 'placed' | 'approved' | 'delivered'; + export const StatusEnum = { + Placed: 'placed' as StatusEnum, + Approved: 'approved' as StatusEnum, + Delivered: 'delivered' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts index ce6c535b867c..342ab5f8e752 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Category } from './category'; import { Tag } from './tag'; @@ -19,21 +18,20 @@ import { Tag } from './tag'; */ export interface Pet { id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - /** * pet status in the store */ status?: Pet.StatusEnum; - } export namespace Pet { export type StatusEnum = 'available' | 'pending' | 'sold'; + export const StatusEnum = { + Available: 'available' as StatusEnum, + Pending: 'pending' as StatusEnum, + Sold: 'sold' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts index 3ed1eeff8f32..c75240003572 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts @@ -11,13 +11,10 @@ */ - /** * A tag for a pet */ export interface Tag { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts index f4914ae26080..a0261a6f37d2 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts @@ -11,28 +11,19 @@ */ - /** * A User who is purchasing from the pet store */ export interface User { id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - /** * User Status */ userStatus?: number; - } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts index 3af781cf5804..eac4208f022a 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts @@ -11,15 +11,11 @@ */ - /** * Describes the result of uploading an image resource */ export interface ApiResponse { code?: number; - type?: string; - message?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/package.json b/samples/client/petstore/typescript-angular-v2/with-interfaces/package.json new file mode 100644 index 000000000000..d6aee04c5899 --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/package.json @@ -0,0 +1,40 @@ +{ + "name": "@swagger/angular2-typescript-petstore", + "version": "0.0.1", + "description": "swagger client for @swagger/angular2-typescript-petstore", + "author": "Swagger Codegen Contributors", + "keywords": [ + "swagger-client" + ], + "license": "Unlicense", + "main": "dist/index.js", + "typings": "dist/index.d.ts", + "scripts": { + "build": "tsc --outDir dist/", + "postinstall": "npm run build" + }, + "peerDependencies": { + "@angular/core": "^2.0.0", + "@angular/http": "^2.0.0", + "@angular/common": "^2.0.0", + "@angular/compiler": "^2.0.0", + "core-js": "^2.4.0", + "reflect-metadata": "^0.1.3", + "rxjs": "^5.4.0", + "zone.js": "^0.7.6" + }, + "devDependencies": { + "@angular/core": "^2.0.0", + "@angular/http": "^2.0.0", + "@angular/common": "^2.0.0", + "@angular/compiler": "^2.0.0", + "@angular/platform-browser": "^2.0.0", + "reflect-metadata": "^0.1.3", + "rxjs": "^5.4.0", + "zone.js": "^0.7.6", + "typescript": "^2.1.5" + }, + "publishConfig": { + "registry":"https://skimdb.npmjs.com/registry" + } +} diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/tsconfig.json b/samples/client/petstore/typescript-angular-v2/with-interfaces/tsconfig.json new file mode 100644 index 000000000000..a6e9096bbf7c --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "noImplicitAny": false, + "suppressImplicitAnyIndexErrors": true, + "target": "es5", + "module": "es6", + "moduleResolution": "node", + "removeComments": true, + "sourceMap": true, + "outDir": "./dist", + "noLib": false, + "declaration": true, + "lib": [ "es6", "dom" ] + }, + "exclude": [ + "node_modules", + "dist" + ], + "filesGlob": [ + "./model/*.ts", + "./api/*.ts" + ] +} diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/typings.json b/samples/client/petstore/typescript-angular-v2/with-interfaces/typings.json new file mode 100644 index 000000000000..507c40e5cbed --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/typings.json @@ -0,0 +1,5 @@ +{ + "globalDependencies": { + "core-js": "registry:dt/core-js#0.0.0+20160725163759" + } +} diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts index ee44df243de8..16a19cdefa87 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts index f0cf7dbc1cb5..3b9c88fbb772 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts index d67fb448fc32..4cf879c80ccc 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts index e79fabe8c8cf..ac34396e0b34 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts @@ -11,17 +11,13 @@ */ - /** * Describes the result of uploading an image resource */ export interface ApiResponse { code?: number; - type?: string; - message?: string; - } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts index 56608731f956..767b49484181 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts @@ -11,15 +11,12 @@ */ - /** * A category for a pet */ export interface Category { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts index 84b59f1b09a6..33b60bb6e163 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts @@ -11,29 +11,25 @@ */ - /** * An order for a pets from the pet store */ export interface Order { id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - /** * Order Status */ status?: Order.StatusEnum; - complete?: boolean; - } export namespace Order { export type StatusEnum = 'placed' | 'approved' | 'delivered'; + export const StatusEnum = { + Placed: 'placed' as StatusEnum, + Approved: 'approved' as StatusEnum, + Delivered: 'delivered' as StatusEnum + } } - - diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts index c0fc942934c3..342ab5f8e752 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Category } from './category'; import { Tag } from './tag'; @@ -19,23 +18,20 @@ import { Tag } from './tag'; */ export interface Pet { id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - /** * pet status in the store */ status?: Pet.StatusEnum; - } export namespace Pet { export type StatusEnum = 'available' | 'pending' | 'sold'; + export const StatusEnum = { + Available: 'available' as StatusEnum, + Pending: 'pending' as StatusEnum, + Sold: 'sold' as StatusEnum + } } - - diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts index dbfa473f538a..73e4d26aa3b2 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts @@ -11,15 +11,12 @@ */ - /** * A tag for a pet */ export interface Tag { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts index 4dfad607c515..de9c1d85670e 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts @@ -11,30 +11,21 @@ */ - /** * A User who is purchasing from the pet store */ export interface User { id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - /** * User Status */ userStatus?: number; - } diff --git a/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts index 11a1b603831e..c2899427ea6e 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts index 393d291ba3d1..24cf96b4136b 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts index f495f1f9d39d..5bd7cdbac655 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts index 3af781cf5804..eac4208f022a 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts @@ -11,15 +11,11 @@ */ - /** * Describes the result of uploading an image resource */ export interface ApiResponse { code?: number; - type?: string; - message?: string; - } diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/category.ts b/samples/client/petstore/typescript-angular-v4/npm/model/category.ts index d09f8d7b265f..5040d1db915b 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/category.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/category.ts @@ -11,13 +11,10 @@ */ - /** * A category for a pet */ export interface Category { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/order.ts b/samples/client/petstore/typescript-angular-v4/npm/model/order.ts index 4639b8c2949e..33b60bb6e163 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/order.ts @@ -11,27 +11,25 @@ */ - /** * An order for a pets from the pet store */ export interface Order { id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - /** * Order Status */ status?: Order.StatusEnum; - complete?: boolean; - } export namespace Order { export type StatusEnum = 'placed' | 'approved' | 'delivered'; + export const StatusEnum = { + Placed: 'placed' as StatusEnum, + Approved: 'approved' as StatusEnum, + Delivered: 'delivered' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts index ce6c535b867c..342ab5f8e752 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Category } from './category'; import { Tag } from './tag'; @@ -19,21 +18,20 @@ import { Tag } from './tag'; */ export interface Pet { id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - /** * pet status in the store */ status?: Pet.StatusEnum; - } export namespace Pet { export type StatusEnum = 'available' | 'pending' | 'sold'; + export const StatusEnum = { + Available: 'available' as StatusEnum, + Pending: 'pending' as StatusEnum, + Sold: 'sold' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts b/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts index 3ed1eeff8f32..c75240003572 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts @@ -11,13 +11,10 @@ */ - /** * A tag for a pet */ export interface Tag { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/user.ts b/samples/client/petstore/typescript-angular-v4/npm/model/user.ts index f4914ae26080..a0261a6f37d2 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/user.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/user.ts @@ -11,28 +11,19 @@ */ - /** * A User who is purchasing from the pet store */ export interface User { id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - /** * User Status */ userStatus?: number; - } From 698149573df78801446463e905f7376f29e9c585 Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 24 Oct 2017 10:45:25 +0800 Subject: [PATCH 13/28] fix r body parameter null issue (#6786) --- .../src/main/resources/r/api.mustache | 13 ++++--- .../client/petstore/r_test/R/ApiResponse.r | 6 ++-- samples/client/petstore/r_test/R/Category.r | 2 +- samples/client/petstore/r_test/R/Order.r | 8 ++--- samples/client/petstore/r_test/R/Pet.r | 6 ++-- samples/client/petstore/r_test/R/PetApi.r | 31 ++++++++-------- samples/client/petstore/r_test/R/StoreApi.r | 11 +++--- samples/client/petstore/r_test/R/Tag.r | 2 +- samples/client/petstore/r_test/R/User.r | 14 ++++---- samples/client/petstore/r_test/R/UserApi.r | 35 ++++++++++--------- 10 files changed, 65 insertions(+), 63 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/r/api.mustache b/modules/swagger-codegen/src/main/resources/r/api.mustache index c2f9f75fbeaa..c47ef9696813 100644 --- a/modules/swagger-codegen/src/main/resources/r/api.mustache +++ b/modules/swagger-codegen/src/main/resources/r/api.mustache @@ -35,14 +35,15 @@ {{#operation}} {{operationId}} = function({{#allParams}}{{paramName}}, {{/allParams}}...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + {{#hasHeaderParams}} {{#headerParams}} if (!missing(`{{paramName}}`)) { headerParams['{{baseName}}'] <- `{{paramName}}` } + {{/headerParams}} {{/hasHeaderParams}} {{#hasQueryParams}} @@ -50,6 +51,7 @@ if (!missing(`{{paramName}}`)) { queryParams['{{baseName}}'] <- {{paramName}} } + {{/queryParams}} {{/hasQueryParams}} {{#hasFormParams}} @@ -62,25 +64,28 @@ "{{baseName}}" = httr::upload_file({{paramName}}){{#hasMore}},{{/hasMore}} {{/isFile}} {{/formParams}} - ) + ) + {{/hasFormParams}} {{#hasBodyParam}} {{#bodyParams}} if (!missing(`{{paramName}}`)) { body <- `{{paramName}}`$toJSONString() + } else { + body <- NULL } + {{/bodyParams}} {{/hasBodyParam}} - urlPath <- "{{path}}" {{#hasPathParams}} {{#pathParams}} if (!missing(`{{paramName}}`)) { urlPath <- gsub(paste0("\\{", "{{baseName}}", "\\}"), `{{paramName}}`, urlPath) } + {{/pathParams}} {{/hasPathParams}} - resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath), method = "{{httpMethod}}", queryParams = queryParams, diff --git a/samples/client/petstore/r_test/R/ApiResponse.r b/samples/client/petstore/r_test/R/ApiResponse.r index 161a765c0a5a..3441c65da1a1 100644 --- a/samples/client/petstore/r_test/R/ApiResponse.r +++ b/samples/client/petstore/r_test/R/ApiResponse.r @@ -65,9 +65,9 @@ ApiResponse <- R6::R6Class( toJSONString = function() { sprintf( '{ - "code": "%s", - "type": "%s", - "message": "%s" + "code": %s, + "type": %s, + "message": %s }', self$`code`, self$`type`, diff --git a/samples/client/petstore/r_test/R/Category.r b/samples/client/petstore/r_test/R/Category.r index 826b6410a88f..36e2d8b20189 100644 --- a/samples/client/petstore/r_test/R/Category.r +++ b/samples/client/petstore/r_test/R/Category.r @@ -54,7 +54,7 @@ Category <- R6::R6Class( sprintf( '{ "id": %d, - "name": "%s" + "name": %s }', self$`id`, self$`name` diff --git a/samples/client/petstore/r_test/R/Order.r b/samples/client/petstore/r_test/R/Order.r index 73fedcb5f867..a0f2f09c1226 100644 --- a/samples/client/petstore/r_test/R/Order.r +++ b/samples/client/petstore/r_test/R/Order.r @@ -102,10 +102,10 @@ Order <- R6::R6Class( '{ "id": %d, "petId": %d, - "quantity": "%s", - "shipDate": "%s", - "status": "%s", - "complete": "%s" + "quantity": %s, + "shipDate": %s, + "status": %s, + "complete": %s }', self$`id`, self$`petId`, diff --git a/samples/client/petstore/r_test/R/Pet.r b/samples/client/petstore/r_test/R/Pet.r index 98ba5d747e57..777589993f5f 100644 --- a/samples/client/petstore/r_test/R/Pet.r +++ b/samples/client/petstore/r_test/R/Pet.r @@ -111,10 +111,10 @@ Pet <- R6::R6Class( '{ "id": %d, "category": %s, - "name": "%s", - "photoUrls": ["%s"], + "name": %s, + "photoUrls": [%s], "tags": [%s], - "status": "%s" + "status": %s }', self$`id`, self$`category`$toJSON(), diff --git a/samples/client/petstore/r_test/R/PetApi.r b/samples/client/petstore/r_test/R/PetApi.r index 6fa5c30cfb41..70087af7fadc 100644 --- a/samples/client/petstore/r_test/R/PetApi.r +++ b/samples/client/petstore/r_test/R/PetApi.r @@ -59,15 +59,16 @@ PetApi <- R6::R6Class( }, add_pet = function(body, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + if (!missing(`body`)) { - body <- `body`$toJSON() + body <- `body`$toJSONString() + } else { + body <- NULL } urlPath <- "/pet" - resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath), method = "POST", queryParams = queryParams, @@ -86,9 +87,9 @@ PetApi <- R6::R6Class( }, delete_pet = function(pet_id, api_key, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + if (!missing(`api_key`)) { headerParams['api_key'] <- `api_key` } @@ -116,15 +117,14 @@ PetApi <- R6::R6Class( }, find_pets_by_status = function(status, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + if (!missing(`status`)) { queryParams['status'] <- status } urlPath <- "/pet/findByStatus" - resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath), method = "GET", queryParams = queryParams, @@ -145,15 +145,14 @@ PetApi <- R6::R6Class( }, find_pets_by_tags = function(tags, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + if (!missing(`tags`)) { queryParams['tags'] <- tags } urlPath <- "/pet/findByTags" - resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath), method = "GET", queryParams = queryParams, @@ -174,7 +173,6 @@ PetApi <- R6::R6Class( }, get_pet_by_id = function(pet_id, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() @@ -203,15 +201,16 @@ PetApi <- R6::R6Class( }, update_pet = function(body, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + if (!missing(`body`)) { - body <- `body`$toJSON() + body <- `body`$toJSONString() + } else { + body <- NULL } urlPath <- "/pet" - resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath), method = "PUT", queryParams = queryParams, @@ -230,13 +229,13 @@ PetApi <- R6::R6Class( }, update_pet_with_form = function(pet_id, name, status, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + body <- list( "name" = name, "status" = status - ) + ) urlPath <- "/pet/{petId}" if (!missing(`pet_id`)) { @@ -261,13 +260,13 @@ PetApi <- R6::R6Class( }, upload_file = function(pet_id, additional_metadata, file, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + body <- list( "additionalMetadata" = additional_metadata, "file" = httr::upload_file(file) - ) + ) urlPath <- "/pet/{petId}/uploadImage" if (!missing(`pet_id`)) { diff --git a/samples/client/petstore/r_test/R/StoreApi.r b/samples/client/petstore/r_test/R/StoreApi.r index b03a50e9ae86..cf99c131e043 100644 --- a/samples/client/petstore/r_test/R/StoreApi.r +++ b/samples/client/petstore/r_test/R/StoreApi.r @@ -47,7 +47,6 @@ StoreApi <- R6::R6Class( }, delete_order = function(order_id, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() @@ -74,12 +73,10 @@ StoreApi <- R6::R6Class( }, get_inventory = function(...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() urlPath <- "/store/inventory" - resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath), method = "GET", queryParams = queryParams, @@ -100,7 +97,6 @@ StoreApi <- R6::R6Class( }, get_order_by_id = function(order_id, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() @@ -129,15 +125,16 @@ StoreApi <- R6::R6Class( }, place_order = function(body, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + if (!missing(`body`)) { - body <- `body`$toJSON() + body <- `body`$toJSONString() + } else { + body <- NULL } urlPath <- "/store/order" - resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath), method = "POST", queryParams = queryParams, diff --git a/samples/client/petstore/r_test/R/Tag.r b/samples/client/petstore/r_test/R/Tag.r index 13501d24f1b7..80c7e01e375b 100644 --- a/samples/client/petstore/r_test/R/Tag.r +++ b/samples/client/petstore/r_test/R/Tag.r @@ -54,7 +54,7 @@ Tag <- R6::R6Class( sprintf( '{ "id": %d, - "name": "%s" + "name": %s }', self$`id`, self$`name` diff --git a/samples/client/petstore/r_test/R/User.r b/samples/client/petstore/r_test/R/User.r index 4c45fb8c00e2..42f3411077c8 100644 --- a/samples/client/petstore/r_test/R/User.r +++ b/samples/client/petstore/r_test/R/User.r @@ -126,13 +126,13 @@ User <- R6::R6Class( sprintf( '{ "id": %d, - "username": "%s", - "firstName": "%s", - "lastName": "%s", - "email": "%s", - "password": "%s", - "phone": "%s", - "userStatus": "%s" + "username": %s, + "firstName": %s, + "lastName": %s, + "email": %s, + "password": %s, + "phone": %s, + "userStatus": %s }', self$`id`, self$`username`, diff --git a/samples/client/petstore/r_test/R/UserApi.r b/samples/client/petstore/r_test/R/UserApi.r index 1ed17ab286ff..6fe335d7dc7a 100644 --- a/samples/client/petstore/r_test/R/UserApi.r +++ b/samples/client/petstore/r_test/R/UserApi.r @@ -59,15 +59,16 @@ UserApi <- R6::R6Class( }, create_user = function(body, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + if (!missing(`body`)) { - body <- `body`$toJSON() + body <- `body`$toJSONString() + } else { + body <- NULL } urlPath <- "/user" - resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath), method = "POST", queryParams = queryParams, @@ -86,15 +87,16 @@ UserApi <- R6::R6Class( }, create_users_with_array_input = function(body, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + if (!missing(`body`)) { - body <- `body`$toJSON() + body <- `body`$toJSONString() + } else { + body <- NULL } urlPath <- "/user/createWithArray" - resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath), method = "POST", queryParams = queryParams, @@ -113,15 +115,16 @@ UserApi <- R6::R6Class( }, create_users_with_list_input = function(body, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + if (!missing(`body`)) { - body <- `body`$toJSON() + body <- `body`$toJSONString() + } else { + body <- NULL } urlPath <- "/user/createWithList" - resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath), method = "POST", queryParams = queryParams, @@ -140,7 +143,6 @@ UserApi <- R6::R6Class( }, delete_user = function(username, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() @@ -167,7 +169,6 @@ UserApi <- R6::R6Class( }, get_user_by_name = function(username, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() @@ -196,18 +197,18 @@ UserApi <- R6::R6Class( }, login_user = function(username, password, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + if (!missing(`username`)) { queryParams['username'] <- username } + if (!missing(`password`)) { queryParams['password'] <- password } urlPath <- "/user/login" - resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath), method = "GET", queryParams = queryParams, @@ -228,12 +229,10 @@ UserApi <- R6::R6Class( }, logout_user = function(...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() urlPath <- "/user/logout" - resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath), method = "GET", queryParams = queryParams, @@ -252,11 +251,13 @@ UserApi <- R6::R6Class( }, update_user = function(username, body, ...){ args <- list(...) - body <- NULL queryParams <- list() headerParams <- character() + if (!missing(`body`)) { - body <- `body`$toJSON() + body <- `body`$toJSONString() + } else { + body <- NULL } urlPath <- "/user/{username}" From 1f9dc4dd2ef0a866a73ad20326774e298966077d Mon Sep 17 00:00:00 2001 From: korkut89 <32836783+korkut89@users.noreply.github.com> Date: Tue, 24 Oct 2017 06:34:24 +0300 Subject: [PATCH 14/28] Fix required bug (#6733) flatten methods replaces original ObjectProperty objects with new RefProperty objects which required variables are false as default. Newly created objects' required variables are set as the original property. --- .../swagger/codegen/InlineModelResolver.java | 68 ++++++++++++++----- .../codegen/InlineModelResolverTest.java | 42 ++++++++++++ 2 files changed, 92 insertions(+), 18 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java index 7cf9dec0a22e..dfa5238f26f6 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java @@ -68,9 +68,13 @@ public class InlineModelResolver { Model innerModel = modelFromProperty(op, modelName); String existing = matchGenerated(innerModel); if (existing != null) { - am.setItems(new RefProperty(existing)); + RefProperty refProperty = new RefProperty(existing); + refProperty.setRequired(op.getRequired()); + am.setItems(refProperty); } else { - am.setItems(new RefProperty(modelName)); + RefProperty refProperty = new RefProperty(modelName); + refProperty.setRequired(op.getRequired()); + am.setItems(refProperty); addGenerated(modelName, innerModel); swagger.addDefinition(modelName, innerModel); } @@ -94,9 +98,13 @@ public class InlineModelResolver { Model model = modelFromProperty(op, modelName); String existing = matchGenerated(model); if (existing != null) { - response.setSchema(this.makeRefProperty(existing, property)); + Property refProperty = this.makeRefProperty(existing, property); + refProperty.setRequired(op.getRequired()); + response.setSchema(refProperty); } else { - response.setSchema(this.makeRefProperty(modelName, property)); + Property refProperty = this.makeRefProperty(modelName, property); + refProperty.setRequired(op.getRequired()); + response.setSchema(refProperty); addGenerated(modelName, model); swagger.addDefinition(modelName, model); } @@ -114,9 +122,13 @@ public class InlineModelResolver { Model innerModel = modelFromProperty(op, modelName); String existing = matchGenerated(innerModel); if (existing != null) { - ap.setItems(this.makeRefProperty(existing, op)); + Property refProperty = this.makeRefProperty(existing, op); + refProperty.setRequired(op.getRequired()); + ap.setItems(refProperty); } else { - ap.setItems(this.makeRefProperty(modelName, op)); + Property refProperty = this.makeRefProperty(modelName, op); + refProperty.setRequired(op.getRequired()); + ap.setItems(refProperty); addGenerated(modelName, innerModel); swagger.addDefinition(modelName, innerModel); } @@ -135,9 +147,13 @@ public class InlineModelResolver { Model innerModel = modelFromProperty(op, modelName); String existing = matchGenerated(innerModel); if (existing != null) { - mp.setAdditionalProperties(new RefProperty(existing)); + RefProperty refProperty = new RefProperty(existing); + refProperty.setRequired(op.getRequired()); + mp.setAdditionalProperties(refProperty); } else { - mp.setAdditionalProperties(new RefProperty(modelName)); + RefProperty refProperty = new RefProperty(modelName); + refProperty.setRequired(op.getRequired()); + mp.setAdditionalProperties(refProperty); addGenerated(modelName, innerModel); swagger.addDefinition(modelName, innerModel); } @@ -174,9 +190,13 @@ public class InlineModelResolver { if (existing == null) { swagger.addDefinition(innerModelName, innerModel); addGenerated(innerModelName, innerModel); - m.setItems(new RefProperty(innerModelName)); + RefProperty refProperty = new RefProperty(innerModelName); + refProperty.setRequired(op.getRequired()); + m.setItems(refProperty); } else { - m.setItems(new RefProperty(existing)); + RefProperty refProperty = new RefProperty(existing); + refProperty.setRequired(op.getRequired()); + m.setItems(refProperty); } } } @@ -271,9 +291,13 @@ public class InlineModelResolver { String existing = matchGenerated(model); if (existing != null) { - propsToUpdate.put(key, new RefProperty(existing)); + RefProperty refProperty = new RefProperty(existing); + refProperty.setRequired(op.getRequired()); + propsToUpdate.put(key, refProperty); } else { - propsToUpdate.put(key, new RefProperty(modelName)); + RefProperty refProperty = new RefProperty(modelName); + refProperty.setRequired(op.getRequired()); + propsToUpdate.put(key, refProperty); modelsToAdd.put(modelName, model); addGenerated(modelName, model); swagger.addDefinition(modelName, model); @@ -290,9 +314,13 @@ public class InlineModelResolver { Model innerModel = modelFromProperty(op, modelName); String existing = matchGenerated(innerModel); if (existing != null) { - ap.setItems(new RefProperty(existing)); + RefProperty refProperty = new RefProperty(existing); + refProperty.setRequired(op.getRequired()); + ap.setItems(refProperty); } else { - ap.setItems(new RefProperty(modelName)); + RefProperty refProperty = new RefProperty(modelName); + refProperty.setRequired(op.getRequired()); + ap.setItems(refProperty); addGenerated(modelName, innerModel); swagger.addDefinition(modelName, innerModel); } @@ -310,9 +338,13 @@ public class InlineModelResolver { Model innerModel = modelFromProperty(op, modelName); String existing = matchGenerated(innerModel); if (existing != null) { - mp.setAdditionalProperties(new RefProperty(existing)); + RefProperty refProperty = new RefProperty(existing); + refProperty.setRequired(op.getRequired()); + mp.setAdditionalProperties(refProperty); } else { - mp.setAdditionalProperties(new RefProperty(modelName)); + RefProperty refProperty = new RefProperty(existing); + refProperty.setRequired(op.getRequired()); + mp.setAdditionalProperties(refProperty); addGenerated(modelName, innerModel); swagger.addDefinition(modelName, innerModel); } @@ -399,7 +431,7 @@ public class InlineModelResolver { /** * Make a RefProperty - * + * * @param ref new property name * @param property Property * @return @@ -412,7 +444,7 @@ public class InlineModelResolver { /** * Copy vendor extensions from Property to another Property - * + * * @param source source property * @param target target property */ diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java index ff69e4b36bf5..a37c72a3efcd 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java @@ -328,6 +328,48 @@ public class InlineModelResolverTest { ModelImpl impl = (ModelImpl) body; assertNotNull(impl.getProperties().get("address")); } + + @Test + public void resolveInlineBodyParameterWithRequired() throws Exception { + Swagger swagger = new Swagger(); + + swagger.path("/hello", new Path() + .get(new Operation() + .parameter(new BodyParameter() + .name("body") + .schema(new ModelImpl() + .property("address", new ObjectProperty() + .property("street", new StringProperty() + .required(true)) + .required(true)) + .property("name", new StringProperty()))))); + + new InlineModelResolver().flatten(swagger); + + Operation operation = swagger.getPaths().get("/hello").getGet(); + BodyParameter bp = (BodyParameter)operation.getParameters().get(0); + assertTrue(bp.getSchema() instanceof RefModel); + + Model body = swagger.getDefinitions().get("body"); + assertTrue(body instanceof ModelImpl); + + ModelImpl impl = (ModelImpl) body; + assertNotNull(impl.getProperties().get("address")); + + Property addressProperty = impl.getProperties().get("address"); + assertTrue(addressProperty instanceof RefProperty); + assertTrue(addressProperty.getRequired()); + + Model helloAddress = swagger.getDefinitions().get("hello_address"); + assertTrue(helloAddress instanceof ModelImpl); + + ModelImpl addressImpl = (ModelImpl) helloAddress; + assertNotNull(addressImpl); + + Property streetProperty = addressImpl.getProperties().get("street"); + assertTrue(streetProperty instanceof StringProperty); + assertTrue(streetProperty.getRequired()); + } @Test public void resolveInlineBodyParameterWithTitle() throws Exception { From 66cbab1947b3a4025cd9fa6a8d1bc3a0ed4457d6 Mon Sep 17 00:00:00 2001 From: Esteban Marin Date: Tue, 24 Oct 2017 16:51:58 +0200 Subject: [PATCH 15/28] Bugfix/6649 angular http client empty body (#6754) * fix empty body issue * #6649: add line break * #6649: improve indentation * #6649: improve indentation * #6649: generate code * #6649: generate samples * #6649: fix method docs --- .../io/swagger/codegen/CodegenOperation.java | 9 ++ .../typescript-angular/api.service.mustache | 16 ++-- .../npm/api/pet.service.ts | 96 +++++++++++-------- .../npm/api/store.service.ts | 45 +++++---- .../npm/api/user.service.ts | 94 ++++++++++-------- .../npm/model/order.ts | 7 +- .../typescript-angular-v4.3/npm/model/pet.ts | 7 +- 7 files changed, 154 insertions(+), 120 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java index 1273b96c5c29..64e76df04828 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java @@ -140,6 +140,15 @@ public class CodegenOperation { return Arrays.asList("PUT", "PATCH").contains(httpMethod.toUpperCase()) && isMemberPath(); } + /** + * Check if body param is allowed for the request method + * + * @return true request method is PUT, PATCH or POST; false otherwise + */ + public boolean isBodyAllowed() { + return Arrays.asList("PUT", "PATCH", "POST").contains(httpMethod.toUpperCase()); + } + /** * Check if act as Restful destroy method * diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache index ea2b19b78852..20be74cfa61e 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache @@ -263,17 +263,19 @@ export class {{classname}} { {{/hasFormParams}} {{#useHttpClient}} - return this.httpClient.{{httpMethod}}{{^isResponseFile}}{{/isResponseFile}}(`${this.basePath}{{{path}}}`, {{#bodyParam}}{{paramName}}, {{/bodyParam}} - {{#hasFormParams}}convertFormParamsToString ? formParams.toString() : formParams, {{/hasFormParams}}{ + return this.httpClient.{{httpMethod}}{{^isResponseFile}}{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#isBodyAllowed}} + {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams.toString() : formParams{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}}, {{/isBodyAllowed}} + { {{#hasQueryParams}} - params: queryParameters, + params: queryParameters, {{/hasQueryParams}} - headers: headers, + headers: headers, {{#isResponseFile}} - responseType: "blob", + responseType: "blob", {{/isResponseFile}} - withCredentials: this.configuration.withCredentials, - }); + withCredentials: this.configuration.withCredentials, + } + ); {{/useHttpClient}} {{^useHttpClient}} let requestOptions: RequestOptionsArgs = new RequestOptions({ diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts index 16a19cdefa87..93d9553627c2 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts @@ -78,11 +78,13 @@ export class PetService { headers = headers.set('Authorization', 'Bearer ' + accessToken); } - return this.httpClient.post(`${this.basePath}/pet`, body, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.post(`${this.basePath}/pet`, + body, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -109,11 +111,12 @@ export class PetService { headers = headers.set('Authorization', 'Bearer ' + accessToken); } - return this.httpClient.delete(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.delete(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -141,12 +144,13 @@ export class PetService { headers = headers.set('Authorization', 'Bearer ' + accessToken); } - return this.httpClient.get(`${this.basePath}/pet/findByStatus`, - { - params: queryParameters, - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.get(`${this.basePath}/pet/findByStatus`, + { + params: queryParameters, + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -174,12 +178,13 @@ export class PetService { headers = headers.set('Authorization', 'Bearer ' + accessToken); } - return this.httpClient.get(`${this.basePath}/pet/findByTags`, - { - params: queryParameters, - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.get(`${this.basePath}/pet/findByTags`, + { + params: queryParameters, + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -199,11 +204,12 @@ export class PetService { headers = headers.set('api_key', this.configuration.apiKeys["api_key"]); } - return this.httpClient.get(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.get(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -226,11 +232,13 @@ export class PetService { headers = headers.set('Authorization', 'Bearer ' + accessToken); } - return this.httpClient.put(`${this.basePath}/pet`, body, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.put(`${this.basePath}/pet`, + body, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -279,11 +287,13 @@ export class PetService { formParams = formParams.append('status', status) || formParams; } - return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, - convertFormParamsToString ? formParams.toString() : formParams, { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, + convertFormParamsToString ? formParams.toString() : formParams, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -335,11 +345,13 @@ export class PetService { formParams = formParams.append('file', file) || formParams; } - return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, - convertFormParamsToString ? formParams.toString() : formParams, { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.post(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, + convertFormParamsToString ? formParams.toString() : formParams, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts index 3b9c88fbb772..7e05cddef8e8 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts @@ -69,11 +69,12 @@ export class StoreService { let headers = this.defaultHeaders; - return this.httpClient.delete(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.delete(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -89,11 +90,12 @@ export class StoreService { headers = headers.set('api_key', this.configuration.apiKeys["api_key"]); } - return this.httpClient.get(`${this.basePath}/store/inventory`, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.get(`${this.basePath}/store/inventory`, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -108,11 +110,12 @@ export class StoreService { let headers = this.defaultHeaders; - return this.httpClient.get(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.get(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -127,11 +130,13 @@ export class StoreService { let headers = this.defaultHeaders; - return this.httpClient.post(`${this.basePath}/store/order`, body, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.post(`${this.basePath}/store/order`, + body, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts index 4cf879c80ccc..f8146a76f454 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts @@ -69,11 +69,13 @@ export class UserService { let headers = this.defaultHeaders; - return this.httpClient.post(`${this.basePath}/user`, body, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.post(`${this.basePath}/user`, + body, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -88,11 +90,13 @@ export class UserService { let headers = this.defaultHeaders; - return this.httpClient.post(`${this.basePath}/user/createWithArray`, body, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.post(`${this.basePath}/user/createWithArray`, + body, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -107,11 +111,13 @@ export class UserService { let headers = this.defaultHeaders; - return this.httpClient.post(`${this.basePath}/user/createWithList`, body, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.post(`${this.basePath}/user/createWithList`, + body, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -126,11 +132,12 @@ export class UserService { let headers = this.defaultHeaders; - return this.httpClient.delete(`${this.basePath}/user/${encodeURIComponent(String(username))}`, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.delete(`${this.basePath}/user/${encodeURIComponent(String(username))}`, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -145,11 +152,12 @@ export class UserService { let headers = this.defaultHeaders; - return this.httpClient.get(`${this.basePath}/user/${encodeURIComponent(String(username))}`, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.get(`${this.basePath}/user/${encodeURIComponent(String(username))}`, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -176,12 +184,13 @@ export class UserService { let headers = this.defaultHeaders; - return this.httpClient.get(`${this.basePath}/user/login`, - { - params: queryParameters, - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.get(`${this.basePath}/user/login`, + { + params: queryParameters, + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -192,11 +201,12 @@ export class UserService { let headers = this.defaultHeaders; - return this.httpClient.get(`${this.basePath}/user/logout`, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.get(`${this.basePath}/user/logout`, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } /** @@ -215,11 +225,13 @@ export class UserService { let headers = this.defaultHeaders; - return this.httpClient.put(`${this.basePath}/user/${encodeURIComponent(String(username))}`, body, - { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.put(`${this.basePath}/user/${encodeURIComponent(String(username))}`, + body, + { + headers: headers, + withCredentials: this.configuration.withCredentials, + } + ); } } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts index 33b60bb6e163..8c1869a4c130 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts @@ -27,9 +27,6 @@ export interface Order { } export namespace Order { export type StatusEnum = 'placed' | 'approved' | 'delivered'; - export const StatusEnum = { - Placed: 'placed' as StatusEnum, - Approved: 'approved' as StatusEnum, - Delivered: 'delivered' as StatusEnum - } } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts index 342ab5f8e752..ce6a095b840d 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts @@ -29,9 +29,6 @@ export interface Pet { } export namespace Pet { export type StatusEnum = 'available' | 'pending' | 'sold'; - export const StatusEnum = { - Available: 'available' as StatusEnum, - Pending: 'pending' as StatusEnum, - Sold: 'sold' as StatusEnum - } } + + From 98e5612c84322c44a08c32a688377b8eed133087 Mon Sep 17 00:00:00 2001 From: Keni Steward Date: Tue, 24 Oct 2017 22:02:05 -0400 Subject: [PATCH 16/28] Update README.md (#6797) Added FINRA as a company using swagger codegen opensource --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cbef495af554..6f6a529dd6b6 100644 --- a/README.md +++ b/README.md @@ -761,6 +761,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you - [everystory.us](http://everystory.us) - [Expected Behavior](http://www.expectedbehavior.com/) - [Fastly](https://www.fastly.com/) +- [FINRA](https://github.com/FINRAOS/herd/) - [Flat](https://flat.io) - [Finder](http://en.finder.pl/) - [Fitwell](https://fitwell.co/) From f4ac6feae2397cca9cd61b05c8bd16a66d995d23 Mon Sep 17 00:00:00 2001 From: Esteban Marin Date: Wed, 25 Oct 2017 04:53:20 +0200 Subject: [PATCH 17/28] Bugfix/6727 import http client module (#6757) * [angular-typescript] imports HttpClientModule HttpModule has no effect, since the new `HttpClient` is now used. fixes #6727 * #6727: import http client module or http module, depending on setting * #6727: import http client module or http module, depending on setting * #6727: generate samples --- .../main/resources/typescript-angular/api.module.mustache | 7 ++++++- .../typescript-angular-v2/default/model/ApiResponse.ts | 2 ++ .../typescript-angular-v2/default/model/category.ts | 2 ++ .../petstore/typescript-angular-v2/default/model/order.ts | 2 ++ .../petstore/typescript-angular-v2/default/model/pet.ts | 2 ++ .../petstore/typescript-angular-v2/default/model/tag.ts | 2 ++ .../petstore/typescript-angular-v2/default/model/user.ts | 2 ++ .../typescript-angular-v2/npm/model/ApiResponse.ts | 2 ++ .../petstore/typescript-angular-v2/npm/model/category.ts | 2 ++ .../petstore/typescript-angular-v2/npm/model/order.ts | 2 ++ .../client/petstore/typescript-angular-v2/npm/model/pet.ts | 2 ++ .../client/petstore/typescript-angular-v2/npm/model/tag.ts | 2 ++ .../petstore/typescript-angular-v2/npm/model/user.ts | 2 ++ .../with-interfaces/model/Category.ts | 2 ++ .../typescript-angular-v2/with-interfaces/model/Order.ts | 2 ++ .../typescript-angular-v2/with-interfaces/model/Pet.ts | 2 ++ .../typescript-angular-v2/with-interfaces/model/Tag.ts | 2 ++ .../typescript-angular-v2/with-interfaces/model/User.ts | 2 ++ .../with-interfaces/model/apiResponse.ts | 2 ++ .../petstore/typescript-angular-v4.3/npm/api.module.ts | 4 ++-- .../typescript-angular-v4/npm/model/apiResponse.ts | 2 ++ .../petstore/typescript-angular-v4/npm/model/category.ts | 2 ++ .../petstore/typescript-angular-v4/npm/model/order.ts | 2 ++ .../client/petstore/typescript-angular-v4/npm/model/pet.ts | 2 ++ .../client/petstore/typescript-angular-v4/npm/model/tag.ts | 2 ++ .../petstore/typescript-angular-v4/npm/model/user.ts | 2 ++ 26 files changed, 56 insertions(+), 3 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/api.module.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/api.module.mustache index d41c41142221..cb695b271e13 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/api.module.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/api.module.mustache @@ -1,6 +1,11 @@ import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; +{{#useHttpClient}} +import { HttpClientModule } from '@angular/common/http'; +{{/useHttpClient}} +{{^useHttpClient}} import { HttpModule } from '@angular/http'; +{{/useHttpClient}} import { Configuration } from './configuration'; {{#apiInfo}} @@ -10,7 +15,7 @@ import { {{classname}} } from './{{importPath}}'; {{/apiInfo}} @NgModule({ - imports: [ CommonModule, HttpModule ], + imports: [ CommonModule, {{#useHttpClient}}HttpClientModule{{/useHttpClient}}{{^useHttpClient}}HttpModule{{/useHttpClient}} ], declarations: [], exports: [], providers: [ {{#apiInfo}}{{#apis}}{{classname}}{{#hasMore}}, {{/hasMore}}{{/apis}}{{/apiInfo}} ] diff --git a/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts b/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts index eac4208f022a..ac34396e0b34 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts @@ -19,3 +19,5 @@ export interface ApiResponse { type?: string; message?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v2/default/model/category.ts b/samples/client/petstore/typescript-angular-v2/default/model/category.ts index 5040d1db915b..767b49484181 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/category.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/category.ts @@ -18,3 +18,5 @@ export interface Category { id?: number; name?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v2/default/model/order.ts b/samples/client/petstore/typescript-angular-v2/default/model/order.ts index 33b60bb6e163..3ac0a1c39c7d 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/order.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/order.ts @@ -33,3 +33,5 @@ export namespace Order { Delivered: 'delivered' as StatusEnum } } + + diff --git a/samples/client/petstore/typescript-angular-v2/default/model/pet.ts b/samples/client/petstore/typescript-angular-v2/default/model/pet.ts index 342ab5f8e752..0e08dee12ae4 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/pet.ts @@ -35,3 +35,5 @@ export namespace Pet { Sold: 'sold' as StatusEnum } } + + diff --git a/samples/client/petstore/typescript-angular-v2/default/model/tag.ts b/samples/client/petstore/typescript-angular-v2/default/model/tag.ts index c75240003572..73e4d26aa3b2 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/tag.ts @@ -18,3 +18,5 @@ export interface Tag { id?: number; name?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v2/default/model/user.ts b/samples/client/petstore/typescript-angular-v2/default/model/user.ts index a0261a6f37d2..de9c1d85670e 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/user.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/user.ts @@ -27,3 +27,5 @@ export interface User { */ userStatus?: number; } + + diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts b/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts index eac4208f022a..ac34396e0b34 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts @@ -19,3 +19,5 @@ export interface ApiResponse { type?: string; message?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/category.ts b/samples/client/petstore/typescript-angular-v2/npm/model/category.ts index 5040d1db915b..767b49484181 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/category.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/category.ts @@ -18,3 +18,5 @@ export interface Category { id?: number; name?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/order.ts b/samples/client/petstore/typescript-angular-v2/npm/model/order.ts index 33b60bb6e163..3ac0a1c39c7d 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/order.ts @@ -33,3 +33,5 @@ export namespace Order { Delivered: 'delivered' as StatusEnum } } + + diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts index 342ab5f8e752..0e08dee12ae4 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts @@ -35,3 +35,5 @@ export namespace Pet { Sold: 'sold' as StatusEnum } } + + diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts b/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts index c75240003572..73e4d26aa3b2 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts @@ -18,3 +18,5 @@ export interface Tag { id?: number; name?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/user.ts b/samples/client/petstore/typescript-angular-v2/npm/model/user.ts index a0261a6f37d2..de9c1d85670e 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/user.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/user.ts @@ -27,3 +27,5 @@ export interface User { */ userStatus?: number; } + + diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts index 5040d1db915b..767b49484181 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts @@ -18,3 +18,5 @@ export interface Category { id?: number; name?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts index 33b60bb6e163..3ac0a1c39c7d 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts @@ -33,3 +33,5 @@ export namespace Order { Delivered: 'delivered' as StatusEnum } } + + diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts index 342ab5f8e752..0e08dee12ae4 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts @@ -35,3 +35,5 @@ export namespace Pet { Sold: 'sold' as StatusEnum } } + + diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts index c75240003572..73e4d26aa3b2 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts @@ -18,3 +18,5 @@ export interface Tag { id?: number; name?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts index a0261a6f37d2..de9c1d85670e 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts @@ -27,3 +27,5 @@ export interface User { */ userStatus?: number; } + + diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts index eac4208f022a..ac34396e0b34 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts @@ -19,3 +19,5 @@ export interface ApiResponse { type?: string; message?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api.module.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api.module.ts index dcce0dbd6286..71f51c70cf9d 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api.module.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api.module.ts @@ -1,6 +1,6 @@ import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { HttpModule } from '@angular/http'; +import { HttpClientModule } from '@angular/common/http'; import { Configuration } from './configuration'; import { PetService } from './api/pet.service'; @@ -8,7 +8,7 @@ import { StoreService } from './api/store.service'; import { UserService } from './api/user.service'; @NgModule({ - imports: [ CommonModule, HttpModule ], + imports: [ CommonModule, HttpClientModule ], declarations: [], exports: [], providers: [ PetService, StoreService, UserService ] diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts index eac4208f022a..ac34396e0b34 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts @@ -19,3 +19,5 @@ export interface ApiResponse { type?: string; message?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/category.ts b/samples/client/petstore/typescript-angular-v4/npm/model/category.ts index 5040d1db915b..767b49484181 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/category.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/category.ts @@ -18,3 +18,5 @@ export interface Category { id?: number; name?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/order.ts b/samples/client/petstore/typescript-angular-v4/npm/model/order.ts index 33b60bb6e163..3ac0a1c39c7d 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/order.ts @@ -33,3 +33,5 @@ export namespace Order { Delivered: 'delivered' as StatusEnum } } + + diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts index 342ab5f8e752..0e08dee12ae4 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts @@ -35,3 +35,5 @@ export namespace Pet { Sold: 'sold' as StatusEnum } } + + diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts b/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts index c75240003572..73e4d26aa3b2 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts @@ -18,3 +18,5 @@ export interface Tag { id?: number; name?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/user.ts b/samples/client/petstore/typescript-angular-v4/npm/model/user.ts index a0261a6f37d2..de9c1d85670e 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/user.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/user.ts @@ -27,3 +27,5 @@ export interface User { */ userStatus?: number; } + + From ab338f8cb958631eeee93c62bc1e7ebd79ad2d45 Mon Sep 17 00:00:00 2001 From: Dimitar Ivanov Date: Wed, 25 Oct 2017 05:57:53 +0300 Subject: [PATCH 18/28] Erlang-server: fix dialyzer; fix min and max checks (#6752) --- .../main/resources/erlang-server/api.mustache | 8 ++- .../resources/erlang-server/auth.mustache | 4 ++ .../resources/erlang-server/handler.mustache | 6 +- .../erlang-server/logic_handler.mustache | 10 +-- .../resources/erlang-server/server.mustache | 1 + .../erlang-server/.swagger-codegen/VERSION | 2 +- .../petstore/erlang-server/priv/swagger.json | 55 +++++++++++++++- .../erlang-server/src/swagger.app.src | 2 +- .../erlang-server/src/swagger_api.erl | 8 ++- .../erlang-server/src/swagger_pet_handler.erl | 2 +- .../erlang-server/src/swagger_server.erl | 1 + .../src/swagger_store_handler.erl | 26 +------- .../src/swagger_user_handler.erl | 66 +------------------ 13 files changed, 85 insertions(+), 106 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/erlang-server/api.mustache b/modules/swagger-codegen/src/main/resources/erlang-server/api.mustache index d948bbae4b29..ed49d5a0a789 100644 --- a/modules/swagger-codegen/src/main/resources/erlang-server/api.mustache +++ b/modules/swagger-codegen/src/main/resources/erlang-server/api.mustache @@ -4,6 +4,8 @@ -export([request_param_info/2]). -export([populate_request/3]). -export([validate_response/4]). +%% exported to silence swagger complains +-export([get_value/3, validate_response_body/4]). -type operation_id() :: atom(). -type request_param() :: atom(). @@ -212,7 +214,7 @@ validate(Rule = {enum, Values}, Name, Value, _ValidatorState) -> end; validate(Rule = {max, Max}, Name, Value, _ValidatorState) -> - case Value >= Max of + case Value =< Max of true -> ok; false -> validation_error(Rule, Name) end; @@ -224,7 +226,7 @@ validate(Rule = {exclusive_max, ExclusiveMax}, Name, Value, _ValidatorState) -> end; validate(Rule = {min, Min}, Name, Value, _ValidatorState) -> - case Value =< Min of + case Value >= Min of true -> ok; false -> validation_error(Rule, Name) end; @@ -290,6 +292,8 @@ validation_error(ViolatedRule, Name) -> validation_error(ViolatedRule, Name, Info) -> throw({wrong_param, Name, ViolatedRule, Info}). +-spec get_value(body | qs_val | header | binding, Name :: any(), Req0 :: cowboy_req:req()) -> + {Value :: any(), Req :: cowboy_req:req()}. get_value(body, _Name, Req0) -> {ok, Body, Req} = cowboy_req:body(Req0), Value = prepare_body(Body), diff --git a/modules/swagger-codegen/src/main/resources/erlang-server/auth.mustache b/modules/swagger-codegen/src/main/resources/erlang-server/auth.mustache index bf988fac3481..c81f989fd38e 100644 --- a/modules/swagger-codegen/src/main/resources/erlang-server/auth.mustache +++ b/modules/swagger-codegen/src/main/resources/erlang-server/auth.mustache @@ -24,8 +24,12 @@ authorize_api_key(LogicHandler, OperationID, From, KeyParam, Req0) -> ApiKey ), case Result of + {{#authMethods}} + {{#isApiKey}} {true, Context} -> {true, Context, Req}; + {{/isApiKey}} + {{/authMethods}} false -> AuthHeader = <<"">>, {false, AuthHeader, Req} diff --git a/modules/swagger-codegen/src/main/resources/erlang-server/handler.mustache b/modules/swagger-codegen/src/main/resources/erlang-server/handler.mustache index 4c0bebc5ff41..4ed2e21a2ae3 100644 --- a/modules/swagger-codegen/src/main/resources/erlang-server/handler.mustache +++ b/modules/swagger-codegen/src/main/resources/erlang-server/handler.mustache @@ -94,13 +94,15 @@ is_authorized( end; {{/isApiKey}} {{/authMethods}} +{{/operation}}{{/operations}} {{^authMethods}} is_authorized(Req, State) -> - {true, Req, State}; + {true, Req, State}. {{/authMethods}} -{{/operation}}{{/operations}} +{{#authMethods}} is_authorized(Req, State) -> {{false, <<"">>}, Req, State}. +{{/authMethods}} -spec content_types_accepted(Req :: cowboy_req:req(), State :: state()) -> { diff --git a/modules/swagger-codegen/src/main/resources/erlang-server/logic_handler.mustache b/modules/swagger-codegen/src/main/resources/erlang-server/logic_handler.mustache index cb4ba201bf48..8baf9b81c20f 100644 --- a/modules/swagger-codegen/src/main/resources/erlang-server/logic_handler.mustache +++ b/modules/swagger-codegen/src/main/resources/erlang-server/logic_handler.mustache @@ -1,11 +1,7 @@ -module({{packageName}}_logic_handler). -export([handle_request/4]). -{{#authMethods}} - {{#isApiKey}} -export([authorize_api_key/3]). - {{/isApiKey}} -{{/authMethods}} -type context() :: #{binary() => any()}. -type handler_response() ::{ Status :: cowboy:http_status(), @@ -48,3 +44,9 @@ authorize_api_key(Handler, OperationID, ApiKey) -> Handler:authorize_api_key(OperationID, ApiKey). {{/isApiKey}} {{/authMethods}} +{{^authMethods}} +-spec authorize_api_key(Handler :: atom(), OperationID :: {{packageName}}_api:operation_id(), ApiKey :: binary()) -> + Result :: false. +authorize_api_key(_Handler, _OperationID, _ApiKey) -> + false. +{{/authMethods}} diff --git a/modules/swagger-codegen/src/main/resources/erlang-server/server.mustache b/modules/swagger-codegen/src/main/resources/erlang-server/server.mustache index 90a6388ea5d0..348a473e9e3d 100644 --- a/modules/swagger-codegen/src/main/resources/erlang-server/server.mustache +++ b/modules/swagger-codegen/src/main/resources/erlang-server/server.mustache @@ -9,6 +9,7 @@ -spec child_spec( ID :: any(), #{ ip => inet:ip_address(), port => inet:port_number(), + logic_handler => module(), net_opts => [] }) -> supervisor:child_spec(). diff --git a/samples/server/petstore/erlang-server/.swagger-codegen/VERSION b/samples/server/petstore/erlang-server/.swagger-codegen/VERSION index 7fea99011a6f..f9f7450d1359 100644 --- a/samples/server/petstore/erlang-server/.swagger-codegen/VERSION +++ b/samples/server/petstore/erlang-server/.swagger-codegen/VERSION @@ -1 +1 @@ -2.2.3-SNAPSHOT \ No newline at end of file +2.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/erlang-server/priv/swagger.json b/samples/server/petstore/erlang-server/priv/swagger.json index 3eef6c58413b..808835928b60 100644 --- a/samples/server/petstore/erlang-server/priv/swagger.json +++ b/samples/server/petstore/erlang-server/priv/swagger.json @@ -9,7 +9,7 @@ "email" : "apiteam@swagger.io" }, "license" : { - "name" : "Apache 2.0", + "name" : "Apache-2.0", "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" } }, @@ -166,7 +166,8 @@ }, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] - } ] + } ], + "deprecated" : true } }, "/pet/{petId}" : { @@ -683,6 +684,14 @@ }, "title" : "Pet Order", "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, "xml" : { "name" : "Order" } @@ -700,6 +709,10 @@ }, "title" : "Pet catehgry", "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, "xml" : { "name" : "Category" } @@ -737,6 +750,16 @@ }, "title" : "a User", "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, "xml" : { "name" : "User" } @@ -754,6 +777,10 @@ }, "title" : "Pet Tag", "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, "xml" : { "name" : "Tag" } @@ -801,6 +828,23 @@ }, "title" : "a Pet", "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, "xml" : { "name" : "Pet" } @@ -820,7 +864,12 @@ } }, "title" : "An uploaded response", - "description" : "Describes the result of uploading an image resource" + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + } } }, "externalDocs" : { diff --git a/samples/server/petstore/erlang-server/src/swagger.app.src b/samples/server/petstore/erlang-server/src/swagger.app.src index 9016bde72193..f76b2b0a1485 100644 --- a/samples/server/petstore/erlang-server/src/swagger.app.src +++ b/samples/server/petstore/erlang-server/src/swagger.app.src @@ -14,6 +14,6 @@ {env, [ ]}, {modules, []}, - {licenses, ["Apache 2.0"]}, + {licenses, ["Apache-2.0"]}, {links, []} ]}. diff --git a/samples/server/petstore/erlang-server/src/swagger_api.erl b/samples/server/petstore/erlang-server/src/swagger_api.erl index 2fbc055ad08f..02e15583133e 100644 --- a/samples/server/petstore/erlang-server/src/swagger_api.erl +++ b/samples/server/petstore/erlang-server/src/swagger_api.erl @@ -4,6 +4,8 @@ -export([request_param_info/2]). -export([populate_request/3]). -export([validate_response/4]). +%% exported to silence swagger complains +-export([get_value/3, validate_response_body/4]). -type operation_id() :: atom(). -type request_param() :: atom(). @@ -599,7 +601,7 @@ validate(Rule = {enum, Values}, Name, Value, _ValidatorState) -> end; validate(Rule = {max, Max}, Name, Value, _ValidatorState) -> - case Value >= Max of + case Value =< Max of true -> ok; false -> validation_error(Rule, Name) end; @@ -611,7 +613,7 @@ validate(Rule = {exclusive_max, ExclusiveMax}, Name, Value, _ValidatorState) -> end; validate(Rule = {min, Min}, Name, Value, _ValidatorState) -> - case Value =< Min of + case Value >= Min of true -> ok; false -> validation_error(Rule, Name) end; @@ -677,6 +679,8 @@ validation_error(ViolatedRule, Name) -> validation_error(ViolatedRule, Name, Info) -> throw({wrong_param, Name, ViolatedRule, Info}). +-spec get_value(body | qs_val | header | binding, Name :: any(), Req0 :: cowboy_req:req()) -> + {Value :: any(), Req :: cowboy_req:req()}. get_value(body, _Name, Req0) -> {ok, Body, Req} = cowboy_req:body(Req0), Value = prepare_body(Body), diff --git a/samples/server/petstore/erlang-server/src/swagger_pet_handler.erl b/samples/server/petstore/erlang-server/src/swagger_pet_handler.erl index 4351da7da6c6..d1c1a7b94d8e 100644 --- a/samples/server/petstore/erlang-server/src/swagger_pet_handler.erl +++ b/samples/server/petstore/erlang-server/src/swagger_pet_handler.erl @@ -204,7 +204,7 @@ is_authorized( ) -> is_authorized(Req, State) -> - {{false, <<"">>}, Req, State}. + {true, Req, State}. -spec content_types_accepted(Req :: cowboy_req:req(), State :: state()) -> { diff --git a/samples/server/petstore/erlang-server/src/swagger_server.erl b/samples/server/petstore/erlang-server/src/swagger_server.erl index 4f56a3260344..1c3b9218afe6 100644 --- a/samples/server/petstore/erlang-server/src/swagger_server.erl +++ b/samples/server/petstore/erlang-server/src/swagger_server.erl @@ -9,6 +9,7 @@ -spec child_spec( ID :: any(), #{ ip => inet:ip_address(), port => inet:port_number(), + logic_handler => module(), net_opts => [] }) -> supervisor:child_spec(). diff --git a/samples/server/petstore/erlang-server/src/swagger_store_handler.erl b/samples/server/petstore/erlang-server/src/swagger_store_handler.erl index 537ecdcb43fa..adfeb256ae67 100644 --- a/samples/server/petstore/erlang-server/src/swagger_store_handler.erl +++ b/samples/server/petstore/erlang-server/src/swagger_store_handler.erl @@ -95,14 +95,6 @@ allowed_methods(Req, State) -> State :: state() }. -is_authorized( - Req0, - State = #state{ - operation_id = 'DeleteOrder' = OperationID, - logic_handler = LogicHandler - } -) -> - {true, Req0, State}; is_authorized( Req0, @@ -124,26 +116,10 @@ is_authorized( {false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State} end; -is_authorized( - Req0, - State = #state{ - operation_id = 'GetOrderById' = OperationID, - logic_handler = LogicHandler - } -) -> - {true, Req0, State}; -is_authorized( - Req0, - State = #state{ - operation_id = 'PlaceOrder' = OperationID, - logic_handler = LogicHandler - } -) -> - {true, Req0, State}; is_authorized(Req, State) -> - {{false, <<"">>}, Req, State}. + {true, Req, State}. -spec content_types_accepted(Req :: cowboy_req:req(), State :: state()) -> { diff --git a/samples/server/petstore/erlang-server/src/swagger_user_handler.erl b/samples/server/petstore/erlang-server/src/swagger_user_handler.erl index 4597046b9560..9e6ccaae3bc1 100644 --- a/samples/server/petstore/erlang-server/src/swagger_user_handler.erl +++ b/samples/server/petstore/erlang-server/src/swagger_user_handler.erl @@ -127,80 +127,16 @@ allowed_methods(Req, State) -> State :: state() }. -is_authorized( - Req0, - State = #state{ - operation_id = 'CreateUser' = OperationID, - logic_handler = LogicHandler - } -) -> - {true, Req0, State}; -is_authorized( - Req0, - State = #state{ - operation_id = 'CreateUsersWithArrayInput' = OperationID, - logic_handler = LogicHandler - } -) -> - {true, Req0, State}; -is_authorized( - Req0, - State = #state{ - operation_id = 'CreateUsersWithListInput' = OperationID, - logic_handler = LogicHandler - } -) -> - {true, Req0, State}; -is_authorized( - Req0, - State = #state{ - operation_id = 'DeleteUser' = OperationID, - logic_handler = LogicHandler - } -) -> - {true, Req0, State}; -is_authorized( - Req0, - State = #state{ - operation_id = 'GetUserByName' = OperationID, - logic_handler = LogicHandler - } -) -> - {true, Req0, State}; -is_authorized( - Req0, - State = #state{ - operation_id = 'LoginUser' = OperationID, - logic_handler = LogicHandler - } -) -> - {true, Req0, State}; -is_authorized( - Req0, - State = #state{ - operation_id = 'LogoutUser' = OperationID, - logic_handler = LogicHandler - } -) -> - {true, Req0, State}; -is_authorized( - Req0, - State = #state{ - operation_id = 'UpdateUser' = OperationID, - logic_handler = LogicHandler - } -) -> - {true, Req0, State}; is_authorized(Req, State) -> - {{false, <<"">>}, Req, State}. + {true, Req, State}. -spec content_types_accepted(Req :: cowboy_req:req(), State :: state()) -> { From 044bfdac399007afbe6f04d210d52a3c4cb12af8 Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Tue, 24 Oct 2017 20:10:03 -0700 Subject: [PATCH 19/28] Fix #6166 by adding @Deprecated annotations in Java jersey2, okhttp-gson, resteasy libraries (#6801) --- .../src/main/resources/Java/api.mustache | 5 +- .../Java/libraries/jersey2/api.mustache | 5 +- .../Java/libraries/okhttp-gson/api.mustache | 41 +++- .../Java/libraries/resteasy/api.mustache | 5 +- .../java/io/swagger/client/api/FakeApi.java | 12 ++ .../petstore/java/jersey1/docs/FakeApi.md | 45 ++++ .../java/io/swagger/client/api/FakeApi.java | 41 ++++ .../java/io/swagger/client/api/PetApi.java | 3 +- .../java/jersey2-java6/docs/FakeApi.md | 45 ++++ .../java/io/swagger/client/api/FakeApi.java | 40 ++++ .../java/io/swagger/client/api/PetApi.java | 3 +- .../java/jersey2-java8/docs/FakeApi.md | 45 ++++ .../java/io/swagger/client/api/FakeApi.java | 40 ++++ .../java/io/swagger/client/api/PetApi.java | 3 +- .../model/AdditionalPropertiesClass.java | 4 +- .../model/ArrayOfArrayOfNumberOnly.java | 2 +- .../client/model/ArrayOfNumberOnly.java | 2 +- .../io/swagger/client/model/ArrayTest.java | 6 +- .../io/swagger/client/model/EnumArrays.java | 2 +- .../java/io/swagger/client/model/MapTest.java | 4 +- ...ropertiesAndAdditionalPropertiesClass.java | 2 +- .../java/io/swagger/client/model/Pet.java | 4 +- .../petstore/java/jersey2/docs/FakeApi.md | 45 ++++ .../java/io/swagger/client/api/FakeApi.java | 40 ++++ .../java/io/swagger/client/api/PetApi.java | 3 +- .../docs/FakeApi.md | 45 ++++ .../io/swagger/client/api/AnotherFakeApi.java | 10 +- .../java/io/swagger/client/api/FakeApi.java | 198 +++++++++++++----- .../client/api/FakeClassnameTags123Api.java | 10 +- .../java/io/swagger/client/api/PetApi.java | 89 +++----- .../java/io/swagger/client/api/StoreApi.java | 40 ++-- .../java/io/swagger/client/api/UserApi.java | 80 +++---- .../petstore/java/okhttp-gson/docs/FakeApi.md | 45 ++++ .../io/swagger/client/api/AnotherFakeApi.java | 10 +- .../java/io/swagger/client/api/FakeApi.java | 198 +++++++++++++----- .../client/api/FakeClassnameTags123Api.java | 10 +- .../java/io/swagger/client/api/PetApi.java | 89 +++----- .../java/io/swagger/client/api/StoreApi.java | 40 ++-- .../java/io/swagger/client/api/UserApi.java | 80 +++---- .../petstore/java/resteasy/docs/FakeApi.md | 45 ++++ .../java/io/swagger/client/api/FakeApi.java | 40 ++++ .../java/io/swagger/client/api/PetApi.java | 3 +- .../java/resttemplate-withXml/docs/FakeApi.md | 45 ++++ .../java/io/swagger/client/api/FakeApi.java | 33 +++ .../java/resttemplate/docs/FakeApi.md | 45 ++++ .../java/io/swagger/client/api/FakeApi.java | 33 +++ .../java/io/swagger/client/api/FakeApi.java | 24 +++ .../java/retrofit2-play24/build.gradle | 2 + .../petstore/java/retrofit2-play24/build.sbt | 1 + .../java/retrofit2-play24/docs/FakeApi.md | 46 ++++ .../petstore/java/retrofit2-play24/pom.xml | 6 + .../java/io/swagger/client/api/FakeApi.java | 14 ++ .../model/AdditionalPropertiesClass.java | 4 +- .../model/ArrayOfArrayOfNumberOnly.java | 2 +- .../client/model/ArrayOfNumberOnly.java | 2 +- .../io/swagger/client/model/ArrayTest.java | 6 +- .../io/swagger/client/model/EnumArrays.java | 2 +- .../java/io/swagger/client/model/MapTest.java | 4 +- ...ropertiesAndAdditionalPropertiesClass.java | 2 +- .../java/io/swagger/client/model/Pet.java | 4 +- .../petstore/java/retrofit2/docs/FakeApi.md | 46 ++++ .../java/io/swagger/client/api/FakeApi.java | 14 ++ .../petstore/java/retrofit2rx/build.gradle | 2 + .../petstore/java/retrofit2rx/build.sbt | 1 + .../petstore/java/retrofit2rx/docs/FakeApi.md | 46 ++++ .../client/petstore/java/retrofit2rx/pom.xml | 6 + .../java/io/swagger/client/ApiClient.java | 2 + .../src/main/java/io/swagger/client/JSON.java | 43 +++- .../java/io/swagger/client/api/FakeApi.java | 14 ++ .../petstore/java/retrofit2rx2/build.gradle | 2 + .../petstore/java/retrofit2rx2/build.sbt | 1 + .../java/retrofit2rx2/docs/FakeApi.md | 46 ++++ .../client/petstore/java/retrofit2rx2/pom.xml | 6 + .../java/io/swagger/client/ApiClient.java | 2 + .../src/main/java/io/swagger/client/JSON.java | 43 +++- .../java/io/swagger/client/api/FakeApi.java | 14 ++ 76 files changed, 1577 insertions(+), 465 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/api.mustache b/modules/swagger-codegen/src/main/resources/Java/api.mustache index a8224d1579bc..542ccbba287c 100644 --- a/modules/swagger-codegen/src/main/resources/Java/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/api.mustache @@ -53,13 +53,16 @@ public class {{classname}} { {{/returnType}} * @throws ApiException if fails to make API call {{#isDeprecated}} - * @Deprecated + * @deprecated {{/isDeprecated}} {{#externalDocs}} * {{description}} * @see {{summary}} Documentation {{/externalDocs}} */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; {{#allParams}}{{#required}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache index ce026ab79e4a..dd84a7dbd318 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache @@ -50,13 +50,16 @@ public class {{classname}} { {{/returnType}} * @throws ApiException if fails to make API call {{#isDeprecated}} - * @Deprecated + * @deprecated {{/isDeprecated}} {{#externalDocs}} * {{description}} * @see {{summary}} Documentation {{/externalDocs}} */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; {{#allParams}}{{#required}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache index a5241d8acaed..ffc68bc7b5a6 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache @@ -70,14 +70,20 @@ public class {{classname}} { * @param progressRequestListener Progress request listener * @return Call to execute * @throws ApiException If fail to serialize the request body object + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} {{#externalDocs}} * {{description}} * @see {{summary}} Documentation {{/externalDocs}} */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} public com.squareup.okhttp.Call {{operationId}}Call({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; - + // create path and map variables String {{localVariablePrefix}}localVarPath = "{{{path}}}"{{#pathParams}} .replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; @@ -122,7 +128,10 @@ public class {{classname}} { String[] {{localVariablePrefix}}localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; return {{localVariablePrefix}}apiClient.buildCall({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarCollectionQueryParams, {{localVariablePrefix}}localVarPostBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAuthNames, progressRequestListener); } - + + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call {{operationId}}ValidateBeforeCall({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { {{^performBeanValidation}} @@ -132,7 +141,7 @@ public class {{classname}} { throw new ApiException("Missing the required parameter '{{paramName}}' when calling {{operationId}}(Async)"); } {{/required}}{{/allParams}} - + com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}progressListener, progressRequestListener); return {{localVariablePrefix}}call; @@ -150,7 +159,7 @@ public class {{classname}} { if (violations.size() == 0) { com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}progressListener, progressRequestListener); return {{localVariablePrefix}}call; - + } else { throw new BeanValidationException((Set) violations); } @@ -161,12 +170,8 @@ public class {{classname}} { e.printStackTrace(); throw new ApiException(e.getMessage()); } - + {{/performBeanValidation}} - - - - } /** @@ -175,11 +180,17 @@ public class {{classname}} { * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}{{#returnType}} * @return {{returnType}}{{/returnType}} * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} {{#externalDocs}} * {{description}} * @see {{summary}} Documentation {{/externalDocs}} */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { {{#returnType}}ApiResponse<{{{returnType}}}> {{localVariablePrefix}}resp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} return {{localVariablePrefix}}resp.getData();{{/returnType}} @@ -191,11 +202,17 @@ public class {{classname}} { * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}} * @return ApiResponse<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} {{#externalDocs}} * {{description}} * @see {{summary}} Documentation {{/externalDocs}} */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}null, null); {{#returnType}}Type {{localVariablePrefix}}localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType(); @@ -209,11 +226,17 @@ public class {{classname}} { * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} {{#externalDocs}} * {{description}} * @see {{summary}} Documentation {{/externalDocs}} */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} public com.squareup.okhttp.Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{localVariablePrefix}}callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/resteasy/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/resteasy/api.mustache index 76eeea1e1ec5..f3fd01ed61b1 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/resteasy/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/resteasy/api.mustache @@ -46,13 +46,16 @@ public class {{classname}} { * @return {{{returnType}}}{{/returnType}} * @throws ApiException if fails to make API call {{#isDeprecated}} - * @Deprecated + * @deprecated {{/isDeprecated}} {{#externalDocs}} * {{description}} * @see {{summary}} Documentation {{/externalDocs}} */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; {{#allParams}}{{#required}} diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java index b757d44bbe9d..613e8a22fe60 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java @@ -181,6 +181,18 @@ public interface FakeApi extends ApiClient.Api { } } + /** + * test inline additionalProperties + * + * @param param request body (required) + */ + @RequestLine("POST /fake/inline-additionalProperties") + @Headers({ + "Content-Type: application/json", + "Accept: application/json", + }) + void testInlineAdditionalProperties(Object param); + /** * test json serialization of form data * diff --git a/samples/client/petstore/java/jersey1/docs/FakeApi.md b/samples/client/petstore/java/jersey1/docs/FakeApi.md index 0418b476a665..88bb107629e4 100644 --- a/samples/client/petstore/java/jersey1/docs/FakeApi.md +++ b/samples/client/petstore/java/jersey1/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -376,6 +377,50 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + apiInstance.testInlineAdditionalProperties(param); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/api/FakeApi.java index f5df2bb813f4..267fd5c8bdac 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/api/FakeApi.java @@ -395,6 +395,47 @@ if (enumQueryDouble != null) apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } + /** + * test inline additionalProperties + * + * @param param request body (required) + * @throws ApiException if fails to make API call + */ + public void testInlineAdditionalProperties(Object param) throws ApiException { + Object localVarPostBody = param; + + // verify the required parameter 'param' is set + if (param == null) { + throw new ApiException(400, "Missing the required parameter 'param' when calling testInlineAdditionalProperties"); + } + + // create path and map variables + String localVarPath = "/fake/inline-additionalProperties"; + + // query params + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + } /** * test json serialization of form data * diff --git a/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/api/PetApi.java index 797c9aaf563e..edd3fb248852 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/api/PetApi.java @@ -185,8 +185,9 @@ public class PetApi { * @param tags Tags to filter by (required) * @return List<Pet> * @throws ApiException if fails to make API call - * @Deprecated + * @deprecated */ + @Deprecated public List findPetsByTags(List tags) throws ApiException { Object localVarPostBody = null; diff --git a/samples/client/petstore/java/jersey2-java6/docs/FakeApi.md b/samples/client/petstore/java/jersey2-java6/docs/FakeApi.md index 0418b476a665..88bb107629e4 100644 --- a/samples/client/petstore/java/jersey2-java6/docs/FakeApi.md +++ b/samples/client/petstore/java/jersey2-java6/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -376,6 +377,50 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + apiInstance.testInlineAdditionalProperties(param); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/FakeApi.java index f810edcd3d1d..2980f8bb1fa9 100644 --- a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/FakeApi.java @@ -374,6 +374,46 @@ if (enumQueryDouble != null) apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } + /** + * test inline additionalProperties + * + * @param param request body (required) + * @throws ApiException if fails to make API call + */ + public void testInlineAdditionalProperties(Object param) throws ApiException { + Object localVarPostBody = param; + + // verify the required parameter 'param' is set + if (param == null) { + throw new ApiException(400, "Missing the required parameter 'param' when calling testInlineAdditionalProperties"); + } + + // create path and map variables + String localVarPath = "/fake/inline-additionalProperties"; + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + } /** * test json serialization of form data * diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/PetApi.java index abac5af4ad02..6af9763779c5 100644 --- a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/PetApi.java @@ -168,8 +168,9 @@ public class PetApi { * @param tags Tags to filter by (required) * @return List<Pet> * @throws ApiException if fails to make API call - * @Deprecated + * @deprecated */ + @Deprecated public List findPetsByTags(List tags) throws ApiException { Object localVarPostBody = null; diff --git a/samples/client/petstore/java/jersey2-java8/docs/FakeApi.md b/samples/client/petstore/java/jersey2-java8/docs/FakeApi.md index 0418b476a665..88bb107629e4 100644 --- a/samples/client/petstore/java/jersey2-java8/docs/FakeApi.md +++ b/samples/client/petstore/java/jersey2-java8/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -376,6 +377,50 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + apiInstance.testInlineAdditionalProperties(param); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/FakeApi.java index 086b22fe49c7..250114eb2569 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/FakeApi.java @@ -374,6 +374,46 @@ if (enumQueryDouble != null) apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } + /** + * test inline additionalProperties + * + * @param param request body (required) + * @throws ApiException if fails to make API call + */ + public void testInlineAdditionalProperties(Object param) throws ApiException { + Object localVarPostBody = param; + + // verify the required parameter 'param' is set + if (param == null) { + throw new ApiException(400, "Missing the required parameter 'param' when calling testInlineAdditionalProperties"); + } + + // create path and map variables + String localVarPath = "/fake/inline-additionalProperties"; + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + } /** * test json serialization of form data * diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/PetApi.java index abac5af4ad02..6af9763779c5 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/PetApi.java @@ -168,8 +168,9 @@ public class PetApi { * @param tags Tags to filter by (required) * @return List<Pet> * @throws ApiException if fails to make API call - * @Deprecated + * @deprecated */ + @Deprecated public List findPetsByTags(List tags) throws ApiException { Object localVarPostBody = null; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java index 7fe69e168fd3..0c24badae383 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java @@ -41,7 +41,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapPropertyItem(String key, String mapPropertyItem) { if (this.mapProperty == null) { - this.mapProperty = new HashMap(); + this.mapProperty = new HashMap<>(); } this.mapProperty.put(key, mapPropertyItem); return this; @@ -67,7 +67,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapOfMapPropertyItem(String key, Map mapOfMapPropertyItem) { if (this.mapOfMapProperty == null) { - this.mapOfMapProperty = new HashMap>(); + this.mapOfMapProperty = new HashMap<>(); } this.mapOfMapProperty.put(key, mapOfMapPropertyItem); return this; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java index b7e59a030a41..5997b31cbd44 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java @@ -38,7 +38,7 @@ public class ArrayOfArrayOfNumberOnly { public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { if (this.arrayArrayNumber == null) { - this.arrayArrayNumber = new ArrayList>(); + this.arrayArrayNumber = new ArrayList<>(); } this.arrayArrayNumber.add(arrayArrayNumberItem); return this; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java index fdfeb6856f31..2bc17f88eb3e 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java @@ -38,7 +38,7 @@ public class ArrayOfNumberOnly { public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { if (this.arrayNumber == null) { - this.arrayNumber = new ArrayList(); + this.arrayNumber = new ArrayList<>(); } this.arrayNumber.add(arrayNumberItem); return this; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayTest.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayTest.java index 62665c2536a5..6804a14e3139 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayTest.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayTest.java @@ -44,7 +44,7 @@ public class ArrayTest { public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { if (this.arrayOfString == null) { - this.arrayOfString = new ArrayList(); + this.arrayOfString = new ArrayList<>(); } this.arrayOfString.add(arrayOfStringItem); return this; @@ -70,7 +70,7 @@ public class ArrayTest { public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { if (this.arrayArrayOfInteger == null) { - this.arrayArrayOfInteger = new ArrayList>(); + this.arrayArrayOfInteger = new ArrayList<>(); } this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); return this; @@ -96,7 +96,7 @@ public class ArrayTest { public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { if (this.arrayArrayOfModel == null) { - this.arrayArrayOfModel = new ArrayList>(); + this.arrayArrayOfModel = new ArrayList<>(); } this.arrayArrayOfModel.add(arrayArrayOfModelItem); return this; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumArrays.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumArrays.java index 12caa4802856..133a31f10b90 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumArrays.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumArrays.java @@ -128,7 +128,7 @@ public class EnumArrays { public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { if (this.arrayEnum == null) { - this.arrayEnum = new ArrayList(); + this.arrayEnum = new ArrayList<>(); } this.arrayEnum.add(arrayEnumItem); return this; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MapTest.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MapTest.java index e6344a1df0fb..31a7dae7253e 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MapTest.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MapTest.java @@ -76,7 +76,7 @@ public class MapTest { public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { if (this.mapMapOfString == null) { - this.mapMapOfString = new HashMap>(); + this.mapMapOfString = new HashMap<>(); } this.mapMapOfString.put(key, mapMapOfStringItem); return this; @@ -102,7 +102,7 @@ public class MapTest { public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { if (this.mapOfEnumString == null) { - this.mapOfEnumString = new HashMap(); + this.mapOfEnumString = new HashMap<>(); } this.mapOfEnumString.put(key, mapOfEnumStringItem); return this; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java index b0736f316e39..98c2ad2cc788 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -83,7 +83,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass { public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { if (this.map == null) { - this.map = new HashMap(); + this.map = new HashMap<>(); } this.map.put(key, mapItem); return this; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Pet.java index 4c351dec3e4c..6ece90bbfc35 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Pet.java @@ -39,7 +39,7 @@ public class Pet { private String name = null; @JsonProperty("photoUrls") - private List photoUrls = new ArrayList(); + private List photoUrls = new ArrayList<>(); @JsonProperty("tags") private List tags = null; @@ -168,7 +168,7 @@ public class Pet { public Pet addTagsItem(Tag tagsItem) { if (this.tags == null) { - this.tags = new ArrayList(); + this.tags = new ArrayList<>(); } this.tags.add(tagsItem); return this; diff --git a/samples/client/petstore/java/jersey2/docs/FakeApi.md b/samples/client/petstore/java/jersey2/docs/FakeApi.md index 0418b476a665..88bb107629e4 100644 --- a/samples/client/petstore/java/jersey2/docs/FakeApi.md +++ b/samples/client/petstore/java/jersey2/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -376,6 +377,50 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + apiInstance.testInlineAdditionalProperties(param); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java index f810edcd3d1d..2980f8bb1fa9 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java @@ -374,6 +374,46 @@ if (enumQueryDouble != null) apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } + /** + * test inline additionalProperties + * + * @param param request body (required) + * @throws ApiException if fails to make API call + */ + public void testInlineAdditionalProperties(Object param) throws ApiException { + Object localVarPostBody = param; + + // verify the required parameter 'param' is set + if (param == null) { + throw new ApiException(400, "Missing the required parameter 'param' when calling testInlineAdditionalProperties"); + } + + // create path and map variables + String localVarPath = "/fake/inline-additionalProperties"; + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + } /** * test json serialization of form data * diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java index abac5af4ad02..6af9763779c5 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -168,8 +168,9 @@ public class PetApi { * @param tags Tags to filter by (required) * @return List<Pet> * @throws ApiException if fails to make API call - * @Deprecated + * @deprecated */ + @Deprecated public List findPetsByTags(List tags) throws ApiException { Object localVarPostBody = null; diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md b/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md index 0418b476a665..88bb107629e4 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -376,6 +377,50 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + apiInstance.testInlineAdditionalProperties(param); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/AnotherFakeApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/AnotherFakeApi.java index e11d4d1a4d02..e8abc4b61d6c 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/AnotherFakeApi.java @@ -64,7 +64,7 @@ public class AnotherFakeApi { */ public com.squareup.okhttp.Call testSpecialTagsCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/another-fake/dummy"; @@ -102,7 +102,7 @@ public class AnotherFakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call testSpecialTagsValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -111,14 +111,10 @@ public class AnotherFakeApi { throw new ApiException("Missing the required parameter 'body' when calling testSpecialTags(Async)"); } - + com.squareup.okhttp.Call call = testSpecialTagsCall(body, progressListener, progressRequestListener); return call; - - - - } /** diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/FakeApi.java index 6cf5cae059ea..beb9cb1f8ff9 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/FakeApi.java @@ -68,7 +68,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call fakeOuterBooleanSerializeCall(Boolean body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/fake/outer/boolean"; @@ -106,18 +106,14 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call fakeOuterBooleanSerializeValidateBeforeCall(Boolean body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = fakeOuterBooleanSerializeCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -189,7 +185,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call fakeOuterCompositeSerializeCall(OuterComposite body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/fake/outer/composite"; @@ -227,18 +223,14 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call fakeOuterCompositeSerializeValidateBeforeCall(OuterComposite body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = fakeOuterCompositeSerializeCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -310,7 +302,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call fakeOuterNumberSerializeCall(BigDecimal body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/fake/outer/number"; @@ -348,18 +340,14 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call fakeOuterNumberSerializeValidateBeforeCall(BigDecimal body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = fakeOuterNumberSerializeCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -431,7 +419,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call fakeOuterStringSerializeCall(String body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/fake/outer/string"; @@ -469,18 +457,14 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call fakeOuterStringSerializeValidateBeforeCall(String body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = fakeOuterStringSerializeCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -552,7 +536,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call testClientModelCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/fake"; @@ -590,7 +574,7 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call testClientModelValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -599,14 +583,10 @@ public class FakeApi { throw new ApiException("Missing the required parameter 'body' when calling testClientModel(Async)"); } - + com.squareup.okhttp.Call call = testClientModelCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -691,7 +671,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call testEndpointParametersCall(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/fake"; @@ -757,7 +737,7 @@ public class FakeApi { String[] localVarAuthNames = new String[] { "http_basic_test" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call testEndpointParametersValidateBeforeCall(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -781,14 +761,10 @@ public class FakeApi { throw new ApiException("Missing the required parameter '_byte' when calling testEndpointParameters(Async)"); } - + com.squareup.okhttp.Call call = testEndpointParametersCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, progressListener, progressRequestListener); return call; - - - - } /** @@ -902,7 +878,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call testEnumParametersCall(List enumFormStringArray, String enumFormString, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/fake"; @@ -956,18 +932,14 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call testEnumParametersValidateBeforeCall(List enumFormStringArray, String enumFormString, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = testEnumParametersCall(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, progressListener, progressRequestListener); return call; - - - - } /** @@ -1046,6 +1018,124 @@ public class FakeApi { apiClient.executeAsync(call, callback); return call; } + /** + * Build call for testInlineAdditionalProperties + * @param param request body (required) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call testInlineAdditionalPropertiesCall(Object param, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = param; + + // create path and map variables + String localVarPath = "/fake/inline-additionalProperties"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call testInlineAdditionalPropertiesValidateBeforeCall(Object param, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'param' is set + if (param == null) { + throw new ApiException("Missing the required parameter 'param' when calling testInlineAdditionalProperties(Async)"); + } + + + com.squareup.okhttp.Call call = testInlineAdditionalPropertiesCall(param, progressListener, progressRequestListener); + return call; + + } + + /** + * test inline additionalProperties + * + * @param param request body (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void testInlineAdditionalProperties(Object param) throws ApiException { + testInlineAdditionalPropertiesWithHttpInfo(param); + } + + /** + * test inline additionalProperties + * + * @param param request body (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse testInlineAdditionalPropertiesWithHttpInfo(Object param) throws ApiException { + com.squareup.okhttp.Call call = testInlineAdditionalPropertiesValidateBeforeCall(param, null, null); + return apiClient.execute(call); + } + + /** + * test inline additionalProperties (asynchronously) + * + * @param param request body (required) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call testInlineAdditionalPropertiesAsync(Object param, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = testInlineAdditionalPropertiesValidateBeforeCall(param, progressListener, progressRequestListener); + apiClient.executeAsync(call, callback); + return call; + } /** * Build call for testJsonFormData * @param param field1 (required) @@ -1057,7 +1147,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call testJsonFormDataCall(String param, String param2, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/fake/jsonFormData"; @@ -1099,7 +1189,7 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call testJsonFormDataValidateBeforeCall(String param, String param2, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -1113,14 +1203,10 @@ public class FakeApi { throw new ApiException("Missing the required parameter 'param2' when calling testJsonFormData(Async)"); } - + com.squareup.okhttp.Call call = testJsonFormDataCall(param, param2, progressListener, progressRequestListener); return call; - - - - } /** diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java index da29f1c830c5..cd516030e2c2 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java @@ -64,7 +64,7 @@ public class FakeClassnameTags123Api { */ public com.squareup.okhttp.Call testClassnameCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/fake_classname_test"; @@ -102,7 +102,7 @@ public class FakeClassnameTags123Api { String[] localVarAuthNames = new String[] { "api_key_query" }; return apiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call testClassnameValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -111,14 +111,10 @@ public class FakeClassnameTags123Api { throw new ApiException("Missing the required parameter 'body' when calling testClassname(Async)"); } - + com.squareup.okhttp.Call call = testClassnameCall(body, progressListener, progressRequestListener); return call; - - - - } /** diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/PetApi.java index e375ad58a345..23b9049e61b7 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/PetApi.java @@ -66,7 +66,7 @@ public class PetApi { */ public com.squareup.okhttp.Call addPetCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/pet"; @@ -104,7 +104,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call addPetValidateBeforeCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -113,14 +113,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'body' when calling addPet(Async)"); } - + com.squareup.okhttp.Call call = addPetCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -189,7 +185,7 @@ public class PetApi { */ public com.squareup.okhttp.Call deletePetCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/pet/{petId}" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); @@ -230,7 +226,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call deletePetValidateBeforeCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -239,14 +235,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'petId' when calling deletePet(Async)"); } - + com.squareup.okhttp.Call call = deletePetCall(petId, apiKey, progressListener, progressRequestListener); return call; - - - - } /** @@ -317,7 +309,7 @@ public class PetApi { */ public com.squareup.okhttp.Call findPetsByStatusCall(List status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/pet/findByStatus"; @@ -357,7 +349,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call findPetsByStatusValidateBeforeCall(List status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -366,14 +358,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'status' when calling findPetsByStatus(Async)"); } - + com.squareup.okhttp.Call call = findPetsByStatusCall(status, progressListener, progressRequestListener); return call; - - - - } /** @@ -442,10 +430,12 @@ public class PetApi { * @param progressRequestListener Progress request listener * @return Call to execute * @throws ApiException If fail to serialize the request body object + * @deprecated */ + @Deprecated public com.squareup.okhttp.Call findPetsByTagsCall(List tags, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/pet/findByTags"; @@ -485,7 +475,8 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + + @Deprecated @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call findPetsByTagsValidateBeforeCall(List tags, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -494,14 +485,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'tags' when calling findPetsByTags(Async)"); } - + com.squareup.okhttp.Call call = findPetsByTagsCall(tags, progressListener, progressRequestListener); return call; - - - - } /** @@ -510,7 +497,9 @@ public class PetApi { * @param tags Tags to filter by (required) * @return List<Pet> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @deprecated */ + @Deprecated public List findPetsByTags(List tags) throws ApiException { ApiResponse> resp = findPetsByTagsWithHttpInfo(tags); return resp.getData(); @@ -522,7 +511,9 @@ public class PetApi { * @param tags Tags to filter by (required) * @return ApiResponse<List<Pet>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @deprecated */ + @Deprecated public ApiResponse> findPetsByTagsWithHttpInfo(List tags) throws ApiException { com.squareup.okhttp.Call call = findPetsByTagsValidateBeforeCall(tags, null, null); Type localVarReturnType = new TypeToken>(){}.getType(); @@ -536,7 +527,9 @@ public class PetApi { * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @deprecated */ + @Deprecated public com.squareup.okhttp.Call findPetsByTagsAsync(List tags, final ApiCallback> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; @@ -573,7 +566,7 @@ public class PetApi { */ public com.squareup.okhttp.Call getPetByIdCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/pet/{petId}" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); @@ -612,7 +605,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "api_key" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call getPetByIdValidateBeforeCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -621,14 +614,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'petId' when calling getPetById(Async)"); } - + com.squareup.okhttp.Call call = getPetByIdCall(petId, progressListener, progressRequestListener); return call; - - - - } /** @@ -700,7 +689,7 @@ public class PetApi { */ public com.squareup.okhttp.Call updatePetCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/pet"; @@ -738,7 +727,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call updatePetValidateBeforeCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -747,14 +736,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'body' when calling updatePet(Async)"); } - + com.squareup.okhttp.Call call = updatePetCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -824,7 +809,7 @@ public class PetApi { */ public com.squareup.okhttp.Call updatePetWithFormCall(Long petId, String name, String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/pet/{petId}" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); @@ -867,7 +852,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call updatePetWithFormValidateBeforeCall(Long petId, String name, String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -876,14 +861,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'petId' when calling updatePetWithForm(Async)"); } - + com.squareup.okhttp.Call call = updatePetWithFormCall(petId, name, status, progressListener, progressRequestListener); return call; - - - - } /** @@ -959,7 +940,7 @@ public class PetApi { */ public com.squareup.okhttp.Call uploadFileCall(Long petId, String additionalMetadata, File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/pet/{petId}/uploadImage" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); @@ -1002,7 +983,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call uploadFileValidateBeforeCall(Long petId, String additionalMetadata, File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -1011,14 +992,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'petId' when calling uploadFile(Async)"); } - + com.squareup.okhttp.Call call = uploadFileCall(petId, additionalMetadata, file, progressListener, progressRequestListener); return call; - - - - } /** diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/StoreApi.java index 29d757735aab..a517a459d797 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/StoreApi.java @@ -64,7 +64,7 @@ public class StoreApi { */ public com.squareup.okhttp.Call deleteOrderCall(String orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/store/order/{order_id}" .replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString())); @@ -103,7 +103,7 @@ public class StoreApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call deleteOrderValidateBeforeCall(String orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -112,14 +112,10 @@ public class StoreApi { throw new ApiException("Missing the required parameter 'orderId' when calling deleteOrder(Async)"); } - + com.squareup.okhttp.Call call = deleteOrderCall(orderId, progressListener, progressRequestListener); return call; - - - - } /** @@ -186,7 +182,7 @@ public class StoreApi { */ public com.squareup.okhttp.Call getInventoryCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/store/inventory"; @@ -224,18 +220,14 @@ public class StoreApi { String[] localVarAuthNames = new String[] { "api_key" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call getInventoryValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = getInventoryCall(progressListener, progressRequestListener); return call; - - - - } /** @@ -304,7 +296,7 @@ public class StoreApi { */ public com.squareup.okhttp.Call getOrderByIdCall(Long orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/store/order/{order_id}" .replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString())); @@ -343,7 +335,7 @@ public class StoreApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call getOrderByIdValidateBeforeCall(Long orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -352,14 +344,10 @@ public class StoreApi { throw new ApiException("Missing the required parameter 'orderId' when calling getOrderById(Async)"); } - + com.squareup.okhttp.Call call = getOrderByIdCall(orderId, progressListener, progressRequestListener); return call; - - - - } /** @@ -431,7 +419,7 @@ public class StoreApi { */ public com.squareup.okhttp.Call placeOrderCall(Order body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/store/order"; @@ -469,7 +457,7 @@ public class StoreApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call placeOrderValidateBeforeCall(Order body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -478,14 +466,10 @@ public class StoreApi { throw new ApiException("Missing the required parameter 'body' when calling placeOrder(Async)"); } - + com.squareup.okhttp.Call call = placeOrderCall(body, progressListener, progressRequestListener); return call; - - - - } /** diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/UserApi.java index 1f38895790ca..d0f16373bec5 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/api/UserApi.java @@ -64,7 +64,7 @@ public class UserApi { */ public com.squareup.okhttp.Call createUserCall(User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/user"; @@ -102,7 +102,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call createUserValidateBeforeCall(User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -111,14 +111,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'body' when calling createUser(Async)"); } - + com.squareup.okhttp.Call call = createUserCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -186,7 +182,7 @@ public class UserApi { */ public com.squareup.okhttp.Call createUsersWithArrayInputCall(List body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/user/createWithArray"; @@ -224,7 +220,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call createUsersWithArrayInputValidateBeforeCall(List body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -233,14 +229,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'body' when calling createUsersWithArrayInput(Async)"); } - + com.squareup.okhttp.Call call = createUsersWithArrayInputCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -308,7 +300,7 @@ public class UserApi { */ public com.squareup.okhttp.Call createUsersWithListInputCall(List body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/user/createWithList"; @@ -346,7 +338,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call createUsersWithListInputValidateBeforeCall(List body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -355,14 +347,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'body' when calling createUsersWithListInput(Async)"); } - + com.squareup.okhttp.Call call = createUsersWithListInputCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -430,7 +418,7 @@ public class UserApi { */ public com.squareup.okhttp.Call deleteUserCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/user/{username}" .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); @@ -469,7 +457,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call deleteUserValidateBeforeCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -478,14 +466,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'username' when calling deleteUser(Async)"); } - + com.squareup.okhttp.Call call = deleteUserCall(username, progressListener, progressRequestListener); return call; - - - - } /** @@ -553,7 +537,7 @@ public class UserApi { */ public com.squareup.okhttp.Call getUserByNameCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/user/{username}" .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); @@ -592,7 +576,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call getUserByNameValidateBeforeCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -601,14 +585,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'username' when calling getUserByName(Async)"); } - + com.squareup.okhttp.Call call = getUserByNameCall(username, progressListener, progressRequestListener); return call; - - - - } /** @@ -681,7 +661,7 @@ public class UserApi { */ public com.squareup.okhttp.Call loginUserCall(String username, String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/user/login"; @@ -723,7 +703,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call loginUserValidateBeforeCall(String username, String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -737,14 +717,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'password' when calling loginUser(Async)"); } - + com.squareup.okhttp.Call call = loginUserCall(username, password, progressListener, progressRequestListener); return call; - - - - } /** @@ -818,7 +794,7 @@ public class UserApi { */ public com.squareup.okhttp.Call logoutUserCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/user/logout"; @@ -856,18 +832,14 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call logoutUserValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = logoutUserCall(progressListener, progressRequestListener); return call; - - - - } /** @@ -933,7 +905,7 @@ public class UserApi { */ public com.squareup.okhttp.Call updateUserCall(String username, User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/user/{username}" .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); @@ -972,7 +944,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call updateUserValidateBeforeCall(String username, User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -986,14 +958,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'body' when calling updateUser(Async)"); } - + com.squareup.okhttp.Call call = updateUserCall(username, body, progressListener, progressRequestListener); return call; - - - - } /** diff --git a/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md b/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md index 0418b476a665..88bb107629e4 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md +++ b/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -376,6 +377,50 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + apiInstance.testInlineAdditionalProperties(param); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/AnotherFakeApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/AnotherFakeApi.java index e11d4d1a4d02..e8abc4b61d6c 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/AnotherFakeApi.java @@ -64,7 +64,7 @@ public class AnotherFakeApi { */ public com.squareup.okhttp.Call testSpecialTagsCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/another-fake/dummy"; @@ -102,7 +102,7 @@ public class AnotherFakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call testSpecialTagsValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -111,14 +111,10 @@ public class AnotherFakeApi { throw new ApiException("Missing the required parameter 'body' when calling testSpecialTags(Async)"); } - + com.squareup.okhttp.Call call = testSpecialTagsCall(body, progressListener, progressRequestListener); return call; - - - - } /** diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java index 6cf5cae059ea..beb9cb1f8ff9 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java @@ -68,7 +68,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call fakeOuterBooleanSerializeCall(Boolean body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/fake/outer/boolean"; @@ -106,18 +106,14 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call fakeOuterBooleanSerializeValidateBeforeCall(Boolean body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = fakeOuterBooleanSerializeCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -189,7 +185,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call fakeOuterCompositeSerializeCall(OuterComposite body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/fake/outer/composite"; @@ -227,18 +223,14 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call fakeOuterCompositeSerializeValidateBeforeCall(OuterComposite body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = fakeOuterCompositeSerializeCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -310,7 +302,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call fakeOuterNumberSerializeCall(BigDecimal body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/fake/outer/number"; @@ -348,18 +340,14 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call fakeOuterNumberSerializeValidateBeforeCall(BigDecimal body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = fakeOuterNumberSerializeCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -431,7 +419,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call fakeOuterStringSerializeCall(String body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/fake/outer/string"; @@ -469,18 +457,14 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call fakeOuterStringSerializeValidateBeforeCall(String body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = fakeOuterStringSerializeCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -552,7 +536,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call testClientModelCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/fake"; @@ -590,7 +574,7 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call testClientModelValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -599,14 +583,10 @@ public class FakeApi { throw new ApiException("Missing the required parameter 'body' when calling testClientModel(Async)"); } - + com.squareup.okhttp.Call call = testClientModelCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -691,7 +671,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call testEndpointParametersCall(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/fake"; @@ -757,7 +737,7 @@ public class FakeApi { String[] localVarAuthNames = new String[] { "http_basic_test" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call testEndpointParametersValidateBeforeCall(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -781,14 +761,10 @@ public class FakeApi { throw new ApiException("Missing the required parameter '_byte' when calling testEndpointParameters(Async)"); } - + com.squareup.okhttp.Call call = testEndpointParametersCall(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback, progressListener, progressRequestListener); return call; - - - - } /** @@ -902,7 +878,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call testEnumParametersCall(List enumFormStringArray, String enumFormString, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/fake"; @@ -956,18 +932,14 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call testEnumParametersValidateBeforeCall(List enumFormStringArray, String enumFormString, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = testEnumParametersCall(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, progressListener, progressRequestListener); return call; - - - - } /** @@ -1046,6 +1018,124 @@ public class FakeApi { apiClient.executeAsync(call, callback); return call; } + /** + * Build call for testInlineAdditionalProperties + * @param param request body (required) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call testInlineAdditionalPropertiesCall(Object param, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = param; + + // create path and map variables + String localVarPath = "/fake/inline-additionalProperties"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call testInlineAdditionalPropertiesValidateBeforeCall(Object param, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + + // verify the required parameter 'param' is set + if (param == null) { + throw new ApiException("Missing the required parameter 'param' when calling testInlineAdditionalProperties(Async)"); + } + + + com.squareup.okhttp.Call call = testInlineAdditionalPropertiesCall(param, progressListener, progressRequestListener); + return call; + + } + + /** + * test inline additionalProperties + * + * @param param request body (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void testInlineAdditionalProperties(Object param) throws ApiException { + testInlineAdditionalPropertiesWithHttpInfo(param); + } + + /** + * test inline additionalProperties + * + * @param param request body (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse testInlineAdditionalPropertiesWithHttpInfo(Object param) throws ApiException { + com.squareup.okhttp.Call call = testInlineAdditionalPropertiesValidateBeforeCall(param, null, null); + return apiClient.execute(call); + } + + /** + * test inline additionalProperties (asynchronously) + * + * @param param request body (required) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public com.squareup.okhttp.Call testInlineAdditionalPropertiesAsync(Object param, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + com.squareup.okhttp.Call call = testInlineAdditionalPropertiesValidateBeforeCall(param, progressListener, progressRequestListener); + apiClient.executeAsync(call, callback); + return call; + } /** * Build call for testJsonFormData * @param param field1 (required) @@ -1057,7 +1147,7 @@ public class FakeApi { */ public com.squareup.okhttp.Call testJsonFormDataCall(String param, String param2, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/fake/jsonFormData"; @@ -1099,7 +1189,7 @@ public class FakeApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call testJsonFormDataValidateBeforeCall(String param, String param2, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -1113,14 +1203,10 @@ public class FakeApi { throw new ApiException("Missing the required parameter 'param2' when calling testJsonFormData(Async)"); } - + com.squareup.okhttp.Call call = testJsonFormDataCall(param, param2, progressListener, progressRequestListener); return call; - - - - } /** diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java index da29f1c830c5..cd516030e2c2 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java @@ -64,7 +64,7 @@ public class FakeClassnameTags123Api { */ public com.squareup.okhttp.Call testClassnameCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/fake_classname_test"; @@ -102,7 +102,7 @@ public class FakeClassnameTags123Api { String[] localVarAuthNames = new String[] { "api_key_query" }; return apiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call testClassnameValidateBeforeCall(Client body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -111,14 +111,10 @@ public class FakeClassnameTags123Api { throw new ApiException("Missing the required parameter 'body' when calling testClassname(Async)"); } - + com.squareup.okhttp.Call call = testClassnameCall(body, progressListener, progressRequestListener); return call; - - - - } /** diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java index e375ad58a345..23b9049e61b7 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java @@ -66,7 +66,7 @@ public class PetApi { */ public com.squareup.okhttp.Call addPetCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/pet"; @@ -104,7 +104,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call addPetValidateBeforeCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -113,14 +113,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'body' when calling addPet(Async)"); } - + com.squareup.okhttp.Call call = addPetCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -189,7 +185,7 @@ public class PetApi { */ public com.squareup.okhttp.Call deletePetCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/pet/{petId}" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); @@ -230,7 +226,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call deletePetValidateBeforeCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -239,14 +235,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'petId' when calling deletePet(Async)"); } - + com.squareup.okhttp.Call call = deletePetCall(petId, apiKey, progressListener, progressRequestListener); return call; - - - - } /** @@ -317,7 +309,7 @@ public class PetApi { */ public com.squareup.okhttp.Call findPetsByStatusCall(List status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/pet/findByStatus"; @@ -357,7 +349,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call findPetsByStatusValidateBeforeCall(List status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -366,14 +358,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'status' when calling findPetsByStatus(Async)"); } - + com.squareup.okhttp.Call call = findPetsByStatusCall(status, progressListener, progressRequestListener); return call; - - - - } /** @@ -442,10 +430,12 @@ public class PetApi { * @param progressRequestListener Progress request listener * @return Call to execute * @throws ApiException If fail to serialize the request body object + * @deprecated */ + @Deprecated public com.squareup.okhttp.Call findPetsByTagsCall(List tags, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/pet/findByTags"; @@ -485,7 +475,8 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + + @Deprecated @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call findPetsByTagsValidateBeforeCall(List tags, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -494,14 +485,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'tags' when calling findPetsByTags(Async)"); } - + com.squareup.okhttp.Call call = findPetsByTagsCall(tags, progressListener, progressRequestListener); return call; - - - - } /** @@ -510,7 +497,9 @@ public class PetApi { * @param tags Tags to filter by (required) * @return List<Pet> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @deprecated */ + @Deprecated public List findPetsByTags(List tags) throws ApiException { ApiResponse> resp = findPetsByTagsWithHttpInfo(tags); return resp.getData(); @@ -522,7 +511,9 @@ public class PetApi { * @param tags Tags to filter by (required) * @return ApiResponse<List<Pet>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @deprecated */ + @Deprecated public ApiResponse> findPetsByTagsWithHttpInfo(List tags) throws ApiException { com.squareup.okhttp.Call call = findPetsByTagsValidateBeforeCall(tags, null, null); Type localVarReturnType = new TypeToken>(){}.getType(); @@ -536,7 +527,9 @@ public class PetApi { * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @deprecated */ + @Deprecated public com.squareup.okhttp.Call findPetsByTagsAsync(List tags, final ApiCallback> callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; @@ -573,7 +566,7 @@ public class PetApi { */ public com.squareup.okhttp.Call getPetByIdCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/pet/{petId}" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); @@ -612,7 +605,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "api_key" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call getPetByIdValidateBeforeCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -621,14 +614,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'petId' when calling getPetById(Async)"); } - + com.squareup.okhttp.Call call = getPetByIdCall(petId, progressListener, progressRequestListener); return call; - - - - } /** @@ -700,7 +689,7 @@ public class PetApi { */ public com.squareup.okhttp.Call updatePetCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/pet"; @@ -738,7 +727,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call updatePetValidateBeforeCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -747,14 +736,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'body' when calling updatePet(Async)"); } - + com.squareup.okhttp.Call call = updatePetCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -824,7 +809,7 @@ public class PetApi { */ public com.squareup.okhttp.Call updatePetWithFormCall(Long petId, String name, String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/pet/{petId}" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); @@ -867,7 +852,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call updatePetWithFormValidateBeforeCall(Long petId, String name, String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -876,14 +861,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'petId' when calling updatePetWithForm(Async)"); } - + com.squareup.okhttp.Call call = updatePetWithFormCall(petId, name, status, progressListener, progressRequestListener); return call; - - - - } /** @@ -959,7 +940,7 @@ public class PetApi { */ public com.squareup.okhttp.Call uploadFileCall(Long petId, String additionalMetadata, File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/pet/{petId}/uploadImage" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); @@ -1002,7 +983,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call uploadFileValidateBeforeCall(Long petId, String additionalMetadata, File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -1011,14 +992,10 @@ public class PetApi { throw new ApiException("Missing the required parameter 'petId' when calling uploadFile(Async)"); } - + com.squareup.okhttp.Call call = uploadFileCall(petId, additionalMetadata, file, progressListener, progressRequestListener); return call; - - - - } /** diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java index 29d757735aab..a517a459d797 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java @@ -64,7 +64,7 @@ public class StoreApi { */ public com.squareup.okhttp.Call deleteOrderCall(String orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/store/order/{order_id}" .replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString())); @@ -103,7 +103,7 @@ public class StoreApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call deleteOrderValidateBeforeCall(String orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -112,14 +112,10 @@ public class StoreApi { throw new ApiException("Missing the required parameter 'orderId' when calling deleteOrder(Async)"); } - + com.squareup.okhttp.Call call = deleteOrderCall(orderId, progressListener, progressRequestListener); return call; - - - - } /** @@ -186,7 +182,7 @@ public class StoreApi { */ public com.squareup.okhttp.Call getInventoryCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/store/inventory"; @@ -224,18 +220,14 @@ public class StoreApi { String[] localVarAuthNames = new String[] { "api_key" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call getInventoryValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = getInventoryCall(progressListener, progressRequestListener); return call; - - - - } /** @@ -304,7 +296,7 @@ public class StoreApi { */ public com.squareup.okhttp.Call getOrderByIdCall(Long orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/store/order/{order_id}" .replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString())); @@ -343,7 +335,7 @@ public class StoreApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call getOrderByIdValidateBeforeCall(Long orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -352,14 +344,10 @@ public class StoreApi { throw new ApiException("Missing the required parameter 'orderId' when calling getOrderById(Async)"); } - + com.squareup.okhttp.Call call = getOrderByIdCall(orderId, progressListener, progressRequestListener); return call; - - - - } /** @@ -431,7 +419,7 @@ public class StoreApi { */ public com.squareup.okhttp.Call placeOrderCall(Order body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/store/order"; @@ -469,7 +457,7 @@ public class StoreApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call placeOrderValidateBeforeCall(Order body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -478,14 +466,10 @@ public class StoreApi { throw new ApiException("Missing the required parameter 'body' when calling placeOrder(Async)"); } - + com.squareup.okhttp.Call call = placeOrderCall(body, progressListener, progressRequestListener); return call; - - - - } /** diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java index 1f38895790ca..d0f16373bec5 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java @@ -64,7 +64,7 @@ public class UserApi { */ public com.squareup.okhttp.Call createUserCall(User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/user"; @@ -102,7 +102,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call createUserValidateBeforeCall(User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -111,14 +111,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'body' when calling createUser(Async)"); } - + com.squareup.okhttp.Call call = createUserCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -186,7 +182,7 @@ public class UserApi { */ public com.squareup.okhttp.Call createUsersWithArrayInputCall(List body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/user/createWithArray"; @@ -224,7 +220,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call createUsersWithArrayInputValidateBeforeCall(List body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -233,14 +229,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'body' when calling createUsersWithArrayInput(Async)"); } - + com.squareup.okhttp.Call call = createUsersWithArrayInputCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -308,7 +300,7 @@ public class UserApi { */ public com.squareup.okhttp.Call createUsersWithListInputCall(List body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/user/createWithList"; @@ -346,7 +338,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call createUsersWithListInputValidateBeforeCall(List body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -355,14 +347,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'body' when calling createUsersWithListInput(Async)"); } - + com.squareup.okhttp.Call call = createUsersWithListInputCall(body, progressListener, progressRequestListener); return call; - - - - } /** @@ -430,7 +418,7 @@ public class UserApi { */ public com.squareup.okhttp.Call deleteUserCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/user/{username}" .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); @@ -469,7 +457,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call deleteUserValidateBeforeCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -478,14 +466,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'username' when calling deleteUser(Async)"); } - + com.squareup.okhttp.Call call = deleteUserCall(username, progressListener, progressRequestListener); return call; - - - - } /** @@ -553,7 +537,7 @@ public class UserApi { */ public com.squareup.okhttp.Call getUserByNameCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/user/{username}" .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); @@ -592,7 +576,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call getUserByNameValidateBeforeCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -601,14 +585,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'username' when calling getUserByName(Async)"); } - + com.squareup.okhttp.Call call = getUserByNameCall(username, progressListener, progressRequestListener); return call; - - - - } /** @@ -681,7 +661,7 @@ public class UserApi { */ public com.squareup.okhttp.Call loginUserCall(String username, String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/user/login"; @@ -723,7 +703,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call loginUserValidateBeforeCall(String username, String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -737,14 +717,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'password' when calling loginUser(Async)"); } - + com.squareup.okhttp.Call call = loginUserCall(username, password, progressListener, progressRequestListener); return call; - - - - } /** @@ -818,7 +794,7 @@ public class UserApi { */ public com.squareup.okhttp.Call logoutUserCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - + // create path and map variables String localVarPath = "/user/logout"; @@ -856,18 +832,14 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call logoutUserValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - + com.squareup.okhttp.Call call = logoutUserCall(progressListener, progressRequestListener); return call; - - - - } /** @@ -933,7 +905,7 @@ public class UserApi { */ public com.squareup.okhttp.Call updateUserCall(String username, User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - + // create path and map variables String localVarPath = "/user/{username}" .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); @@ -972,7 +944,7 @@ public class UserApi { String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - + @SuppressWarnings("rawtypes") private com.squareup.okhttp.Call updateUserValidateBeforeCall(String username, User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { @@ -986,14 +958,10 @@ public class UserApi { throw new ApiException("Missing the required parameter 'body' when calling updateUser(Async)"); } - + com.squareup.okhttp.Call call = updateUserCall(username, body, progressListener, progressRequestListener); return call; - - - - } /** diff --git a/samples/client/petstore/java/resteasy/docs/FakeApi.md b/samples/client/petstore/java/resteasy/docs/FakeApi.md index 0418b476a665..88bb107629e4 100644 --- a/samples/client/petstore/java/resteasy/docs/FakeApi.md +++ b/samples/client/petstore/java/resteasy/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -376,6 +377,50 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + apiInstance.testInlineAdditionalProperties(param); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeApi.java index 8110632ad665..9a9757e898b0 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeApi.java @@ -374,6 +374,46 @@ if (enumQueryDouble != null) apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } + /** + * test inline additionalProperties + * + * @param param request body (required) + * @throws ApiException if fails to make API call + */ + public void testInlineAdditionalProperties(Object param) throws ApiException { + Object localVarPostBody = param; + + // verify the required parameter 'param' is set + if (param == null) { + throw new ApiException(400, "Missing the required parameter 'param' when calling testInlineAdditionalProperties"); + } + + // create path and map variables + String localVarPath = "/fake/inline-additionalProperties".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + } /** * test json serialization of form data * diff --git a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/PetApi.java index 61eddf5eff95..d95172a97410 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/PetApi.java @@ -168,8 +168,9 @@ public class PetApi { * @param tags Tags to filter by (required) * @return List * @throws ApiException if fails to make API call - * @Deprecated + * @deprecated */ + @Deprecated public List findPetsByTags(List tags) throws ApiException { Object localVarPostBody = null; diff --git a/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md b/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md index 0418b476a665..88bb107629e4 100644 --- a/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md +++ b/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -376,6 +377,50 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + apiInstance.testInlineAdditionalProperties(param); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/io/swagger/client/api/FakeApi.java index 8393e7097f14..768e7e8fc095 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/io/swagger/client/api/FakeApi.java @@ -340,6 +340,39 @@ public class FakeApi { ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } + /** + * test inline additionalProperties + * + *

200 - successful operation + * @param param request body + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public void testInlineAdditionalProperties(Object param) throws RestClientException { + Object postBody = param; + + // verify the required parameter 'param' is set + if (param == null) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'param' when calling testInlineAdditionalProperties"); + } + + String path = UriComponentsBuilder.fromPath("/fake/inline-additionalProperties").build().toUriString(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] accepts = { }; + final List accept = apiClient.selectHeaderAccept(accepts); + final String[] contentTypes = { + "application/json" + }; + final MediaType contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; + apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } /** * test json serialization of form data * diff --git a/samples/client/petstore/java/resttemplate/docs/FakeApi.md b/samples/client/petstore/java/resttemplate/docs/FakeApi.md index 0418b476a665..88bb107629e4 100644 --- a/samples/client/petstore/java/resttemplate/docs/FakeApi.md +++ b/samples/client/petstore/java/resttemplate/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -376,6 +377,50 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + apiInstance.testInlineAdditionalProperties(param); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java index 8393e7097f14..768e7e8fc095 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java @@ -340,6 +340,39 @@ public class FakeApi { ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } + /** + * test inline additionalProperties + * + *

200 - successful operation + * @param param request body + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public void testInlineAdditionalProperties(Object param) throws RestClientException { + Object postBody = param; + + // verify the required parameter 'param' is set + if (param == null) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'param' when calling testInlineAdditionalProperties"); + } + + String path = UriComponentsBuilder.fromPath("/fake/inline-additionalProperties").build().toUriString(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] accepts = { }; + final List accept = apiClient.selectHeaderAccept(accepts); + final String[] contentTypes = { + "application/json" + }; + final MediaType contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; + apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } /** * test json serialization of form data * diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java index c0ca330ddba0..07681e62c983 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java @@ -230,6 +230,30 @@ public interface FakeApi { void testEnumParameters( @retrofit.http.Field("enum_form_string_array") List enumFormStringArray, @retrofit.http.Field("enum_form_string") String enumFormString, @retrofit.http.Header("enum_header_string_array") List enumHeaderStringArray, @retrofit.http.Header("enum_header_string") String enumHeaderString, @retrofit.http.Query("enum_query_string_array") CSVParams enumQueryStringArray, @retrofit.http.Query("enum_query_string") String enumQueryString, @retrofit.http.Query("enum_query_integer") Integer enumQueryInteger, @retrofit.http.Field("enum_query_double") Double enumQueryDouble, Callback cb ); + /** + * test inline additionalProperties + * Sync method + * + * @param param request body (required) + * @return Void + */ + + @POST("/fake/inline-additionalProperties") + Void testInlineAdditionalProperties( + @retrofit.http.Body Object param + ); + + /** + * test inline additionalProperties + * Async method + * @param param request body (required) + * @param cb callback method + */ + + @POST("/fake/inline-additionalProperties") + void testInlineAdditionalProperties( + @retrofit.http.Body Object param, Callback cb + ); /** * test json serialization of form data * Sync method diff --git a/samples/client/petstore/java/retrofit2-play24/build.gradle b/samples/client/petstore/java/retrofit2-play24/build.gradle index dab54a7dba81..5ba5dc34efcf 100644 --- a/samples/client/petstore/java/retrofit2-play24/build.gradle +++ b/samples/client/petstore/java/retrofit2-play24/build.gradle @@ -100,6 +100,7 @@ ext { play_version = "2.4.11" swagger_annotations_version = "1.5.15" junit_version = "4.12" + json_fire_version = "1.8.0" } dependencies { @@ -108,6 +109,7 @@ dependencies { compile "com.squareup.retrofit2:converter-gson:$retrofit_version" compile "io.swagger:swagger-annotations:$swagger_annotations_version" compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version" + compile "io.gsonfire:gson-fire:$json_fire_version" compile "com.typesafe.play:play-java-ws_2.11:$play_version" compile "com.squareup.retrofit2:converter-jackson:$retrofit_version" compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" diff --git a/samples/client/petstore/java/retrofit2-play24/build.sbt b/samples/client/petstore/java/retrofit2-play24/build.sbt index e3323ddd04b7..9320633cf848 100644 --- a/samples/client/petstore/java/retrofit2-play24/build.sbt +++ b/samples/client/petstore/java/retrofit2-play24/build.sbt @@ -18,6 +18,7 @@ lazy val root = (project in file(".")). "com.squareup.retrofit2" % "converter-jackson" % "2.3.0" % "compile", "io.swagger" % "swagger-annotations" % "1.5.15" % "compile", "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile", + "io.gsonfire" % "gson-fire" % "1.8.0" % "compile", "junit" % "junit" % "4.12" % "test", "com.novocode" % "junit-interface" % "0.11" % "test" ) diff --git a/samples/client/petstore/java/retrofit2-play24/docs/FakeApi.md b/samples/client/petstore/java/retrofit2-play24/docs/FakeApi.md index 1467a2943d67..3eed01e889bf 100644 --- a/samples/client/petstore/java/retrofit2-play24/docs/FakeApi.md +++ b/samples/client/petstore/java/retrofit2-play24/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** fake/jsonFormData | test json serialization of form data @@ -378,6 +379,51 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> Void testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + Void result = apiInstance.testInlineAdditionalProperties(param); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +[**Void**](.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > Void testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/retrofit2-play24/pom.xml b/samples/client/petstore/java/retrofit2-play24/pom.xml index 9a72e7356fb8..0156fa1d293e 100644 --- a/samples/client/petstore/java/retrofit2-play24/pom.xml +++ b/samples/client/petstore/java/retrofit2-play24/pom.xml @@ -194,6 +194,11 @@ org.apache.oltu.oauth2.client ${oltu-version} + + io.gsonfire + gson-fire + ${gson-fire-version} + @@ -241,6 +246,7 @@ 1.8 ${java.version} ${java.version} + 1.8.0 1.5.15 2.6.6 2.4.11 diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/api/FakeApi.java index eb9240dfaef6..64649d8607a8 100644 --- a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/api/FakeApi.java @@ -126,6 +126,20 @@ public interface FakeApi { @retrofit2.http.Field("enum_form_string_array") List enumFormStringArray, @retrofit2.http.Field("enum_form_string") String enumFormString, @retrofit2.http.Header("enum_header_string_array") List enumHeaderStringArray, @retrofit2.http.Header("enum_header_string") String enumHeaderString, @retrofit2.http.Query("enum_query_string_array") CSVParams enumQueryStringArray, @retrofit2.http.Query("enum_query_string") String enumQueryString, @retrofit2.http.Query("enum_query_integer") Integer enumQueryInteger, @retrofit2.http.Field("enum_query_double") Double enumQueryDouble ); + /** + * test inline additionalProperties + * + * @param param request body (required) + * @return Call<Void> + */ + @Headers({ + "Content-Type:application/json" + }) + @POST("fake/inline-additionalProperties") + F.Promise> testInlineAdditionalProperties( + @retrofit2.http.Body Object param + ); + /** * test json serialization of form data * diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java index e2bb686e9354..f03052a0c413 100644 --- a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java +++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java @@ -43,7 +43,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapPropertyItem(String key, String mapPropertyItem) { if (this.mapProperty == null) { - this.mapProperty = new HashMap(); + this.mapProperty = new HashMap<>(); } this.mapProperty.put(key, mapPropertyItem); return this; @@ -69,7 +69,7 @@ public class AdditionalPropertiesClass { public AdditionalPropertiesClass putMapOfMapPropertyItem(String key, Map mapOfMapPropertyItem) { if (this.mapOfMapProperty == null) { - this.mapOfMapProperty = new HashMap>(); + this.mapOfMapProperty = new HashMap<>(); } this.mapOfMapProperty.put(key, mapOfMapPropertyItem); return this; diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java index 87d66e0750d8..a5f6292b7b43 100644 --- a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java +++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java @@ -40,7 +40,7 @@ public class ArrayOfArrayOfNumberOnly { public ArrayOfArrayOfNumberOnly addArrayArrayNumberItem(List arrayArrayNumberItem) { if (this.arrayArrayNumber == null) { - this.arrayArrayNumber = new ArrayList>(); + this.arrayArrayNumber = new ArrayList<>(); } this.arrayArrayNumber.add(arrayArrayNumberItem); return this; diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java index 50e094682194..443501f05983 100644 --- a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java +++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java @@ -40,7 +40,7 @@ public class ArrayOfNumberOnly { public ArrayOfNumberOnly addArrayNumberItem(BigDecimal arrayNumberItem) { if (this.arrayNumber == null) { - this.arrayNumber = new ArrayList(); + this.arrayNumber = new ArrayList<>(); } this.arrayNumber.add(arrayNumberItem); return this; diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/ArrayTest.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/ArrayTest.java index b944839bc471..4934689e7dca 100644 --- a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/ArrayTest.java +++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/ArrayTest.java @@ -46,7 +46,7 @@ public class ArrayTest { public ArrayTest addArrayOfStringItem(String arrayOfStringItem) { if (this.arrayOfString == null) { - this.arrayOfString = new ArrayList(); + this.arrayOfString = new ArrayList<>(); } this.arrayOfString.add(arrayOfStringItem); return this; @@ -72,7 +72,7 @@ public class ArrayTest { public ArrayTest addArrayArrayOfIntegerItem(List arrayArrayOfIntegerItem) { if (this.arrayArrayOfInteger == null) { - this.arrayArrayOfInteger = new ArrayList>(); + this.arrayArrayOfInteger = new ArrayList<>(); } this.arrayArrayOfInteger.add(arrayArrayOfIntegerItem); return this; @@ -99,7 +99,7 @@ public class ArrayTest { public ArrayTest addArrayArrayOfModelItem(List arrayArrayOfModelItem) { if (this.arrayArrayOfModel == null) { - this.arrayArrayOfModel = new ArrayList>(); + this.arrayArrayOfModel = new ArrayList<>(); } this.arrayArrayOfModel.add(arrayArrayOfModelItem); return this; diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/EnumArrays.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/EnumArrays.java index 2019cbae634b..f3cff0ea172c 100644 --- a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/EnumArrays.java +++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/EnumArrays.java @@ -130,7 +130,7 @@ public class EnumArrays { public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) { if (this.arrayEnum == null) { - this.arrayEnum = new ArrayList(); + this.arrayEnum = new ArrayList<>(); } this.arrayEnum.add(arrayEnumItem); return this; diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/MapTest.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/MapTest.java index 7c013ad8e69c..1a15255161d2 100644 --- a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/MapTest.java +++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/MapTest.java @@ -78,7 +78,7 @@ public class MapTest { public MapTest putMapMapOfStringItem(String key, Map mapMapOfStringItem) { if (this.mapMapOfString == null) { - this.mapMapOfString = new HashMap>(); + this.mapMapOfString = new HashMap<>(); } this.mapMapOfString.put(key, mapMapOfStringItem); return this; @@ -105,7 +105,7 @@ public class MapTest { public MapTest putMapOfEnumStringItem(String key, InnerEnum mapOfEnumStringItem) { if (this.mapOfEnumString == null) { - this.mapOfEnumString = new HashMap(); + this.mapOfEnumString = new HashMap<>(); } this.mapOfEnumString.put(key, mapOfEnumStringItem); return this; diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java index 44dba37c6aa5..01184029234c 100644 --- a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -87,7 +87,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass { public MixedPropertiesAndAdditionalPropertiesClass putMapItem(String key, Animal mapItem) { if (this.map == null) { - this.map = new HashMap(); + this.map = new HashMap<>(); } this.map.put(key, mapItem); return this; diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/Pet.java index 145360c48a9d..653a9765a661 100644 --- a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/Pet.java @@ -41,7 +41,7 @@ public class Pet { private String name = null; @JsonProperty("photoUrls") - private List photoUrls = new ArrayList(); + private List photoUrls = new ArrayList<>(); @JsonProperty("tags") private List tags = null; @@ -173,7 +173,7 @@ public class Pet { public Pet addTagsItem(Tag tagsItem) { if (this.tags == null) { - this.tags = new ArrayList(); + this.tags = new ArrayList<>(); } this.tags.add(tagsItem); return this; diff --git a/samples/client/petstore/java/retrofit2/docs/FakeApi.md b/samples/client/petstore/java/retrofit2/docs/FakeApi.md index 1467a2943d67..3eed01e889bf 100644 --- a/samples/client/petstore/java/retrofit2/docs/FakeApi.md +++ b/samples/client/petstore/java/retrofit2/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** fake/jsonFormData | test json serialization of form data @@ -378,6 +379,51 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> Void testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + Void result = apiInstance.testInlineAdditionalProperties(param); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +[**Void**](.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > Void testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java index d169b8111b74..8842354c81f5 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java @@ -122,6 +122,20 @@ public interface FakeApi { @retrofit2.http.Field("enum_form_string_array") List enumFormStringArray, @retrofit2.http.Field("enum_form_string") String enumFormString, @retrofit2.http.Header("enum_header_string_array") List enumHeaderStringArray, @retrofit2.http.Header("enum_header_string") String enumHeaderString, @retrofit2.http.Query("enum_query_string_array") CSVParams enumQueryStringArray, @retrofit2.http.Query("enum_query_string") String enumQueryString, @retrofit2.http.Query("enum_query_integer") Integer enumQueryInteger, @retrofit2.http.Field("enum_query_double") Double enumQueryDouble ); + /** + * test inline additionalProperties + * + * @param param request body (required) + * @return Call<Void> + */ + @Headers({ + "Content-Type:application/json" + }) + @POST("fake/inline-additionalProperties") + Call testInlineAdditionalProperties( + @retrofit2.http.Body Object param + ); + /** * test json serialization of form data * diff --git a/samples/client/petstore/java/retrofit2rx/build.gradle b/samples/client/petstore/java/retrofit2rx/build.gradle index fe0538acddcd..efbc57f9f81a 100644 --- a/samples/client/petstore/java/retrofit2rx/build.gradle +++ b/samples/client/petstore/java/retrofit2rx/build.gradle @@ -100,6 +100,7 @@ ext { junit_version = "4.12" rx_java_version = "1.3.0" threetenbp_version = "1.3.5" + json_fire_version = "1.8.0" } dependencies { @@ -110,6 +111,7 @@ dependencies { compile "io.reactivex:rxjava:$rx_java_version" compile "io.swagger:swagger-annotations:$swagger_annotations_version" compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version" + compile "io.gsonfire:gson-fire:$json_fire_version" compile "org.threeten:threetenbp:$threetenbp_version" testCompile "junit:junit:$junit_version" diff --git a/samples/client/petstore/java/retrofit2rx/build.sbt b/samples/client/petstore/java/retrofit2rx/build.sbt index 992dd1963dc9..e8748e9d2f73 100644 --- a/samples/client/petstore/java/retrofit2rx/build.sbt +++ b/samples/client/petstore/java/retrofit2rx/build.sbt @@ -17,6 +17,7 @@ lazy val root = (project in file(".")). "io.swagger" % "swagger-annotations" % "1.5.15" % "compile", "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile", "org.threeten" % "threetenbp" % "1.3.5" % "compile", + "io.gsonfire" % "gson-fire" % "1.8.0" % "compile", "junit" % "junit" % "4.12" % "test", "com.novocode" % "junit-interface" % "0.11" % "test" ) diff --git a/samples/client/petstore/java/retrofit2rx/docs/FakeApi.md b/samples/client/petstore/java/retrofit2rx/docs/FakeApi.md index 1467a2943d67..3eed01e889bf 100644 --- a/samples/client/petstore/java/retrofit2rx/docs/FakeApi.md +++ b/samples/client/petstore/java/retrofit2rx/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** fake/jsonFormData | test json serialization of form data @@ -378,6 +379,51 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> Void testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + Void result = apiInstance.testInlineAdditionalProperties(param); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +[**Void**](.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > Void testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/retrofit2rx/pom.xml b/samples/client/petstore/java/retrofit2rx/pom.xml index f78f35da747a..d825abfe3eda 100644 --- a/samples/client/petstore/java/retrofit2rx/pom.xml +++ b/samples/client/petstore/java/retrofit2rx/pom.xml @@ -194,6 +194,11 @@ org.apache.oltu.oauth2.client ${oltu-version} + + io.gsonfire + gson-fire + ${gson-fire-version} + org.threeten threetenbp @@ -225,6 +230,7 @@ 1.7 ${java.version} ${java.version} + 1.8.0 1.5.15 2.3.0 1.3.0 diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java index dfdf92060ad2..03c74e2ac201 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java @@ -2,6 +2,7 @@ package io.swagger.client; import com.google.gson.Gson; import com.google.gson.JsonParseException; +import com.google.gson.JsonElement; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import okhttp3.RequestBody; @@ -26,6 +27,7 @@ import java.lang.reflect.Type; import java.text.DateFormat; import java.util.LinkedHashMap; import java.util.Map; +import java.util.HashMap; public class ApiClient { diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/JSON.java index 590495331b63..aa07fc781cca 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/JSON.java @@ -20,10 +20,15 @@ import com.google.gson.TypeAdapter; import com.google.gson.internal.bind.util.ISO8601Utils; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonElement; +import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import org.threeten.bp.format.DateTimeFormatter; +import io.swagger.client.model.*; + import java.io.IOException; import java.io.StringReader; import java.lang.reflect.Type; @@ -31,6 +36,8 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.ParsePosition; import java.util.Date; +import java.util.Map; +import java.util.HashMap; public class JSON { private Gson gson; @@ -39,8 +46,42 @@ public class JSON { private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder() + .registerTypeSelector(Animal.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("Cat".toUpperCase(), Cat.class); + classByDiscriminatorValue.put("Dog".toUpperCase(), Dog.class); + classByDiscriminatorValue.put("Animal".toUpperCase(), Animal.class); + return getClassByDiscriminator( + classByDiscriminatorValue, + getDiscriminatorValue(readElement, "className")); + } + }) + ; + return fireBuilder.createGsonBuilder(); + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if(null == element) { + throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + + private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue.toUpperCase()); + if(null == clazz) { + throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } + public JSON() { - gson = new GsonBuilder() + gson = createGson() .registerTypeAdapter(Date.class, dateTypeAdapter) .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java index 1104aaeced57..475de10d9407 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java @@ -122,6 +122,20 @@ public interface FakeApi { @retrofit2.http.Field("enum_form_string_array") List enumFormStringArray, @retrofit2.http.Field("enum_form_string") String enumFormString, @retrofit2.http.Header("enum_header_string_array") List enumHeaderStringArray, @retrofit2.http.Header("enum_header_string") String enumHeaderString, @retrofit2.http.Query("enum_query_string_array") CSVParams enumQueryStringArray, @retrofit2.http.Query("enum_query_string") String enumQueryString, @retrofit2.http.Query("enum_query_integer") Integer enumQueryInteger, @retrofit2.http.Field("enum_query_double") Double enumQueryDouble ); + /** + * test inline additionalProperties + * + * @param param request body (required) + * @return Call<Void> + */ + @Headers({ + "Content-Type:application/json" + }) + @POST("fake/inline-additionalProperties") + Observable testInlineAdditionalProperties( + @retrofit2.http.Body Object param + ); + /** * test json serialization of form data * diff --git a/samples/client/petstore/java/retrofit2rx2/build.gradle b/samples/client/petstore/java/retrofit2rx2/build.gradle index 9c5787a93e8a..22dff04b7d1d 100644 --- a/samples/client/petstore/java/retrofit2rx2/build.gradle +++ b/samples/client/petstore/java/retrofit2rx2/build.gradle @@ -100,6 +100,7 @@ ext { junit_version = "4.12" rx_java_version = "2.1.1" threetenbp_version = "1.3.5" + json_fire_version = "1.8.0" } dependencies { @@ -110,6 +111,7 @@ dependencies { compile "io.reactivex.rxjava2:rxjava:$rx_java_version" compile "io.swagger:swagger-annotations:$swagger_annotations_version" compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version" + compile "io.gsonfire:gson-fire:$json_fire_version" compile "org.threeten:threetenbp:$threetenbp_version" testCompile "junit:junit:$junit_version" diff --git a/samples/client/petstore/java/retrofit2rx2/build.sbt b/samples/client/petstore/java/retrofit2rx2/build.sbt index 46ef2833c05c..89f22bca2a06 100644 --- a/samples/client/petstore/java/retrofit2rx2/build.sbt +++ b/samples/client/petstore/java/retrofit2rx2/build.sbt @@ -17,6 +17,7 @@ lazy val root = (project in file(".")). "io.swagger" % "swagger-annotations" % "1.5.15" % "compile", "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile", "org.threeten" % "threetenbp" % "1.3.5" % "compile", + "io.gsonfire" % "gson-fire" % "1.8.0" % "compile", "junit" % "junit" % "4.12" % "test", "com.novocode" % "junit-interface" % "0.11" % "test" ) diff --git a/samples/client/petstore/java/retrofit2rx2/docs/FakeApi.md b/samples/client/petstore/java/retrofit2rx2/docs/FakeApi.md index 1467a2943d67..3eed01e889bf 100644 --- a/samples/client/petstore/java/retrofit2rx2/docs/FakeApi.md +++ b/samples/client/petstore/java/retrofit2rx2/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** fake/jsonFormData | test json serialization of form data @@ -378,6 +379,51 @@ No authorization required - **Content-Type**: */* - **Accept**: */* + +# **testInlineAdditionalProperties** +> Void testInlineAdditionalProperties(param) + +test inline additionalProperties + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Object param = null; // Object | request body +try { + Void result = apiInstance.testInlineAdditionalProperties(param); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **Object**| request body | + +### Return type + +[**Void**](.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + # **testJsonFormData** > Void testJsonFormData(param, param2) diff --git a/samples/client/petstore/java/retrofit2rx2/pom.xml b/samples/client/petstore/java/retrofit2rx2/pom.xml index c3750d0b9b5e..b670d70167d3 100644 --- a/samples/client/petstore/java/retrofit2rx2/pom.xml +++ b/samples/client/petstore/java/retrofit2rx2/pom.xml @@ -194,6 +194,11 @@ org.apache.oltu.oauth2.client ${oltu-version} + + io.gsonfire + gson-fire + ${gson-fire-version} + org.threeten threetenbp @@ -225,6 +230,7 @@ 1.7 ${java.version} ${java.version} + 1.8.0 1.5.15 2.3.0 2.1.1 diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit2rx2/src/main/java/io/swagger/client/ApiClient.java index 9310c72d1a18..a2bddc869345 100644 --- a/samples/client/petstore/java/retrofit2rx2/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit2rx2/src/main/java/io/swagger/client/ApiClient.java @@ -2,6 +2,7 @@ package io.swagger.client; import com.google.gson.Gson; import com.google.gson.JsonParseException; +import com.google.gson.JsonElement; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import okhttp3.RequestBody; @@ -26,6 +27,7 @@ import java.lang.reflect.Type; import java.text.DateFormat; import java.util.LinkedHashMap; import java.util.Map; +import java.util.HashMap; public class ApiClient { diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/retrofit2rx2/src/main/java/io/swagger/client/JSON.java index 590495331b63..aa07fc781cca 100644 --- a/samples/client/petstore/java/retrofit2rx2/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/retrofit2rx2/src/main/java/io/swagger/client/JSON.java @@ -20,10 +20,15 @@ import com.google.gson.TypeAdapter; import com.google.gson.internal.bind.util.ISO8601Utils; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonElement; +import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; import org.threeten.bp.LocalDate; import org.threeten.bp.OffsetDateTime; import org.threeten.bp.format.DateTimeFormatter; +import io.swagger.client.model.*; + import java.io.IOException; import java.io.StringReader; import java.lang.reflect.Type; @@ -31,6 +36,8 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.ParsePosition; import java.util.Date; +import java.util.Map; +import java.util.HashMap; public class JSON { private Gson gson; @@ -39,8 +46,42 @@ public class JSON { private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder() + .registerTypeSelector(Animal.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("Cat".toUpperCase(), Cat.class); + classByDiscriminatorValue.put("Dog".toUpperCase(), Dog.class); + classByDiscriminatorValue.put("Animal".toUpperCase(), Animal.class); + return getClassByDiscriminator( + classByDiscriminatorValue, + getDiscriminatorValue(readElement, "className")); + } + }) + ; + return fireBuilder.createGsonBuilder(); + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if(null == element) { + throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + + private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue.toUpperCase()); + if(null == clazz) { + throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } + public JSON() { - gson = new GsonBuilder() + gson = createGson() .registerTypeAdapter(Date.class, dateTypeAdapter) .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit2rx2/src/main/java/io/swagger/client/api/FakeApi.java index 933e33cb88b4..37673eac589c 100644 --- a/samples/client/petstore/java/retrofit2rx2/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/retrofit2rx2/src/main/java/io/swagger/client/api/FakeApi.java @@ -122,6 +122,20 @@ public interface FakeApi { @retrofit2.http.Field("enum_form_string_array") List enumFormStringArray, @retrofit2.http.Field("enum_form_string") String enumFormString, @retrofit2.http.Header("enum_header_string_array") List enumHeaderStringArray, @retrofit2.http.Header("enum_header_string") String enumHeaderString, @retrofit2.http.Query("enum_query_string_array") CSVParams enumQueryStringArray, @retrofit2.http.Query("enum_query_string") String enumQueryString, @retrofit2.http.Query("enum_query_integer") Integer enumQueryInteger, @retrofit2.http.Field("enum_query_double") Double enumQueryDouble ); + /** + * test inline additionalProperties + * + * @param param request body (required) + * @return Call<Void> + */ + @Headers({ + "Content-Type:application/json" + }) + @POST("fake/inline-additionalProperties") + Observable testInlineAdditionalProperties( + @retrofit2.http.Body Object param + ); + /** * test json serialization of form data * From f42a4a51ddce5cb70b892cc52d4752274fbbba3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20=C5=9Eener?= Date: Wed, 25 Oct 2017 06:12:41 +0300 Subject: [PATCH 20/28] [javascript] Use babel-preset-env instead of es2015 and upgrade babel-cli and babel-core (#6799) --- .../src/main/resources/Javascript/es6/.babelrc.mustache | 4 ++-- .../src/main/resources/Javascript/es6/package.mustache | 6 +++--- samples/client/petstore/javascript-es6/.babelrc | 4 ++-- samples/client/petstore/javascript-es6/package.json | 6 +++--- samples/client/petstore/javascript-promise-es6/.babelrc | 4 ++-- samples/client/petstore/javascript-promise-es6/package.json | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Javascript/es6/.babelrc.mustache b/modules/swagger-codegen/src/main/resources/Javascript/es6/.babelrc.mustache index bcb6ee8de93c..67b369ed370c 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/es6/.babelrc.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/es6/.babelrc.mustache @@ -1,3 +1,3 @@ { - "presets": ["es2015", "stage-0"] -} \ No newline at end of file + "presets": ["env", "stage-0"] +} diff --git a/modules/swagger-codegen/src/main/resources/Javascript/es6/package.mustache b/modules/swagger-codegen/src/main/resources/Javascript/es6/package.mustache index 179f5cd3c73e..997c5e240558 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/es6/package.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/es6/package.mustache @@ -12,12 +12,12 @@ }, "dependencies": { "babel": "^6.23.0", - "babel-cli": "^6.24.1", + "babel-cli": "^6.26.0", "superagent": "3.5.2" }, "devDependencies": { - "babel-core": "6.18.0", - "babel-preset-es2015": "^6.24.1", + "babel-core": "6.26.0", + "babel-preset-env": "^1.6.1", "babel-preset-stage-0": "^6.24.1", "expect.js": "~0.3.1", "mocha": "~2.3.4", diff --git a/samples/client/petstore/javascript-es6/.babelrc b/samples/client/petstore/javascript-es6/.babelrc index bcb6ee8de93c..67b369ed370c 100644 --- a/samples/client/petstore/javascript-es6/.babelrc +++ b/samples/client/petstore/javascript-es6/.babelrc @@ -1,3 +1,3 @@ { - "presets": ["es2015", "stage-0"] -} \ No newline at end of file + "presets": ["env", "stage-0"] +} diff --git a/samples/client/petstore/javascript-es6/package.json b/samples/client/petstore/javascript-es6/package.json index 427e6b3a5064..afb99e8a97a0 100644 --- a/samples/client/petstore/javascript-es6/package.json +++ b/samples/client/petstore/javascript-es6/package.json @@ -12,12 +12,12 @@ }, "dependencies": { "babel": "^6.23.0", - "babel-cli": "^6.24.1", + "babel-cli": "^6.26.0", "superagent": "3.5.2" }, "devDependencies": { - "babel-core": "6.18.0", - "babel-preset-es2015": "^6.24.1", + "babel-core": "6.26.0", + "babel-preset-env": "^1.6.1", "babel-preset-stage-0": "^6.24.1", "expect.js": "~0.3.1", "mocha": "~2.3.4", diff --git a/samples/client/petstore/javascript-promise-es6/.babelrc b/samples/client/petstore/javascript-promise-es6/.babelrc index bcb6ee8de93c..67b369ed370c 100644 --- a/samples/client/petstore/javascript-promise-es6/.babelrc +++ b/samples/client/petstore/javascript-promise-es6/.babelrc @@ -1,3 +1,3 @@ { - "presets": ["es2015", "stage-0"] -} \ No newline at end of file + "presets": ["env", "stage-0"] +} diff --git a/samples/client/petstore/javascript-promise-es6/package.json b/samples/client/petstore/javascript-promise-es6/package.json index 427e6b3a5064..afb99e8a97a0 100644 --- a/samples/client/petstore/javascript-promise-es6/package.json +++ b/samples/client/petstore/javascript-promise-es6/package.json @@ -12,12 +12,12 @@ }, "dependencies": { "babel": "^6.23.0", - "babel-cli": "^6.24.1", + "babel-cli": "^6.26.0", "superagent": "3.5.2" }, "devDependencies": { - "babel-core": "6.18.0", - "babel-preset-es2015": "^6.24.1", + "babel-core": "6.26.0", + "babel-preset-env": "^1.6.1", "babel-preset-stage-0": "^6.24.1", "expect.js": "~0.3.1", "mocha": "~2.3.4", From 49974c51bd817c99e7a733f42f86cac10dcb9132 Mon Sep 17 00:00:00 2001 From: Asad Saeeduddin Date: Wed, 25 Oct 2017 00:34:37 -0400 Subject: [PATCH 21/28] Change return type from any -> Response (#6774) * Leftover updates to sample file * Change return type any -> Response * Update samples --- .../resources/typescript-fetch/api.mustache | 4 +- .../typescript-fetch/builds/default/api.ts | 598 +++++++++--------- .../typescript-fetch/builds/es6-target/api.ts | 24 +- .../builds/with-npm-version/api.ts | 24 +- 4 files changed, 325 insertions(+), 325 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-fetch/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-fetch/api.mustache index 2fe42a8dd167..a3ac50c3e7c8 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-fetch/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-fetch/api.mustache @@ -24,7 +24,7 @@ export const COLLECTION_FORMATS = { * @interface FetchAPI */ export interface FetchAPI { - (url: string, init?: any): Promise; + (url: string, init?: any): Promise; } /** @@ -253,7 +253,7 @@ export const {{classname}}Fp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}> { + {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> { const localVarFetchArgs = {{classname}}FetchParamCreator(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { diff --git a/samples/client/petstore/typescript-fetch/builds/default/api.ts b/samples/client/petstore/typescript-fetch/builds/default/api.ts index b31bd51457eb..a3de24bc6f9c 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/api.ts @@ -35,7 +35,7 @@ export const COLLECTION_FORMATS = { * @interface FetchAPI */ export interface FetchAPI { - (url: string, init?: any): Promise; + (url: string, init?: any): Promise; } /** @@ -338,32 +338,32 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) if (body === null || body === undefined) { throw new RequiredError('body','Required parameter body was null or undefined when calling addPet.'); } - const path = `/pet`; - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'POST' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarPath = `/pet`; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'POST' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; // authentication petstore_auth required // oauth required if (configuration && configuration.accessToken) { - const accessTokenValue = typeof configuration.accessToken === 'function' + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) : configuration.accessToken; - headerParameter["Authorization"] = "Bearer " + accessTokenValue; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; } - headerParameter['Content-Type'] = 'application/json'; + localVarHeaderParameter['Content-Type'] = 'application/json'; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); - requestOptions.body = JSON.stringify(body || {}); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); + localVarRequestOptions.body = JSON.stringify(body || {}); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -379,34 +379,34 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) if (petId === null || petId === undefined) { throw new RequiredError('petId','Required parameter petId was null or undefined when calling deletePet.'); } - const path = `/pet/{petId}` + const localVarPath = `/pet/{petId}` .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'DELETE' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; // authentication petstore_auth required // oauth required if (configuration && configuration.accessToken) { - const accessTokenValue = typeof configuration.accessToken === 'function' + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) : configuration.accessToken; - headerParameter["Authorization"] = "Bearer " + accessTokenValue; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; } if (apiKey !== undefined && apiKey !== null) { - headerParameter['api_key'] = String(apiKey); + localVarHeaderParameter['api_key'] = String(apiKey); } - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -421,33 +421,33 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) if (status === null || status === undefined) { throw new RequiredError('status','Required parameter status was null or undefined when calling findPetsByStatus.'); } - const path = `/pet/findByStatus`; - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'GET' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarPath = `/pet/findByStatus`; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'GET' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; // authentication petstore_auth required // oauth required if (configuration && configuration.accessToken) { - const accessTokenValue = typeof configuration.accessToken === 'function' + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) : configuration.accessToken; - headerParameter["Authorization"] = "Bearer " + accessTokenValue; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; } if (status) { - queryParameter['status'] = status.join(COLLECTION_FORMATS["csv"]); + localVarQueryParameter['status'] = status.join(COLLECTION_FORMATS["csv"]); } - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -462,33 +462,33 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) if (tags === null || tags === undefined) { throw new RequiredError('tags','Required parameter tags was null or undefined when calling findPetsByTags.'); } - const path = `/pet/findByTags`; - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'GET' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarPath = `/pet/findByTags`; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'GET' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; // authentication petstore_auth required // oauth required if (configuration && configuration.accessToken) { - const accessTokenValue = typeof configuration.accessToken === 'function' + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) : configuration.accessToken; - headerParameter["Authorization"] = "Bearer " + accessTokenValue; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; } if (tags) { - queryParameter['tags'] = tags.join(COLLECTION_FORMATS["csv"]); + localVarQueryParameter['tags'] = tags.join(COLLECTION_FORMATS["csv"]); } - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -503,29 +503,29 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) if (petId === null || petId === undefined) { throw new RequiredError('petId','Required parameter petId was null or undefined when calling getPetById.'); } - const path = `/pet/{petId}` + const localVarPath = `/pet/{petId}` .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'GET' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'GET' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; // authentication api_key required if (configuration && configuration.apiKey) { - const apiKeyValue = typeof configuration.apiKey === 'function' + const localVarApiKeyValue = typeof configuration.apiKey === 'function' ? configuration.apiKey("api_key") : configuration.apiKey; - headerParameter["api_key"] = apiKeyValue; + localVarHeaderParameter["api_key"] = localVarApiKeyValue; } - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -540,32 +540,32 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) if (body === null || body === undefined) { throw new RequiredError('body','Required parameter body was null or undefined when calling updatePet.'); } - const path = `/pet`; - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'PUT' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarPath = `/pet`; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'PUT' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; // authentication petstore_auth required // oauth required if (configuration && configuration.accessToken) { - const accessTokenValue = typeof configuration.accessToken === 'function' + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) : configuration.accessToken; - headerParameter["Authorization"] = "Bearer " + accessTokenValue; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; } - headerParameter['Content-Type'] = 'application/json'; + localVarHeaderParameter['Content-Type'] = 'application/json'; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); - requestOptions.body = JSON.stringify(body || {}); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); + localVarRequestOptions.body = JSON.stringify(body || {}); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -582,42 +582,42 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) if (petId === null || petId === undefined) { throw new RequiredError('petId','Required parameter petId was null or undefined when calling updatePetWithForm.'); } - const path = `/pet/{petId}` + const localVarPath = `/pet/{petId}` .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'POST' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; - const formParams = new url.URLSearchParams(); + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'POST' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new url.URLSearchParams(); // authentication petstore_auth required // oauth required if (configuration && configuration.accessToken) { - const accessTokenValue = typeof configuration.accessToken === 'function' + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) : configuration.accessToken; - headerParameter["Authorization"] = "Bearer " + accessTokenValue; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; } if (name !== undefined) { - formParams.set('name', name as any); + localVarFormParams.set('name', name as any); } if (status !== undefined) { - formParams.set('status', status as any); + localVarFormParams.set('status', status as any); } - headerParameter['Content-Type'] = 'application/x-www-form-urlencoded'; + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); - requestOptions.body = formParams.toString(); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); + localVarRequestOptions.body = localVarFormParams.toString(); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -634,42 +634,42 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) if (petId === null || petId === undefined) { throw new RequiredError('petId','Required parameter petId was null or undefined when calling uploadFile.'); } - const path = `/pet/{petId}/uploadImage` + const localVarPath = `/pet/{petId}/uploadImage` .replace(`{${"petId"}}`, encodeURIComponent(String(petId))); - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'POST' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; - const formParams = new url.URLSearchParams(); + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'POST' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + const localVarFormParams = new url.URLSearchParams(); // authentication petstore_auth required // oauth required if (configuration && configuration.accessToken) { - const accessTokenValue = typeof configuration.accessToken === 'function' + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' ? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]) : configuration.accessToken; - headerParameter["Authorization"] = "Bearer " + accessTokenValue; + localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue; } if (additionalMetadata !== undefined) { - formParams.set('additionalMetadata', additionalMetadata as any); + localVarFormParams.set('additionalMetadata', additionalMetadata as any); } if (file !== undefined) { - formParams.set('file', file as any); + localVarFormParams.set('file', file as any); } - headerParameter['Content-Type'] = 'application/x-www-form-urlencoded'; + localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded'; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); - requestOptions.body = formParams.toString(); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); + localVarRequestOptions.body = localVarFormParams.toString(); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, } @@ -688,10 +688,10 @@ export const PetApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreator(configuration).addPet(body, options); + addPet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + const localVarFetchArgs = PetApiFetchParamCreator(configuration).addPet(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response; } else { @@ -708,10 +708,10 @@ export const PetApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreator(configuration).deletePet(petId, apiKey, options); + deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + const localVarFetchArgs = PetApiFetchParamCreator(configuration).deletePet(petId, apiKey, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response; } else { @@ -728,9 +728,9 @@ export const PetApiFp = function(configuration?: Configuration) { * @throws {RequiredError} */ findPetsByStatus(status: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise> { - const fetchArgs = PetApiFetchParamCreator(configuration).findPetsByStatus(status, options); + const localVarFetchArgs = PetApiFetchParamCreator(configuration).findPetsByStatus(status, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response.json(); } else { @@ -747,9 +747,9 @@ export const PetApiFp = function(configuration?: Configuration) { * @throws {RequiredError} */ findPetsByTags(tags: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise> { - const fetchArgs = PetApiFetchParamCreator(configuration).findPetsByTags(tags, options); + const localVarFetchArgs = PetApiFetchParamCreator(configuration).findPetsByTags(tags, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response.json(); } else { @@ -766,9 +766,9 @@ export const PetApiFp = function(configuration?: Configuration) { * @throws {RequiredError} */ getPetById(petId: number, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreator(configuration).getPetById(petId, options); + const localVarFetchArgs = PetApiFetchParamCreator(configuration).getPetById(petId, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response.json(); } else { @@ -784,10 +784,10 @@ export const PetApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreator(configuration).updatePet(body, options); + updatePet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePet(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response; } else { @@ -805,10 +805,10 @@ export const PetApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreator(configuration).updatePetWithForm(petId, name, status, options); + updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePetWithForm(petId, name, status, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response; } else { @@ -827,9 +827,9 @@ export const PetApiFp = function(configuration?: Configuration) { * @throws {RequiredError} */ uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = PetApiFetchParamCreator(configuration).uploadFile(petId, additionalMetadata, file, options); + const localVarFetchArgs = PetApiFetchParamCreator(configuration).uploadFile(petId, additionalMetadata, file, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response.json(); } else { @@ -1063,21 +1063,21 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration if (orderId === null || orderId === undefined) { throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling deleteOrder.'); } - const path = `/store/order/{orderId}` + const localVarPath = `/store/order/{orderId}` .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'DELETE' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -1087,28 +1087,28 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration * @throws {RequiredError} */ getInventory(options: any = {}): FetchArgs { - const path = `/store/inventory`; - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'GET' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarPath = `/store/inventory`; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'GET' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; // authentication api_key required if (configuration && configuration.apiKey) { - const apiKeyValue = typeof configuration.apiKey === 'function' + const localVarApiKeyValue = typeof configuration.apiKey === 'function' ? configuration.apiKey("api_key") : configuration.apiKey; - headerParameter["api_key"] = apiKeyValue; + localVarHeaderParameter["api_key"] = localVarApiKeyValue; } - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -1123,21 +1123,21 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration if (orderId === null || orderId === undefined) { throw new RequiredError('orderId','Required parameter orderId was null or undefined when calling getOrderById.'); } - const path = `/store/order/{orderId}` + const localVarPath = `/store/order/{orderId}` .replace(`{${"orderId"}}`, encodeURIComponent(String(orderId))); - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'GET' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'GET' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -1152,23 +1152,23 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration if (body === null || body === undefined) { throw new RequiredError('body','Required parameter body was null or undefined when calling placeOrder.'); } - const path = `/store/order`; - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'POST' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarPath = `/store/order`; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'POST' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; - headerParameter['Content-Type'] = 'application/json'; + localVarHeaderParameter['Content-Type'] = 'application/json'; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); - requestOptions.body = JSON.stringify(body || {}); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); + localVarRequestOptions.body = JSON.stringify(body || {}); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, } @@ -1187,10 +1187,10 @@ export const StoreApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = StoreApiFetchParamCreator(configuration).deleteOrder(orderId, options); + deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + const localVarFetchArgs = StoreApiFetchParamCreator(configuration).deleteOrder(orderId, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response; } else { @@ -1206,9 +1206,9 @@ export const StoreApiFp = function(configuration?: Configuration) { * @throws {RequiredError} */ getInventory(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { - const fetchArgs = StoreApiFetchParamCreator(configuration).getInventory(options); + const localVarFetchArgs = StoreApiFetchParamCreator(configuration).getInventory(options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response.json(); } else { @@ -1225,9 +1225,9 @@ export const StoreApiFp = function(configuration?: Configuration) { * @throws {RequiredError} */ getOrderById(orderId: number, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = StoreApiFetchParamCreator(configuration).getOrderById(orderId, options); + const localVarFetchArgs = StoreApiFetchParamCreator(configuration).getOrderById(orderId, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response.json(); } else { @@ -1244,9 +1244,9 @@ export const StoreApiFp = function(configuration?: Configuration) { * @throws {RequiredError} */ placeOrder(body: Order, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = StoreApiFetchParamCreator(configuration).placeOrder(body, options); + const localVarFetchArgs = StoreApiFetchParamCreator(configuration).placeOrder(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response.json(); } else { @@ -1380,23 +1380,23 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) if (body === null || body === undefined) { throw new RequiredError('body','Required parameter body was null or undefined when calling createUser.'); } - const path = `/user`; - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'POST' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarPath = `/user`; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'POST' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; - headerParameter['Content-Type'] = 'application/json'; + localVarHeaderParameter['Content-Type'] = 'application/json'; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); - requestOptions.body = JSON.stringify(body || {}); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); + localVarRequestOptions.body = JSON.stringify(body || {}); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -1411,23 +1411,23 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) if (body === null || body === undefined) { throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithArrayInput.'); } - const path = `/user/createWithArray`; - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'POST' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarPath = `/user/createWithArray`; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'POST' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; - headerParameter['Content-Type'] = 'application/json'; + localVarHeaderParameter['Content-Type'] = 'application/json'; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); - requestOptions.body = JSON.stringify(body || {}); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); + localVarRequestOptions.body = JSON.stringify(body || {}); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -1442,23 +1442,23 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) if (body === null || body === undefined) { throw new RequiredError('body','Required parameter body was null or undefined when calling createUsersWithListInput.'); } - const path = `/user/createWithList`; - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'POST' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarPath = `/user/createWithList`; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'POST' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; - headerParameter['Content-Type'] = 'application/json'; + localVarHeaderParameter['Content-Type'] = 'application/json'; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); - requestOptions.body = JSON.stringify(body || {}); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); + localVarRequestOptions.body = JSON.stringify(body || {}); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -1473,21 +1473,21 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) if (username === null || username === undefined) { throw new RequiredError('username','Required parameter username was null or undefined when calling deleteUser.'); } - const path = `/user/{username}` + const localVarPath = `/user/{username}` .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'DELETE' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'DELETE' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -1502,21 +1502,21 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) if (username === null || username === undefined) { throw new RequiredError('username','Required parameter username was null or undefined when calling getUserByName.'); } - const path = `/user/{username}` + const localVarPath = `/user/{username}` .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'GET' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'GET' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -1536,28 +1536,28 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) if (password === null || password === undefined) { throw new RequiredError('password','Required parameter password was null or undefined when calling loginUser.'); } - const path = `/user/login`; - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'GET' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarPath = `/user/login`; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'GET' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; if (username !== undefined) { - queryParameter['username'] = username; + localVarQueryParameter['username'] = username; } if (password !== undefined) { - queryParameter['password'] = password; + localVarQueryParameter['password'] = password; } - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -1567,20 +1567,20 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) * @throws {RequiredError} */ logoutUser(options: any = {}): FetchArgs { - const path = `/user/logout`; - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'GET' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarPath = `/user/logout`; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'GET' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, /** @@ -1600,24 +1600,24 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) if (body === null || body === undefined) { throw new RequiredError('body','Required parameter body was null or undefined when calling updateUser.'); } - const path = `/user/{username}` + const localVarPath = `/user/{username}` .replace(`{${"username"}}`, encodeURIComponent(String(username))); - const urlObj = url.parse(path, true); - const requestOptions = Object.assign({ method: 'PUT' }, options); - const headerParameter = {} as any; - const queryParameter = {} as any; + const localVarUrlObj = url.parse(localVarPath, true); + const localVarRequestOptions = Object.assign({ method: 'PUT' }, options); + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; - headerParameter['Content-Type'] = 'application/json'; + localVarHeaderParameter['Content-Type'] = 'application/json'; - urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query); + localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete urlObj.search; - requestOptions.headers = Object.assign({}, headerParameter, options.headers); - requestOptions.body = JSON.stringify(body || {}); + delete localVarUrlObj.search; + localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); + localVarRequestOptions.body = JSON.stringify(body || {}); return { - url: url.format(urlObj), - options: requestOptions, + url: url.format(localVarUrlObj), + options: localVarRequestOptions, }; }, } @@ -1636,10 +1636,10 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreator(configuration).createUser(body, options); + createUser(body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUser(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response; } else { @@ -1655,10 +1655,10 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(body: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreator(configuration).createUsersWithArrayInput(body, options); + createUsersWithArrayInput(body: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithArrayInput(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response; } else { @@ -1674,10 +1674,10 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(body: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreator(configuration).createUsersWithListInput(body, options); + createUsersWithListInput(body: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithListInput(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response; } else { @@ -1693,10 +1693,10 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreator(configuration).deleteUser(username, options); + deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + const localVarFetchArgs = UserApiFetchParamCreator(configuration).deleteUser(username, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response; } else { @@ -1713,9 +1713,9 @@ export const UserApiFp = function(configuration?: Configuration) { * @throws {RequiredError} */ getUserByName(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreator(configuration).getUserByName(username, options); + const localVarFetchArgs = UserApiFetchParamCreator(configuration).getUserByName(username, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response.json(); } else { @@ -1733,9 +1733,9 @@ export const UserApiFp = function(configuration?: Configuration) { * @throws {RequiredError} */ loginUser(username: string, password: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreator(configuration).loginUser(username, password, options); + const localVarFetchArgs = UserApiFetchParamCreator(configuration).loginUser(username, password, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response.json(); } else { @@ -1750,10 +1750,10 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreator(configuration).logoutUser(options); + logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + const localVarFetchArgs = UserApiFetchParamCreator(configuration).logoutUser(options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response; } else { @@ -1770,10 +1770,10 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { - const fetchArgs = UserApiFetchParamCreator(configuration).updateUser(username, body, options); + updateUser(username: string, body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + const localVarFetchArgs = UserApiFetchParamCreator(configuration).updateUser(username, body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { - return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { + return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { if (response.status >= 200 && response.status < 300) { return response; } else { diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts index 16f039fab86c..a3de24bc6f9c 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts @@ -35,7 +35,7 @@ export const COLLECTION_FORMATS = { * @interface FetchAPI */ export interface FetchAPI { - (url: string, init?: any): Promise; + (url: string, init?: any): Promise; } /** @@ -688,7 +688,7 @@ export const PetApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + addPet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = PetApiFetchParamCreator(configuration).addPet(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -708,7 +708,7 @@ export const PetApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = PetApiFetchParamCreator(configuration).deletePet(petId, apiKey, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -784,7 +784,7 @@ export const PetApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + updatePet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePet(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -805,7 +805,7 @@ export const PetApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePetWithForm(petId, name, status, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1187,7 +1187,7 @@ export const StoreApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = StoreApiFetchParamCreator(configuration).deleteOrder(orderId, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1636,7 +1636,7 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + createUser(body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUser(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1655,7 +1655,7 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(body: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + createUsersWithArrayInput(body: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithArrayInput(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1674,7 +1674,7 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(body: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + createUsersWithListInput(body: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithListInput(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1693,7 +1693,7 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = UserApiFetchParamCreator(configuration).deleteUser(username, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1750,7 +1750,7 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = UserApiFetchParamCreator(configuration).logoutUser(options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1770,7 +1770,7 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + updateUser(username: string, body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = UserApiFetchParamCreator(configuration).updateUser(username, body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts index 16f039fab86c..a3de24bc6f9c 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts @@ -35,7 +35,7 @@ export const COLLECTION_FORMATS = { * @interface FetchAPI */ export interface FetchAPI { - (url: string, init?: any): Promise; + (url: string, init?: any): Promise; } /** @@ -688,7 +688,7 @@ export const PetApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - addPet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + addPet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = PetApiFetchParamCreator(configuration).addPet(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -708,7 +708,7 @@ export const PetApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = PetApiFetchParamCreator(configuration).deletePet(petId, apiKey, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -784,7 +784,7 @@ export const PetApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + updatePet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePet(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -805,7 +805,7 @@ export const PetApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePetWithForm(petId, name, status, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1187,7 +1187,7 @@ export const StoreApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = StoreApiFetchParamCreator(configuration).deleteOrder(orderId, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1636,7 +1636,7 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUser(body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + createUser(body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUser(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1655,7 +1655,7 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithArrayInput(body: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + createUsersWithArrayInput(body: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithArrayInput(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1674,7 +1674,7 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - createUsersWithListInput(body: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + createUsersWithListInput(body: Array, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithListInput(body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1693,7 +1693,7 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = UserApiFetchParamCreator(configuration).deleteUser(username, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1750,7 +1750,7 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = UserApiFetchParamCreator(configuration).logoutUser(options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { @@ -1770,7 +1770,7 @@ export const UserApiFp = function(configuration?: Configuration) { * @param {*} [options] Override http request option. * @throws {RequiredError} */ - updateUser(username: string, body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { + updateUser(username: string, body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise { const localVarFetchArgs = UserApiFetchParamCreator(configuration).updateUser(username, body, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { From 6814530d690db7b88e91fc1aab50f10472f707bd Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 25 Oct 2017 22:30:36 +0800 Subject: [PATCH 22/28] fix enum in path parameter (spring) (#6810) --- .../main/resources/JavaSpring/api.mustache | 4 +++- .../resources/JavaSpring/pathParams.mustache | 2 +- .../src/main/java/io/swagger/api/PetApi.java | 8 +++---- .../main/java/io/swagger/api/StoreApi.java | 4 ++-- .../src/main/java/io/swagger/api/UserApi.java | 6 +++--- .../src/main/java/io/swagger/api/PetApi.java | 8 +++---- .../main/java/io/swagger/api/StoreApi.java | 4 ++-- .../src/main/java/io/swagger/api/UserApi.java | 6 +++--- .../src/main/java/io/swagger/api/FakeApi.java | 12 +++++++++++ .../src/main/java/io/swagger/api/PetApi.java | 8 +++---- .../main/java/io/swagger/api/StoreApi.java | 4 ++-- .../src/main/java/io/swagger/api/UserApi.java | 6 +++--- .../src/main/java/io/swagger/api/FakeApi.java | 9 ++++++++ .../io/swagger/api/FakeApiController.java | 6 ++++++ .../src/main/java/io/swagger/api/PetApi.java | 8 +++---- .../java/io/swagger/api/PetApiController.java | 8 +++---- .../main/java/io/swagger/api/StoreApi.java | 4 ++-- .../io/swagger/api/StoreApiController.java | 4 ++-- .../src/main/java/io/swagger/api/UserApi.java | 6 +++--- .../io/swagger/api/UserApiController.java | 6 +++--- .../src/main/java/io/swagger/api/FakeApi.java | 9 ++++++++ .../io/swagger/api/FakeApiController.java | 6 ++++++ .../src/main/java/io/swagger/api/PetApi.java | 8 +++---- .../java/io/swagger/api/PetApiController.java | 8 +++---- .../main/java/io/swagger/api/StoreApi.java | 4 ++-- .../io/swagger/api/StoreApiController.java | 4 ++-- .../src/main/java/io/swagger/api/UserApi.java | 6 +++--- .../io/swagger/api/UserApiController.java | 6 +++--- .../src/main/java/io/swagger/api/FakeApi.java | 12 +++++++++++ .../io/swagger/api/FakeApiController.java | 6 ++++++ .../java/io/swagger/api/FakeApiDelegate.java | 8 +++++++ .../src/main/java/io/swagger/api/PetApi.java | 8 +++---- .../java/io/swagger/api/PetApiController.java | 8 +++---- .../main/java/io/swagger/api/StoreApi.java | 4 ++-- .../io/swagger/api/StoreApiController.java | 4 ++-- .../src/main/java/io/swagger/api/UserApi.java | 6 +++--- .../io/swagger/api/UserApiController.java | 6 +++--- .../src/main/java/io/swagger/api/FakeApi.java | 9 ++++++++ .../io/swagger/api/FakeApiController.java | 6 ++++++ .../java/io/swagger/api/FakeApiDelegate.java | 5 +++++ .../src/main/java/io/swagger/api/PetApi.java | 8 +++---- .../java/io/swagger/api/PetApiController.java | 8 +++---- .../main/java/io/swagger/api/StoreApi.java | 4 ++-- .../io/swagger/api/StoreApiController.java | 4 ++-- .../src/main/java/io/swagger/api/UserApi.java | 6 +++--- .../io/swagger/api/UserApiController.java | 6 +++--- .../java/io/swagger/api/AnotherFakeApi.java | 1 - .../src/main/java/io/swagger/api/FakeApi.java | 21 ++++++++++++------- .../io/swagger/api/FakeApiController.java | 6 ++++++ .../io/swagger/api/FakeClassnameTestApi.java | 1 - .../src/main/java/io/swagger/api/PetApi.java | 15 ++++--------- .../java/io/swagger/api/PetApiController.java | 8 +++---- .../main/java/io/swagger/api/StoreApi.java | 8 ++----- .../io/swagger/api/StoreApiController.java | 4 ++-- .../src/main/java/io/swagger/api/UserApi.java | 14 +++---------- .../io/swagger/api/UserApiController.java | 6 +++--- .../src/main/java/io/swagger/api/FakeApi.java | 9 ++++++++ .../io/swagger/api/FakeApiController.java | 6 ++++++ .../src/main/java/io/swagger/api/PetApi.java | 8 +++---- .../java/io/swagger/api/PetApiController.java | 8 +++---- .../main/java/io/swagger/api/StoreApi.java | 4 ++-- .../io/swagger/api/StoreApiController.java | 4 ++-- .../src/main/java/io/swagger/api/UserApi.java | 6 +++--- .../io/swagger/api/UserApiController.java | 6 +++--- .../src/main/java/io/swagger/api/FakeApi.java | 9 ++++++++ .../io/swagger/api/FakeApiController.java | 6 ++++++ .../src/main/java/io/swagger/api/PetApi.java | 8 +++---- .../java/io/swagger/api/PetApiController.java | 8 +++---- .../main/java/io/swagger/api/StoreApi.java | 4 ++-- .../io/swagger/api/StoreApiController.java | 4 ++-- .../src/main/java/io/swagger/api/UserApi.java | 6 +++--- .../io/swagger/api/UserApiController.java | 6 +++--- 72 files changed, 294 insertions(+), 184 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache index f2f7c15f1a2e..be425a1e760c 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/api.mustache @@ -54,7 +54,9 @@ public interface {{classname}} { @ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{baseType}}}.class{{/baseType}}{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{#hasMore}},{{/hasMore}}{{/responses}} }) {{#implicitHeaders}} @ApiImplicitParams({ - {{#headerParams}}{{>implicitHeader}}{{/headerParams}} + {{#headerParams}} + {{>implicitHeader}} + {{/headerParams}} }) {{/implicitHeaders}} @RequestMapping(value = "{{{path}}}",{{#singleContentTypes}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/pathParams.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/pathParams.mustache index 62342d01bfa9..f2b5c5b2ea82 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/pathParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/pathParams.mustache @@ -1 +1 @@ -{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}} {{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}} \ No newline at end of file +{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java index 9dc45ad56347..657744b92662 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/PetApi.java @@ -55,7 +55,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.DELETE) - com.netflix.hystrix.HystrixCommand> deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); + com.netflix.hystrix.HystrixCommand> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey); @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -101,7 +101,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId); + com.netflix.hystrix.HystrixCommand> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId); @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -133,7 +133,7 @@ public interface PetApi { produces = "application/json", consumes = "application/x-www-form-urlencoded", method = RequestMethod.POST) - com.netflix.hystrix.HystrixCommand> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet" ) @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet" ) @RequestParam(value="status", required=false) String status); + com.netflix.hystrix.HystrixCommand> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet" ) @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet" ) @RequestParam(value="status", required=false) String status); @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -148,6 +148,6 @@ public interface PetApi { produces = "application/json", consumes = "multipart/form-data", method = RequestMethod.POST) - com.netflix.hystrix.HystrixCommand> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestParam("file") MultipartFile file); + com.netflix.hystrix.HystrixCommand> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @RequestParam("file") MultipartFile file); } diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java index a93edffab2dc..8c15c2c3d7b0 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/StoreApi.java @@ -35,7 +35,7 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.DELETE) - com.netflix.hystrix.HystrixCommand> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId); + com.netflix.hystrix.HystrixCommand> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId); @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -59,7 +59,7 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId); + com.netflix.hystrix.HystrixCommand> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId); @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) diff --git a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java index cf2a1b89cdc4..2fb94582c146 100644 --- a/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java +++ b/samples/client/petstore/spring-cloud/src/main/java/io/swagger/api/UserApi.java @@ -65,7 +65,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.DELETE) - com.netflix.hystrix.HystrixCommand> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username); + com.netflix.hystrix.HystrixCommand> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username); @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -77,7 +77,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - com.netflix.hystrix.HystrixCommand> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username); + com.netflix.hystrix.HystrixCommand> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username); @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -109,6 +109,6 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.PUT) - com.netflix.hystrix.HystrixCommand> updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); + com.netflix.hystrix.HystrixCommand> updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body); } diff --git a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java index 65fd59009b15..051830693514 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/PetApi.java @@ -56,7 +56,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -102,7 +102,7 @@ public interface PetApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -134,7 +134,7 @@ public interface PetApi { produces = "application/json", consumes = "application/x-www-form-urlencoded", method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -149,6 +149,6 @@ public interface PetApi { produces = "application/json", consumes = "multipart/form-data", method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/StoreApi.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/StoreApi.java index 33fd53aa2e25..86121d67f362 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/StoreApi.java @@ -36,7 +36,7 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -60,7 +60,7 @@ public interface StoreApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) diff --git a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/UserApi.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/UserApi.java index d1e1f9e5def7..9a01e79fa0e9 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/UserApi.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/api/UserApi.java @@ -66,7 +66,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -78,7 +78,7 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -110,6 +110,6 @@ public interface UserApi { produces = "application/json", consumes = "application/json", method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java index 867a58e7730f..b26932119079 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/FakeApi.java @@ -120,6 +120,18 @@ public interface FakeApi { } + @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + @RequestMapping(value = "/fake/inline-additionalProperties", + consumes = { "application/json" }, + method = RequestMethod.POST) + default CompletableFuture> testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + // do some magic! + return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); + } + + @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java index d322c3004dd6..ee21db44fa8d 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java @@ -60,7 +60,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default CompletableFuture> deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default CompletableFuture> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -112,7 +112,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default CompletableFuture> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -150,7 +150,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - default CompletableFuture> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default CompletableFuture> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -168,7 +168,7 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - default CompletableFuture> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default CompletableFuture> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java index dc7778018fe1..c19e7c487336 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/StoreApi.java @@ -37,7 +37,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default CompletableFuture> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default CompletableFuture> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -65,7 +65,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default CompletableFuture> getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } diff --git a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java index 1bb90cbfa0bf..1a8a82de5c60 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/UserApi.java @@ -73,7 +73,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default CompletableFuture> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default CompletableFuture> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -87,7 +87,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default CompletableFuture> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default CompletableFuture> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } @@ -125,7 +125,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - default CompletableFuture> updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default CompletableFuture> updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return CompletableFuture.completedFuture(new ResponseEntity(HttpStatus.OK)); } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java index db6e0e39f59f..814003e2086e 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java @@ -97,6 +97,15 @@ public interface FakeApi { ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + @RequestMapping(value = "/fake/inline-additionalProperties", + consumes = { "application/json" }, + method = RequestMethod.POST) + ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + + @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java index dc7c60f97909..e3eebeca3b27 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java @@ -119,6 +119,12 @@ public class FakeApiController implements FakeApi { return new ResponseEntity(HttpStatus.OK); } + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, + @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java index e8e51f438d61..247fa4dec596 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java @@ -55,7 +55,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -98,7 +98,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -130,7 +130,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -145,6 +145,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java index 2153b86a87ad..5a6f5dc28083 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java @@ -36,7 +36,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -75,7 +75,7 @@ public class PetApiController implements PetApi { return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -97,7 +97,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { @@ -105,7 +105,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java index 50abaa03dff5..f0dd4e2d631e 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java @@ -35,7 +35,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -57,7 +57,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java index 6e596b41279d..8d84a45d9494 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApiController.java @@ -29,7 +29,7 @@ public class StoreApiController implements StoreApi { this.objectMapper = objectMapper; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); @@ -45,7 +45,7 @@ public class StoreApiController implements StoreApi { return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java index 7264a3bc9cc1..0f8609bc6ac0 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java @@ -62,7 +62,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -73,7 +73,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -102,6 +102,6 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java index c0f360c35433..b0bf6f653808 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApiController.java @@ -47,13 +47,13 @@ public class UserApiController implements UserApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -91,7 +91,7 @@ public class UserApiController implements UserApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java index db6e0e39f59f..814003e2086e 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApi.java @@ -97,6 +97,15 @@ public interface FakeApi { ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + @RequestMapping(value = "/fake/inline-additionalProperties", + consumes = { "application/json" }, + method = RequestMethod.POST) + ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + + @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java index dc7c60f97909..e3eebeca3b27 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/FakeApiController.java @@ -119,6 +119,12 @@ public class FakeApiController implements FakeApi { return new ResponseEntity(HttpStatus.OK); } + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, + @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java index e8e51f438d61..247fa4dec596 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApi.java @@ -55,7 +55,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -98,7 +98,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -130,7 +130,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -145,6 +145,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java index 2153b86a87ad..5a6f5dc28083 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/PetApiController.java @@ -36,7 +36,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -75,7 +75,7 @@ public class PetApiController implements PetApi { return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -97,7 +97,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { @@ -105,7 +105,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java index 50abaa03dff5..f0dd4e2d631e 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApi.java @@ -35,7 +35,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -57,7 +57,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java index 6e596b41279d..8d84a45d9494 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/StoreApiController.java @@ -29,7 +29,7 @@ public class StoreApiController implements StoreApi { this.objectMapper = objectMapper; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); @@ -45,7 +45,7 @@ public class StoreApiController implements StoreApi { return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java index 7264a3bc9cc1..0f8609bc6ac0 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApi.java @@ -62,7 +62,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -73,7 +73,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -102,6 +102,6 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java index c0f360c35433..b0bf6f653808 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/io/swagger/api/UserApiController.java @@ -47,13 +47,13 @@ public class UserApiController implements UserApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -91,7 +91,7 @@ public class UserApiController implements UserApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApi.java index 79cc25c16b0a..29cfced70390 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApi.java @@ -119,6 +119,18 @@ public interface FakeApi { } + @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + @RequestMapping(value = "/fake/inline-additionalProperties", + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + + @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiController.java index fd75b3ed1546..c898df89b452 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiController.java @@ -101,6 +101,12 @@ public class FakeApiController implements FakeApi { return delegate.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble); } + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, + @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + // do some magic! + return delegate.testInlineAdditionalProperties(param); + } + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiDelegate.java index 6029e71010b6..f3ce2e50bd8b 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/FakeApiDelegate.java @@ -97,6 +97,14 @@ public interface FakeApiDelegate { return new ResponseEntity(HttpStatus.OK); } + /** + * @see FakeApi#testInlineAdditionalProperties + */ + default ResponseEntity testInlineAdditionalProperties(Object param) { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + /** * @see FakeApi#testJsonFormData */ diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java index 239a5e189d6b..97b085a2b78a 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApi.java @@ -59,7 +59,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } @@ -111,7 +111,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } @@ -149,7 +149,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } @@ -167,7 +167,7 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java index 62d04acc8fca..066d70752486 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/PetApiController.java @@ -43,7 +43,7 @@ public class PetApiController implements PetApi { return delegate.addPet(body); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -62,7 +62,7 @@ public class PetApiController implements PetApi { return delegate.findPetsByTags(tags); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return delegate.getPetById(petId); @@ -74,7 +74,7 @@ public class PetApiController implements PetApi { return delegate.updatePet(body); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { @@ -82,7 +82,7 @@ public class PetApiController implements PetApi { return delegate.updatePetWithForm(petId, name, status); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApi.java index 2361343fe79e..429c00ba0696 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApi.java @@ -36,7 +36,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } @@ -64,7 +64,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiController.java index dff545adaba4..45235d0af2e2 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/StoreApiController.java @@ -36,7 +36,7 @@ public class StoreApiController implements StoreApi { this.delegate = delegate; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return delegate.deleteOrder(orderId); @@ -47,7 +47,7 @@ public class StoreApiController implements StoreApi { return delegate.getInventory(); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return delegate.getOrderById(orderId); diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApi.java index aeb4b57e6671..2ab8710c94e9 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApi.java @@ -72,7 +72,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } @@ -86,7 +86,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } @@ -124,7 +124,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - default ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + default ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiController.java index 9f013c422173..0477eadb15cb 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/io/swagger/api/UserApiController.java @@ -54,13 +54,13 @@ public class UserApiController implements UserApi { return delegate.createUsersWithListInput(body); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return delegate.deleteUser(username); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return delegate.getUserByName(username); @@ -78,7 +78,7 @@ public class UserApiController implements UserApi { return delegate.logoutUser(); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApi.java index db6e0e39f59f..814003e2086e 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApi.java @@ -97,6 +97,15 @@ public interface FakeApi { ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + @RequestMapping(value = "/fake/inline-additionalProperties", + consumes = { "application/json" }, + method = RequestMethod.POST) + ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + + @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiController.java index 1936ebcc6b8c..1f9c4d4fd125 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiController.java @@ -101,6 +101,12 @@ public class FakeApiController implements FakeApi { return delegate.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble); } + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, + @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + // do some magic! + return delegate.testInlineAdditionalProperties(param); + } + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiDelegate.java index 141576280a95..d4f5be8dbe78 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/FakeApiDelegate.java @@ -75,6 +75,11 @@ public interface FakeApiDelegate { Integer enumQueryInteger, Double enumQueryDouble); + /** + * @see FakeApi#testInlineAdditionalProperties + */ + ResponseEntity testInlineAdditionalProperties(Object param); + /** * @see FakeApi#testJsonFormData */ diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java index e8e51f438d61..247fa4dec596 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApi.java @@ -55,7 +55,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -98,7 +98,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -130,7 +130,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -145,6 +145,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java index 62d04acc8fca..066d70752486 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/PetApiController.java @@ -43,7 +43,7 @@ public class PetApiController implements PetApi { return delegate.addPet(body); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -62,7 +62,7 @@ public class PetApiController implements PetApi { return delegate.findPetsByTags(tags); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return delegate.getPetById(petId); @@ -74,7 +74,7 @@ public class PetApiController implements PetApi { return delegate.updatePet(body); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { @@ -82,7 +82,7 @@ public class PetApiController implements PetApi { return delegate.updatePetWithForm(petId, name, status); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApi.java index 50abaa03dff5..f0dd4e2d631e 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApi.java @@ -35,7 +35,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -57,7 +57,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiController.java index dff545adaba4..45235d0af2e2 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/StoreApiController.java @@ -36,7 +36,7 @@ public class StoreApiController implements StoreApi { this.delegate = delegate; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return delegate.deleteOrder(orderId); @@ -47,7 +47,7 @@ public class StoreApiController implements StoreApi { return delegate.getInventory(); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return delegate.getOrderById(orderId); diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApi.java index 7264a3bc9cc1..0f8609bc6ac0 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApi.java @@ -62,7 +62,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -73,7 +73,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -102,6 +102,6 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiController.java index 9f013c422173..0477eadb15cb 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/io/swagger/api/UserApiController.java @@ -54,13 +54,13 @@ public class UserApiController implements UserApi { return delegate.createUsersWithListInput(body); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return delegate.deleteUser(username); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return delegate.getUserByName(username); @@ -78,7 +78,7 @@ public class UserApiController implements UserApi { return delegate.logoutUser(); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/AnotherFakeApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/AnotherFakeApi.java index f4111f3fbd24..d9e7d4a9fbbd 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/AnotherFakeApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/AnotherFakeApi.java @@ -31,7 +31,6 @@ public interface AnotherFakeApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) @ApiImplicitParams({ - }) @RequestMapping(value = "/another-fake/dummy", produces = { "application/json" }, diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApi.java index 8ce5280a6f2f..75bd99fd3600 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApi.java @@ -35,7 +35,6 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "Output boolean", response = Boolean.class) }) @ApiImplicitParams({ - }) @RequestMapping(value = "/fake/outer/boolean", method = RequestMethod.POST) @@ -46,7 +45,6 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "Output composite", response = OuterComposite.class) }) @ApiImplicitParams({ - }) @RequestMapping(value = "/fake/outer/composite", method = RequestMethod.POST) @@ -57,7 +55,6 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "Output number", response = BigDecimal.class) }) @ApiImplicitParams({ - }) @RequestMapping(value = "/fake/outer/number", method = RequestMethod.POST) @@ -68,7 +65,6 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "Output string", response = String.class) }) @ApiImplicitParams({ - }) @RequestMapping(value = "/fake/outer/string", method = RequestMethod.POST) @@ -79,7 +75,6 @@ public interface FakeApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) @ApiImplicitParams({ - }) @RequestMapping(value = "/fake", produces = { "application/json" }, @@ -95,7 +90,6 @@ public interface FakeApi { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/fake", produces = { "application/xml; charset=utf-8", "application/json; charset=utf-8" }, @@ -109,7 +103,8 @@ public interface FakeApi { @ApiResponse(code = 400, message = "Invalid request"), @ApiResponse(code = 404, message = "Not found") }) @ApiImplicitParams({ - @ApiImplicitParam(name = "enumHeaderStringArray", value = "Header parameter enum test (string array)", dataType = "List", paramType = "header"),@ApiImplicitParam(name = "enumHeaderString", value = "Header parameter enum test (string)", dataType = "String", paramType = "header") + @ApiImplicitParam(name = "enumHeaderStringArray", value = "Header parameter enum test (string array)", dataType = "List", paramType = "header"), + @ApiImplicitParam(name = "enumHeaderString", value = "Header parameter enum test (string)", dataType = "String", paramType = "header") }) @RequestMapping(value = "/fake", produces = { "*/*" }, @@ -118,11 +113,21 @@ public interface FakeApi { ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + @ApiImplicitParams({ + }) + @RequestMapping(value = "/fake/inline-additionalProperties", + consumes = { "application/json" }, + method = RequestMethod.POST) + ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + + @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/fake/jsonFormData", consumes = { "application/json" }, diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApiController.java index 4e7742348776..36b114491c4b 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeApiController.java @@ -117,6 +117,12 @@ public class FakeApiController implements FakeApi { return new ResponseEntity(HttpStatus.OK); } + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, + @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeClassnameTestApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeClassnameTestApi.java index 8780b066c187..4625f340a18d 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeClassnameTestApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/FakeClassnameTestApi.java @@ -33,7 +33,6 @@ public interface FakeClassnameTestApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) @ApiImplicitParams({ - }) @RequestMapping(value = "/fake_classname_test", produces = { "application/json" }, diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApi.java index e787d55f2a83..da2e86506905 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApi.java @@ -38,7 +38,6 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/pet", produces = { "application/xml", "application/json" }, @@ -61,7 +60,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -74,7 +73,6 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid status value") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }, @@ -92,7 +90,6 @@ public interface PetApi { @ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @ApiResponse(code = 400, message = "Invalid tag value") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }, @@ -108,12 +105,11 @@ public interface PetApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Pet not found") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -127,7 +123,6 @@ public interface PetApi { @ApiResponse(code = 404, message = "Pet not found"), @ApiResponse(code = 405, message = "Validation exception") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/pet", produces = { "application/xml", "application/json" }, @@ -145,13 +140,12 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -163,12 +157,11 @@ public interface PetApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @ApiImplicitParams({ - }) @RequestMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApiController.java index 8dfade4628e4..731b377d9bf1 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/PetApiController.java @@ -36,7 +36,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); @@ -74,7 +74,7 @@ public class PetApiController implements PetApi { return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -96,7 +96,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { @@ -104,7 +104,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApi.java index 6206381ca929..5e1427e459ba 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApi.java @@ -33,12 +33,11 @@ public interface StoreApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -47,7 +46,6 @@ public interface StoreApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/store/inventory", produces = { "application/json" }, @@ -61,12 +59,11 @@ public interface StoreApi { @ApiResponse(code = 400, message = "Invalid ID supplied"), @ApiResponse(code = 404, message = "Order not found") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) @@ -74,7 +71,6 @@ public interface StoreApi { @ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 400, message = "Invalid Order") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/store/order", produces = { "application/xml", "application/json" }, diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApiController.java index 6e596b41279d..8d84a45d9494 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/StoreApiController.java @@ -29,7 +29,7 @@ public class StoreApiController implements StoreApi { this.objectMapper = objectMapper; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); @@ -45,7 +45,7 @@ public class StoreApiController implements StoreApi { return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApi.java index 9b3e8feb6b3a..cce5a66a1ac2 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApi.java @@ -32,7 +32,6 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/user", produces = { "application/xml", "application/json" }, @@ -44,7 +43,6 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/user/createWithArray", produces = { "application/xml", "application/json" }, @@ -56,7 +54,6 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/user/createWithList", produces = { "application/xml", "application/json" }, @@ -69,12 +66,11 @@ public interface UserApi { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -83,12 +79,11 @@ public interface UserApi { @ApiResponse(code = 400, message = "Invalid username supplied"), @ApiResponse(code = 404, message = "User not found") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -96,7 +91,6 @@ public interface UserApi { @ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 400, message = "Invalid username/password supplied") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/user/login", produces = { "application/xml", "application/json" }, @@ -108,7 +102,6 @@ public interface UserApi { @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/user/logout", produces = { "application/xml", "application/json" }, @@ -121,11 +114,10 @@ public interface UserApi { @ApiResponse(code = 400, message = "Invalid user supplied"), @ApiResponse(code = 404, message = "User not found") }) @ApiImplicitParams({ - }) @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApiController.java index c0f360c35433..b0bf6f653808 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/io/swagger/api/UserApiController.java @@ -47,13 +47,13 @@ public class UserApiController implements UserApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -91,7 +91,7 @@ public class UserApiController implements UserApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApi.java index 97e16f68d86e..60ba7b12cbe5 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApi.java @@ -98,6 +98,15 @@ public interface FakeApi { ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) Optional> enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) Optional enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) Optional> enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") Optional enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Optional enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + @RequestMapping(value = "/fake/inline-additionalProperties", + consumes = { "application/json" }, + method = RequestMethod.POST) + ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + + @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApiController.java index 64337b2530f2..7a93d8657c75 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/FakeApiController.java @@ -120,6 +120,12 @@ public class FakeApiController implements FakeApi { return new ResponseEntity(HttpStatus.OK); } + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, + @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApi.java index d5723ddec2a2..a185f9061aec 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApi.java @@ -56,7 +56,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) Optional apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) Optional apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -99,7 +99,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -131,7 +131,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -146,6 +146,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApiController.java index ee3aa428362d..5d82b397bb7f 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/PetApiController.java @@ -37,7 +37,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) Optional apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -76,7 +76,7 @@ public class PetApiController implements PetApi { return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -98,7 +98,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { @@ -106,7 +106,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApi.java index 461faf4522a4..3df1045f37a5 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApi.java @@ -36,7 +36,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -58,7 +58,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApiController.java index d534a47a0206..3b61ee56049e 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/StoreApiController.java @@ -30,7 +30,7 @@ public class StoreApiController implements StoreApi { this.objectMapper = objectMapper; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); @@ -46,7 +46,7 @@ public class StoreApiController implements StoreApi { return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApi.java index 40ac1add4bdc..d62e4a644c29 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApi.java @@ -63,7 +63,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -74,7 +74,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -103,6 +103,6 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApiController.java index a2f4a5478f1a..a1d88ff251ab 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/io/swagger/api/UserApiController.java @@ -48,13 +48,13 @@ public class UserApiController implements UserApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -92,7 +92,7 @@ public class UserApiController implements UserApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java index db6e0e39f59f..814003e2086e 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java @@ -97,6 +97,15 @@ public interface FakeApi { ResponseEntity testEnumParameters(@ApiParam(value = "Form parameter enum test (string array)", allowableValues=">, $") @RequestPart(value="enum_form_string_array", required=false) List enumFormStringArray,@ApiParam(value = "Form parameter enum test (string)", allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestPart(value="enum_form_string", required=false) String enumFormString,@ApiParam(value = "Header parameter enum test (string array)" , allowableValues=">, $") @RequestHeader(value="enum_header_string_array", required=false) List enumHeaderStringArray,@ApiParam(value = "Header parameter enum test (string)" , allowableValues="_abc, -efg, (xyz)", defaultValue="-efg") @RequestHeader(value="enum_header_string", required=false) String enumHeaderString,@ApiParam(value = "Query parameter enum test (string array)", allowableValues = ">, $") @Valid @RequestParam(value = "enum_query_string_array", required = false) List enumQueryStringArray,@ApiParam(value = "Query parameter enum test (string)", allowableValues = "_abc, -efg, (xyz)", defaultValue = "-efg") @Valid @RequestParam(value = "enum_query_string", required = false, defaultValue="-efg") String enumQueryString,@ApiParam(value = "Query parameter enum test (double)", allowableValues = "1, -2") @Valid @RequestParam(value = "enum_query_integer", required = false) Integer enumQueryInteger,@ApiParam(value = "Query parameter enum test (double)", allowableValues="1.1, -1.2") @RequestPart(value="enum_query_double", required=false) Double enumQueryDouble, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + @ApiOperation(value = "test inline additionalProperties", nickname = "testInlineAdditionalProperties", notes = "", tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + @RequestMapping(value = "/fake/inline-additionalProperties", + consumes = { "application/json" }, + method = RequestMethod.POST) + ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + + @ApiOperation(value = "test json serialization of form data", nickname = "testJsonFormData", notes = "", tags={ "fake", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "successful operation") }) diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java index dc7c60f97909..e3eebeca3b27 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java @@ -119,6 +119,12 @@ public class FakeApiController implements FakeApi { return new ResponseEntity(HttpStatus.OK); } + public ResponseEntity testInlineAdditionalProperties(@ApiParam(value = "request body" ,required=true ) @Valid @RequestBody Object param, + @RequestHeader(value = "Accept", required = false) String accept) throws Exception { + // do some magic! + return new ResponseEntity(HttpStatus.OK); + } + public ResponseEntity testJsonFormData(@ApiParam(value = "field1", required=true) @RequestPart(value="param", required=true) String param, @ApiParam(value = "field2", required=true) @RequestPart(value="param2", required=true) String param2, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java index e8e51f438d61..247fa4dec596 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApi.java @@ -55,7 +55,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @@ -98,7 +98,7 @@ public interface PetApi { @RequestMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = { @@ -130,7 +130,7 @@ public interface PetApi { produces = { "application/xml", "application/json" }, consumes = { "application/x-www-form-urlencoded" }, method = RequestMethod.POST) - ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = { @@ -145,6 +145,6 @@ public interface PetApi { produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java index 2153b86a87ad..5a6f5dc28083 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/PetApiController.java @@ -36,7 +36,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -75,7 +75,7 @@ public class PetApiController implements PetApi { return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -97,7 +97,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Updated name of the pet") @RequestPart(value="name", required=false) String name, @ApiParam(value = "Updated status of the pet") @RequestPart(value="status", required=false) String status, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { @@ -105,7 +105,7 @@ public class PetApiController implements PetApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId, + public ResponseEntity uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId, @ApiParam(value = "Additional data to pass to server") @RequestPart(value="additionalMetadata", required=false) String additionalMetadata, @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java index 50abaa03dff5..f0dd4e2d631e 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApi.java @@ -35,7 +35,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @@ -57,7 +57,7 @@ public interface StoreApi { @RequestMapping(value = "/store/order/{order_id}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", }) diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java index 6e596b41279d..8d84a45d9494 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/StoreApiController.java @@ -29,7 +29,7 @@ public class StoreApiController implements StoreApi { this.objectMapper = objectMapper; } - public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("order_id") String orderId, + public ResponseEntity deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("order_id") String orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); @@ -45,7 +45,7 @@ public class StoreApiController implements StoreApi { return new ResponseEntity>(HttpStatus.OK); } - public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("order_id") Long orderId, + public ResponseEntity getOrderById( @Min(1) @Max(5)@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java index 7264a3bc9cc1..0f8609bc6ac0 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApi.java @@ -62,7 +62,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.DELETE) - ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Get user by user name", nickname = "getUserByName", notes = "", response = User.class, tags={ "user", }) @@ -73,7 +73,7 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.GET) - ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; @ApiOperation(value = "Logs user into the system", nickname = "loginUser", notes = "", response = String.class, tags={ "user", }) @@ -102,6 +102,6 @@ public interface UserApi { @RequestMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }, method = RequestMethod.PUT) - ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; + ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception; } diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java index c0f360c35433..b0bf6f653808 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/api/UserApiController.java @@ -47,13 +47,13 @@ public class UserApiController implements UserApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username, + public ResponseEntity getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathVariable("username") String username, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! @@ -91,7 +91,7 @@ public class UserApiController implements UserApi { return new ResponseEntity(HttpStatus.OK); } - public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username, + public ResponseEntity updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username, @ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body, @RequestHeader(value = "Accept", required = false) String accept) throws Exception { // do some magic! From 681b1c20ea775a0c2dc718137ad3e3040f215031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Fraudeau?= Date: Thu, 26 Oct 2017 10:44:06 +0200 Subject: [PATCH 23/28] [Scala][Finch] Fix interpretation of queryParams and headers (#6809) * [Scala][Finch] Fix interpretation of queryParams and headers * [Scala][Finch] Updates the sample for Finch generated server --- .../codegen/languages/FinchServerCodegen.java | 27 ++++++++++++++----- .../petstore/finch/.swagger-codegen/VERSION | 2 +- .../main/scala/io/swagger/apis/PetApi.scala | 6 ++--- .../main/scala/io/swagger/apis/UserApi.scala | 2 +- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FinchServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FinchServerCodegen.java index f807325c1442..612c0b7a68d2 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FinchServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FinchServerCodegen.java @@ -248,17 +248,30 @@ public class FinchServerCodegen extends DefaultCodegen implements CodegenConfig for (CodegenParameter p : op.allParams) { // TODO: This hacky, should be converted to mappings if possible to keep it clean. // This could also be done using template imports - if(Boolean.TRUE.equals(p.isPrimitiveType)) { + if(p.isPathParam && p.isPrimitiveType) { p.vendorExtensions.put("x-codegen-normalized-path-type", p.dataType.toLowerCase()); p.vendorExtensions.put("x-codegen-normalized-input-type", p.dataType); - } else if(Boolean.TRUE.equals(p.isBodyParam)) { + } else if(p.isHeaderParam) { + if(p.required) { + p.vendorExtensions.put("x-codegen-normalized-path-type", "header(\"" + p.baseName + "\")"); + p.vendorExtensions.put("x-codegen-normalized-input-type", p.dataType); + } else { + p.vendorExtensions.put("x-codegen-normalized-path-type", "headerOption(\"" + p.baseName + "\")"); + p.vendorExtensions.put("x-codegen-normalized-input-type", "Option["+ p.dataType + "]"); + } + } else if(p.isQueryParam) { + if(p.isContainer || p.isListContainer) { + p.vendorExtensions.put("x-codegen-normalized-path-type", "params(\"" + p.baseName + "\")"); + p.vendorExtensions.put("x-codegen-normalized-input-type", p.dataType.replaceAll("^[^\\[]+", "Seq")); + } else { + p.vendorExtensions.put("x-codegen-normalized-path-type", "param(\"" + p.baseName + "\")"); + p.vendorExtensions.put("x-codegen-normalized-input-type", p.dataType); + } + } else if(p.isBodyParam) { p.vendorExtensions.put("x-codegen-normalized-path-type", "jsonBody["+ p.dataType + "]"); p.vendorExtensions.put("x-codegen-normalized-input-type", p.dataType); - } else if(Boolean.TRUE.equals(p.isContainer) || Boolean.TRUE.equals(p.isListContainer)) { - p.vendorExtensions.put("x-codegen-normalized-path-type", "params(\""+ p.paramName + "\")"); - p.vendorExtensions.put("x-codegen-normalized-input-type", p.dataType.replaceAll("^[^\\[]+", "Seq")); - } else if(Boolean.TRUE.equals(p.isFile)) { - p.vendorExtensions.put("x-codegen-normalized-path-type", "fileUpload(\""+ p.paramName + "\")"); + } else if(p.isFile) { + p.vendorExtensions.put("x-codegen-normalized-path-type", "fileUpload(\""+ p.baseName + "\")"); p.vendorExtensions.put("x-codegen-normalized-input-type", "FileUpload"); } else { p.vendorExtensions.put("x-codegen-normalized-path-type", p.dataType); diff --git a/samples/server/petstore/finch/.swagger-codegen/VERSION b/samples/server/petstore/finch/.swagger-codegen/VERSION index 7fea99011a6f..f9f7450d1359 100644 --- a/samples/server/petstore/finch/.swagger-codegen/VERSION +++ b/samples/server/petstore/finch/.swagger-codegen/VERSION @@ -1 +1 @@ -2.2.3-SNAPSHOT \ No newline at end of file +2.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/finch/src/main/scala/io/swagger/apis/PetApi.scala b/samples/server/petstore/finch/src/main/scala/io/swagger/apis/PetApi.scala index 74a01c56f51c..be9bc36a557d 100644 --- a/samples/server/petstore/finch/src/main/scala/io/swagger/apis/PetApi.scala +++ b/samples/server/petstore/finch/src/main/scala/io/swagger/apis/PetApi.scala @@ -51,7 +51,7 @@ object PetApi { * @return And endpoint representing a Unit */ private def deletePet(da: DataAccessor): Endpoint[Unit] = - delete("pet" :: long :: string) { (petId: Long, apiKey: String) => + delete("pet" :: long :: headerOption("api_key")) { (petId: Long, apiKey: Option[String]) => da.Pet_deletePet(petId, apiKey) NoContent[Unit] } handle { @@ -108,7 +108,7 @@ object PetApi { * @return And endpoint representing a Unit */ private def updatePetWithForm(da: DataAccessor): Endpoint[Unit] = - post("pet" :: long :: string :: string) { (petId: Long, name: String, status: String) => + post("pet" :: long :: String :: String) { (petId: Long, name: String, status: String) => da.Pet_updatePetWithForm(petId, name, status) NoContent[Unit] } handle { @@ -120,7 +120,7 @@ object PetApi { * @return And endpoint representing a ApiResponse */ private def uploadFile(da: DataAccessor): Endpoint[ApiResponse] = - post("pet" :: long :: "uploadImage" :: string :: fileUpload("file")) { (petId: Long, additionalMetadata: String, file: FileUpload) => + post("pet" :: long :: "uploadImage" :: String :: fileUpload("file")) { (petId: Long, additionalMetadata: String, file: FileUpload) => Ok(da.Pet_uploadFile(petId, additionalMetadata, file)) } handle { case e: Exception => BadRequest(e) diff --git a/samples/server/petstore/finch/src/main/scala/io/swagger/apis/UserApi.scala b/samples/server/petstore/finch/src/main/scala/io/swagger/apis/UserApi.scala index dfb49b4291a8..bf1579835aa5 100644 --- a/samples/server/petstore/finch/src/main/scala/io/swagger/apis/UserApi.scala +++ b/samples/server/petstore/finch/src/main/scala/io/swagger/apis/UserApi.scala @@ -97,7 +97,7 @@ object UserApi { * @return And endpoint representing a String */ private def loginUser(da: DataAccessor): Endpoint[String] = - get("user" :: "login" :: string :: string) { (username: String, password: String) => + get("user" :: "login" :: param("username") :: param("password")) { (username: String, password: String) => Ok(da.User_loginUser(username, password)) } handle { case e: Exception => BadRequest(e) From 4f3c86aa145e040024ee4d539947cf3b69c60d21 Mon Sep 17 00:00:00 2001 From: Keni Steward Date: Thu, 26 Oct 2017 05:57:30 -0400 Subject: [PATCH 24/28] Adding forRoot instead of forConfig and forcing only 1 instantiation of the ApiModule (#6775) * Added forRoot and constructure duplicate check * added imports * updated providers display format * updated examples * Moved providers so users don't hav eto use forRoot if they don't want. * Updated the readme --- .../typescript-angular/README.mustache | 65 +++++++++++++++---- .../typescript-angular/api.module.mustache | 16 +++-- .../default/api.module.ts | 17 +++-- .../default/model/ApiResponse.ts | 2 - .../default/model/category.ts | 2 - .../default/model/order.ts | 2 - .../default/model/pet.ts | 2 - .../default/model/tag.ts | 2 - .../default/model/user.ts | 2 - .../typescript-angular-v2/npm/README.md | 65 +++++++++++++++---- .../typescript-angular-v2/npm/api.module.ts | 17 +++-- .../npm/model/ApiResponse.ts | 2 - .../npm/model/category.ts | 2 - .../typescript-angular-v2/npm/model/order.ts | 2 - .../typescript-angular-v2/npm/model/pet.ts | 2 - .../typescript-angular-v2/npm/model/tag.ts | 2 - .../typescript-angular-v2/npm/model/user.ts | 2 - .../with-interfaces/README.md | 65 +++++++++++++++---- .../with-interfaces/api.module.ts | 17 +++-- .../with-interfaces/model/Category.ts | 2 - .../with-interfaces/model/Order.ts | 2 - .../with-interfaces/model/Pet.ts | 2 - .../with-interfaces/model/Tag.ts | 2 - .../with-interfaces/model/User.ts | 2 - .../with-interfaces/model/apiResponse.ts | 2 - .../typescript-angular-v4.3/npm/README.md | 65 +++++++++++++++---- .../typescript-angular-v4.3/npm/api.module.ts | 17 +++-- .../npm/model/apiResponse.ts | 2 - .../npm/model/category.ts | 2 - .../npm/model/order.ts | 7 +- .../typescript-angular-v4.3/npm/model/pet.ts | 7 +- .../typescript-angular-v4.3/npm/model/tag.ts | 2 - .../typescript-angular-v4.3/npm/model/user.ts | 2 - .../typescript-angular-v4/npm/README.md | 65 +++++++++++++++---- .../typescript-angular-v4/npm/api.module.ts | 17 +++-- .../npm/model/apiResponse.ts | 2 - .../npm/model/category.ts | 2 - .../typescript-angular-v4/npm/model/order.ts | 2 - .../typescript-angular-v4/npm/model/pet.ts | 2 - .../typescript-angular-v4/npm/model/tag.ts | 2 - .../typescript-angular-v4/npm/model/user.ts | 2 - 41 files changed, 352 insertions(+), 144 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/README.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/README.mustache index 5c46e73275f5..c48b905d4cf5 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/README.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/README.mustache @@ -40,36 +40,77 @@ In your project: npm link {{npmName}}@{{npmVersion}} ``` -In your angular2 project: +In your Angular project: + ``` -import { DefaultApi } from '{{npmName}}/api/api'; +// without configuring providers +import { ApiModule } from '{{npmName}}'; + @NgModule({ - imports: [], - declarations: [], - exports: [], - providers: [AppModule] + imports: [ ApiModule ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] }) -export class CoreModule {} +export class AppModule {} ``` + ``` -import { DefaultApi } from '{{npmName}}/api/api'; +// configuring providers +import { ApiModule, Configuration, ConfigurationParameters } from '{{npmName}}'; + +export function apiConfigFactory (): Configuration => { + const params: ConfigurationParameters = { + // set configuration parameters here. + } + return new Configuration(params); +} + +@NgModule({ + imports: [ ApiModule.forRoot(apiConfigFactory) ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + +``` +import { DefaultApi } from '{{npmName}}'; export class AppComponent { constructor(private apiGateway: DefaultApi) { } } ``` +Note: The ApiModule is restricted to being instantiated once app wide. +This is to ensure that all services are treated as singletons. + ### Set service base path If different than the generated base path, during app bootstrap, you can provide the base path to your service. ``` -import { BASE_PATH } from './path-to-swagger-gen-service/index'; +import { BASE_PATH } from '{{npmName}}'; bootstrap(AppComponent, [ { provide: BASE_PATH, useValue: 'https://your-web-service.com' }, ]); ``` +or + +``` +import { BASE_PATH } from '{{npmName}}'; + +@NgModule({ + imports: [], + declarations: [ AppComponent ], + providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + #### Using @angular/cli First extend your `src/environments/*.ts` files by adding the corresponding base path: @@ -88,11 +129,11 @@ import { environment } from '../environments/environment'; @NgModule({ declarations: [ - AppComponent, + AppComponent ], imports: [ ], - providers: [{ provide: BASE_PATH, useValue: useValue: environment.API_BASE_PATH }], - bootstrap: [AppComponent] + providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }], + bootstrap: [ AppComponent ] }) export class AppModule { } ``` \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/api.module.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/api.module.mustache index cb695b271e13..9cba3ae5afe2 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/api.module.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/api.module.mustache @@ -1,4 +1,4 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; import { CommonModule } from '@angular/common'; {{#useHttpClient}} import { HttpClientModule } from '@angular/common/http'; @@ -18,13 +18,21 @@ import { {{classname}} } from './{{importPath}}'; imports: [ CommonModule, {{#useHttpClient}}HttpClientModule{{/useHttpClient}}{{^useHttpClient}}HttpModule{{/useHttpClient}} ], declarations: [], exports: [], - providers: [ {{#apiInfo}}{{#apis}}{{classname}}{{#hasMore}}, {{/hasMore}}{{/apis}}{{/apiInfo}} ] + providers: [ + {{#apiInfo}}{{#apis}}{{classname}}{{#hasMore}}, + {{/hasMore}}{{/apis}}{{/apiInfo}} ] }) export class ApiModule { - public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders { + public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders { return { ngModule: ApiModule, - providers: [ {provide: Configuration, useFactory: configurationFactory}] + providers: [ { provide: Configuration, useFactory: configurationFactory } ] + } + } + + constructor( @Optional() @SkipSelf() parentModule: ApiModule) { + if (parentModule) { + throw new Error('ApiModule is already loaded. Import your base AppModule only.'); } } } diff --git a/samples/client/petstore/typescript-angular-v2/default/api.module.ts b/samples/client/petstore/typescript-angular-v2/default/api.module.ts index dcce0dbd6286..a506a90adfcc 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api.module.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api.module.ts @@ -1,4 +1,4 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; import { CommonModule } from '@angular/common'; import { HttpModule } from '@angular/http'; import { Configuration } from './configuration'; @@ -11,13 +11,22 @@ import { UserService } from './api/user.service'; imports: [ CommonModule, HttpModule ], declarations: [], exports: [], - providers: [ PetService, StoreService, UserService ] + providers: [ + PetService, + StoreService, + UserService ] }) export class ApiModule { - public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders { + public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders { return { ngModule: ApiModule, - providers: [ {provide: Configuration, useFactory: configurationFactory}] + providers: [ { provide: Configuration, useFactory: configurationFactory } ] + } + } + + constructor( @Optional() @SkipSelf() parentModule: ApiModule) { + if (parentModule) { + throw new Error('ApiModule is already loaded. Import your base AppModule only.'); } } } diff --git a/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts b/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts index ac34396e0b34..eac4208f022a 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts @@ -19,5 +19,3 @@ export interface ApiResponse { type?: string; message?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v2/default/model/category.ts b/samples/client/petstore/typescript-angular-v2/default/model/category.ts index 767b49484181..5040d1db915b 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/category.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/category.ts @@ -18,5 +18,3 @@ export interface Category { id?: number; name?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v2/default/model/order.ts b/samples/client/petstore/typescript-angular-v2/default/model/order.ts index 3ac0a1c39c7d..33b60bb6e163 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/order.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/order.ts @@ -33,5 +33,3 @@ export namespace Order { Delivered: 'delivered' as StatusEnum } } - - diff --git a/samples/client/petstore/typescript-angular-v2/default/model/pet.ts b/samples/client/petstore/typescript-angular-v2/default/model/pet.ts index 0e08dee12ae4..342ab5f8e752 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/pet.ts @@ -35,5 +35,3 @@ export namespace Pet { Sold: 'sold' as StatusEnum } } - - diff --git a/samples/client/petstore/typescript-angular-v2/default/model/tag.ts b/samples/client/petstore/typescript-angular-v2/default/model/tag.ts index 73e4d26aa3b2..c75240003572 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/tag.ts @@ -18,5 +18,3 @@ export interface Tag { id?: number; name?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v2/default/model/user.ts b/samples/client/petstore/typescript-angular-v2/default/model/user.ts index de9c1d85670e..a0261a6f37d2 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/user.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/user.ts @@ -27,5 +27,3 @@ export interface User { */ userStatus?: number; } - - diff --git a/samples/client/petstore/typescript-angular-v2/npm/README.md b/samples/client/petstore/typescript-angular-v2/npm/README.md index 038fd51491ce..afa7807e82a4 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/README.md +++ b/samples/client/petstore/typescript-angular-v2/npm/README.md @@ -40,36 +40,77 @@ In your project: npm link @swagger/angular2-typescript-petstore@0.0.1 ``` -In your angular2 project: +In your Angular project: + ``` -import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api'; +// without configuring providers +import { ApiModule } from '@swagger/angular2-typescript-petstore'; + @NgModule({ - imports: [], - declarations: [], - exports: [], - providers: [AppModule] + imports: [ ApiModule ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] }) -export class CoreModule {} +export class AppModule {} ``` + ``` -import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api'; +// configuring providers +import { ApiModule, Configuration, ConfigurationParameters } from '@swagger/angular2-typescript-petstore'; + +export function apiConfigFactory (): Configuration => { + const params: ConfigurationParameters = { + // set configuration parameters here. + } + return new Configuration(params); +} + +@NgModule({ + imports: [ ApiModule.forRoot(apiConfigFactory) ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + +``` +import { DefaultApi } from '@swagger/angular2-typescript-petstore'; export class AppComponent { constructor(private apiGateway: DefaultApi) { } } ``` +Note: The ApiModule is restricted to being instantiated once app wide. +This is to ensure that all services are treated as singletons. + ### Set service base path If different than the generated base path, during app bootstrap, you can provide the base path to your service. ``` -import { BASE_PATH } from './path-to-swagger-gen-service/index'; +import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; bootstrap(AppComponent, [ { provide: BASE_PATH, useValue: 'https://your-web-service.com' }, ]); ``` +or + +``` +import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; + +@NgModule({ + imports: [], + declarations: [ AppComponent ], + providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + #### Using @angular/cli First extend your `src/environments/*.ts` files by adding the corresponding base path: @@ -88,11 +129,11 @@ import { environment } from '../environments/environment'; @NgModule({ declarations: [ - AppComponent, + AppComponent ], imports: [ ], - providers: [{ provide: BASE_PATH, useValue: useValue: environment.API_BASE_PATH }], - bootstrap: [AppComponent] + providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }], + bootstrap: [ AppComponent ] }) export class AppModule { } ``` \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v2/npm/api.module.ts b/samples/client/petstore/typescript-angular-v2/npm/api.module.ts index dcce0dbd6286..a506a90adfcc 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api.module.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api.module.ts @@ -1,4 +1,4 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; import { CommonModule } from '@angular/common'; import { HttpModule } from '@angular/http'; import { Configuration } from './configuration'; @@ -11,13 +11,22 @@ import { UserService } from './api/user.service'; imports: [ CommonModule, HttpModule ], declarations: [], exports: [], - providers: [ PetService, StoreService, UserService ] + providers: [ + PetService, + StoreService, + UserService ] }) export class ApiModule { - public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders { + public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders { return { ngModule: ApiModule, - providers: [ {provide: Configuration, useFactory: configurationFactory}] + providers: [ { provide: Configuration, useFactory: configurationFactory } ] + } + } + + constructor( @Optional() @SkipSelf() parentModule: ApiModule) { + if (parentModule) { + throw new Error('ApiModule is already loaded. Import your base AppModule only.'); } } } diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts b/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts index ac34396e0b34..eac4208f022a 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts @@ -19,5 +19,3 @@ export interface ApiResponse { type?: string; message?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/category.ts b/samples/client/petstore/typescript-angular-v2/npm/model/category.ts index 767b49484181..5040d1db915b 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/category.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/category.ts @@ -18,5 +18,3 @@ export interface Category { id?: number; name?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/order.ts b/samples/client/petstore/typescript-angular-v2/npm/model/order.ts index 3ac0a1c39c7d..33b60bb6e163 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/order.ts @@ -33,5 +33,3 @@ export namespace Order { Delivered: 'delivered' as StatusEnum } } - - diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts index 0e08dee12ae4..342ab5f8e752 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts @@ -35,5 +35,3 @@ export namespace Pet { Sold: 'sold' as StatusEnum } } - - diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts b/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts index 73e4d26aa3b2..c75240003572 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts @@ -18,5 +18,3 @@ export interface Tag { id?: number; name?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/user.ts b/samples/client/petstore/typescript-angular-v2/npm/model/user.ts index de9c1d85670e..a0261a6f37d2 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/user.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/user.ts @@ -27,5 +27,3 @@ export interface User { */ userStatus?: number; } - - diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md b/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md index 038fd51491ce..afa7807e82a4 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md @@ -40,36 +40,77 @@ In your project: npm link @swagger/angular2-typescript-petstore@0.0.1 ``` -In your angular2 project: +In your Angular project: + ``` -import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api'; +// without configuring providers +import { ApiModule } from '@swagger/angular2-typescript-petstore'; + @NgModule({ - imports: [], - declarations: [], - exports: [], - providers: [AppModule] + imports: [ ApiModule ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] }) -export class CoreModule {} +export class AppModule {} ``` + ``` -import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api'; +// configuring providers +import { ApiModule, Configuration, ConfigurationParameters } from '@swagger/angular2-typescript-petstore'; + +export function apiConfigFactory (): Configuration => { + const params: ConfigurationParameters = { + // set configuration parameters here. + } + return new Configuration(params); +} + +@NgModule({ + imports: [ ApiModule.forRoot(apiConfigFactory) ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + +``` +import { DefaultApi } from '@swagger/angular2-typescript-petstore'; export class AppComponent { constructor(private apiGateway: DefaultApi) { } } ``` +Note: The ApiModule is restricted to being instantiated once app wide. +This is to ensure that all services are treated as singletons. + ### Set service base path If different than the generated base path, during app bootstrap, you can provide the base path to your service. ``` -import { BASE_PATH } from './path-to-swagger-gen-service/index'; +import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; bootstrap(AppComponent, [ { provide: BASE_PATH, useValue: 'https://your-web-service.com' }, ]); ``` +or + +``` +import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; + +@NgModule({ + imports: [], + declarations: [ AppComponent ], + providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + #### Using @angular/cli First extend your `src/environments/*.ts` files by adding the corresponding base path: @@ -88,11 +129,11 @@ import { environment } from '../environments/environment'; @NgModule({ declarations: [ - AppComponent, + AppComponent ], imports: [ ], - providers: [{ provide: BASE_PATH, useValue: useValue: environment.API_BASE_PATH }], - bootstrap: [AppComponent] + providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }], + bootstrap: [ AppComponent ] }) export class AppModule { } ``` \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api.module.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api.module.ts index dcce0dbd6286..a506a90adfcc 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api.module.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api.module.ts @@ -1,4 +1,4 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; import { CommonModule } from '@angular/common'; import { HttpModule } from '@angular/http'; import { Configuration } from './configuration'; @@ -11,13 +11,22 @@ import { UserService } from './api/user.service'; imports: [ CommonModule, HttpModule ], declarations: [], exports: [], - providers: [ PetService, StoreService, UserService ] + providers: [ + PetService, + StoreService, + UserService ] }) export class ApiModule { - public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders { + public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders { return { ngModule: ApiModule, - providers: [ {provide: Configuration, useFactory: configurationFactory}] + providers: [ { provide: Configuration, useFactory: configurationFactory } ] + } + } + + constructor( @Optional() @SkipSelf() parentModule: ApiModule) { + if (parentModule) { + throw new Error('ApiModule is already loaded. Import your base AppModule only.'); } } } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts index 767b49484181..5040d1db915b 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts @@ -18,5 +18,3 @@ export interface Category { id?: number; name?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts index 3ac0a1c39c7d..33b60bb6e163 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts @@ -33,5 +33,3 @@ export namespace Order { Delivered: 'delivered' as StatusEnum } } - - diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts index 0e08dee12ae4..342ab5f8e752 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts @@ -35,5 +35,3 @@ export namespace Pet { Sold: 'sold' as StatusEnum } } - - diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts index 73e4d26aa3b2..c75240003572 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts @@ -18,5 +18,3 @@ export interface Tag { id?: number; name?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts index de9c1d85670e..a0261a6f37d2 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts @@ -27,5 +27,3 @@ export interface User { */ userStatus?: number; } - - diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts index ac34396e0b34..eac4208f022a 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts @@ -19,5 +19,3 @@ export interface ApiResponse { type?: string; message?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/README.md b/samples/client/petstore/typescript-angular-v4.3/npm/README.md index 038fd51491ce..afa7807e82a4 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/README.md +++ b/samples/client/petstore/typescript-angular-v4.3/npm/README.md @@ -40,36 +40,77 @@ In your project: npm link @swagger/angular2-typescript-petstore@0.0.1 ``` -In your angular2 project: +In your Angular project: + ``` -import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api'; +// without configuring providers +import { ApiModule } from '@swagger/angular2-typescript-petstore'; + @NgModule({ - imports: [], - declarations: [], - exports: [], - providers: [AppModule] + imports: [ ApiModule ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] }) -export class CoreModule {} +export class AppModule {} ``` + ``` -import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api'; +// configuring providers +import { ApiModule, Configuration, ConfigurationParameters } from '@swagger/angular2-typescript-petstore'; + +export function apiConfigFactory (): Configuration => { + const params: ConfigurationParameters = { + // set configuration parameters here. + } + return new Configuration(params); +} + +@NgModule({ + imports: [ ApiModule.forRoot(apiConfigFactory) ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + +``` +import { DefaultApi } from '@swagger/angular2-typescript-petstore'; export class AppComponent { constructor(private apiGateway: DefaultApi) { } } ``` +Note: The ApiModule is restricted to being instantiated once app wide. +This is to ensure that all services are treated as singletons. + ### Set service base path If different than the generated base path, during app bootstrap, you can provide the base path to your service. ``` -import { BASE_PATH } from './path-to-swagger-gen-service/index'; +import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; bootstrap(AppComponent, [ { provide: BASE_PATH, useValue: 'https://your-web-service.com' }, ]); ``` +or + +``` +import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; + +@NgModule({ + imports: [], + declarations: [ AppComponent ], + providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + #### Using @angular/cli First extend your `src/environments/*.ts` files by adding the corresponding base path: @@ -88,11 +129,11 @@ import { environment } from '../environments/environment'; @NgModule({ declarations: [ - AppComponent, + AppComponent ], imports: [ ], - providers: [{ provide: BASE_PATH, useValue: useValue: environment.API_BASE_PATH }], - bootstrap: [AppComponent] + providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }], + bootstrap: [ AppComponent ] }) export class AppModule { } ``` \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api.module.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api.module.ts index 71f51c70cf9d..0ffccef9c704 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api.module.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api.module.ts @@ -1,4 +1,4 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; import { CommonModule } from '@angular/common'; import { HttpClientModule } from '@angular/common/http'; import { Configuration } from './configuration'; @@ -11,13 +11,22 @@ import { UserService } from './api/user.service'; imports: [ CommonModule, HttpClientModule ], declarations: [], exports: [], - providers: [ PetService, StoreService, UserService ] + providers: [ + PetService, + StoreService, + UserService ] }) export class ApiModule { - public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders { + public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders { return { ngModule: ApiModule, - providers: [ {provide: Configuration, useFactory: configurationFactory}] + providers: [ { provide: Configuration, useFactory: configurationFactory } ] + } + } + + constructor( @Optional() @SkipSelf() parentModule: ApiModule) { + if (parentModule) { + throw new Error('ApiModule is already loaded. Import your base AppModule only.'); } } } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts index ac34396e0b34..eac4208f022a 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts @@ -19,5 +19,3 @@ export interface ApiResponse { type?: string; message?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts index 767b49484181..5040d1db915b 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts @@ -18,5 +18,3 @@ export interface Category { id?: number; name?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts index 8c1869a4c130..33b60bb6e163 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts @@ -27,6 +27,9 @@ export interface Order { } export namespace Order { export type StatusEnum = 'placed' | 'approved' | 'delivered'; + export const StatusEnum = { + Placed: 'placed' as StatusEnum, + Approved: 'approved' as StatusEnum, + Delivered: 'delivered' as StatusEnum + } } - - diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts index ce6a095b840d..342ab5f8e752 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts @@ -29,6 +29,9 @@ export interface Pet { } export namespace Pet { export type StatusEnum = 'available' | 'pending' | 'sold'; + export const StatusEnum = { + Available: 'available' as StatusEnum, + Pending: 'pending' as StatusEnum, + Sold: 'sold' as StatusEnum + } } - - diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts index 73e4d26aa3b2..c75240003572 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts @@ -18,5 +18,3 @@ export interface Tag { id?: number; name?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts index de9c1d85670e..a0261a6f37d2 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts @@ -27,5 +27,3 @@ export interface User { */ userStatus?: number; } - - diff --git a/samples/client/petstore/typescript-angular-v4/npm/README.md b/samples/client/petstore/typescript-angular-v4/npm/README.md index 038fd51491ce..afa7807e82a4 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/README.md +++ b/samples/client/petstore/typescript-angular-v4/npm/README.md @@ -40,36 +40,77 @@ In your project: npm link @swagger/angular2-typescript-petstore@0.0.1 ``` -In your angular2 project: +In your Angular project: + ``` -import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api'; +// without configuring providers +import { ApiModule } from '@swagger/angular2-typescript-petstore'; + @NgModule({ - imports: [], - declarations: [], - exports: [], - providers: [AppModule] + imports: [ ApiModule ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] }) -export class CoreModule {} +export class AppModule {} ``` + ``` -import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api'; +// configuring providers +import { ApiModule, Configuration, ConfigurationParameters } from '@swagger/angular2-typescript-petstore'; + +export function apiConfigFactory (): Configuration => { + const params: ConfigurationParameters = { + // set configuration parameters here. + } + return new Configuration(params); +} + +@NgModule({ + imports: [ ApiModule.forRoot(apiConfigFactory) ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + +``` +import { DefaultApi } from '@swagger/angular2-typescript-petstore'; export class AppComponent { constructor(private apiGateway: DefaultApi) { } } ``` +Note: The ApiModule is restricted to being instantiated once app wide. +This is to ensure that all services are treated as singletons. + ### Set service base path If different than the generated base path, during app bootstrap, you can provide the base path to your service. ``` -import { BASE_PATH } from './path-to-swagger-gen-service/index'; +import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; bootstrap(AppComponent, [ { provide: BASE_PATH, useValue: 'https://your-web-service.com' }, ]); ``` +or + +``` +import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; + +@NgModule({ + imports: [], + declarations: [ AppComponent ], + providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + #### Using @angular/cli First extend your `src/environments/*.ts` files by adding the corresponding base path: @@ -88,11 +129,11 @@ import { environment } from '../environments/environment'; @NgModule({ declarations: [ - AppComponent, + AppComponent ], imports: [ ], - providers: [{ provide: BASE_PATH, useValue: useValue: environment.API_BASE_PATH }], - bootstrap: [AppComponent] + providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }], + bootstrap: [ AppComponent ] }) export class AppModule { } ``` \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v4/npm/api.module.ts b/samples/client/petstore/typescript-angular-v4/npm/api.module.ts index dcce0dbd6286..a506a90adfcc 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api.module.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api.module.ts @@ -1,4 +1,4 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; import { CommonModule } from '@angular/common'; import { HttpModule } from '@angular/http'; import { Configuration } from './configuration'; @@ -11,13 +11,22 @@ import { UserService } from './api/user.service'; imports: [ CommonModule, HttpModule ], declarations: [], exports: [], - providers: [ PetService, StoreService, UserService ] + providers: [ + PetService, + StoreService, + UserService ] }) export class ApiModule { - public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders { + public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders { return { ngModule: ApiModule, - providers: [ {provide: Configuration, useFactory: configurationFactory}] + providers: [ { provide: Configuration, useFactory: configurationFactory } ] + } + } + + constructor( @Optional() @SkipSelf() parentModule: ApiModule) { + if (parentModule) { + throw new Error('ApiModule is already loaded. Import your base AppModule only.'); } } } diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts index ac34396e0b34..eac4208f022a 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts @@ -19,5 +19,3 @@ export interface ApiResponse { type?: string; message?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/category.ts b/samples/client/petstore/typescript-angular-v4/npm/model/category.ts index 767b49484181..5040d1db915b 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/category.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/category.ts @@ -18,5 +18,3 @@ export interface Category { id?: number; name?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/order.ts b/samples/client/petstore/typescript-angular-v4/npm/model/order.ts index 3ac0a1c39c7d..33b60bb6e163 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/order.ts @@ -33,5 +33,3 @@ export namespace Order { Delivered: 'delivered' as StatusEnum } } - - diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts index 0e08dee12ae4..342ab5f8e752 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts @@ -35,5 +35,3 @@ export namespace Pet { Sold: 'sold' as StatusEnum } } - - diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts b/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts index 73e4d26aa3b2..c75240003572 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts @@ -18,5 +18,3 @@ export interface Tag { id?: number; name?: string; } - - diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/user.ts b/samples/client/petstore/typescript-angular-v4/npm/model/user.ts index de9c1d85670e..a0261a6f37d2 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/user.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/user.ts @@ -27,5 +27,3 @@ export interface User { */ userStatus?: number; } - - From f78d958ec01917353fa43aad49ad4f6744843bdb Mon Sep 17 00:00:00 2001 From: Stephan E Date: Thu, 26 Oct 2017 13:59:38 +0200 Subject: [PATCH 25/28] Fix ruby model generation with objects and additionalProperties (#6816) * Fix model generation with objects and additionalProperties * Generate Ruby Petstore * Generate Ruby Security Petstore --- .../main/resources/ruby/partial_model_generic.mustache | 9 +++++++-- .../lib/petstore/models/additional_properties_class.rb | 4 ++-- .../client/petstore/ruby/lib/petstore/models/map_test.rb | 4 ++-- .../mixed_properties_and_additional_properties_class.rb | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache b/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache index 00a75b253960..d1882aa26410 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache @@ -56,11 +56,16 @@ {{#vars}} if attributes.has_key?(:'{{{baseName}}}') - {{#isContainer}} + {{#isListContainer}} if (value = attributes[:'{{{baseName}}}']).is_a?(Array) self.{{{name}}} = value end - {{/isContainer}} + {{/isListContainer}} + {{#isMapContainer}} + if (value = attributes[:'{{{baseName}}}']).is_a?(Hash) + self.{{{name}}} = value + end + {{/isMapContainer}} {{^isContainer}} self.{{{name}}} = attributes[:'{{{baseName}}}'] {{/isContainer}} diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb index e5d7fb8f24b4..e3d8890b6e22 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb @@ -45,13 +45,13 @@ module Petstore attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} if attributes.has_key?(:'map_property') - if (value = attributes[:'map_property']).is_a?(Array) + if (value = attributes[:'map_property']).is_a?(Hash) self.map_property = value end end if attributes.has_key?(:'map_of_map_property') - if (value = attributes[:'map_of_map_property']).is_a?(Array) + if (value = attributes[:'map_of_map_property']).is_a?(Hash) self.map_of_map_property = value end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb index 9510ce2a93ce..7b8f95277974 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -66,13 +66,13 @@ module Petstore attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} if attributes.has_key?(:'map_map_of_string') - if (value = attributes[:'map_map_of_string']).is_a?(Array) + if (value = attributes[:'map_map_of_string']).is_a?(Hash) self.map_map_of_string = value end end if attributes.has_key?(:'map_of_enum_string') - if (value = attributes[:'map_of_enum_string']).is_a?(Array) + if (value = attributes[:'map_of_enum_string']).is_a?(Hash) self.map_of_enum_string = value end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index f16ce716f337..75c9795f4795 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -57,7 +57,7 @@ module Petstore end if attributes.has_key?(:'map') - if (value = attributes[:'map']).is_a?(Array) + if (value = attributes[:'map']).is_a?(Hash) self.map = value end end From 54b670b7e0ee851d0e9b29c815111f5572d7da22 Mon Sep 17 00:00:00 2001 From: Kenny Jones Date: Thu, 26 Oct 2017 08:38:30 -0400 Subject: [PATCH 26/28] [python-flask] Create main function and entrypoint (#6814) Enable the creation of the entrypoint so that the server can be started using a named command instead of needing to always use `python -m` to run the server. --- .../flaskConnexion/__main__.mustache | 6 ++- .../flaskConnexion/git_push.sh.mustache | 2 +- .../resources/flaskConnexion/setup.mustache | 2 + .../resources/flaskConnexion/tox.mustache | 2 +- .../flaskConnexion-python2/git_push.sh | 2 +- .../petstore/flaskConnexion-python2/setup.py | 2 + .../swagger_server/__main__.py | 6 ++- .../swagger_server/swagger/swagger.yaml | 48 +++++++++---------- .../petstore/flaskConnexion-python2/tox.ini | 2 +- .../petstore/flaskConnexion/git_push.sh | 2 +- .../server/petstore/flaskConnexion/setup.py | 2 + .../flaskConnexion/swagger_server/__main__.py | 6 ++- .../swagger_server/swagger/swagger.yaml | 48 +++++++++---------- .../server/petstore/flaskConnexion/tox.ini | 2 +- 14 files changed, 75 insertions(+), 57 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/__main__.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/__main__.mustache index efbea8409c5e..8884887471f5 100644 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/__main__.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/__main__.mustache @@ -9,8 +9,12 @@ import connexion from .encoder import JSONEncoder -if __name__ == '__main__': +def main(): app = connexion.App(__name__, specification_dir='./swagger/') app.app.json_encoder = JSONEncoder app.add_api('swagger.yaml', arguments={'title': '{{appDescription}}'}) app.run(port={{serverPort}}) + + +if __name__ == '__main__': + main() diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/git_push.sh.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/git_push.sh.mustache index e153ce23ecf4..a9b0f28edfb9 100755 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/git_push.sh.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/git_push.sh.mustache @@ -28,7 +28,7 @@ git init # Adds the files in the local repository and stages them for commit. git add . -# Commits the tracked changes and prepares them to be pushed to a remote repository. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/setup.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/setup.mustache index dd2dea6aeed3..56f8bc1ec176 100644 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/setup.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/setup.mustache @@ -26,6 +26,8 @@ setup( packages=find_packages(), package_data={'': ['swagger/swagger.yaml']}, include_package_data=True, + entry_points={ + 'console_scripts': ['{{packageName}}={{packageName}}.__main__:main']}, long_description="""\ {{appDescription}} """ diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/tox.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/tox.mustache index 5ad8fe6c031b..3efa994317d9 100644 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/tox.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/tox.mustache @@ -4,7 +4,7 @@ envlist = {{#supportPython2}}py27, {{/supportPython2}}py35 [testenv] deps=-r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt - + commands= nosetests \ [] \ No newline at end of file diff --git a/samples/server/petstore/flaskConnexion-python2/git_push.sh b/samples/server/petstore/flaskConnexion-python2/git_push.sh index ed374619b139..792320114fbe 100644 --- a/samples/server/petstore/flaskConnexion-python2/git_push.sh +++ b/samples/server/petstore/flaskConnexion-python2/git_push.sh @@ -28,7 +28,7 @@ git init # Adds the files in the local repository and stages them for commit. git add . -# Commits the tracked changes and prepares them to be pushed to a remote repository. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote diff --git a/samples/server/petstore/flaskConnexion-python2/setup.py b/samples/server/petstore/flaskConnexion-python2/setup.py index 7a1ce575d354..be5dce52ab74 100644 --- a/samples/server/petstore/flaskConnexion-python2/setup.py +++ b/samples/server/petstore/flaskConnexion-python2/setup.py @@ -26,6 +26,8 @@ setup( packages=find_packages(), package_data={'': ['swagger/swagger.yaml']}, include_package_data=True, + entry_points={ + 'console_scripts': ['swagger_server=swagger_server.__main__:main']}, long_description="""\ 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. """ diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/__main__.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/__main__.py index a85a5591ecea..3310c69bea7c 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/__main__.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/__main__.py @@ -4,8 +4,12 @@ import connexion from .encoder import JSONEncoder -if __name__ == '__main__': +def main(): app = connexion.App(__name__, specification_dir='./swagger/') app.app.json_encoder = JSONEncoder app.add_api('swagger.yaml', arguments={'title': '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.'}) app.run(port=8080) + + +if __name__ == '__main__': + main() diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/swagger/swagger.yaml b/samples/server/petstore/flaskConnexion-python2/swagger_server/swagger/swagger.yaml index 32000d3c2dca..ba2a870047dd 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/swagger/swagger.yaml +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/swagger/swagger.yaml @@ -108,11 +108,11 @@ paths: type: "array" items: type: "string" - default: "available" enum: - "available" - "pending" - "sold" + default: "available" collectionFormat: "csv" responses: 200: @@ -627,12 +627,12 @@ definitions: title: "Pet Order" description: "An order for a pets from the pet store" example: - petId: 6 - quantity: 1 id: 0 - shipDate: "2000-01-23T04:56:07.000+00:00" + petId: 6 complete: false status: "placed" + quantity: 1 + shipDate: "2000-01-23T04:56:07.000+00:00" xml: name: "Order" Category: @@ -646,8 +646,8 @@ definitions: title: "Pet catehgry" description: "A category for a pet" example: - name: "name" id: 6 + name: "name" xml: name: "Category" User: @@ -675,14 +675,14 @@ definitions: title: "a User" description: "A User who is purchasing from the pet store" example: - firstName: "firstName" - lastName: "lastName" - password: "password" - userStatus: 6 - phone: "phone" id: 0 - email: "email" + lastName: "lastName" + phone: "phone" username: "username" + email: "email" + userStatus: 6 + firstName: "firstName" + password: "password" xml: name: "User" Tag: @@ -696,8 +696,8 @@ definitions: title: "Pet Tag" description: "A tag for a pet" example: - name: "name" id: 1 + name: "name" xml: name: "Tag" Pet: @@ -738,20 +738,20 @@ definitions: title: "a Pet" description: "A pet for sale in the pet store" example: + tags: + - id: 1 + name: "name" + - id: 1 + name: "name" + id: 0 + category: + id: 6 + name: "name" + status: "available" + name: "doggie" photoUrls: - "photoUrls" - "photoUrls" - name: "doggie" - id: 0 - category: - name: "name" - id: 6 - tags: - - name: "name" - id: 1 - - name: "name" - id: 1 - status: "available" xml: name: "Pet" ApiResponse: @@ -767,9 +767,9 @@ definitions: title: "An uploaded response" description: "Describes the result of uploading an image resource" example: + message: "message" code: 0 type: "type" - message: "message" externalDocs: description: "Find out more about Swagger" url: "http://swagger.io" diff --git a/samples/server/petstore/flaskConnexion-python2/tox.ini b/samples/server/petstore/flaskConnexion-python2/tox.ini index fe94589593a9..b633a1f05980 100644 --- a/samples/server/petstore/flaskConnexion-python2/tox.ini +++ b/samples/server/petstore/flaskConnexion-python2/tox.ini @@ -4,7 +4,7 @@ envlist = py27, py35 [testenv] deps=-r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt - + commands= nosetests \ [] \ No newline at end of file diff --git a/samples/server/petstore/flaskConnexion/git_push.sh b/samples/server/petstore/flaskConnexion/git_push.sh index ed374619b139..792320114fbe 100644 --- a/samples/server/petstore/flaskConnexion/git_push.sh +++ b/samples/server/petstore/flaskConnexion/git_push.sh @@ -28,7 +28,7 @@ git init # Adds the files in the local repository and stages them for commit. git add . -# Commits the tracked changes and prepares them to be pushed to a remote repository. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote diff --git a/samples/server/petstore/flaskConnexion/setup.py b/samples/server/petstore/flaskConnexion/setup.py index 7a1ce575d354..be5dce52ab74 100644 --- a/samples/server/petstore/flaskConnexion/setup.py +++ b/samples/server/petstore/flaskConnexion/setup.py @@ -26,6 +26,8 @@ setup( packages=find_packages(), package_data={'': ['swagger/swagger.yaml']}, include_package_data=True, + entry_points={ + 'console_scripts': ['swagger_server=swagger_server.__main__:main']}, long_description="""\ 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. """ diff --git a/samples/server/petstore/flaskConnexion/swagger_server/__main__.py b/samples/server/petstore/flaskConnexion/swagger_server/__main__.py index b0d689211d27..6cc3e2d95115 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/__main__.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/__main__.py @@ -4,8 +4,12 @@ import connexion from .encoder import JSONEncoder -if __name__ == '__main__': +def main(): app = connexion.App(__name__, specification_dir='./swagger/') app.app.json_encoder = JSONEncoder app.add_api('swagger.yaml', arguments={'title': '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.'}) app.run(port=8080) + + +if __name__ == '__main__': + main() diff --git a/samples/server/petstore/flaskConnexion/swagger_server/swagger/swagger.yaml b/samples/server/petstore/flaskConnexion/swagger_server/swagger/swagger.yaml index 32000d3c2dca..ba2a870047dd 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/swagger/swagger.yaml +++ b/samples/server/petstore/flaskConnexion/swagger_server/swagger/swagger.yaml @@ -108,11 +108,11 @@ paths: type: "array" items: type: "string" - default: "available" enum: - "available" - "pending" - "sold" + default: "available" collectionFormat: "csv" responses: 200: @@ -627,12 +627,12 @@ definitions: title: "Pet Order" description: "An order for a pets from the pet store" example: - petId: 6 - quantity: 1 id: 0 - shipDate: "2000-01-23T04:56:07.000+00:00" + petId: 6 complete: false status: "placed" + quantity: 1 + shipDate: "2000-01-23T04:56:07.000+00:00" xml: name: "Order" Category: @@ -646,8 +646,8 @@ definitions: title: "Pet catehgry" description: "A category for a pet" example: - name: "name" id: 6 + name: "name" xml: name: "Category" User: @@ -675,14 +675,14 @@ definitions: title: "a User" description: "A User who is purchasing from the pet store" example: - firstName: "firstName" - lastName: "lastName" - password: "password" - userStatus: 6 - phone: "phone" id: 0 - email: "email" + lastName: "lastName" + phone: "phone" username: "username" + email: "email" + userStatus: 6 + firstName: "firstName" + password: "password" xml: name: "User" Tag: @@ -696,8 +696,8 @@ definitions: title: "Pet Tag" description: "A tag for a pet" example: - name: "name" id: 1 + name: "name" xml: name: "Tag" Pet: @@ -738,20 +738,20 @@ definitions: title: "a Pet" description: "A pet for sale in the pet store" example: + tags: + - id: 1 + name: "name" + - id: 1 + name: "name" + id: 0 + category: + id: 6 + name: "name" + status: "available" + name: "doggie" photoUrls: - "photoUrls" - "photoUrls" - name: "doggie" - id: 0 - category: - name: "name" - id: 6 - tags: - - name: "name" - id: 1 - - name: "name" - id: 1 - status: "available" xml: name: "Pet" ApiResponse: @@ -767,9 +767,9 @@ definitions: title: "An uploaded response" description: "Describes the result of uploading an image resource" example: + message: "message" code: 0 type: "type" - message: "message" externalDocs: description: "Find out more about Swagger" url: "http://swagger.io" diff --git a/samples/server/petstore/flaskConnexion/tox.ini b/samples/server/petstore/flaskConnexion/tox.ini index b696749b3a16..3e0b644eec48 100644 --- a/samples/server/petstore/flaskConnexion/tox.ini +++ b/samples/server/petstore/flaskConnexion/tox.ini @@ -4,7 +4,7 @@ envlist = py35 [testenv] deps=-r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt - + commands= nosetests \ [] \ No newline at end of file From f472b623f05f7e3f570a2085d86a6c4579afe84c Mon Sep 17 00:00:00 2001 From: korkut89 <32836783+korkut89@users.noreply.github.com> Date: Thu, 26 Oct 2017 18:55:00 +0300 Subject: [PATCH 27/28] Fix RefProperty bug for flattening MapProperty's inner properties. (#6823) --- .../src/main/java/io/swagger/codegen/InlineModelResolver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java index dfa5238f26f6..143fa9568f6c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java @@ -342,7 +342,7 @@ public class InlineModelResolver { refProperty.setRequired(op.getRequired()); mp.setAdditionalProperties(refProperty); } else { - RefProperty refProperty = new RefProperty(existing); + RefProperty refProperty = new RefProperty(modelName); refProperty.setRequired(op.getRequired()); mp.setAdditionalProperties(refProperty); addGenerated(modelName, innerModel); From 28d14e34c4180eb943624e8edfde130af035217a Mon Sep 17 00:00:00 2001 From: Kenny Jones Date: Fri, 27 Oct 2017 10:18:14 -0400 Subject: [PATCH 28/28] [python-flask] Apply template tweaks to improve lint results (#6826) The linting results for the generated samples are as follows where the first number is the BEFORE and the second is AFTER. flaskConnexion 1843 vs. 20 flaskConnexion-python2 1841 vs. 19 For the complete details please see the following gist. https://gist.github.com/kenjones-cisco/edc9d71ef7fd2bf23714ecbb693d52b3 --- .../flaskConnexion/__init__model.mustache | 3 +- .../flaskConnexion/__init__test.mustache | 8 +- .../flaskConnexion/__main__.mustache | 7 +- .../flaskConnexion/base_model_.mustache | 50 ++++---- .../flaskConnexion/controller.mustache | 36 +++--- .../flaskConnexion/controller_test.mustache | 34 ++--- .../resources/flaskConnexion/encoder.mustache | 10 +- .../resources/flaskConnexion/model.mustache | 107 ++++++++-------- .../resources/flaskConnexion/util.mustache | 44 +++---- .../swagger_server/__main__.py | 7 +- .../controllers/pet_controller.py | 87 +++++++------ .../controllers/store_controller.py | 47 +++---- .../controllers/user_controller.py | 89 +++++++------ .../swagger_server/encoder.py | 10 +- .../swagger_server/models/__init__.py | 13 +- .../swagger_server/models/api_response.py | 58 ++++----- .../swagger_server/models/base_model_.py | 44 +++---- .../swagger_server/models/category.py | 48 ++++--- .../swagger_server/models/order.py | 94 +++++++------- .../swagger_server/models/pet.py | 102 ++++++++------- .../swagger_server/models/tag.py | 48 ++++--- .../swagger_server/models/user.py | 112 ++++++++-------- .../swagger_server/swagger/swagger.yaml | 2 +- .../swagger_server/test/__init__.py | 8 +- .../test/test_pet_controller.py | 121 ++++++++++-------- .../test/test_store_controller.py | 57 +++++---- .../test/test_user_controller.py | 115 +++++++++-------- .../swagger_server/util.py | 44 +++---- .../flaskConnexion/swagger_server/__main__.py | 7 +- .../controllers/pet_controller.py | 87 +++++++------ .../controllers/store_controller.py | 47 +++---- .../controllers/user_controller.py | 89 +++++++------ .../flaskConnexion/swagger_server/encoder.py | 10 +- .../swagger_server/models/__init__.py | 13 +- .../swagger_server/models/api_response.py | 58 ++++----- .../swagger_server/models/base_model_.py | 50 ++++---- .../swagger_server/models/category.py | 48 ++++--- .../swagger_server/models/order.py | 94 +++++++------- .../swagger_server/models/pet.py | 102 ++++++++------- .../swagger_server/models/tag.py | 48 ++++--- .../swagger_server/models/user.py | 112 ++++++++-------- .../swagger_server/test/__init__.py | 8 +- .../test/test_pet_controller.py | 121 ++++++++++-------- .../test/test_store_controller.py | 57 +++++---- .../test/test_user_controller.py | 115 +++++++++-------- .../flaskConnexion/swagger_server/util.py | 44 +++---- 46 files changed, 1276 insertions(+), 1239 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/__init__model.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/__init__model.mustache index 764211e2120f..98b56e3d1540 100644 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/__init__model.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/__init__model.mustache @@ -1,6 +1,7 @@ # coding: utf-8 +# flake8: noqa from __future__ import absolute_import # import models into model package -{{#models}}{{#model}}from .{{classFilename}} import {{classname}}{{/model}} +{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}}{{/model}} {{/models}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/__init__test.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/__init__test.mustache index 77b10c3a012f..9cea80bc6302 100644 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/__init__test.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/__init__test.mustache @@ -1,8 +1,10 @@ -from flask_testing import TestCase -from ..encoder import JSONEncoder -import connexion import logging +import connexion +from flask_testing import TestCase + +from {{packageName}}.encoder import JSONEncoder + class BaseTestCase(TestCase): diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/__main__.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/__main__.mustache index 8884887471f5..10756347223c 100644 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/__main__.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/__main__.mustache @@ -6,13 +6,14 @@ {{/supportPython2}} import connexion -from .encoder import JSONEncoder + +from {{packageName}} import encoder def main(): app = connexion.App(__name__, specification_dir='./swagger/') - app.app.json_encoder = JSONEncoder - app.add_api('swagger.yaml', arguments={'title': '{{appDescription}}'}) + app.app.json_encoder = encoder.JSONEncoder + app.add_api('swagger.yaml', arguments={'title': '{{appName}}'}) app.run(port={{serverPort}}) diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/base_model_.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/base_model_.mustache index 6e3464c70199..54517a06d53a 100644 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/base_model_.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/base_model_.mustache @@ -1,38 +1,39 @@ -from pprint import pformat +import pprint + +import six {{^supportPython2}} -from typing import TypeVar, Type +import typing {{/supportPython2}} -from six import iteritems -from ..util import deserialize_model + +from {{packageName}} import util {{^supportPython2}} -T = TypeVar('T') +T = typing.TypeVar('T') {{/supportPython2}} class Model(object): - # swaggerTypes: The key is attribute name and the value is attribute type. + # swaggerTypes: The key is attribute name and the + # value is attribute type. swagger_types = {} - # attributeMap: The key is attribute name and the value is json key in definition. + # attributeMap: The key is attribute name and the + # value is json key in definition. attribute_map = {} @classmethod - def from_dict(cls{{^supportPython2}}: Type[T]{{/supportPython2}}, dikt){{^supportPython2}} -> T{{/supportPython2}}: - """ - Returns the dict as a model - """ - return deserialize_model(dikt, cls) + def from_dict(cls{{^supportPython2}}: typing.Type[T]{{/supportPython2}}, dikt){{^supportPython2}} -> T{{/supportPython2}}: + """Returns the dict as a model""" + return util.deserialize_model(dikt, cls) def to_dict(self): - """ - Returns the model properties as a dict + """Returns the model properties as a dict :rtype: dict """ result = {} - for attr, _ in iteritems(self.swagger_types): + for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): result[attr] = list(map( @@ -53,27 +54,20 @@ class Model(object): return result def to_str(self): - """ - Returns the string representation of the model + """Returns the string representation of the model :rtype: str """ - return pformat(self.to_dict()) + return pprint.pformat(self.to_dict()) def __repr__(self): - """ - For `print` and `pprint` - """ + """For `print` and `pprint`""" return self.to_str() def __eq__(self, other): - """ - Returns true if both objects are equal - """ + """Returns true if both objects are equal""" return self.__dict__ == other.__dict__ def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other \ No newline at end of file + """Returns true if both objects are not equal""" + return not self == other diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/controller.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/controller.mustache index 8fc01dbd7ac0..b865222c7d2c 100644 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/controller.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/controller.mustache @@ -1,18 +1,18 @@ import connexion -{{#imports}}{{import}} +import six + +{{#imports}}{{import}} # noqa: E501 {{/imports}} -from datetime import date, datetime -from typing import List, Dict -from six import iteritems -from ..util import deserialize_date, deserialize_datetime +from {{packageName}} import util {{#operations}} {{#operation}} -def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): - """ - {{#summary}}{{.}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} - {{#notes}}{{.}}{{/notes}} +def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): # noqa: E501 + """{{#summary}}{{.}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} + + {{#notes}}{{.}}{{/notes}} # noqa: E501 + {{#allParams}} :param {{paramName}}: {{description}} {{^isContainer}} @@ -55,15 +55,15 @@ def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{ {{#allParams}} {{^isContainer}} {{#isDate}} - {{paramName}} = deserialize_date({{paramName}}) + {{paramName}} = util.deserialize_date({{paramName}}) {{/isDate}} {{#isDateTime}} - {{paramName}} = deserialize_datetime({{paramName}}) + {{paramName}} = util.deserialize_datetime({{paramName}}) {{/isDateTime}} {{^isPrimitiveType}} {{^isFile}} if connexion.request.is_json: - {{paramName}} = {{baseType}}.from_dict(connexion.request.get_json()) + {{paramName}} = {{baseType}}.from_dict(connexion.request.get_json()) # noqa: E501 {{/isFile}} {{/isPrimitiveType}} {{/isContainer}} @@ -71,15 +71,15 @@ def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{ {{#items}} {{#isDate}} if connexion.request.is_json: - {{paramName}} = [deserialize_date(s) for s in connexion.request.get_json()] + {{paramName}} = [util.deserialize_date(s) for s in connexion.request.get_json()] # noqa: E501 {{/isDate}} {{#isDateTime}} if connexion.request.is_json: - {{paramName}} = [deserialize_datetime(s) for s in connexion.request.get_json()] + {{paramName}} = [util.deserialize_datetime(s) for s in connexion.request.get_json()] # noqa: E501 {{/isDateTime}} {{#complexType}} if connexion.request.is_json: - {{paramName}} = [{{complexType}}.from_dict(d) for d in connexion.request.get_json()] + {{paramName}} = [{{complexType}}.from_dict(d) for d in connexion.request.get_json()] # noqa: E501 {{/complexType}} {{/items}} {{/isListContainer}} @@ -87,15 +87,15 @@ def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{ {{#items}} {{#isDate}} if connexion.request.is_json: - {{paramName}} = {k: deserialize_date(v) for k, v in iteritems(connexion.request.get_json())} + {{paramName}} = {k: util.deserialize_date(v) for k, v in six.iteritems(connexion.request.get_json())} # noqa: E501 {{/isDate}} {{#isDateTime}} if connexion.request.is_json: - {{paramName}} = {k: deserialize_datetime(v) for k, v in iteritems(connexion.request.get_json())} + {{paramName}} = {k: util.deserialize_datetime(v) for k, v in six.iteritems(connexion.request.get_json())} # noqa: E501 {{/isDateTime}} {{#complexType}} if connexion.request.is_json: - {{paramName}} = {k: {{baseType}}.from_dict(v) for k, v in iteritems(connexion.request.get_json())} + {{paramName}} = {k: {{baseType}}.from_dict(v) for k, v in six.iteritems(connexion.request.get_json())} # noqa: E501 {{/complexType}} {{/items}} {{/isMapContainer}} diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/controller_test.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/controller_test.mustache index 7b202bb91262..a41b12f2c210 100644 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/controller_test.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/controller_test.mustache @@ -2,20 +2,20 @@ from __future__ import absolute_import -{{#imports}}{{import}} -{{/imports}} -from . import BaseTestCase -from six import BytesIO from flask import json +from six import BytesIO + +{{#imports}}{{import}} # noqa: E501 +{{/imports}} +from {{packageName}}.test import BaseTestCase class {{#operations}}Test{{classname}}(BaseTestCase): - """ {{classname}} integration test stubs """ + """{{classname}} integration test stubs""" {{#operation}} def test_{{operationId}}(self): - """ - Test case for {{{operationId}}} + """Test case for {{{operationId}}} {{{summary}}} """ @@ -31,15 +31,17 @@ class {{#operations}}Test{{classname}}(BaseTestCase): {{#formParams}} {{#-first}}data = dict({{/-first}}{{^-first}} {{/-first}}{{paramName}}={{{example}}}{{#hasMore}},{{/hasMore}}{{#-last}}){{/-last}} {{/formParams}} - response = self.client.open('{{#contextPath}}{{{.}}}{{/contextPath}}{{{path}}}'{{#pathParams}}{{#-first}}.format({{/-first}}{{paramName}}={{{example}}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/pathParams}}, - method='{{httpMethod}}'{{#bodyParam}}, - data=json.dumps({{paramName}}){{^consumes}}, - content_type='application/json'{{/consumes}}{{/bodyParam}}{{#headerParams}}{{#-first}}, - headers=headers{{/-first}}{{/headerParams}}{{#formParams}}{{#-first}}, - data=data{{/-first}}{{/formParams}}{{#consumes}}{{#-first}}, - content_type='{{{mediaType}}}'{{/-first}}{{/consumes}}{{#queryParams}}{{#-first}}, - query_string=query_string{{/-first}}{{/queryParams}}) - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '{{#contextPath}}{{{.}}}{{/contextPath}}{{{path}}}'{{#pathParams}}{{#-first}}.format({{/-first}}{{paramName}}={{{example}}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/pathParams}}, + method='{{httpMethod}}'{{#bodyParam}}, + data=json.dumps({{paramName}}){{^consumes}}, + content_type='application/json'{{/consumes}}{{/bodyParam}}{{#headerParams}}{{#-first}}, + headers=headers{{/-first}}{{/headerParams}}{{#formParams}}{{#-first}}, + data=data{{/-first}}{{/formParams}}{{#consumes}}{{#-first}}, + content_type='{{{mediaType}}}'{{/-first}}{{/consumes}}{{#queryParams}}{{#-first}}, + query_string=query_string{{/-first}}{{/queryParams}}) + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) {{/operation}} {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/encoder.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/encoder.mustache index 996d74f21e7d..e303a0e41a76 100644 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/encoder.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/encoder.mustache @@ -1,6 +1,8 @@ -from six import iteritems -from {{modelPackage}}.base_model_ import Model from connexion.apps.flask_app import FlaskJSONEncoder +import six + +from {{modelPackage}}.base_model_ import Model + class JSONEncoder(FlaskJSONEncoder): include_nulls = False @@ -8,11 +10,11 @@ class JSONEncoder(FlaskJSONEncoder): def default(self, o): if isinstance(o, Model): dikt = {} - for attr, _ in iteritems(o.swagger_types): + for attr, _ in six.iteritems(o.swagger_types): value = getattr(o, attr) if value is None and not self.include_nulls: continue attr = o.attribute_map[attr] dikt[attr] = value return dikt - return FlaskJSONEncoder.default(self, o) \ No newline at end of file + return FlaskJSONEncoder.default(self, o) diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/model.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/model.mustache index 761492870bf2..44bb954db2fa 100644 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/model.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/model.mustache @@ -1,73 +1,74 @@ # coding: utf-8 from __future__ import absolute_import -{{#imports}}{{import}} +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from {{modelPackage}}.base_model_ import Model +{{#imports}}{{import}} # noqa: E501 {{/imports}} -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from {{packageName}} import util {{#models}} {{#model}} class {{classname}}(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. - Do not edit the class manually. - """ + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """{{#allowableValues}} -{{#allowableValues}} """ allowed enum values """ {{#enumVars}} - {{name}} = {{{value}}} -{{/enumVars}} -{{/allowableValues}} + {{name}} = {{{value}}}{{^-last}} +{{/-last}} +{{/enumVars}}{{/allowableValues}} - def __init__(self{{#vars}}, {{name}}{{^supportPython2}}: {{datatype}}{{/supportPython2}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): - """ - {{classname}} - a model defined in Swagger + def __init__(self{{#vars}}, {{name}}{{^supportPython2}}: {{datatype}}{{/supportPython2}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501 + """{{classname}} - a model defined in Swagger {{#vars}} - :param {{name}}: The {{name}} of this {{classname}}. + :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 :type {{name}}: {{datatype}} {{/vars}} """ self.swagger_types = { - {{#vars}}'{{name}}': {{{datatype}}}{{#hasMore}}, - {{/hasMore}}{{/vars}} +{{#vars}} + '{{name}}': {{{datatype}}}{{#hasMore}},{{/hasMore}} +{{/vars}} } self.attribute_map = { - {{#vars}}'{{name}}': '{{baseName}}'{{#hasMore}}, - {{/hasMore}}{{/vars}} - } - {{#vars}} + '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} +{{/vars}} + } +{{#vars}}{{#-first}} +{{/-first}} self._{{name}} = {{name}} {{/vars}} @classmethod def from_dict(cls, dikt){{^supportPython2}} -> '{{classname}}'{{/supportPython2}}: - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The {{name}} of this {{classname}}. + :return: The {{name}} of this {{classname}}. # noqa: E501 :rtype: {{classname}} """ - return deserialize_model(dikt, cls) -{{#vars}}{{#-first}} + return util.deserialize_model(dikt, cls){{#vars}}{{#-first}} + {{/-first}} @property def {{name}}(self){{^supportPython2}} -> {{datatype}}{{/supportPython2}}: - """ - Gets the {{name}} of this {{classname}}. + """Gets the {{name}} of this {{classname}}. + {{#description}} - {{{description}}} + {{{description}}} # noqa: E501 {{/description}} :return: The {{name}} of this {{classname}}. @@ -77,31 +78,31 @@ class {{classname}}(Model): @{{name}}.setter def {{name}}(self, {{name}}{{^supportPython2}}: {{datatype}}{{/supportPython2}}): - """ - Sets the {{name}} of this {{classname}}. + """Sets the {{name}} of this {{classname}}. + {{#description}} - {{{description}}} + {{{description}}} # noqa: E501 {{/description}} :param {{name}}: The {{name}} of this {{classname}}. :type {{name}}: {{datatype}} """ {{#isEnum}} - allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] + allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 {{#isContainer}} {{#isListContainer}} if not set({{{name}}}).issubset(set(allowed_values)): raise ValueError( - "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" - .format(", ".join(map(str, set({{{name}}})-set(allowed_values))), + "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 + .format(", ".join(map(str, set({{{name}}})-set(allowed_values))), # noqa: E501 ", ".join(map(str, allowed_values))) ) {{/isListContainer}} {{#isMapContainer}} if not set({{{name}}}.keys()).issubset(set(allowed_values)): raise ValueError( - "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" - .format(", ".join(map(str, set({{{name}}}.keys())-set(allowed_values))), + "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 + .format(", ".join(map(str, set({{{name}}}.keys())-set(allowed_values))), # noqa: E501 ", ".join(map(str, allowed_values))) ) {{/isMapContainer}} @@ -117,42 +118,44 @@ class {{classname}}(Model): {{^isEnum}} {{#required}} if {{name}} is None: - raise ValueError("Invalid value for `{{name}}`, must not be `None`") + raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 {{/required}} {{#hasValidation}} {{#maxLength}} if {{name}} is not None and len({{name}}) > {{maxLength}}: - raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") + raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 {{/maxLength}} {{#minLength}} if {{name}} is not None and len({{name}}) < {{minLength}}: - raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") + raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 {{/minLength}} {{#maximum}} - if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: - raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") + if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 + raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 {{/maximum}} {{#minimum}} - if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: - raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") + if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 + raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 {{/minimum}} {{#pattern}} - if {{name}} is not None and not re.search('{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): - raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") + if {{name}} is not None and not re.search('{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 + raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 {{/pattern}} {{#maxItems}} if {{name}} is not None and len({{name}}) > {{maxItems}}: - raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") + raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 {{/maxItems}} {{#minItems}} if {{name}} is not None and len({{name}}) < {{minItems}}: - raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") + raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 {{/minItems}} {{/hasValidation}} {{/isEnum}} - self._{{name}} = {{name}} + self._{{name}} = {{name}}{{^-last}} +{{/-last}} {{/vars}} + {{/model}} -{{/models}} +{{/models}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/flaskConnexion/util.mustache b/modules/swagger-codegen/src/main/resources/flaskConnexion/util.mustache index 40c72d43ebd2..b0576ef95947 100644 --- a/modules/swagger-codegen/src/main/resources/flaskConnexion/util.mustache +++ b/modules/swagger-codegen/src/main/resources/flaskConnexion/util.mustache @@ -1,11 +1,11 @@ -from typing import GenericMeta -from datetime import datetime, date -from six import integer_types, iteritems +import datetime + +import six +import typing def _deserialize(data, klass): - """ - Deserializes dict, list, str into an object. + """Deserializes dict, list, str into an object. :param data: dict, list or str. :param klass: class literal, or string of class name. @@ -15,15 +15,15 @@ def _deserialize(data, klass): if data is None: return None - if klass in integer_types or klass in (float, str, bool): + if klass in six.integer_types or klass in (float, str, bool): return _deserialize_primitive(data, klass) elif klass == object: return _deserialize_object(data) - elif klass == date: + elif klass == datetime.date: return deserialize_date(data) - elif klass == datetime: + elif klass == datetime.datetime: return deserialize_datetime(data) - elif type(klass) == GenericMeta: + elif type(klass) == typing.GenericMeta: if klass.__extra__ == list: return _deserialize_list(data, klass.__args__[0]) if klass.__extra__ == dict: @@ -33,8 +33,7 @@ def _deserialize(data, klass): def _deserialize_primitive(data, klass): - """ - Deserializes to primitive type. + """Deserializes to primitive type. :param data: data to deserialize. :param klass: class literal. @@ -52,8 +51,7 @@ def _deserialize_primitive(data, klass): def _deserialize_object(value): - """ - Return a original value. + """Return a original value. :return: object. """ @@ -61,8 +59,7 @@ def _deserialize_object(value): def deserialize_date(string): - """ - Deserializes string to date. + """Deserializes string to date. :param string: str. :type string: str @@ -77,8 +74,7 @@ def deserialize_date(string): def deserialize_datetime(string): - """ - Deserializes string to datetime. + """Deserializes string to datetime. The string should be in iso8601 datetime format. @@ -95,8 +91,7 @@ def deserialize_datetime(string): def deserialize_model(data, klass): - """ - Deserializes list or dict to model. + """Deserializes list or dict to model. :param data: dict, list. :type data: dict | list @@ -108,7 +103,7 @@ def deserialize_model(data, klass): if not instance.swagger_types: return data - for attr, attr_type in iteritems(instance.swagger_types): + for attr, attr_type in six.iteritems(instance.swagger_types): if data is not None \ and instance.attribute_map[attr] in data \ and isinstance(data, (list, dict)): @@ -119,8 +114,7 @@ def deserialize_model(data, klass): def _deserialize_list(data, boxed_type): - """ - Deserializes a list and its elements. + """Deserializes a list and its elements. :param data: list to deserialize. :type data: list @@ -133,10 +127,8 @@ def _deserialize_list(data, boxed_type): for sub_data in data] - def _deserialize_dict(data, boxed_type): - """ - Deserializes a dict and its elements. + """Deserializes a dict and its elements. :param data: dict to deserialize. :type data: dict @@ -146,4 +138,4 @@ def _deserialize_dict(data, boxed_type): :rtype: dict """ return {k: _deserialize(v, boxed_type) - for k, v in iteritems(data)} + for k, v in six.iteritems(data)} diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/__main__.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/__main__.py index 3310c69bea7c..9f4473760ee9 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/__main__.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/__main__.py @@ -1,13 +1,14 @@ #!/usr/bin/env python import connexion -from .encoder import JSONEncoder + +from swagger_server import encoder def main(): app = connexion.App(__name__, specification_dir='./swagger/') - app.app.json_encoder = JSONEncoder - app.add_api('swagger.yaml', arguments={'title': '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.'}) + app.app.json_encoder = encoder.JSONEncoder + app.add_api('swagger.yaml', arguments={'title': 'Swagger Petstore'}) app.run(port=8080) diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/controllers/pet_controller.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/controllers/pet_controller.py index 5a999aae88fd..5de865c908a6 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/controllers/pet_controller.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/controllers/pet_controller.py @@ -1,30 +1,31 @@ import connexion -from swagger_server.models.api_response import ApiResponse -from swagger_server.models.pet import Pet -from datetime import date, datetime -from typing import List, Dict -from six import iteritems -from ..util import deserialize_date, deserialize_datetime +import six + +from swagger_server.models.api_response import ApiResponse # noqa: E501 +from swagger_server.models.pet import Pet # noqa: E501 +from swagger_server import util -def add_pet(body): - """ - Add a new pet to the store - +def add_pet(body): # noqa: E501 + """Add a new pet to the store + + # noqa: E501 + :param body: Pet object that needs to be added to the store :type body: dict | bytes :rtype: None """ if connexion.request.is_json: - body = Pet.from_dict(connexion.request.get_json()) + body = Pet.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!' -def delete_pet(petId, api_key=None): - """ - Deletes a pet - +def delete_pet(petId, api_key=None): # noqa: E501 + """Deletes a pet + + # noqa: E501 + :param petId: Pet id to delete :type petId: int :param api_key: @@ -35,10 +36,11 @@ def delete_pet(petId, api_key=None): return 'do some magic!' -def find_pets_by_status(status): - """ - Finds Pets by status - Multiple status values can be provided with comma separated strings +def find_pets_by_status(status): # noqa: E501 + """Finds Pets by status + + Multiple status values can be provided with comma separated strings # noqa: E501 + :param status: Status values that need to be considered for filter :type status: List[str] @@ -47,10 +49,11 @@ def find_pets_by_status(status): return 'do some magic!' -def find_pets_by_tags(tags): - """ - Finds Pets by tags - Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. +def find_pets_by_tags(tags): # noqa: E501 + """Finds Pets by tags + + Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501 + :param tags: Tags to filter by :type tags: List[str] @@ -59,10 +62,11 @@ def find_pets_by_tags(tags): return 'do some magic!' -def get_pet_by_id(petId): - """ - Find pet by ID - Returns a single pet +def get_pet_by_id(petId): # noqa: E501 + """Find pet by ID + + Returns a single pet # noqa: E501 + :param petId: ID of pet to return :type petId: int @@ -71,24 +75,26 @@ def get_pet_by_id(petId): return 'do some magic!' -def update_pet(body): - """ - Update an existing pet - +def update_pet(body): # noqa: E501 + """Update an existing pet + + # noqa: E501 + :param body: Pet object that needs to be added to the store :type body: dict | bytes :rtype: None """ if connexion.request.is_json: - body = Pet.from_dict(connexion.request.get_json()) + body = Pet.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!' -def update_pet_with_form(petId, name=None, status=None): - """ - Updates a pet in the store with form data - +def update_pet_with_form(petId, name=None, status=None): # noqa: E501 + """Updates a pet in the store with form data + + # noqa: E501 + :param petId: ID of pet that needs to be updated :type petId: int :param name: Updated name of the pet @@ -101,10 +107,11 @@ def update_pet_with_form(petId, name=None, status=None): return 'do some magic!' -def upload_file(petId, additionalMetadata=None, file=None): - """ - uploads an image - +def upload_file(petId, additionalMetadata=None, file=None): # noqa: E501 + """uploads an image + + # noqa: E501 + :param petId: ID of pet to update :type petId: int :param additionalMetadata: Additional data to pass to server diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/controllers/store_controller.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/controllers/store_controller.py index 0cdcaf445dc1..eae3546c21ed 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/controllers/store_controller.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/controllers/store_controller.py @@ -1,15 +1,15 @@ import connexion -from swagger_server.models.order import Order -from datetime import date, datetime -from typing import List, Dict -from six import iteritems -from ..util import deserialize_date, deserialize_datetime +import six + +from swagger_server.models.order import Order # noqa: E501 +from swagger_server import util -def delete_order(orderId): - """ - Delete purchase order by ID - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors +def delete_order(orderId): # noqa: E501 + """Delete purchase order by ID + + For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501 + :param orderId: ID of the order that needs to be deleted :type orderId: str @@ -18,20 +18,22 @@ def delete_order(orderId): return 'do some magic!' -def get_inventory(): - """ - Returns pet inventories by status - Returns a map of status codes to quantities +def get_inventory(): # noqa: E501 + """Returns pet inventories by status + + Returns a map of status codes to quantities # noqa: E501 + :rtype: Dict[str, int] """ return 'do some magic!' -def get_order_by_id(orderId): - """ - Find purchase order by ID - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions +def get_order_by_id(orderId): # noqa: E501 + """Find purchase order by ID + + For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501 + :param orderId: ID of pet that needs to be fetched :type orderId: int @@ -40,15 +42,16 @@ def get_order_by_id(orderId): return 'do some magic!' -def place_order(body): - """ - Place an order for a pet - +def place_order(body): # noqa: E501 + """Place an order for a pet + + # noqa: E501 + :param body: order placed for purchasing the pet :type body: dict | bytes :rtype: Order """ if connexion.request.is_json: - body = Order.from_dict(connexion.request.get_json()) + body = Order.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!' diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/controllers/user_controller.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/controllers/user_controller.py index 9a88626c5b8a..c7c3ee3519ab 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/controllers/user_controller.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/controllers/user_controller.py @@ -1,57 +1,60 @@ import connexion -from swagger_server.models.user import User -from datetime import date, datetime -from typing import List, Dict -from six import iteritems -from ..util import deserialize_date, deserialize_datetime +import six + +from swagger_server.models.user import User # noqa: E501 +from swagger_server import util -def create_user(body): - """ - Create user - This can only be done by the logged in user. +def create_user(body): # noqa: E501 + """Create user + + This can only be done by the logged in user. # noqa: E501 + :param body: Created user object :type body: dict | bytes :rtype: None """ if connexion.request.is_json: - body = User.from_dict(connexion.request.get_json()) + body = User.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!' -def create_users_with_array_input(body): - """ - Creates list of users with given input array - +def create_users_with_array_input(body): # noqa: E501 + """Creates list of users with given input array + + # noqa: E501 + :param body: List of user object :type body: list | bytes :rtype: None """ if connexion.request.is_json: - body = [User.from_dict(d) for d in connexion.request.get_json()] + body = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501 return 'do some magic!' -def create_users_with_list_input(body): - """ - Creates list of users with given input array - +def create_users_with_list_input(body): # noqa: E501 + """Creates list of users with given input array + + # noqa: E501 + :param body: List of user object :type body: list | bytes :rtype: None """ if connexion.request.is_json: - body = [User.from_dict(d) for d in connexion.request.get_json()] + body = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501 return 'do some magic!' -def delete_user(username): - """ - Delete user - This can only be done by the logged in user. +def delete_user(username): # noqa: E501 + """Delete user + + This can only be done by the logged in user. # noqa: E501 + :param username: The name that needs to be deleted :type username: str @@ -60,10 +63,11 @@ def delete_user(username): return 'do some magic!' -def get_user_by_name(username): - """ - Get user by user name - +def get_user_by_name(username): # noqa: E501 + """Get user by user name + + # noqa: E501 + :param username: The name that needs to be fetched. Use user1 for testing. :type username: str @@ -72,10 +76,11 @@ def get_user_by_name(username): return 'do some magic!' -def login_user(username, password): - """ - Logs user into the system - +def login_user(username, password): # noqa: E501 + """Logs user into the system + + # noqa: E501 + :param username: The user name for login :type username: str :param password: The password for login in clear text @@ -86,20 +91,22 @@ def login_user(username, password): return 'do some magic!' -def logout_user(): - """ - Logs out current logged in user session - +def logout_user(): # noqa: E501 + """Logs out current logged in user session + + # noqa: E501 + :rtype: None """ return 'do some magic!' -def update_user(username, body): - """ - Updated user - This can only be done by the logged in user. +def update_user(username, body): # noqa: E501 + """Updated user + + This can only be done by the logged in user. # noqa: E501 + :param username: name that need to be deleted :type username: str :param body: Updated user object @@ -108,5 +115,5 @@ def update_user(username, body): :rtype: None """ if connexion.request.is_json: - body = User.from_dict(connexion.request.get_json()) + body = User.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!' diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/encoder.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/encoder.py index 3ff8cad5d729..61ba4721961a 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/encoder.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/encoder.py @@ -1,6 +1,8 @@ -from six import iteritems -from swagger_server.models.base_model_ import Model from connexion.apps.flask_app import FlaskJSONEncoder +import six + +from swagger_server.models.base_model_ import Model + class JSONEncoder(FlaskJSONEncoder): include_nulls = False @@ -8,11 +10,11 @@ class JSONEncoder(FlaskJSONEncoder): def default(self, o): if isinstance(o, Model): dikt = {} - for attr, _ in iteritems(o.swagger_types): + for attr, _ in six.iteritems(o.swagger_types): value = getattr(o, attr) if value is None and not self.include_nulls: continue attr = o.attribute_map[attr] dikt[attr] = value return dikt - return FlaskJSONEncoder.default(self, o) \ No newline at end of file + return FlaskJSONEncoder.default(self, o) diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/__init__.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/__init__.py index 6571ad28e0fd..fcf8253348da 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/__init__.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/__init__.py @@ -1,10 +1,11 @@ # coding: utf-8 +# flake8: noqa from __future__ import absolute_import # import models into model package -from .api_response import ApiResponse -from .category import Category -from .order import Order -from .pet import Pet -from .tag import Tag -from .user import User +from swagger_server.models.api_response import ApiResponse +from swagger_server.models.category import Category +from swagger_server.models.order import Order +from swagger_server.models.pet import Pet +from swagger_server.models.tag import Tag +from swagger_server.models.user import User diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/api_response.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/api_response.py index c1e510332989..08e4007b9c22 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/api_response.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/api_response.py @@ -1,28 +1,28 @@ # coding: utf-8 from __future__ import absolute_import -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server import util class ApiResponse(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. """ + def __init__(self, code=None, type=None, message=None): # noqa: E501 + """ApiResponse - a model defined in Swagger - def __init__(self, code=None, type=None, message=None): - """ - ApiResponse - a model defined in Swagger - - :param code: The code of this ApiResponse. + :param code: The code of this ApiResponse. # noqa: E501 :type code: int - :param type: The type of this ApiResponse. + :param type: The type of this ApiResponse. # noqa: E501 :type type: str - :param message: The message of this ApiResponse. + :param message: The message of this ApiResponse. # noqa: E501 :type message: str """ self.swagger_types = { @@ -43,20 +43,19 @@ class ApiResponse(Model): @classmethod def from_dict(cls, dikt): - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The ApiResponse of this ApiResponse. + :return: The ApiResponse of this ApiResponse. # noqa: E501 :rtype: ApiResponse """ - return deserialize_model(dikt, cls) + return util.deserialize_model(dikt, cls) @property def code(self): - """ - Gets the code of this ApiResponse. + """Gets the code of this ApiResponse. + :return: The code of this ApiResponse. :rtype: int @@ -65,8 +64,8 @@ class ApiResponse(Model): @code.setter def code(self, code): - """ - Sets the code of this ApiResponse. + """Sets the code of this ApiResponse. + :param code: The code of this ApiResponse. :type code: int @@ -76,8 +75,8 @@ class ApiResponse(Model): @property def type(self): - """ - Gets the type of this ApiResponse. + """Gets the type of this ApiResponse. + :return: The type of this ApiResponse. :rtype: str @@ -86,8 +85,8 @@ class ApiResponse(Model): @type.setter def type(self, type): - """ - Sets the type of this ApiResponse. + """Sets the type of this ApiResponse. + :param type: The type of this ApiResponse. :type type: str @@ -97,8 +96,8 @@ class ApiResponse(Model): @property def message(self): - """ - Gets the message of this ApiResponse. + """Gets the message of this ApiResponse. + :return: The message of this ApiResponse. :rtype: str @@ -107,12 +106,11 @@ class ApiResponse(Model): @message.setter def message(self, message): - """ - Sets the message of this ApiResponse. + """Sets the message of this ApiResponse. + :param message: The message of this ApiResponse. :type message: str """ self._message = message - diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/base_model_.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/base_model_.py index 30a7a03577aa..35296d34ca46 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/base_model_.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/base_model_.py @@ -1,31 +1,32 @@ -from pprint import pformat -from six import iteritems -from ..util import deserialize_model +import pprint + +import six + +from swagger_server import util class Model(object): - # swaggerTypes: The key is attribute name and the value is attribute type. + # swaggerTypes: The key is attribute name and the + # value is attribute type. swagger_types = {} - # attributeMap: The key is attribute name and the value is json key in definition. + # attributeMap: The key is attribute name and the + # value is json key in definition. attribute_map = {} @classmethod def from_dict(cls, dikt): - """ - Returns the dict as a model - """ - return deserialize_model(dikt, cls) + """Returns the dict as a model""" + return util.deserialize_model(dikt, cls) def to_dict(self): - """ - Returns the model properties as a dict + """Returns the model properties as a dict :rtype: dict """ result = {} - for attr, _ in iteritems(self.swagger_types): + for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): result[attr] = list(map( @@ -46,27 +47,20 @@ class Model(object): return result def to_str(self): - """ - Returns the string representation of the model + """Returns the string representation of the model :rtype: str """ - return pformat(self.to_dict()) + return pprint.pformat(self.to_dict()) def __repr__(self): - """ - For `print` and `pprint` - """ + """For `print` and `pprint`""" return self.to_str() def __eq__(self, other): - """ - Returns true if both objects are equal - """ + """Returns true if both objects are equal""" return self.__dict__ == other.__dict__ def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other \ No newline at end of file + """Returns true if both objects are not equal""" + return not self == other diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/category.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/category.py index d465845fe110..34aa53d3ce0a 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/category.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/category.py @@ -1,26 +1,26 @@ # coding: utf-8 from __future__ import absolute_import -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server import util class Category(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. """ + def __init__(self, id=None, name=None): # noqa: E501 + """Category - a model defined in Swagger - def __init__(self, id=None, name=None): - """ - Category - a model defined in Swagger - - :param id: The id of this Category. + :param id: The id of this Category. # noqa: E501 :type id: long - :param name: The name of this Category. + :param name: The name of this Category. # noqa: E501 :type name: str """ self.swagger_types = { @@ -38,20 +38,19 @@ class Category(Model): @classmethod def from_dict(cls, dikt): - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The Category of this Category. + :return: The Category of this Category. # noqa: E501 :rtype: Category """ - return deserialize_model(dikt, cls) + return util.deserialize_model(dikt, cls) @property def id(self): - """ - Gets the id of this Category. + """Gets the id of this Category. + :return: The id of this Category. :rtype: long @@ -60,8 +59,8 @@ class Category(Model): @id.setter def id(self, id): - """ - Sets the id of this Category. + """Sets the id of this Category. + :param id: The id of this Category. :type id: long @@ -71,8 +70,8 @@ class Category(Model): @property def name(self): - """ - Gets the name of this Category. + """Gets the name of this Category. + :return: The name of this Category. :rtype: str @@ -81,12 +80,11 @@ class Category(Model): @name.setter def name(self, name): - """ - Sets the name of this Category. + """Sets the name of this Category. + :param name: The name of this Category. :type name: str """ self._name = name - diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/order.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/order.py index fefe4cb8c5fc..7b7f5f0645fa 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/order.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/order.py @@ -1,34 +1,34 @@ # coding: utf-8 from __future__ import absolute_import -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server import util class Order(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. """ + def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=None, complete=False): # noqa: E501 + """Order - a model defined in Swagger - def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=None, complete=False): - """ - Order - a model defined in Swagger - - :param id: The id of this Order. + :param id: The id of this Order. # noqa: E501 :type id: long - :param pet_id: The pet_id of this Order. + :param pet_id: The pet_id of this Order. # noqa: E501 :type pet_id: long - :param quantity: The quantity of this Order. + :param quantity: The quantity of this Order. # noqa: E501 :type quantity: int - :param ship_date: The ship_date of this Order. + :param ship_date: The ship_date of this Order. # noqa: E501 :type ship_date: datetime - :param status: The status of this Order. + :param status: The status of this Order. # noqa: E501 :type status: str - :param complete: The complete of this Order. + :param complete: The complete of this Order. # noqa: E501 :type complete: bool """ self.swagger_types = { @@ -58,20 +58,19 @@ class Order(Model): @classmethod def from_dict(cls, dikt): - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The Order of this Order. + :return: The Order of this Order. # noqa: E501 :rtype: Order """ - return deserialize_model(dikt, cls) + return util.deserialize_model(dikt, cls) @property def id(self): - """ - Gets the id of this Order. + """Gets the id of this Order. + :return: The id of this Order. :rtype: long @@ -80,8 +79,8 @@ class Order(Model): @id.setter def id(self, id): - """ - Sets the id of this Order. + """Sets the id of this Order. + :param id: The id of this Order. :type id: long @@ -91,8 +90,8 @@ class Order(Model): @property def pet_id(self): - """ - Gets the pet_id of this Order. + """Gets the pet_id of this Order. + :return: The pet_id of this Order. :rtype: long @@ -101,8 +100,8 @@ class Order(Model): @pet_id.setter def pet_id(self, pet_id): - """ - Sets the pet_id of this Order. + """Sets the pet_id of this Order. + :param pet_id: The pet_id of this Order. :type pet_id: long @@ -112,8 +111,8 @@ class Order(Model): @property def quantity(self): - """ - Gets the quantity of this Order. + """Gets the quantity of this Order. + :return: The quantity of this Order. :rtype: int @@ -122,8 +121,8 @@ class Order(Model): @quantity.setter def quantity(self, quantity): - """ - Sets the quantity of this Order. + """Sets the quantity of this Order. + :param quantity: The quantity of this Order. :type quantity: int @@ -133,8 +132,8 @@ class Order(Model): @property def ship_date(self): - """ - Gets the ship_date of this Order. + """Gets the ship_date of this Order. + :return: The ship_date of this Order. :rtype: datetime @@ -143,8 +142,8 @@ class Order(Model): @ship_date.setter def ship_date(self, ship_date): - """ - Sets the ship_date of this Order. + """Sets the ship_date of this Order. + :param ship_date: The ship_date of this Order. :type ship_date: datetime @@ -154,9 +153,9 @@ class Order(Model): @property def status(self): - """ - Gets the status of this Order. - Order Status + """Gets the status of this Order. + + Order Status # noqa: E501 :return: The status of this Order. :rtype: str @@ -165,14 +164,14 @@ class Order(Model): @status.setter def status(self, status): - """ - Sets the status of this Order. - Order Status + """Sets the status of this Order. + + Order Status # noqa: E501 :param status: The status of this Order. :type status: str """ - allowed_values = ["placed", "approved", "delivered"] + allowed_values = ["placed", "approved", "delivered"] # noqa: E501 if status not in allowed_values: raise ValueError( "Invalid value for `status` ({0}), must be one of {1}" @@ -183,8 +182,8 @@ class Order(Model): @property def complete(self): - """ - Gets the complete of this Order. + """Gets the complete of this Order. + :return: The complete of this Order. :rtype: bool @@ -193,12 +192,11 @@ class Order(Model): @complete.setter def complete(self, complete): - """ - Sets the complete of this Order. + """Sets the complete of this Order. + :param complete: The complete of this Order. :type complete: bool """ self._complete = complete - diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/pet.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/pet.py index 35dac42dc45a..52ef5f7e9d33 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/pet.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/pet.py @@ -1,36 +1,36 @@ # coding: utf-8 from __future__ import absolute_import -from swagger_server.models.category import Category -from swagger_server.models.tag import Tag -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server.models.category import Category # noqa: E501 +from swagger_server.models.tag import Tag # noqa: E501 +from swagger_server import util class Pet(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. """ + def __init__(self, id=None, category=None, name=None, photo_urls=None, tags=None, status=None): # noqa: E501 + """Pet - a model defined in Swagger - def __init__(self, id=None, category=None, name=None, photo_urls=None, tags=None, status=None): - """ - Pet - a model defined in Swagger - - :param id: The id of this Pet. + :param id: The id of this Pet. # noqa: E501 :type id: long - :param category: The category of this Pet. + :param category: The category of this Pet. # noqa: E501 :type category: Category - :param name: The name of this Pet. + :param name: The name of this Pet. # noqa: E501 :type name: str - :param photo_urls: The photo_urls of this Pet. + :param photo_urls: The photo_urls of this Pet. # noqa: E501 :type photo_urls: List[str] - :param tags: The tags of this Pet. + :param tags: The tags of this Pet. # noqa: E501 :type tags: List[Tag] - :param status: The status of this Pet. + :param status: The status of this Pet. # noqa: E501 :type status: str """ self.swagger_types = { @@ -60,20 +60,19 @@ class Pet(Model): @classmethod def from_dict(cls, dikt): - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The Pet of this Pet. + :return: The Pet of this Pet. # noqa: E501 :rtype: Pet """ - return deserialize_model(dikt, cls) + return util.deserialize_model(dikt, cls) @property def id(self): - """ - Gets the id of this Pet. + """Gets the id of this Pet. + :return: The id of this Pet. :rtype: long @@ -82,8 +81,8 @@ class Pet(Model): @id.setter def id(self, id): - """ - Sets the id of this Pet. + """Sets the id of this Pet. + :param id: The id of this Pet. :type id: long @@ -93,8 +92,8 @@ class Pet(Model): @property def category(self): - """ - Gets the category of this Pet. + """Gets the category of this Pet. + :return: The category of this Pet. :rtype: Category @@ -103,8 +102,8 @@ class Pet(Model): @category.setter def category(self, category): - """ - Sets the category of this Pet. + """Sets the category of this Pet. + :param category: The category of this Pet. :type category: Category @@ -114,8 +113,8 @@ class Pet(Model): @property def name(self): - """ - Gets the name of this Pet. + """Gets the name of this Pet. + :return: The name of this Pet. :rtype: str @@ -124,21 +123,21 @@ class Pet(Model): @name.setter def name(self, name): - """ - Sets the name of this Pet. + """Sets the name of this Pet. + :param name: The name of this Pet. :type name: str """ if name is None: - raise ValueError("Invalid value for `name`, must not be `None`") + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 self._name = name @property def photo_urls(self): - """ - Gets the photo_urls of this Pet. + """Gets the photo_urls of this Pet. + :return: The photo_urls of this Pet. :rtype: List[str] @@ -147,21 +146,21 @@ class Pet(Model): @photo_urls.setter def photo_urls(self, photo_urls): - """ - Sets the photo_urls of this Pet. + """Sets the photo_urls of this Pet. + :param photo_urls: The photo_urls of this Pet. :type photo_urls: List[str] """ if photo_urls is None: - raise ValueError("Invalid value for `photo_urls`, must not be `None`") + raise ValueError("Invalid value for `photo_urls`, must not be `None`") # noqa: E501 self._photo_urls = photo_urls @property def tags(self): - """ - Gets the tags of this Pet. + """Gets the tags of this Pet. + :return: The tags of this Pet. :rtype: List[Tag] @@ -170,8 +169,8 @@ class Pet(Model): @tags.setter def tags(self, tags): - """ - Sets the tags of this Pet. + """Sets the tags of this Pet. + :param tags: The tags of this Pet. :type tags: List[Tag] @@ -181,9 +180,9 @@ class Pet(Model): @property def status(self): - """ - Gets the status of this Pet. - pet status in the store + """Gets the status of this Pet. + + pet status in the store # noqa: E501 :return: The status of this Pet. :rtype: str @@ -192,14 +191,14 @@ class Pet(Model): @status.setter def status(self, status): - """ - Sets the status of this Pet. - pet status in the store + """Sets the status of this Pet. + + pet status in the store # noqa: E501 :param status: The status of this Pet. :type status: str """ - allowed_values = ["available", "pending", "sold"] + allowed_values = ["available", "pending", "sold"] # noqa: E501 if status not in allowed_values: raise ValueError( "Invalid value for `status` ({0}), must be one of {1}" @@ -207,4 +206,3 @@ class Pet(Model): ) self._status = status - diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/tag.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/tag.py index 0933d44d0b16..d26d435242ed 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/tag.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/tag.py @@ -1,26 +1,26 @@ # coding: utf-8 from __future__ import absolute_import -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server import util class Tag(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. """ + def __init__(self, id=None, name=None): # noqa: E501 + """Tag - a model defined in Swagger - def __init__(self, id=None, name=None): - """ - Tag - a model defined in Swagger - - :param id: The id of this Tag. + :param id: The id of this Tag. # noqa: E501 :type id: long - :param name: The name of this Tag. + :param name: The name of this Tag. # noqa: E501 :type name: str """ self.swagger_types = { @@ -38,20 +38,19 @@ class Tag(Model): @classmethod def from_dict(cls, dikt): - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The Tag of this Tag. + :return: The Tag of this Tag. # noqa: E501 :rtype: Tag """ - return deserialize_model(dikt, cls) + return util.deserialize_model(dikt, cls) @property def id(self): - """ - Gets the id of this Tag. + """Gets the id of this Tag. + :return: The id of this Tag. :rtype: long @@ -60,8 +59,8 @@ class Tag(Model): @id.setter def id(self, id): - """ - Sets the id of this Tag. + """Sets the id of this Tag. + :param id: The id of this Tag. :type id: long @@ -71,8 +70,8 @@ class Tag(Model): @property def name(self): - """ - Gets the name of this Tag. + """Gets the name of this Tag. + :return: The name of this Tag. :rtype: str @@ -81,12 +80,11 @@ class Tag(Model): @name.setter def name(self, name): - """ - Sets the name of this Tag. + """Sets the name of this Tag. + :param name: The name of this Tag. :type name: str """ self._name = name - diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/user.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/user.py index eddf5ef92ef8..84956ff26632 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/models/user.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/models/user.py @@ -1,38 +1,38 @@ # coding: utf-8 from __future__ import absolute_import -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server import util class User(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. """ + def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None): # noqa: E501 + """User - a model defined in Swagger - def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None): - """ - User - a model defined in Swagger - - :param id: The id of this User. + :param id: The id of this User. # noqa: E501 :type id: long - :param username: The username of this User. + :param username: The username of this User. # noqa: E501 :type username: str - :param first_name: The first_name of this User. + :param first_name: The first_name of this User. # noqa: E501 :type first_name: str - :param last_name: The last_name of this User. + :param last_name: The last_name of this User. # noqa: E501 :type last_name: str - :param email: The email of this User. + :param email: The email of this User. # noqa: E501 :type email: str - :param password: The password of this User. + :param password: The password of this User. # noqa: E501 :type password: str - :param phone: The phone of this User. + :param phone: The phone of this User. # noqa: E501 :type phone: str - :param user_status: The user_status of this User. + :param user_status: The user_status of this User. # noqa: E501 :type user_status: int """ self.swagger_types = { @@ -68,20 +68,19 @@ class User(Model): @classmethod def from_dict(cls, dikt): - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The User of this User. + :return: The User of this User. # noqa: E501 :rtype: User """ - return deserialize_model(dikt, cls) + return util.deserialize_model(dikt, cls) @property def id(self): - """ - Gets the id of this User. + """Gets the id of this User. + :return: The id of this User. :rtype: long @@ -90,8 +89,8 @@ class User(Model): @id.setter def id(self, id): - """ - Sets the id of this User. + """Sets the id of this User. + :param id: The id of this User. :type id: long @@ -101,8 +100,8 @@ class User(Model): @property def username(self): - """ - Gets the username of this User. + """Gets the username of this User. + :return: The username of this User. :rtype: str @@ -111,8 +110,8 @@ class User(Model): @username.setter def username(self, username): - """ - Sets the username of this User. + """Sets the username of this User. + :param username: The username of this User. :type username: str @@ -122,8 +121,8 @@ class User(Model): @property def first_name(self): - """ - Gets the first_name of this User. + """Gets the first_name of this User. + :return: The first_name of this User. :rtype: str @@ -132,8 +131,8 @@ class User(Model): @first_name.setter def first_name(self, first_name): - """ - Sets the first_name of this User. + """Sets the first_name of this User. + :param first_name: The first_name of this User. :type first_name: str @@ -143,8 +142,8 @@ class User(Model): @property def last_name(self): - """ - Gets the last_name of this User. + """Gets the last_name of this User. + :return: The last_name of this User. :rtype: str @@ -153,8 +152,8 @@ class User(Model): @last_name.setter def last_name(self, last_name): - """ - Sets the last_name of this User. + """Sets the last_name of this User. + :param last_name: The last_name of this User. :type last_name: str @@ -164,8 +163,8 @@ class User(Model): @property def email(self): - """ - Gets the email of this User. + """Gets the email of this User. + :return: The email of this User. :rtype: str @@ -174,8 +173,8 @@ class User(Model): @email.setter def email(self, email): - """ - Sets the email of this User. + """Sets the email of this User. + :param email: The email of this User. :type email: str @@ -185,8 +184,8 @@ class User(Model): @property def password(self): - """ - Gets the password of this User. + """Gets the password of this User. + :return: The password of this User. :rtype: str @@ -195,8 +194,8 @@ class User(Model): @password.setter def password(self, password): - """ - Sets the password of this User. + """Sets the password of this User. + :param password: The password of this User. :type password: str @@ -206,8 +205,8 @@ class User(Model): @property def phone(self): - """ - Gets the phone of this User. + """Gets the phone of this User. + :return: The phone of this User. :rtype: str @@ -216,8 +215,8 @@ class User(Model): @phone.setter def phone(self, phone): - """ - Sets the phone of this User. + """Sets the phone of this User. + :param phone: The phone of this User. :type phone: str @@ -227,9 +226,9 @@ class User(Model): @property def user_status(self): - """ - Gets the user_status of this User. - User Status + """Gets the user_status of this User. + + User Status # noqa: E501 :return: The user_status of this User. :rtype: int @@ -238,13 +237,12 @@ class User(Model): @user_status.setter def user_status(self, user_status): - """ - Sets the user_status of this User. - User Status + """Sets the user_status of this User. + + User Status # noqa: E501 :param user_status: The user_status of this User. :type user_status: int """ self._user_status = user_status - diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/swagger/swagger.yaml b/samples/server/petstore/flaskConnexion-python2/swagger_server/swagger/swagger.yaml index ba2a870047dd..28b7a179620f 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/swagger/swagger.yaml +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/swagger/swagger.yaml @@ -108,11 +108,11 @@ paths: type: "array" items: type: "string" + default: "available" enum: - "available" - "pending" - "sold" - default: "available" collectionFormat: "csv" responses: 200: diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/test/__init__.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/test/__init__.py index 77b10c3a012f..644506301ce0 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/test/__init__.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/test/__init__.py @@ -1,8 +1,10 @@ -from flask_testing import TestCase -from ..encoder import JSONEncoder -import connexion import logging +import connexion +from flask_testing import TestCase + +from swagger_server.encoder import JSONEncoder + class BaseTestCase(TestCase): diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/test/test_pet_controller.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/test/test_pet_controller.py index b99269a991aa..fb4c34ea3e10 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/test/test_pet_controller.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/test/test_pet_controller.py @@ -2,115 +2,124 @@ from __future__ import absolute_import -from swagger_server.models.api_response import ApiResponse -from swagger_server.models.pet import Pet -from . import BaseTestCase -from six import BytesIO from flask import json +from six import BytesIO + +from swagger_server.models.api_response import ApiResponse # noqa: E501 +from swagger_server.models.pet import Pet # noqa: E501 +from swagger_server.test import BaseTestCase class TestPetController(BaseTestCase): - """ PetController integration test stubs """ + """PetController integration test stubs""" def test_add_pet(self): - """ - Test case for add_pet + """Test case for add_pet Add a new pet to the store """ body = Pet() - response = self.client.open('/v2/pet', - method='POST', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet', + method='POST', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_delete_pet(self): - """ - Test case for delete_pet + """Test case for delete_pet Deletes a pet """ headers = [('api_key', 'api_key_example')] - response = self.client.open('/v2/pet/{petId}'.format(petId=789), - method='DELETE', - headers=headers) - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet/{petId}'.format(petId=789), + method='DELETE', + headers=headers) + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_find_pets_by_status(self): - """ - Test case for find_pets_by_status + """Test case for find_pets_by_status Finds Pets by status """ query_string = [('status', 'available')] - response = self.client.open('/v2/pet/findByStatus', - method='GET', - query_string=query_string) - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet/findByStatus', + method='GET', + query_string=query_string) + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_find_pets_by_tags(self): - """ - Test case for find_pets_by_tags + """Test case for find_pets_by_tags Finds Pets by tags """ query_string = [('tags', 'tags_example')] - response = self.client.open('/v2/pet/findByTags', - method='GET', - query_string=query_string) - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet/findByTags', + method='GET', + query_string=query_string) + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_get_pet_by_id(self): - """ - Test case for get_pet_by_id + """Test case for get_pet_by_id Find pet by ID """ - response = self.client.open('/v2/pet/{petId}'.format(petId=789), - method='GET') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet/{petId}'.format(petId=789), + method='GET') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_update_pet(self): - """ - Test case for update_pet + """Test case for update_pet Update an existing pet """ body = Pet() - response = self.client.open('/v2/pet', - method='PUT', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet', + method='PUT', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_update_pet_with_form(self): - """ - Test case for update_pet_with_form + """Test case for update_pet_with_form Updates a pet in the store with form data """ data = dict(name='name_example', status='status_example') - response = self.client.open('/v2/pet/{petId}'.format(petId=789), - method='POST', - data=data, - content_type='application/x-www-form-urlencoded') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet/{petId}'.format(petId=789), + method='POST', + data=data, + content_type='application/x-www-form-urlencoded') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_upload_file(self): - """ - Test case for upload_file + """Test case for upload_file uploads an image """ data = dict(additionalMetadata='additionalMetadata_example', file=(BytesIO(b'some file data'), 'file.txt')) - response = self.client.open('/v2/pet/{petId}/uploadImage'.format(petId=789), - method='POST', - data=data, - content_type='multipart/form-data') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet/{petId}/uploadImage'.format(petId=789), + method='POST', + data=data, + content_type='multipart/form-data') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) if __name__ == '__main__': diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/test/test_store_controller.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/test/test_store_controller.py index 0a5360b4e25f..854e18600fc3 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/test/test_store_controller.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/test/test_store_controller.py @@ -2,57 +2,62 @@ from __future__ import absolute_import -from swagger_server.models.order import Order -from . import BaseTestCase -from six import BytesIO from flask import json +from six import BytesIO + +from swagger_server.models.order import Order # noqa: E501 +from swagger_server.test import BaseTestCase class TestStoreController(BaseTestCase): - """ StoreController integration test stubs """ + """StoreController integration test stubs""" def test_delete_order(self): - """ - Test case for delete_order + """Test case for delete_order Delete purchase order by ID """ - response = self.client.open('/v2/store/order/{orderId}'.format(orderId='orderId_example'), - method='DELETE') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/store/order/{orderId}'.format(orderId='orderId_example'), + method='DELETE') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_get_inventory(self): - """ - Test case for get_inventory + """Test case for get_inventory Returns pet inventories by status """ - response = self.client.open('/v2/store/inventory', - method='GET') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/store/inventory', + method='GET') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_get_order_by_id(self): - """ - Test case for get_order_by_id + """Test case for get_order_by_id Find purchase order by ID """ - response = self.client.open('/v2/store/order/{orderId}'.format(orderId=5), - method='GET') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/store/order/{orderId}'.format(orderId=5), + method='GET') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_place_order(self): - """ - Test case for place_order + """Test case for place_order Place an order for a pet """ body = Order() - response = self.client.open('/v2/store/order', - method='POST', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/store/order', + method='POST', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) if __name__ == '__main__': diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/test/test_user_controller.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/test/test_user_controller.py index 867de3c01506..30e1885afabf 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/test/test_user_controller.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/test/test_user_controller.py @@ -2,109 +2,118 @@ from __future__ import absolute_import -from swagger_server.models.user import User -from . import BaseTestCase -from six import BytesIO from flask import json +from six import BytesIO + +from swagger_server.models.user import User # noqa: E501 +from swagger_server.test import BaseTestCase class TestUserController(BaseTestCase): - """ UserController integration test stubs """ + """UserController integration test stubs""" def test_create_user(self): - """ - Test case for create_user + """Test case for create_user Create user """ body = User() - response = self.client.open('/v2/user', - method='POST', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user', + method='POST', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_create_users_with_array_input(self): - """ - Test case for create_users_with_array_input + """Test case for create_users_with_array_input Creates list of users with given input array """ body = [User()] - response = self.client.open('/v2/user/createWithArray', - method='POST', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/createWithArray', + method='POST', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_create_users_with_list_input(self): - """ - Test case for create_users_with_list_input + """Test case for create_users_with_list_input Creates list of users with given input array """ body = [User()] - response = self.client.open('/v2/user/createWithList', - method='POST', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/createWithList', + method='POST', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_delete_user(self): - """ - Test case for delete_user + """Test case for delete_user Delete user """ - response = self.client.open('/v2/user/{username}'.format(username='username_example'), - method='DELETE') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/{username}'.format(username='username_example'), + method='DELETE') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_get_user_by_name(self): - """ - Test case for get_user_by_name + """Test case for get_user_by_name Get user by user name """ - response = self.client.open('/v2/user/{username}'.format(username='username_example'), - method='GET') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/{username}'.format(username='username_example'), + method='GET') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_login_user(self): - """ - Test case for login_user + """Test case for login_user Logs user into the system """ query_string = [('username', 'username_example'), ('password', 'password_example')] - response = self.client.open('/v2/user/login', - method='GET', - query_string=query_string) - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/login', + method='GET', + query_string=query_string) + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_logout_user(self): - """ - Test case for logout_user + """Test case for logout_user Logs out current logged in user session """ - response = self.client.open('/v2/user/logout', - method='GET') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/logout', + method='GET') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_update_user(self): - """ - Test case for update_user + """Test case for update_user Updated user """ body = User() - response = self.client.open('/v2/user/{username}'.format(username='username_example'), - method='PUT', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/{username}'.format(username='username_example'), + method='PUT', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) if __name__ == '__main__': diff --git a/samples/server/petstore/flaskConnexion-python2/swagger_server/util.py b/samples/server/petstore/flaskConnexion-python2/swagger_server/util.py index 40c72d43ebd2..b0576ef95947 100644 --- a/samples/server/petstore/flaskConnexion-python2/swagger_server/util.py +++ b/samples/server/petstore/flaskConnexion-python2/swagger_server/util.py @@ -1,11 +1,11 @@ -from typing import GenericMeta -from datetime import datetime, date -from six import integer_types, iteritems +import datetime + +import six +import typing def _deserialize(data, klass): - """ - Deserializes dict, list, str into an object. + """Deserializes dict, list, str into an object. :param data: dict, list or str. :param klass: class literal, or string of class name. @@ -15,15 +15,15 @@ def _deserialize(data, klass): if data is None: return None - if klass in integer_types or klass in (float, str, bool): + if klass in six.integer_types or klass in (float, str, bool): return _deserialize_primitive(data, klass) elif klass == object: return _deserialize_object(data) - elif klass == date: + elif klass == datetime.date: return deserialize_date(data) - elif klass == datetime: + elif klass == datetime.datetime: return deserialize_datetime(data) - elif type(klass) == GenericMeta: + elif type(klass) == typing.GenericMeta: if klass.__extra__ == list: return _deserialize_list(data, klass.__args__[0]) if klass.__extra__ == dict: @@ -33,8 +33,7 @@ def _deserialize(data, klass): def _deserialize_primitive(data, klass): - """ - Deserializes to primitive type. + """Deserializes to primitive type. :param data: data to deserialize. :param klass: class literal. @@ -52,8 +51,7 @@ def _deserialize_primitive(data, klass): def _deserialize_object(value): - """ - Return a original value. + """Return a original value. :return: object. """ @@ -61,8 +59,7 @@ def _deserialize_object(value): def deserialize_date(string): - """ - Deserializes string to date. + """Deserializes string to date. :param string: str. :type string: str @@ -77,8 +74,7 @@ def deserialize_date(string): def deserialize_datetime(string): - """ - Deserializes string to datetime. + """Deserializes string to datetime. The string should be in iso8601 datetime format. @@ -95,8 +91,7 @@ def deserialize_datetime(string): def deserialize_model(data, klass): - """ - Deserializes list or dict to model. + """Deserializes list or dict to model. :param data: dict, list. :type data: dict | list @@ -108,7 +103,7 @@ def deserialize_model(data, klass): if not instance.swagger_types: return data - for attr, attr_type in iteritems(instance.swagger_types): + for attr, attr_type in six.iteritems(instance.swagger_types): if data is not None \ and instance.attribute_map[attr] in data \ and isinstance(data, (list, dict)): @@ -119,8 +114,7 @@ def deserialize_model(data, klass): def _deserialize_list(data, boxed_type): - """ - Deserializes a list and its elements. + """Deserializes a list and its elements. :param data: list to deserialize. :type data: list @@ -133,10 +127,8 @@ def _deserialize_list(data, boxed_type): for sub_data in data] - def _deserialize_dict(data, boxed_type): - """ - Deserializes a dict and its elements. + """Deserializes a dict and its elements. :param data: dict to deserialize. :type data: dict @@ -146,4 +138,4 @@ def _deserialize_dict(data, boxed_type): :rtype: dict """ return {k: _deserialize(v, boxed_type) - for k, v in iteritems(data)} + for k, v in six.iteritems(data)} diff --git a/samples/server/petstore/flaskConnexion/swagger_server/__main__.py b/samples/server/petstore/flaskConnexion/swagger_server/__main__.py index 6cc3e2d95115..734cc4b3dd21 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/__main__.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/__main__.py @@ -1,13 +1,14 @@ #!/usr/bin/env python3 import connexion -from .encoder import JSONEncoder + +from swagger_server import encoder def main(): app = connexion.App(__name__, specification_dir='./swagger/') - app.app.json_encoder = JSONEncoder - app.add_api('swagger.yaml', arguments={'title': '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.'}) + app.app.json_encoder = encoder.JSONEncoder + app.add_api('swagger.yaml', arguments={'title': 'Swagger Petstore'}) app.run(port=8080) diff --git a/samples/server/petstore/flaskConnexion/swagger_server/controllers/pet_controller.py b/samples/server/petstore/flaskConnexion/swagger_server/controllers/pet_controller.py index 5a999aae88fd..5de865c908a6 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/controllers/pet_controller.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/controllers/pet_controller.py @@ -1,30 +1,31 @@ import connexion -from swagger_server.models.api_response import ApiResponse -from swagger_server.models.pet import Pet -from datetime import date, datetime -from typing import List, Dict -from six import iteritems -from ..util import deserialize_date, deserialize_datetime +import six + +from swagger_server.models.api_response import ApiResponse # noqa: E501 +from swagger_server.models.pet import Pet # noqa: E501 +from swagger_server import util -def add_pet(body): - """ - Add a new pet to the store - +def add_pet(body): # noqa: E501 + """Add a new pet to the store + + # noqa: E501 + :param body: Pet object that needs to be added to the store :type body: dict | bytes :rtype: None """ if connexion.request.is_json: - body = Pet.from_dict(connexion.request.get_json()) + body = Pet.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!' -def delete_pet(petId, api_key=None): - """ - Deletes a pet - +def delete_pet(petId, api_key=None): # noqa: E501 + """Deletes a pet + + # noqa: E501 + :param petId: Pet id to delete :type petId: int :param api_key: @@ -35,10 +36,11 @@ def delete_pet(petId, api_key=None): return 'do some magic!' -def find_pets_by_status(status): - """ - Finds Pets by status - Multiple status values can be provided with comma separated strings +def find_pets_by_status(status): # noqa: E501 + """Finds Pets by status + + Multiple status values can be provided with comma separated strings # noqa: E501 + :param status: Status values that need to be considered for filter :type status: List[str] @@ -47,10 +49,11 @@ def find_pets_by_status(status): return 'do some magic!' -def find_pets_by_tags(tags): - """ - Finds Pets by tags - Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. +def find_pets_by_tags(tags): # noqa: E501 + """Finds Pets by tags + + Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501 + :param tags: Tags to filter by :type tags: List[str] @@ -59,10 +62,11 @@ def find_pets_by_tags(tags): return 'do some magic!' -def get_pet_by_id(petId): - """ - Find pet by ID - Returns a single pet +def get_pet_by_id(petId): # noqa: E501 + """Find pet by ID + + Returns a single pet # noqa: E501 + :param petId: ID of pet to return :type petId: int @@ -71,24 +75,26 @@ def get_pet_by_id(petId): return 'do some magic!' -def update_pet(body): - """ - Update an existing pet - +def update_pet(body): # noqa: E501 + """Update an existing pet + + # noqa: E501 + :param body: Pet object that needs to be added to the store :type body: dict | bytes :rtype: None """ if connexion.request.is_json: - body = Pet.from_dict(connexion.request.get_json()) + body = Pet.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!' -def update_pet_with_form(petId, name=None, status=None): - """ - Updates a pet in the store with form data - +def update_pet_with_form(petId, name=None, status=None): # noqa: E501 + """Updates a pet in the store with form data + + # noqa: E501 + :param petId: ID of pet that needs to be updated :type petId: int :param name: Updated name of the pet @@ -101,10 +107,11 @@ def update_pet_with_form(petId, name=None, status=None): return 'do some magic!' -def upload_file(petId, additionalMetadata=None, file=None): - """ - uploads an image - +def upload_file(petId, additionalMetadata=None, file=None): # noqa: E501 + """uploads an image + + # noqa: E501 + :param petId: ID of pet to update :type petId: int :param additionalMetadata: Additional data to pass to server diff --git a/samples/server/petstore/flaskConnexion/swagger_server/controllers/store_controller.py b/samples/server/petstore/flaskConnexion/swagger_server/controllers/store_controller.py index 0cdcaf445dc1..eae3546c21ed 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/controllers/store_controller.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/controllers/store_controller.py @@ -1,15 +1,15 @@ import connexion -from swagger_server.models.order import Order -from datetime import date, datetime -from typing import List, Dict -from six import iteritems -from ..util import deserialize_date, deserialize_datetime +import six + +from swagger_server.models.order import Order # noqa: E501 +from swagger_server import util -def delete_order(orderId): - """ - Delete purchase order by ID - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors +def delete_order(orderId): # noqa: E501 + """Delete purchase order by ID + + For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501 + :param orderId: ID of the order that needs to be deleted :type orderId: str @@ -18,20 +18,22 @@ def delete_order(orderId): return 'do some magic!' -def get_inventory(): - """ - Returns pet inventories by status - Returns a map of status codes to quantities +def get_inventory(): # noqa: E501 + """Returns pet inventories by status + + Returns a map of status codes to quantities # noqa: E501 + :rtype: Dict[str, int] """ return 'do some magic!' -def get_order_by_id(orderId): - """ - Find purchase order by ID - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions +def get_order_by_id(orderId): # noqa: E501 + """Find purchase order by ID + + For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501 + :param orderId: ID of pet that needs to be fetched :type orderId: int @@ -40,15 +42,16 @@ def get_order_by_id(orderId): return 'do some magic!' -def place_order(body): - """ - Place an order for a pet - +def place_order(body): # noqa: E501 + """Place an order for a pet + + # noqa: E501 + :param body: order placed for purchasing the pet :type body: dict | bytes :rtype: Order """ if connexion.request.is_json: - body = Order.from_dict(connexion.request.get_json()) + body = Order.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!' diff --git a/samples/server/petstore/flaskConnexion/swagger_server/controllers/user_controller.py b/samples/server/petstore/flaskConnexion/swagger_server/controllers/user_controller.py index 9a88626c5b8a..c7c3ee3519ab 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/controllers/user_controller.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/controllers/user_controller.py @@ -1,57 +1,60 @@ import connexion -from swagger_server.models.user import User -from datetime import date, datetime -from typing import List, Dict -from six import iteritems -from ..util import deserialize_date, deserialize_datetime +import six + +from swagger_server.models.user import User # noqa: E501 +from swagger_server import util -def create_user(body): - """ - Create user - This can only be done by the logged in user. +def create_user(body): # noqa: E501 + """Create user + + This can only be done by the logged in user. # noqa: E501 + :param body: Created user object :type body: dict | bytes :rtype: None """ if connexion.request.is_json: - body = User.from_dict(connexion.request.get_json()) + body = User.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!' -def create_users_with_array_input(body): - """ - Creates list of users with given input array - +def create_users_with_array_input(body): # noqa: E501 + """Creates list of users with given input array + + # noqa: E501 + :param body: List of user object :type body: list | bytes :rtype: None """ if connexion.request.is_json: - body = [User.from_dict(d) for d in connexion.request.get_json()] + body = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501 return 'do some magic!' -def create_users_with_list_input(body): - """ - Creates list of users with given input array - +def create_users_with_list_input(body): # noqa: E501 + """Creates list of users with given input array + + # noqa: E501 + :param body: List of user object :type body: list | bytes :rtype: None """ if connexion.request.is_json: - body = [User.from_dict(d) for d in connexion.request.get_json()] + body = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501 return 'do some magic!' -def delete_user(username): - """ - Delete user - This can only be done by the logged in user. +def delete_user(username): # noqa: E501 + """Delete user + + This can only be done by the logged in user. # noqa: E501 + :param username: The name that needs to be deleted :type username: str @@ -60,10 +63,11 @@ def delete_user(username): return 'do some magic!' -def get_user_by_name(username): - """ - Get user by user name - +def get_user_by_name(username): # noqa: E501 + """Get user by user name + + # noqa: E501 + :param username: The name that needs to be fetched. Use user1 for testing. :type username: str @@ -72,10 +76,11 @@ def get_user_by_name(username): return 'do some magic!' -def login_user(username, password): - """ - Logs user into the system - +def login_user(username, password): # noqa: E501 + """Logs user into the system + + # noqa: E501 + :param username: The user name for login :type username: str :param password: The password for login in clear text @@ -86,20 +91,22 @@ def login_user(username, password): return 'do some magic!' -def logout_user(): - """ - Logs out current logged in user session - +def logout_user(): # noqa: E501 + """Logs out current logged in user session + + # noqa: E501 + :rtype: None """ return 'do some magic!' -def update_user(username, body): - """ - Updated user - This can only be done by the logged in user. +def update_user(username, body): # noqa: E501 + """Updated user + + This can only be done by the logged in user. # noqa: E501 + :param username: name that need to be deleted :type username: str :param body: Updated user object @@ -108,5 +115,5 @@ def update_user(username, body): :rtype: None """ if connexion.request.is_json: - body = User.from_dict(connexion.request.get_json()) + body = User.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!' diff --git a/samples/server/petstore/flaskConnexion/swagger_server/encoder.py b/samples/server/petstore/flaskConnexion/swagger_server/encoder.py index 3ff8cad5d729..61ba4721961a 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/encoder.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/encoder.py @@ -1,6 +1,8 @@ -from six import iteritems -from swagger_server.models.base_model_ import Model from connexion.apps.flask_app import FlaskJSONEncoder +import six + +from swagger_server.models.base_model_ import Model + class JSONEncoder(FlaskJSONEncoder): include_nulls = False @@ -8,11 +10,11 @@ class JSONEncoder(FlaskJSONEncoder): def default(self, o): if isinstance(o, Model): dikt = {} - for attr, _ in iteritems(o.swagger_types): + for attr, _ in six.iteritems(o.swagger_types): value = getattr(o, attr) if value is None and not self.include_nulls: continue attr = o.attribute_map[attr] dikt[attr] = value return dikt - return FlaskJSONEncoder.default(self, o) \ No newline at end of file + return FlaskJSONEncoder.default(self, o) diff --git a/samples/server/petstore/flaskConnexion/swagger_server/models/__init__.py b/samples/server/petstore/flaskConnexion/swagger_server/models/__init__.py index 6571ad28e0fd..fcf8253348da 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/models/__init__.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/models/__init__.py @@ -1,10 +1,11 @@ # coding: utf-8 +# flake8: noqa from __future__ import absolute_import # import models into model package -from .api_response import ApiResponse -from .category import Category -from .order import Order -from .pet import Pet -from .tag import Tag -from .user import User +from swagger_server.models.api_response import ApiResponse +from swagger_server.models.category import Category +from swagger_server.models.order import Order +from swagger_server.models.pet import Pet +from swagger_server.models.tag import Tag +from swagger_server.models.user import User diff --git a/samples/server/petstore/flaskConnexion/swagger_server/models/api_response.py b/samples/server/petstore/flaskConnexion/swagger_server/models/api_response.py index 8b7cecc3398c..17e3d36ce610 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/models/api_response.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/models/api_response.py @@ -1,28 +1,28 @@ # coding: utf-8 from __future__ import absolute_import -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server import util class ApiResponse(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. """ + def __init__(self, code: int=None, type: str=None, message: str=None): # noqa: E501 + """ApiResponse - a model defined in Swagger - def __init__(self, code: int=None, type: str=None, message: str=None): - """ - ApiResponse - a model defined in Swagger - - :param code: The code of this ApiResponse. + :param code: The code of this ApiResponse. # noqa: E501 :type code: int - :param type: The type of this ApiResponse. + :param type: The type of this ApiResponse. # noqa: E501 :type type: str - :param message: The message of this ApiResponse. + :param message: The message of this ApiResponse. # noqa: E501 :type message: str """ self.swagger_types = { @@ -43,20 +43,19 @@ class ApiResponse(Model): @classmethod def from_dict(cls, dikt) -> 'ApiResponse': - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The ApiResponse of this ApiResponse. + :return: The ApiResponse of this ApiResponse. # noqa: E501 :rtype: ApiResponse """ - return deserialize_model(dikt, cls) + return util.deserialize_model(dikt, cls) @property def code(self) -> int: - """ - Gets the code of this ApiResponse. + """Gets the code of this ApiResponse. + :return: The code of this ApiResponse. :rtype: int @@ -65,8 +64,8 @@ class ApiResponse(Model): @code.setter def code(self, code: int): - """ - Sets the code of this ApiResponse. + """Sets the code of this ApiResponse. + :param code: The code of this ApiResponse. :type code: int @@ -76,8 +75,8 @@ class ApiResponse(Model): @property def type(self) -> str: - """ - Gets the type of this ApiResponse. + """Gets the type of this ApiResponse. + :return: The type of this ApiResponse. :rtype: str @@ -86,8 +85,8 @@ class ApiResponse(Model): @type.setter def type(self, type: str): - """ - Sets the type of this ApiResponse. + """Sets the type of this ApiResponse. + :param type: The type of this ApiResponse. :type type: str @@ -97,8 +96,8 @@ class ApiResponse(Model): @property def message(self) -> str: - """ - Gets the message of this ApiResponse. + """Gets the message of this ApiResponse. + :return: The message of this ApiResponse. :rtype: str @@ -107,12 +106,11 @@ class ApiResponse(Model): @message.setter def message(self, message: str): - """ - Sets the message of this ApiResponse. + """Sets the message of this ApiResponse. + :param message: The message of this ApiResponse. :type message: str """ self._message = message - diff --git a/samples/server/petstore/flaskConnexion/swagger_server/models/base_model_.py b/samples/server/petstore/flaskConnexion/swagger_server/models/base_model_.py index 5202b30fb63d..97999c3d3237 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/models/base_model_.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/models/base_model_.py @@ -1,34 +1,35 @@ -from pprint import pformat -from typing import TypeVar, Type -from six import iteritems -from ..util import deserialize_model +import pprint -T = TypeVar('T') +import six +import typing + +from swagger_server import util + +T = typing.TypeVar('T') class Model(object): - # swaggerTypes: The key is attribute name and the value is attribute type. + # swaggerTypes: The key is attribute name and the + # value is attribute type. swagger_types = {} - # attributeMap: The key is attribute name and the value is json key in definition. + # attributeMap: The key is attribute name and the + # value is json key in definition. attribute_map = {} @classmethod - def from_dict(cls: Type[T], dikt) -> T: - """ - Returns the dict as a model - """ - return deserialize_model(dikt, cls) + def from_dict(cls: typing.Type[T], dikt) -> T: + """Returns the dict as a model""" + return util.deserialize_model(dikt, cls) def to_dict(self): - """ - Returns the model properties as a dict + """Returns the model properties as a dict :rtype: dict """ result = {} - for attr, _ in iteritems(self.swagger_types): + for attr, _ in six.iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): result[attr] = list(map( @@ -49,27 +50,20 @@ class Model(object): return result def to_str(self): - """ - Returns the string representation of the model + """Returns the string representation of the model :rtype: str """ - return pformat(self.to_dict()) + return pprint.pformat(self.to_dict()) def __repr__(self): - """ - For `print` and `pprint` - """ + """For `print` and `pprint`""" return self.to_str() def __eq__(self, other): - """ - Returns true if both objects are equal - """ + """Returns true if both objects are equal""" return self.__dict__ == other.__dict__ def __ne__(self, other): - """ - Returns true if both objects are not equal - """ - return not self == other \ No newline at end of file + """Returns true if both objects are not equal""" + return not self == other diff --git a/samples/server/petstore/flaskConnexion/swagger_server/models/category.py b/samples/server/petstore/flaskConnexion/swagger_server/models/category.py index 42657e8447da..5a5bab5913db 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/models/category.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/models/category.py @@ -1,26 +1,26 @@ # coding: utf-8 from __future__ import absolute_import -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server import util class Category(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. """ + def __init__(self, id: int=None, name: str=None): # noqa: E501 + """Category - a model defined in Swagger - def __init__(self, id: int=None, name: str=None): - """ - Category - a model defined in Swagger - - :param id: The id of this Category. + :param id: The id of this Category. # noqa: E501 :type id: int - :param name: The name of this Category. + :param name: The name of this Category. # noqa: E501 :type name: str """ self.swagger_types = { @@ -38,20 +38,19 @@ class Category(Model): @classmethod def from_dict(cls, dikt) -> 'Category': - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The Category of this Category. + :return: The Category of this Category. # noqa: E501 :rtype: Category """ - return deserialize_model(dikt, cls) + return util.deserialize_model(dikt, cls) @property def id(self) -> int: - """ - Gets the id of this Category. + """Gets the id of this Category. + :return: The id of this Category. :rtype: int @@ -60,8 +59,8 @@ class Category(Model): @id.setter def id(self, id: int): - """ - Sets the id of this Category. + """Sets the id of this Category. + :param id: The id of this Category. :type id: int @@ -71,8 +70,8 @@ class Category(Model): @property def name(self) -> str: - """ - Gets the name of this Category. + """Gets the name of this Category. + :return: The name of this Category. :rtype: str @@ -81,12 +80,11 @@ class Category(Model): @name.setter def name(self, name: str): - """ - Sets the name of this Category. + """Sets the name of this Category. + :param name: The name of this Category. :type name: str """ self._name = name - diff --git a/samples/server/petstore/flaskConnexion/swagger_server/models/order.py b/samples/server/petstore/flaskConnexion/swagger_server/models/order.py index deffb5236b2e..5b36925d07f1 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/models/order.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/models/order.py @@ -1,34 +1,34 @@ # coding: utf-8 from __future__ import absolute_import -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server import util class Order(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. """ + def __init__(self, id: int=None, pet_id: int=None, quantity: int=None, ship_date: datetime=None, status: str=None, complete: bool=False): # noqa: E501 + """Order - a model defined in Swagger - def __init__(self, id: int=None, pet_id: int=None, quantity: int=None, ship_date: datetime=None, status: str=None, complete: bool=False): - """ - Order - a model defined in Swagger - - :param id: The id of this Order. + :param id: The id of this Order. # noqa: E501 :type id: int - :param pet_id: The pet_id of this Order. + :param pet_id: The pet_id of this Order. # noqa: E501 :type pet_id: int - :param quantity: The quantity of this Order. + :param quantity: The quantity of this Order. # noqa: E501 :type quantity: int - :param ship_date: The ship_date of this Order. + :param ship_date: The ship_date of this Order. # noqa: E501 :type ship_date: datetime - :param status: The status of this Order. + :param status: The status of this Order. # noqa: E501 :type status: str - :param complete: The complete of this Order. + :param complete: The complete of this Order. # noqa: E501 :type complete: bool """ self.swagger_types = { @@ -58,20 +58,19 @@ class Order(Model): @classmethod def from_dict(cls, dikt) -> 'Order': - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The Order of this Order. + :return: The Order of this Order. # noqa: E501 :rtype: Order """ - return deserialize_model(dikt, cls) + return util.deserialize_model(dikt, cls) @property def id(self) -> int: - """ - Gets the id of this Order. + """Gets the id of this Order. + :return: The id of this Order. :rtype: int @@ -80,8 +79,8 @@ class Order(Model): @id.setter def id(self, id: int): - """ - Sets the id of this Order. + """Sets the id of this Order. + :param id: The id of this Order. :type id: int @@ -91,8 +90,8 @@ class Order(Model): @property def pet_id(self) -> int: - """ - Gets the pet_id of this Order. + """Gets the pet_id of this Order. + :return: The pet_id of this Order. :rtype: int @@ -101,8 +100,8 @@ class Order(Model): @pet_id.setter def pet_id(self, pet_id: int): - """ - Sets the pet_id of this Order. + """Sets the pet_id of this Order. + :param pet_id: The pet_id of this Order. :type pet_id: int @@ -112,8 +111,8 @@ class Order(Model): @property def quantity(self) -> int: - """ - Gets the quantity of this Order. + """Gets the quantity of this Order. + :return: The quantity of this Order. :rtype: int @@ -122,8 +121,8 @@ class Order(Model): @quantity.setter def quantity(self, quantity: int): - """ - Sets the quantity of this Order. + """Sets the quantity of this Order. + :param quantity: The quantity of this Order. :type quantity: int @@ -133,8 +132,8 @@ class Order(Model): @property def ship_date(self) -> datetime: - """ - Gets the ship_date of this Order. + """Gets the ship_date of this Order. + :return: The ship_date of this Order. :rtype: datetime @@ -143,8 +142,8 @@ class Order(Model): @ship_date.setter def ship_date(self, ship_date: datetime): - """ - Sets the ship_date of this Order. + """Sets the ship_date of this Order. + :param ship_date: The ship_date of this Order. :type ship_date: datetime @@ -154,9 +153,9 @@ class Order(Model): @property def status(self) -> str: - """ - Gets the status of this Order. - Order Status + """Gets the status of this Order. + + Order Status # noqa: E501 :return: The status of this Order. :rtype: str @@ -165,14 +164,14 @@ class Order(Model): @status.setter def status(self, status: str): - """ - Sets the status of this Order. - Order Status + """Sets the status of this Order. + + Order Status # noqa: E501 :param status: The status of this Order. :type status: str """ - allowed_values = ["placed", "approved", "delivered"] + allowed_values = ["placed", "approved", "delivered"] # noqa: E501 if status not in allowed_values: raise ValueError( "Invalid value for `status` ({0}), must be one of {1}" @@ -183,8 +182,8 @@ class Order(Model): @property def complete(self) -> bool: - """ - Gets the complete of this Order. + """Gets the complete of this Order. + :return: The complete of this Order. :rtype: bool @@ -193,12 +192,11 @@ class Order(Model): @complete.setter def complete(self, complete: bool): - """ - Sets the complete of this Order. + """Sets the complete of this Order. + :param complete: The complete of this Order. :type complete: bool """ self._complete = complete - diff --git a/samples/server/petstore/flaskConnexion/swagger_server/models/pet.py b/samples/server/petstore/flaskConnexion/swagger_server/models/pet.py index 30173e024fbc..8c511d9801a9 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/models/pet.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/models/pet.py @@ -1,36 +1,36 @@ # coding: utf-8 from __future__ import absolute_import -from swagger_server.models.category import Category -from swagger_server.models.tag import Tag -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server.models.category import Category # noqa: E501 +from swagger_server.models.tag import Tag # noqa: E501 +from swagger_server import util class Pet(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. """ + def __init__(self, id: int=None, category: Category=None, name: str=None, photo_urls: List[str]=None, tags: List[Tag]=None, status: str=None): # noqa: E501 + """Pet - a model defined in Swagger - def __init__(self, id: int=None, category: Category=None, name: str=None, photo_urls: List[str]=None, tags: List[Tag]=None, status: str=None): - """ - Pet - a model defined in Swagger - - :param id: The id of this Pet. + :param id: The id of this Pet. # noqa: E501 :type id: int - :param category: The category of this Pet. + :param category: The category of this Pet. # noqa: E501 :type category: Category - :param name: The name of this Pet. + :param name: The name of this Pet. # noqa: E501 :type name: str - :param photo_urls: The photo_urls of this Pet. + :param photo_urls: The photo_urls of this Pet. # noqa: E501 :type photo_urls: List[str] - :param tags: The tags of this Pet. + :param tags: The tags of this Pet. # noqa: E501 :type tags: List[Tag] - :param status: The status of this Pet. + :param status: The status of this Pet. # noqa: E501 :type status: str """ self.swagger_types = { @@ -60,20 +60,19 @@ class Pet(Model): @classmethod def from_dict(cls, dikt) -> 'Pet': - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The Pet of this Pet. + :return: The Pet of this Pet. # noqa: E501 :rtype: Pet """ - return deserialize_model(dikt, cls) + return util.deserialize_model(dikt, cls) @property def id(self) -> int: - """ - Gets the id of this Pet. + """Gets the id of this Pet. + :return: The id of this Pet. :rtype: int @@ -82,8 +81,8 @@ class Pet(Model): @id.setter def id(self, id: int): - """ - Sets the id of this Pet. + """Sets the id of this Pet. + :param id: The id of this Pet. :type id: int @@ -93,8 +92,8 @@ class Pet(Model): @property def category(self) -> Category: - """ - Gets the category of this Pet. + """Gets the category of this Pet. + :return: The category of this Pet. :rtype: Category @@ -103,8 +102,8 @@ class Pet(Model): @category.setter def category(self, category: Category): - """ - Sets the category of this Pet. + """Sets the category of this Pet. + :param category: The category of this Pet. :type category: Category @@ -114,8 +113,8 @@ class Pet(Model): @property def name(self) -> str: - """ - Gets the name of this Pet. + """Gets the name of this Pet. + :return: The name of this Pet. :rtype: str @@ -124,21 +123,21 @@ class Pet(Model): @name.setter def name(self, name: str): - """ - Sets the name of this Pet. + """Sets the name of this Pet. + :param name: The name of this Pet. :type name: str """ if name is None: - raise ValueError("Invalid value for `name`, must not be `None`") + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 self._name = name @property def photo_urls(self) -> List[str]: - """ - Gets the photo_urls of this Pet. + """Gets the photo_urls of this Pet. + :return: The photo_urls of this Pet. :rtype: List[str] @@ -147,21 +146,21 @@ class Pet(Model): @photo_urls.setter def photo_urls(self, photo_urls: List[str]): - """ - Sets the photo_urls of this Pet. + """Sets the photo_urls of this Pet. + :param photo_urls: The photo_urls of this Pet. :type photo_urls: List[str] """ if photo_urls is None: - raise ValueError("Invalid value for `photo_urls`, must not be `None`") + raise ValueError("Invalid value for `photo_urls`, must not be `None`") # noqa: E501 self._photo_urls = photo_urls @property def tags(self) -> List[Tag]: - """ - Gets the tags of this Pet. + """Gets the tags of this Pet. + :return: The tags of this Pet. :rtype: List[Tag] @@ -170,8 +169,8 @@ class Pet(Model): @tags.setter def tags(self, tags: List[Tag]): - """ - Sets the tags of this Pet. + """Sets the tags of this Pet. + :param tags: The tags of this Pet. :type tags: List[Tag] @@ -181,9 +180,9 @@ class Pet(Model): @property def status(self) -> str: - """ - Gets the status of this Pet. - pet status in the store + """Gets the status of this Pet. + + pet status in the store # noqa: E501 :return: The status of this Pet. :rtype: str @@ -192,14 +191,14 @@ class Pet(Model): @status.setter def status(self, status: str): - """ - Sets the status of this Pet. - pet status in the store + """Sets the status of this Pet. + + pet status in the store # noqa: E501 :param status: The status of this Pet. :type status: str """ - allowed_values = ["available", "pending", "sold"] + allowed_values = ["available", "pending", "sold"] # noqa: E501 if status not in allowed_values: raise ValueError( "Invalid value for `status` ({0}), must be one of {1}" @@ -207,4 +206,3 @@ class Pet(Model): ) self._status = status - diff --git a/samples/server/petstore/flaskConnexion/swagger_server/models/tag.py b/samples/server/petstore/flaskConnexion/swagger_server/models/tag.py index 9931b7476b10..62ba5b21be88 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/models/tag.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/models/tag.py @@ -1,26 +1,26 @@ # coding: utf-8 from __future__ import absolute_import -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server import util class Tag(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. """ + def __init__(self, id: int=None, name: str=None): # noqa: E501 + """Tag - a model defined in Swagger - def __init__(self, id: int=None, name: str=None): - """ - Tag - a model defined in Swagger - - :param id: The id of this Tag. + :param id: The id of this Tag. # noqa: E501 :type id: int - :param name: The name of this Tag. + :param name: The name of this Tag. # noqa: E501 :type name: str """ self.swagger_types = { @@ -38,20 +38,19 @@ class Tag(Model): @classmethod def from_dict(cls, dikt) -> 'Tag': - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The Tag of this Tag. + :return: The Tag of this Tag. # noqa: E501 :rtype: Tag """ - return deserialize_model(dikt, cls) + return util.deserialize_model(dikt, cls) @property def id(self) -> int: - """ - Gets the id of this Tag. + """Gets the id of this Tag. + :return: The id of this Tag. :rtype: int @@ -60,8 +59,8 @@ class Tag(Model): @id.setter def id(self, id: int): - """ - Sets the id of this Tag. + """Sets the id of this Tag. + :param id: The id of this Tag. :type id: int @@ -71,8 +70,8 @@ class Tag(Model): @property def name(self) -> str: - """ - Gets the name of this Tag. + """Gets the name of this Tag. + :return: The name of this Tag. :rtype: str @@ -81,12 +80,11 @@ class Tag(Model): @name.setter def name(self, name: str): - """ - Sets the name of this Tag. + """Sets the name of this Tag. + :param name: The name of this Tag. :type name: str """ self._name = name - diff --git a/samples/server/petstore/flaskConnexion/swagger_server/models/user.py b/samples/server/petstore/flaskConnexion/swagger_server/models/user.py index c4ea4d373bc2..bf1fd963c707 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/models/user.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/models/user.py @@ -1,38 +1,38 @@ # coding: utf-8 from __future__ import absolute_import -from .base_model_ import Model -from datetime import date, datetime -from typing import List, Dict -from ..util import deserialize_model +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from swagger_server.models.base_model_ import Model +from swagger_server import util class User(Model): - """ - NOTE: This class is auto generated by the swagger code generator program. + """NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. """ + def __init__(self, id: int=None, username: str=None, first_name: str=None, last_name: str=None, email: str=None, password: str=None, phone: str=None, user_status: int=None): # noqa: E501 + """User - a model defined in Swagger - def __init__(self, id: int=None, username: str=None, first_name: str=None, last_name: str=None, email: str=None, password: str=None, phone: str=None, user_status: int=None): - """ - User - a model defined in Swagger - - :param id: The id of this User. + :param id: The id of this User. # noqa: E501 :type id: int - :param username: The username of this User. + :param username: The username of this User. # noqa: E501 :type username: str - :param first_name: The first_name of this User. + :param first_name: The first_name of this User. # noqa: E501 :type first_name: str - :param last_name: The last_name of this User. + :param last_name: The last_name of this User. # noqa: E501 :type last_name: str - :param email: The email of this User. + :param email: The email of this User. # noqa: E501 :type email: str - :param password: The password of this User. + :param password: The password of this User. # noqa: E501 :type password: str - :param phone: The phone of this User. + :param phone: The phone of this User. # noqa: E501 :type phone: str - :param user_status: The user_status of this User. + :param user_status: The user_status of this User. # noqa: E501 :type user_status: int """ self.swagger_types = { @@ -68,20 +68,19 @@ class User(Model): @classmethod def from_dict(cls, dikt) -> 'User': - """ - Returns the dict as a model + """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The User of this User. + :return: The User of this User. # noqa: E501 :rtype: User """ - return deserialize_model(dikt, cls) + return util.deserialize_model(dikt, cls) @property def id(self) -> int: - """ - Gets the id of this User. + """Gets the id of this User. + :return: The id of this User. :rtype: int @@ -90,8 +89,8 @@ class User(Model): @id.setter def id(self, id: int): - """ - Sets the id of this User. + """Sets the id of this User. + :param id: The id of this User. :type id: int @@ -101,8 +100,8 @@ class User(Model): @property def username(self) -> str: - """ - Gets the username of this User. + """Gets the username of this User. + :return: The username of this User. :rtype: str @@ -111,8 +110,8 @@ class User(Model): @username.setter def username(self, username: str): - """ - Sets the username of this User. + """Sets the username of this User. + :param username: The username of this User. :type username: str @@ -122,8 +121,8 @@ class User(Model): @property def first_name(self) -> str: - """ - Gets the first_name of this User. + """Gets the first_name of this User. + :return: The first_name of this User. :rtype: str @@ -132,8 +131,8 @@ class User(Model): @first_name.setter def first_name(self, first_name: str): - """ - Sets the first_name of this User. + """Sets the first_name of this User. + :param first_name: The first_name of this User. :type first_name: str @@ -143,8 +142,8 @@ class User(Model): @property def last_name(self) -> str: - """ - Gets the last_name of this User. + """Gets the last_name of this User. + :return: The last_name of this User. :rtype: str @@ -153,8 +152,8 @@ class User(Model): @last_name.setter def last_name(self, last_name: str): - """ - Sets the last_name of this User. + """Sets the last_name of this User. + :param last_name: The last_name of this User. :type last_name: str @@ -164,8 +163,8 @@ class User(Model): @property def email(self) -> str: - """ - Gets the email of this User. + """Gets the email of this User. + :return: The email of this User. :rtype: str @@ -174,8 +173,8 @@ class User(Model): @email.setter def email(self, email: str): - """ - Sets the email of this User. + """Sets the email of this User. + :param email: The email of this User. :type email: str @@ -185,8 +184,8 @@ class User(Model): @property def password(self) -> str: - """ - Gets the password of this User. + """Gets the password of this User. + :return: The password of this User. :rtype: str @@ -195,8 +194,8 @@ class User(Model): @password.setter def password(self, password: str): - """ - Sets the password of this User. + """Sets the password of this User. + :param password: The password of this User. :type password: str @@ -206,8 +205,8 @@ class User(Model): @property def phone(self) -> str: - """ - Gets the phone of this User. + """Gets the phone of this User. + :return: The phone of this User. :rtype: str @@ -216,8 +215,8 @@ class User(Model): @phone.setter def phone(self, phone: str): - """ - Sets the phone of this User. + """Sets the phone of this User. + :param phone: The phone of this User. :type phone: str @@ -227,9 +226,9 @@ class User(Model): @property def user_status(self) -> int: - """ - Gets the user_status of this User. - User Status + """Gets the user_status of this User. + + User Status # noqa: E501 :return: The user_status of this User. :rtype: int @@ -238,13 +237,12 @@ class User(Model): @user_status.setter def user_status(self, user_status: int): - """ - Sets the user_status of this User. - User Status + """Sets the user_status of this User. + + User Status # noqa: E501 :param user_status: The user_status of this User. :type user_status: int """ self._user_status = user_status - diff --git a/samples/server/petstore/flaskConnexion/swagger_server/test/__init__.py b/samples/server/petstore/flaskConnexion/swagger_server/test/__init__.py index 77b10c3a012f..644506301ce0 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/test/__init__.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/test/__init__.py @@ -1,8 +1,10 @@ -from flask_testing import TestCase -from ..encoder import JSONEncoder -import connexion import logging +import connexion +from flask_testing import TestCase + +from swagger_server.encoder import JSONEncoder + class BaseTestCase(TestCase): diff --git a/samples/server/petstore/flaskConnexion/swagger_server/test/test_pet_controller.py b/samples/server/petstore/flaskConnexion/swagger_server/test/test_pet_controller.py index b99269a991aa..fb4c34ea3e10 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/test/test_pet_controller.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/test/test_pet_controller.py @@ -2,115 +2,124 @@ from __future__ import absolute_import -from swagger_server.models.api_response import ApiResponse -from swagger_server.models.pet import Pet -from . import BaseTestCase -from six import BytesIO from flask import json +from six import BytesIO + +from swagger_server.models.api_response import ApiResponse # noqa: E501 +from swagger_server.models.pet import Pet # noqa: E501 +from swagger_server.test import BaseTestCase class TestPetController(BaseTestCase): - """ PetController integration test stubs """ + """PetController integration test stubs""" def test_add_pet(self): - """ - Test case for add_pet + """Test case for add_pet Add a new pet to the store """ body = Pet() - response = self.client.open('/v2/pet', - method='POST', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet', + method='POST', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_delete_pet(self): - """ - Test case for delete_pet + """Test case for delete_pet Deletes a pet """ headers = [('api_key', 'api_key_example')] - response = self.client.open('/v2/pet/{petId}'.format(petId=789), - method='DELETE', - headers=headers) - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet/{petId}'.format(petId=789), + method='DELETE', + headers=headers) + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_find_pets_by_status(self): - """ - Test case for find_pets_by_status + """Test case for find_pets_by_status Finds Pets by status """ query_string = [('status', 'available')] - response = self.client.open('/v2/pet/findByStatus', - method='GET', - query_string=query_string) - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet/findByStatus', + method='GET', + query_string=query_string) + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_find_pets_by_tags(self): - """ - Test case for find_pets_by_tags + """Test case for find_pets_by_tags Finds Pets by tags """ query_string = [('tags', 'tags_example')] - response = self.client.open('/v2/pet/findByTags', - method='GET', - query_string=query_string) - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet/findByTags', + method='GET', + query_string=query_string) + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_get_pet_by_id(self): - """ - Test case for get_pet_by_id + """Test case for get_pet_by_id Find pet by ID """ - response = self.client.open('/v2/pet/{petId}'.format(petId=789), - method='GET') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet/{petId}'.format(petId=789), + method='GET') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_update_pet(self): - """ - Test case for update_pet + """Test case for update_pet Update an existing pet """ body = Pet() - response = self.client.open('/v2/pet', - method='PUT', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet', + method='PUT', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_update_pet_with_form(self): - """ - Test case for update_pet_with_form + """Test case for update_pet_with_form Updates a pet in the store with form data """ data = dict(name='name_example', status='status_example') - response = self.client.open('/v2/pet/{petId}'.format(petId=789), - method='POST', - data=data, - content_type='application/x-www-form-urlencoded') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet/{petId}'.format(petId=789), + method='POST', + data=data, + content_type='application/x-www-form-urlencoded') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_upload_file(self): - """ - Test case for upload_file + """Test case for upload_file uploads an image """ data = dict(additionalMetadata='additionalMetadata_example', file=(BytesIO(b'some file data'), 'file.txt')) - response = self.client.open('/v2/pet/{petId}/uploadImage'.format(petId=789), - method='POST', - data=data, - content_type='multipart/form-data') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/pet/{petId}/uploadImage'.format(petId=789), + method='POST', + data=data, + content_type='multipart/form-data') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) if __name__ == '__main__': diff --git a/samples/server/petstore/flaskConnexion/swagger_server/test/test_store_controller.py b/samples/server/petstore/flaskConnexion/swagger_server/test/test_store_controller.py index 0a5360b4e25f..854e18600fc3 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/test/test_store_controller.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/test/test_store_controller.py @@ -2,57 +2,62 @@ from __future__ import absolute_import -from swagger_server.models.order import Order -from . import BaseTestCase -from six import BytesIO from flask import json +from six import BytesIO + +from swagger_server.models.order import Order # noqa: E501 +from swagger_server.test import BaseTestCase class TestStoreController(BaseTestCase): - """ StoreController integration test stubs """ + """StoreController integration test stubs""" def test_delete_order(self): - """ - Test case for delete_order + """Test case for delete_order Delete purchase order by ID """ - response = self.client.open('/v2/store/order/{orderId}'.format(orderId='orderId_example'), - method='DELETE') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/store/order/{orderId}'.format(orderId='orderId_example'), + method='DELETE') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_get_inventory(self): - """ - Test case for get_inventory + """Test case for get_inventory Returns pet inventories by status """ - response = self.client.open('/v2/store/inventory', - method='GET') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/store/inventory', + method='GET') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_get_order_by_id(self): - """ - Test case for get_order_by_id + """Test case for get_order_by_id Find purchase order by ID """ - response = self.client.open('/v2/store/order/{orderId}'.format(orderId=5), - method='GET') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/store/order/{orderId}'.format(orderId=5), + method='GET') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_place_order(self): - """ - Test case for place_order + """Test case for place_order Place an order for a pet """ body = Order() - response = self.client.open('/v2/store/order', - method='POST', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/store/order', + method='POST', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) if __name__ == '__main__': diff --git a/samples/server/petstore/flaskConnexion/swagger_server/test/test_user_controller.py b/samples/server/petstore/flaskConnexion/swagger_server/test/test_user_controller.py index 867de3c01506..30e1885afabf 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/test/test_user_controller.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/test/test_user_controller.py @@ -2,109 +2,118 @@ from __future__ import absolute_import -from swagger_server.models.user import User -from . import BaseTestCase -from six import BytesIO from flask import json +from six import BytesIO + +from swagger_server.models.user import User # noqa: E501 +from swagger_server.test import BaseTestCase class TestUserController(BaseTestCase): - """ UserController integration test stubs """ + """UserController integration test stubs""" def test_create_user(self): - """ - Test case for create_user + """Test case for create_user Create user """ body = User() - response = self.client.open('/v2/user', - method='POST', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user', + method='POST', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_create_users_with_array_input(self): - """ - Test case for create_users_with_array_input + """Test case for create_users_with_array_input Creates list of users with given input array """ body = [User()] - response = self.client.open('/v2/user/createWithArray', - method='POST', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/createWithArray', + method='POST', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_create_users_with_list_input(self): - """ - Test case for create_users_with_list_input + """Test case for create_users_with_list_input Creates list of users with given input array """ body = [User()] - response = self.client.open('/v2/user/createWithList', - method='POST', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/createWithList', + method='POST', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_delete_user(self): - """ - Test case for delete_user + """Test case for delete_user Delete user """ - response = self.client.open('/v2/user/{username}'.format(username='username_example'), - method='DELETE') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/{username}'.format(username='username_example'), + method='DELETE') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_get_user_by_name(self): - """ - Test case for get_user_by_name + """Test case for get_user_by_name Get user by user name """ - response = self.client.open('/v2/user/{username}'.format(username='username_example'), - method='GET') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/{username}'.format(username='username_example'), + method='GET') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_login_user(self): - """ - Test case for login_user + """Test case for login_user Logs user into the system """ query_string = [('username', 'username_example'), ('password', 'password_example')] - response = self.client.open('/v2/user/login', - method='GET', - query_string=query_string) - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/login', + method='GET', + query_string=query_string) + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_logout_user(self): - """ - Test case for logout_user + """Test case for logout_user Logs out current logged in user session """ - response = self.client.open('/v2/user/logout', - method='GET') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/logout', + method='GET') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) def test_update_user(self): - """ - Test case for update_user + """Test case for update_user Updated user """ body = User() - response = self.client.open('/v2/user/{username}'.format(username='username_example'), - method='PUT', - data=json.dumps(body), - content_type='application/json') - self.assert200(response, "Response body is : " + response.data.decode('utf-8')) + response = self.client.open( + '/v2/user/{username}'.format(username='username_example'), + method='PUT', + data=json.dumps(body), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) if __name__ == '__main__': diff --git a/samples/server/petstore/flaskConnexion/swagger_server/util.py b/samples/server/petstore/flaskConnexion/swagger_server/util.py index 40c72d43ebd2..b0576ef95947 100644 --- a/samples/server/petstore/flaskConnexion/swagger_server/util.py +++ b/samples/server/petstore/flaskConnexion/swagger_server/util.py @@ -1,11 +1,11 @@ -from typing import GenericMeta -from datetime import datetime, date -from six import integer_types, iteritems +import datetime + +import six +import typing def _deserialize(data, klass): - """ - Deserializes dict, list, str into an object. + """Deserializes dict, list, str into an object. :param data: dict, list or str. :param klass: class literal, or string of class name. @@ -15,15 +15,15 @@ def _deserialize(data, klass): if data is None: return None - if klass in integer_types or klass in (float, str, bool): + if klass in six.integer_types or klass in (float, str, bool): return _deserialize_primitive(data, klass) elif klass == object: return _deserialize_object(data) - elif klass == date: + elif klass == datetime.date: return deserialize_date(data) - elif klass == datetime: + elif klass == datetime.datetime: return deserialize_datetime(data) - elif type(klass) == GenericMeta: + elif type(klass) == typing.GenericMeta: if klass.__extra__ == list: return _deserialize_list(data, klass.__args__[0]) if klass.__extra__ == dict: @@ -33,8 +33,7 @@ def _deserialize(data, klass): def _deserialize_primitive(data, klass): - """ - Deserializes to primitive type. + """Deserializes to primitive type. :param data: data to deserialize. :param klass: class literal. @@ -52,8 +51,7 @@ def _deserialize_primitive(data, klass): def _deserialize_object(value): - """ - Return a original value. + """Return a original value. :return: object. """ @@ -61,8 +59,7 @@ def _deserialize_object(value): def deserialize_date(string): - """ - Deserializes string to date. + """Deserializes string to date. :param string: str. :type string: str @@ -77,8 +74,7 @@ def deserialize_date(string): def deserialize_datetime(string): - """ - Deserializes string to datetime. + """Deserializes string to datetime. The string should be in iso8601 datetime format. @@ -95,8 +91,7 @@ def deserialize_datetime(string): def deserialize_model(data, klass): - """ - Deserializes list or dict to model. + """Deserializes list or dict to model. :param data: dict, list. :type data: dict | list @@ -108,7 +103,7 @@ def deserialize_model(data, klass): if not instance.swagger_types: return data - for attr, attr_type in iteritems(instance.swagger_types): + for attr, attr_type in six.iteritems(instance.swagger_types): if data is not None \ and instance.attribute_map[attr] in data \ and isinstance(data, (list, dict)): @@ -119,8 +114,7 @@ def deserialize_model(data, klass): def _deserialize_list(data, boxed_type): - """ - Deserializes a list and its elements. + """Deserializes a list and its elements. :param data: list to deserialize. :type data: list @@ -133,10 +127,8 @@ def _deserialize_list(data, boxed_type): for sub_data in data] - def _deserialize_dict(data, boxed_type): - """ - Deserializes a dict and its elements. + """Deserializes a dict and its elements. :param data: dict to deserialize. :type data: dict @@ -146,4 +138,4 @@ def _deserialize_dict(data, boxed_type): :rtype: dict """ return {k: _deserialize(v, boxed_type) - for k, v in iteritems(data)} + for k, v in six.iteritems(data)}