From 6801741592922502f78409c480bf1deb1251eea5 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 31 Jan 2019 15:27:24 +0800 Subject: [PATCH] Add Bearer authentication support to JS client (#2020) * add bearer authentication support to js client * add bearer format to js client * fix test case * update php ze-ph samples --- .../openapitools/codegen/DefaultCodegen.java | 17 +- .../resources/Javascript/ApiClient.mustache | 10 + .../main/resources/Javascript/README.mustache | 41 ++- .../resources/Javascript/api_doc.mustache | 10 +- .../Javascript/es6/ApiClient.mustache | 11 + .../resources/Javascript/es6/README.mustache | 27 +- .../resources/Javascript/es6/api_doc.mustache | 21 +- .../client/petstore/javascript-es6/README.md | 5 + .../petstore/javascript-es6/docs/FakeApi.md | 44 ++- .../docs/FakeClassnameTags123Api.md | 1 - .../petstore/javascript-es6/docs/PetApi.md | 9 - .../petstore/javascript-es6/docs/StoreApi.md | 1 - .../petstore/javascript-es6/docs/XmlItem.md | 36 +++ .../petstore/javascript-es6/src/ApiClient.js | 6 + .../javascript-es6/src/api/FakeApi.js | 45 +++ .../petstore/javascript-es6/src/index.js | 7 + .../javascript-es6/src/model/XmlItem.js | 295 ++++++++++++++++++ .../javascript-es6/test/model/XmlItem.spec.js | 233 ++++++++++++++ .../petstore/javascript-promise-es6/README.md | 5 + .../javascript-promise-es6/docs/FakeApi.md | 43 ++- .../docs/FakeClassnameTags123Api.md | 1 - .../javascript-promise-es6/docs/PetApi.md | 9 - .../javascript-promise-es6/docs/StoreApi.md | 1 - .../javascript-promise-es6/docs/XmlItem.md | 36 +++ .../javascript-promise-es6/src/ApiClient.js | 6 + .../javascript-promise-es6/src/api/FakeApi.js | 51 +++ .../javascript-promise-es6/src/index.js | 7 + .../src/model/XmlItem.js | 295 ++++++++++++++++++ .../test/model/XmlItem.spec.js | 233 ++++++++++++++ .../petstore/javascript-promise/README.md | 6 + .../javascript-promise/docs/FakeApi.md | 43 ++- .../javascript-promise/docs/XmlItem.md | 36 +++ .../javascript-promise/src/ApiClient.js | 5 + .../javascript-promise/src/api/FakeApi.js | 60 +++- .../petstore/javascript-promise/src/index.js | 11 +- .../javascript-promise/src/model/XmlItem.js | 274 ++++++++++++++++ .../test/model/XmlItem.spec.js | 235 ++++++++++++++ samples/client/petstore/javascript/README.md | 6 + .../petstore/javascript/docs/FakeApi.md | 45 ++- .../petstore/javascript/docs/XmlItem.md | 36 +++ .../petstore/javascript/src/ApiClient.js | 5 + .../petstore/javascript/src/api/FakeApi.js | 54 +++- .../client/petstore/javascript/src/index.js | 11 +- .../petstore/javascript/src/model/XmlItem.js | 274 ++++++++++++++++ .../javascript/test/model/XmlItem.spec.js | 235 ++++++++++++++ .../client/petstore/javascript-es6/README.md | 8 + .../petstore/javascript-es6/docs/FakeApi.md | 7 +- .../docs/FakeClassnameTags123Api.md | 1 - .../petstore/javascript-es6/docs/PetApi.md | 9 - .../petstore/javascript-es6/docs/StoreApi.md | 1 - .../petstore/javascript-es6/src/ApiClient.js | 7 + .../javascript-es6/src/api/FakeApi.js | 2 +- .../javascript-es6/test/ApiClientTest.js | 1 + 53 files changed, 2797 insertions(+), 81 deletions(-) create mode 100644 samples/client/petstore/javascript-es6/docs/XmlItem.md create mode 100644 samples/client/petstore/javascript-es6/src/model/XmlItem.js create mode 100644 samples/client/petstore/javascript-es6/test/model/XmlItem.spec.js create mode 100644 samples/client/petstore/javascript-promise-es6/docs/XmlItem.md create mode 100644 samples/client/petstore/javascript-promise-es6/src/model/XmlItem.js create mode 100644 samples/client/petstore/javascript-promise-es6/test/model/XmlItem.spec.js create mode 100644 samples/client/petstore/javascript-promise/docs/XmlItem.md create mode 100644 samples/client/petstore/javascript-promise/src/model/XmlItem.js create mode 100644 samples/client/petstore/javascript-promise/test/model/XmlItem.spec.js create mode 100644 samples/client/petstore/javascript/docs/XmlItem.md create mode 100644 samples/client/petstore/javascript/src/model/XmlItem.js create mode 100644 samples/client/petstore/javascript/test/model/XmlItem.spec.js diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 760a7462c6b6..a53bf70569c4 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -1559,8 +1559,8 @@ public String toModelName(final String name) { /** * Convert OAS Model object to Codegen Model object * - * @param name the name of the model - * @param schema OAS Model object + * @param name the name of the model + * @param schema OAS Model object * @return Codegen Model object */ public CodegenModel fromModel(String name, Schema schema) { @@ -1993,7 +1993,7 @@ public CodegenProperty fromProperty(String name, Schema p) { if (property.minimum != null || property.maximum != null) property.hasValidation = true; - } else if (ModelUtils.isFreeFormObject(p)){ + } else if (ModelUtils.isFreeFormObject(p)) { property.isFreeFormObject = true; } @@ -2005,7 +2005,7 @@ public CodegenProperty fromProperty(String name, Schema p) { property._enum.add(String.valueOf(i)); } property.isEnum = true; - + Map allowableValues = new HashMap(); allowableValues.put("values", _enum); if (allowableValues.size() > 0) { @@ -2273,6 +2273,7 @@ protected ApiResponse findMethodResponse(ApiResponses responses) { /** * Convert OAS Operation object to Codegen Operation object + * * @param httpMethod HTTP method * @param operation OAS operation object * @param path the path of the operation @@ -2587,9 +2588,9 @@ public boolean isParameterNameUnique(CodegenParameter p, List /** * Convert OAS Response object to Codegen Response object + * * @param responseCode HTTP response code * @param response OAS Response object - * * @return Codegen Response object */ public CodegenResponse fromResponse(String responseCode, ApiResponse response) { @@ -3121,8 +3122,7 @@ public List fromSecurity(Map securitySc cs.isBasic = true; if ("basic".equals(securityScheme.getScheme())) { cs.isBasicBasic = true; - } - else if ("bearer".equals(securityScheme.getScheme())) { + } else if ("bearer".equals(securityScheme.getScheme())) { cs.isBasicBearer = true; cs.bearerFormat = securityScheme.getBearerFormat(); } @@ -3250,6 +3250,7 @@ protected List> toExamples(Map examples) { /** * Add headers to codegen property + * * @param response API response * @param properties list of codegen property */ @@ -3366,8 +3367,8 @@ protected void addImport(CodegenModel m, String type) { /** * Loop through propertiies and unalias the reference if $ref (reference) is defined - * @param properties model properties (schemas) * + * @param properties model properties (schemas) * @return model properties with direct reference to schemas */ private Map unaliasPropertySchema(Map properties) { diff --git a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache index ae872d431cc3..36a31d25edc1 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache @@ -43,7 +43,12 @@ {{/emitJSDoc}}{{=< >=}} this.authentications = { <#authMethods> <#isBasic> +<^isBasicBearer> '': {type: 'basic'}<^-last>, + +<#isBasicBearer> + '': {type: 'bearer'}<^-last>,<#bearerFormat> // <&.> + <#isApiKey> '': {type: 'apiKey', 'in': <#isKeyInHeader>'header'<^isKeyInHeader>'query', name: ''}<^-last>, @@ -303,6 +308,11 @@ request.auth(auth.username || '', auth.password || ''); } break; + case 'bearer': + if (auth.accessToken) { + request.set({'Authorization': 'Bearer ' + auth.accessToken}); + } + break; case 'apiKey': if (auth.apiKey) { var data = {}; diff --git a/modules/openapi-generator/src/main/resources/Javascript/README.mustache b/modules/openapi-generator/src/main/resources/Javascript/README.mustache index 7511114fba52..572a236f6bd5 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/README.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/README.mustache @@ -102,21 +102,35 @@ Please follow the [installation](#installation) instruction and execute the foll ```javascript var {{{moduleName}}} = require('{{{projectName}}}'); -{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}} +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} +{{#hasAuthMethods}} var defaultClient = {{{moduleName}}}.ApiClient.instance; -{{#authMethods}}{{#isBasic}} +{{#authMethods}} +{{#isBasic}} +{{^isBasicBearer}} // Configure HTTP basic authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; {{{name}}}.username = 'YOUR USERNAME' -{{{name}}}.password = 'YOUR PASSWORD'{{/isBasic}}{{#isApiKey}} +{{{name}}}.password = 'YOUR PASSWORD' +{{/isBasicBearer}} +{{#isBasicBearer}} +// Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}} +var {{{name}}} = defaultClient.authentications['{{{name}}}']; +{{{name}}}.accessToken = "YOUR ACCESS TOKEN" +{{/isBasicBearer}} +{{/isBasic}} +{{#isApiKey}} // Configure API key authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; {{{name}}}.apiKey = "YOUR API KEY" // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) -//{{{name}}}.apiKeyPrefix['{{{keyParamName}}}'] = "Token"{{/isApiKey}}{{#isOAuth}} +//{{{name}}}.apiKeyPrefix['{{{keyParamName}}}'] = "Token" +{{/isApiKey}} +{{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; -{{{name}}}.accessToken = "YOUR ACCESS TOKEN"{{/isOAuth}} +{{{name}}}.accessToken = "YOUR ACCESS TOKEN" +{{/isOAuth}} {{/authMethods}} {{/hasAuthMethods}} @@ -170,15 +184,24 @@ Class | Method | HTTP request | Description ## Documentation for Authorization -{{^authMethods}} All endpoints do not require authorization. -{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} -{{#authMethods}}### {{name}} +{{^authMethods}} +All endpoints do not require authorization. +{{/authMethods}} +{{#authMethods}} +{{#last}} Authentication schemes defined for the API:{{/last}} +### {{name}} {{#isApiKey}}- **Type**: API key - **API key parameter name**: {{keyParamName}} - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} {{/isApiKey}} -{{#isBasic}}- **Type**: HTTP basic authentication +{{#isBasic}} +{{^isBasicBearer}} +- **Type**: HTTP basic authentication +{{/isBasicBearer}} +{{#isBasicBearer}} +- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} +{{/isBasicBearer}} {{/isBasic}} {{#isOAuth}}- **Type**: OAuth - **Flow**: {{flow}} diff --git a/modules/openapi-generator/src/main/resources/Javascript/api_doc.mustache b/modules/openapi-generator/src/main/resources/Javascript/api_doc.mustache index 7506b091bdea..76a3d87b410b 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/api_doc.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/api_doc.mustache @@ -23,11 +23,19 @@ Method | HTTP request | Description var {{{moduleName}}} = require('{{{projectName}}}'); {{#hasAuthMethods}} var defaultClient = {{{moduleName}}}.ApiClient.instance; -{{#authMethods}}{{#isBasic}} +{{#authMethods}} +{{#isBasic}} +{{^isBasicBearer}} // Configure HTTP basic authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; {{{name}}}.username = 'YOUR USERNAME'; {{{name}}}.password = 'YOUR PASSWORD'; +{{/isBasicBearer}} +{{#isBasicBearer}} +// Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}} +var {{{name}}} = defaultClient.authentications['{{{name}}}']; +{{{name}}}.accessToken = 'YOUR ACCESS TOKEN'; +{{/isBasicBearer}} {{/isBasic}} {{#isApiKey}} // Configure API key authorization: {{{name}}} diff --git a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache index f9c7a871ab7c..397e41671570 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache @@ -31,7 +31,12 @@ class ApiClient { this.authentications = { <#authMethods> <#isBasic> +<^isBasicBearer> '': {type: 'basic'}<^-last>, + +<#isBasicBearer> + '': {type: 'bearer'}<^-last>,<#bearerFormat> // <&.> + <#isApiKey> '': {type: 'apiKey', 'in': <#isKeyInHeader>'header'<^isKeyInHeader>'query', name: ''}<^-last>, @@ -268,6 +273,12 @@ class ApiClient { request.auth(auth.username || '', auth.password || ''); } + break; + case 'bearer': + if (auth.accessToken) { + request.set({'Authorization': 'Bearer ' + auth.accessToken}); + } + break; case 'apiKey': if (auth.apiKey) { diff --git a/modules/openapi-generator/src/main/resources/Javascript/es6/README.mustache b/modules/openapi-generator/src/main/resources/Javascript/es6/README.mustache index e19f96524485..f40c60c2d0e2 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/es6/README.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/es6/README.mustache @@ -82,10 +82,17 @@ var {{{moduleName}}} = require('{{{projectName}}}'); var defaultClient = {{{moduleName}}}.ApiClient.instance; {{#authMethods}} {{#isBasic}} +{{^isBasicBearer}} // Configure HTTP basic authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; {{{name}}}.username = 'YOUR USERNAME' {{{name}}}.password = 'YOUR PASSWORD' +{{/isBasicBearer}} +{{#isBasicBearer}} +// Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}} +var {{{name}}} = defaultClient.authentications['{{{name}}}']; +{{{name}}}.accessToken = "YOUR ACCESS TOKEN" +{{/isBasicBearer}} {{/isBasic}} {{#isApiKey}} // Configure API key authorization: {{{name}}} @@ -154,15 +161,25 @@ Class | Method | HTTP request | Description ## Documentation for Authorization -{{^authMethods}} All endpoints do not require authorization. -{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} -{{#authMethods}}### {{name}} +{{^authMethods}} +All endpoints do not require authorization. +{{/authMethods}} +{{#authMethods}} +{{#last}} Authentication schemes defined for the API:{{/last}} +### {{name}} -{{#isApiKey}}- **Type**: API key +{{#isApiKey}} +- **Type**: API key - **API key parameter name**: {{keyParamName}} - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} {{/isApiKey}} -{{#isBasic}}- **Type**: HTTP basic authentication +{{#isBasic}} +{{^isBasicBearer}} +- **Type**: HTTP basic authentication +{{/isBasicBearer}} +{{#isBasicBearer}} +- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} +{{/isBasicBearer}} {{/isBasic}} {{#isOAuth}}- **Type**: OAuth - **Flow**: {{flow}} diff --git a/modules/openapi-generator/src/main/resources/Javascript/es6/api_doc.mustache b/modules/openapi-generator/src/main/resources/Javascript/es6/api_doc.mustache index c041b5ffaeb7..0bdd48e8f50c 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/es6/api_doc.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/es6/api_doc.mustache @@ -23,19 +23,32 @@ Method | HTTP request | Description import {{{moduleName}}} from '{{{projectName}}}'; {{#hasAuthMethods}} let defaultClient = {{{moduleName}}}.ApiClient.instance; -{{#authMethods}}{{#isBasic}} +{{#authMethods}} +{{#isBasic}} +{{^isBasicBearer}} // Configure HTTP basic authorization: {{{name}}} let {{{name}}} = defaultClient.authentications['{{{name}}}']; {{{name}}}.username = 'YOUR USERNAME'; -{{{name}}}.password = 'YOUR PASSWORD';{{/isBasic}}{{#isApiKey}} +{{{name}}}.password = 'YOUR PASSWORD'; +{{/isBasicBearer}} +{{#isBasicBearer}} +// Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}} +let {{{name}}} = defaultClient.authentications['{{{name}}}']; +{{{name}}}.accessToken = "YOUR ACCESS TOKEN" +{{/isBasicBearer}} +{{/isBasic}} +{{#isApiKey}} // Configure API key authorization: {{{name}}} let {{{name}}} = defaultClient.authentications['{{{name}}}']; {{{name}}}.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) -//{{{name}}}.apiKeyPrefix = 'Token';{{/isApiKey}}{{#isOAuth}} +//{{{name}}}.apiKeyPrefix = 'Token'; +{{/isApiKey}} +{{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} let {{{name}}} = defaultClient.authentications['{{{name}}}']; -{{{name}}}.accessToken = 'YOUR ACCESS TOKEN';{{/isOAuth}} +{{{name}}}.accessToken = 'YOUR ACCESS TOKEN'; +{{/isOAuth}} {{/authMethods}} {{/hasAuthMethods}} diff --git a/samples/client/petstore/javascript-es6/README.md b/samples/client/petstore/javascript-es6/README.md index d871319d13da..32f91d1d0ebb 100644 --- a/samples/client/petstore/javascript-es6/README.md +++ b/samples/client/petstore/javascript-es6/README.md @@ -91,6 +91,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *OpenApiPetstore.AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags +*OpenApiPetstore.FakeApi* | [**createXmlItem**](docs/FakeApi.md#createXmlItem) | **POST** /fake/create_xml_item | creates an XmlItem *OpenApiPetstore.FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | *OpenApiPetstore.FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | *OpenApiPetstore.FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | @@ -165,6 +166,7 @@ Class | Method | HTTP request | Description - [OpenApiPetstore.TypeHolderDefault](docs/TypeHolderDefault.md) - [OpenApiPetstore.TypeHolderExample](docs/TypeHolderExample.md) - [OpenApiPetstore.User](docs/User.md) + - [OpenApiPetstore.XmlItem](docs/XmlItem.md) ## Documentation for Authorization @@ -176,16 +178,19 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header + ### api_key_query - **Type**: API key - **API key parameter name**: api_key_query - **Location**: URL query string + ### http_basic_test - **Type**: HTTP basic authentication + ### petstore_auth - **Type**: OAuth diff --git a/samples/client/petstore/javascript-es6/docs/FakeApi.md b/samples/client/petstore/javascript-es6/docs/FakeApi.md index 11052f519d66..8169e553587d 100644 --- a/samples/client/petstore/javascript-es6/docs/FakeApi.md +++ b/samples/client/petstore/javascript-es6/docs/FakeApi.md @@ -4,6 +4,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**createXmlItem**](FakeApi.md#createXmlItem) | **POST** /fake/create_xml_item | creates an XmlItem [**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | [**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | [**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | @@ -18,6 +19,48 @@ Method | HTTP request | Description [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data + +# **createXmlItem** +> createXmlItem(xmlItem) + +creates an XmlItem + +this route creates an XmlItem + +### Example +```javascript +import OpenApiPetstore from 'open_api_petstore'; + +let apiInstance = new OpenApiPetstore.FakeApi(); +let xmlItem = new OpenApiPetstore.XmlItem(); // XmlItem | XmlItem Body +apiInstance.createXmlItem(xmlItem, (error, data, response) => { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **xmlItem** | [**XmlItem**](XmlItem.md)| XmlItem Body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/xml, application/xml; charset=utf-8, application/xml; charset=utf-16, text/xml, text/xml; charset=utf-8, text/xml; charset=utf-16 + - **Accept**: Not defined + # **fakeOuterBooleanSerialize** > Boolean fakeOuterBooleanSerialize(opts) @@ -332,7 +375,6 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure HTTP basic authorization: http_basic_test let http_basic_test = defaultClient.authentications['http_basic_test']; http_basic_test.username = 'YOUR USERNAME'; diff --git a/samples/client/petstore/javascript-es6/docs/FakeClassnameTags123Api.md b/samples/client/petstore/javascript-es6/docs/FakeClassnameTags123Api.md index ae78655ca974..ef3c044a1996 100644 --- a/samples/client/petstore/javascript-es6/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/javascript-es6/docs/FakeClassnameTags123Api.md @@ -19,7 +19,6 @@ To test class name in snake case ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure API key authorization: api_key_query let api_key_query = defaultClient.authentications['api_key_query']; api_key_query.apiKey = 'YOUR API KEY'; diff --git a/samples/client/petstore/javascript-es6/docs/PetApi.md b/samples/client/petstore/javascript-es6/docs/PetApi.md index b231a29e36e8..22aa9859ade0 100644 --- a/samples/client/petstore/javascript-es6/docs/PetApi.md +++ b/samples/client/petstore/javascript-es6/docs/PetApi.md @@ -25,7 +25,6 @@ Add a new pet to the store ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -70,7 +69,6 @@ Deletes a pet ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -121,7 +119,6 @@ Multiple status values can be provided with comma separated strings ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -168,7 +165,6 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -215,7 +211,6 @@ Returns a single pet ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure API key authorization: api_key let api_key = defaultClient.authentications['api_key']; api_key.apiKey = 'YOUR API KEY'; @@ -262,7 +257,6 @@ Update an existing pet ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -307,7 +301,6 @@ Updates a pet in the store with form data ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -358,7 +351,6 @@ uploads an image ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -409,7 +401,6 @@ uploads an image (required) ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; diff --git a/samples/client/petstore/javascript-es6/docs/StoreApi.md b/samples/client/petstore/javascript-es6/docs/StoreApi.md index 6c4da6dabea0..8887a4515188 100644 --- a/samples/client/petstore/javascript-es6/docs/StoreApi.md +++ b/samples/client/petstore/javascript-es6/docs/StoreApi.md @@ -64,7 +64,6 @@ Returns a map of status codes to quantities ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure API key authorization: api_key let api_key = defaultClient.authentications['api_key']; api_key.apiKey = 'YOUR API KEY'; diff --git a/samples/client/petstore/javascript-es6/docs/XmlItem.md b/samples/client/petstore/javascript-es6/docs/XmlItem.md new file mode 100644 index 000000000000..f27c0b9c39d6 --- /dev/null +++ b/samples/client/petstore/javascript-es6/docs/XmlItem.md @@ -0,0 +1,36 @@ +# OpenApiPetstore.XmlItem + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**attributeString** | **String** | | [optional] +**attributeNumber** | **Number** | | [optional] +**attributeInteger** | **Number** | | [optional] +**attributeBoolean** | **Boolean** | | [optional] +**wrappedArray** | **[Number]** | | [optional] +**nameString** | **String** | | [optional] +**nameNumber** | **Number** | | [optional] +**nameInteger** | **Number** | | [optional] +**nameBoolean** | **Boolean** | | [optional] +**nameArray** | **[Number]** | | [optional] +**nameWrappedArray** | **[Number]** | | [optional] +**prefixString** | **String** | | [optional] +**prefixNumber** | **Number** | | [optional] +**prefixInteger** | **Number** | | [optional] +**prefixBoolean** | **Boolean** | | [optional] +**prefixArray** | **[Number]** | | [optional] +**prefixWrappedArray** | **[Number]** | | [optional] +**namespaceString** | **String** | | [optional] +**namespaceNumber** | **Number** | | [optional] +**namespaceInteger** | **Number** | | [optional] +**namespaceBoolean** | **Boolean** | | [optional] +**namespaceArray** | **[Number]** | | [optional] +**namespaceWrappedArray** | **[Number]** | | [optional] +**prefixNsString** | **String** | | [optional] +**prefixNsNumber** | **Number** | | [optional] +**prefixNsInteger** | **Number** | | [optional] +**prefixNsBoolean** | **Boolean** | | [optional] +**prefixNsArray** | **[Number]** | | [optional] +**prefixNsWrappedArray** | **[Number]** | | [optional] + + diff --git a/samples/client/petstore/javascript-es6/src/ApiClient.js b/samples/client/petstore/javascript-es6/src/ApiClient.js index 8c8ee7963aaa..06944c72b2dd 100644 --- a/samples/client/petstore/javascript-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-es6/src/ApiClient.js @@ -272,6 +272,12 @@ class ApiClient { request.auth(auth.username || '', auth.password || ''); } + break; + case 'bearer': + if (auth.accessToken) { + request.set({'Authorization': 'Bearer ' + auth.accessToken}); + } + break; case 'apiKey': if (auth.apiKey) { diff --git a/samples/client/petstore/javascript-es6/src/api/FakeApi.js b/samples/client/petstore/javascript-es6/src/api/FakeApi.js index c6b3fe1634f1..24af9ec0d209 100644 --- a/samples/client/petstore/javascript-es6/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-es6/src/api/FakeApi.js @@ -17,6 +17,7 @@ import Client from '../model/Client'; import FileSchemaTestClass from '../model/FileSchemaTestClass'; import OuterComposite from '../model/OuterComposite'; import User from '../model/User'; +import XmlItem from '../model/XmlItem'; /** * Fake service. @@ -37,6 +38,50 @@ export default class FakeApi { } + /** + * Callback function to receive the result of the createXmlItem operation. + * @callback module:api/FakeApi~createXmlItemCallback + * @param {String} error Error message, if any. + * @param data This operation does not return a value. + * @param {String} response The complete HTTP response. + */ + + /** + * creates an XmlItem + * this route creates an XmlItem + * @param {module:model/XmlItem} xmlItem XmlItem Body + * @param {module:api/FakeApi~createXmlItemCallback} callback The callback function, accepting three arguments: error, data, response + */ + createXmlItem(xmlItem, callback) { + let postBody = xmlItem; + + // verify the required parameter 'xmlItem' is set + if (xmlItem === undefined || xmlItem === null) { + throw new Error("Missing the required parameter 'xmlItem' when calling createXmlItem"); + } + + + let pathParams = { + }; + let queryParams = { + }; + let headerParams = { + }; + let formParams = { + }; + + let authNames = []; + let contentTypes = ['application/xml', 'application/xml; charset=utf-8', 'application/xml; charset=utf-16', 'text/xml', 'text/xml; charset=utf-8', 'text/xml; charset=utf-16']; + let accepts = []; + let returnType = null; + + return this.apiClient.callApi( + '/fake/create_xml_item', 'POST', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + } + /** * Callback function to receive the result of the fakeOuterBooleanSerialize operation. * @callback module:api/FakeApi~fakeOuterBooleanSerializeCallback diff --git a/samples/client/petstore/javascript-es6/src/index.js b/samples/client/petstore/javascript-es6/src/index.js index 5c87df51d0fe..07c3b4f5ac82 100644 --- a/samples/client/petstore/javascript-es6/src/index.js +++ b/samples/client/petstore/javascript-es6/src/index.js @@ -49,6 +49,7 @@ import Tag from './model/Tag'; import TypeHolderDefault from './model/TypeHolderDefault'; import TypeHolderExample from './model/TypeHolderExample'; import User from './model/User'; +import XmlItem from './model/XmlItem'; import AnotherFakeApi from './api/AnotherFakeApi'; import FakeApi from './api/FakeApi'; import FakeClassnameTags123Api from './api/FakeClassnameTags123Api'; @@ -311,6 +312,12 @@ export { */ User, + /** + * The XmlItem model constructor. + * @property {module:model/XmlItem} + */ + XmlItem, + /** * The AnotherFakeApi service constructor. * @property {module:api/AnotherFakeApi} diff --git a/samples/client/petstore/javascript-es6/src/model/XmlItem.js b/samples/client/petstore/javascript-es6/src/model/XmlItem.js new file mode 100644 index 000000000000..c40a3f48dd42 --- /dev/null +++ b/samples/client/petstore/javascript-es6/src/model/XmlItem.js @@ -0,0 +1,295 @@ +/** + * OpenAPI 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 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + */ + +import ApiClient from '../ApiClient'; + +/** + * The XmlItem model module. + * @module model/XmlItem + * @version 1.0.0 + */ +class XmlItem { + /** + * Constructs a new XmlItem. + * @alias module:model/XmlItem + */ + constructor() { + + XmlItem.initialize(this); + } + + /** + * Initializes the fields of this object. + * This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins). + * Only for internal use. + */ + static initialize(obj) { + } + + /** + * Constructs a XmlItem from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/XmlItem} obj Optional instance to populate. + * @return {module:model/XmlItem} The populated XmlItem instance. + */ + static constructFromObject(data, obj) { + if (data) { + obj = obj || new XmlItem(); + + if (data.hasOwnProperty('attribute_string')) { + obj['attribute_string'] = ApiClient.convertToType(data['attribute_string'], 'String'); + } + if (data.hasOwnProperty('attribute_number')) { + obj['attribute_number'] = ApiClient.convertToType(data['attribute_number'], 'Number'); + } + if (data.hasOwnProperty('attribute_integer')) { + obj['attribute_integer'] = ApiClient.convertToType(data['attribute_integer'], 'Number'); + } + if (data.hasOwnProperty('attribute_boolean')) { + obj['attribute_boolean'] = ApiClient.convertToType(data['attribute_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('wrapped_array')) { + obj['wrapped_array'] = ApiClient.convertToType(data['wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('name_string')) { + obj['name_string'] = ApiClient.convertToType(data['name_string'], 'String'); + } + if (data.hasOwnProperty('name_number')) { + obj['name_number'] = ApiClient.convertToType(data['name_number'], 'Number'); + } + if (data.hasOwnProperty('name_integer')) { + obj['name_integer'] = ApiClient.convertToType(data['name_integer'], 'Number'); + } + if (data.hasOwnProperty('name_boolean')) { + obj['name_boolean'] = ApiClient.convertToType(data['name_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('name_array')) { + obj['name_array'] = ApiClient.convertToType(data['name_array'], ['Number']); + } + if (data.hasOwnProperty('name_wrapped_array')) { + obj['name_wrapped_array'] = ApiClient.convertToType(data['name_wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_string')) { + obj['prefix_string'] = ApiClient.convertToType(data['prefix_string'], 'String'); + } + if (data.hasOwnProperty('prefix_number')) { + obj['prefix_number'] = ApiClient.convertToType(data['prefix_number'], 'Number'); + } + if (data.hasOwnProperty('prefix_integer')) { + obj['prefix_integer'] = ApiClient.convertToType(data['prefix_integer'], 'Number'); + } + if (data.hasOwnProperty('prefix_boolean')) { + obj['prefix_boolean'] = ApiClient.convertToType(data['prefix_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('prefix_array')) { + obj['prefix_array'] = ApiClient.convertToType(data['prefix_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_wrapped_array')) { + obj['prefix_wrapped_array'] = ApiClient.convertToType(data['prefix_wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('namespace_string')) { + obj['namespace_string'] = ApiClient.convertToType(data['namespace_string'], 'String'); + } + if (data.hasOwnProperty('namespace_number')) { + obj['namespace_number'] = ApiClient.convertToType(data['namespace_number'], 'Number'); + } + if (data.hasOwnProperty('namespace_integer')) { + obj['namespace_integer'] = ApiClient.convertToType(data['namespace_integer'], 'Number'); + } + if (data.hasOwnProperty('namespace_boolean')) { + obj['namespace_boolean'] = ApiClient.convertToType(data['namespace_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('namespace_array')) { + obj['namespace_array'] = ApiClient.convertToType(data['namespace_array'], ['Number']); + } + if (data.hasOwnProperty('namespace_wrapped_array')) { + obj['namespace_wrapped_array'] = ApiClient.convertToType(data['namespace_wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_ns_string')) { + obj['prefix_ns_string'] = ApiClient.convertToType(data['prefix_ns_string'], 'String'); + } + if (data.hasOwnProperty('prefix_ns_number')) { + obj['prefix_ns_number'] = ApiClient.convertToType(data['prefix_ns_number'], 'Number'); + } + if (data.hasOwnProperty('prefix_ns_integer')) { + obj['prefix_ns_integer'] = ApiClient.convertToType(data['prefix_ns_integer'], 'Number'); + } + if (data.hasOwnProperty('prefix_ns_boolean')) { + obj['prefix_ns_boolean'] = ApiClient.convertToType(data['prefix_ns_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('prefix_ns_array')) { + obj['prefix_ns_array'] = ApiClient.convertToType(data['prefix_ns_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_ns_wrapped_array')) { + obj['prefix_ns_wrapped_array'] = ApiClient.convertToType(data['prefix_ns_wrapped_array'], ['Number']); + } + } + return obj; + } + + +} + +/** + * @member {String} attribute_string + */ +XmlItem.prototype['attribute_string'] = undefined; + +/** + * @member {Number} attribute_number + */ +XmlItem.prototype['attribute_number'] = undefined; + +/** + * @member {Number} attribute_integer + */ +XmlItem.prototype['attribute_integer'] = undefined; + +/** + * @member {Boolean} attribute_boolean + */ +XmlItem.prototype['attribute_boolean'] = undefined; + +/** + * @member {Array.} wrapped_array + */ +XmlItem.prototype['wrapped_array'] = undefined; + +/** + * @member {String} name_string + */ +XmlItem.prototype['name_string'] = undefined; + +/** + * @member {Number} name_number + */ +XmlItem.prototype['name_number'] = undefined; + +/** + * @member {Number} name_integer + */ +XmlItem.prototype['name_integer'] = undefined; + +/** + * @member {Boolean} name_boolean + */ +XmlItem.prototype['name_boolean'] = undefined; + +/** + * @member {Array.} name_array + */ +XmlItem.prototype['name_array'] = undefined; + +/** + * @member {Array.} name_wrapped_array + */ +XmlItem.prototype['name_wrapped_array'] = undefined; + +/** + * @member {String} prefix_string + */ +XmlItem.prototype['prefix_string'] = undefined; + +/** + * @member {Number} prefix_number + */ +XmlItem.prototype['prefix_number'] = undefined; + +/** + * @member {Number} prefix_integer + */ +XmlItem.prototype['prefix_integer'] = undefined; + +/** + * @member {Boolean} prefix_boolean + */ +XmlItem.prototype['prefix_boolean'] = undefined; + +/** + * @member {Array.} prefix_array + */ +XmlItem.prototype['prefix_array'] = undefined; + +/** + * @member {Array.} prefix_wrapped_array + */ +XmlItem.prototype['prefix_wrapped_array'] = undefined; + +/** + * @member {String} namespace_string + */ +XmlItem.prototype['namespace_string'] = undefined; + +/** + * @member {Number} namespace_number + */ +XmlItem.prototype['namespace_number'] = undefined; + +/** + * @member {Number} namespace_integer + */ +XmlItem.prototype['namespace_integer'] = undefined; + +/** + * @member {Boolean} namespace_boolean + */ +XmlItem.prototype['namespace_boolean'] = undefined; + +/** + * @member {Array.} namespace_array + */ +XmlItem.prototype['namespace_array'] = undefined; + +/** + * @member {Array.} namespace_wrapped_array + */ +XmlItem.prototype['namespace_wrapped_array'] = undefined; + +/** + * @member {String} prefix_ns_string + */ +XmlItem.prototype['prefix_ns_string'] = undefined; + +/** + * @member {Number} prefix_ns_number + */ +XmlItem.prototype['prefix_ns_number'] = undefined; + +/** + * @member {Number} prefix_ns_integer + */ +XmlItem.prototype['prefix_ns_integer'] = undefined; + +/** + * @member {Boolean} prefix_ns_boolean + */ +XmlItem.prototype['prefix_ns_boolean'] = undefined; + +/** + * @member {Array.} prefix_ns_array + */ +XmlItem.prototype['prefix_ns_array'] = undefined; + +/** + * @member {Array.} prefix_ns_wrapped_array + */ +XmlItem.prototype['prefix_ns_wrapped_array'] = undefined; + + + + + + +export default XmlItem; + diff --git a/samples/client/petstore/javascript-es6/test/model/XmlItem.spec.js b/samples/client/petstore/javascript-es6/test/model/XmlItem.spec.js new file mode 100644 index 000000000000..5b6326b74301 --- /dev/null +++ b/samples/client/petstore/javascript-es6/test/model/XmlItem.spec.js @@ -0,0 +1,233 @@ +/** + * OpenAPI 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 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.OpenApiPetstore); + } +}(this, function(expect, OpenApiPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new OpenApiPetstore.XmlItem(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('XmlItem', function() { + it('should create an instance of XmlItem', function() { + // uncomment below and update the code to test XmlItem + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be.a(OpenApiPetstore.XmlItem); + }); + + it('should have the property attributeString (base name: "attribute_string")', function() { + // uncomment below and update the code to test the property attributeString + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property attributeNumber (base name: "attribute_number")', function() { + // uncomment below and update the code to test the property attributeNumber + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property attributeInteger (base name: "attribute_integer")', function() { + // uncomment below and update the code to test the property attributeInteger + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property attributeBoolean (base name: "attribute_boolean")', function() { + // uncomment below and update the code to test the property attributeBoolean + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property wrappedArray (base name: "wrapped_array")', function() { + // uncomment below and update the code to test the property wrappedArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameString (base name: "name_string")', function() { + // uncomment below and update the code to test the property nameString + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameNumber (base name: "name_number")', function() { + // uncomment below and update the code to test the property nameNumber + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameInteger (base name: "name_integer")', function() { + // uncomment below and update the code to test the property nameInteger + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameBoolean (base name: "name_boolean")', function() { + // uncomment below and update the code to test the property nameBoolean + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameArray (base name: "name_array")', function() { + // uncomment below and update the code to test the property nameArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameWrappedArray (base name: "name_wrapped_array")', function() { + // uncomment below and update the code to test the property nameWrappedArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixString (base name: "prefix_string")', function() { + // uncomment below and update the code to test the property prefixString + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNumber (base name: "prefix_number")', function() { + // uncomment below and update the code to test the property prefixNumber + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixInteger (base name: "prefix_integer")', function() { + // uncomment below and update the code to test the property prefixInteger + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixBoolean (base name: "prefix_boolean")', function() { + // uncomment below and update the code to test the property prefixBoolean + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixArray (base name: "prefix_array")', function() { + // uncomment below and update the code to test the property prefixArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixWrappedArray (base name: "prefix_wrapped_array")', function() { + // uncomment below and update the code to test the property prefixWrappedArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceString (base name: "namespace_string")', function() { + // uncomment below and update the code to test the property namespaceString + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceNumber (base name: "namespace_number")', function() { + // uncomment below and update the code to test the property namespaceNumber + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceInteger (base name: "namespace_integer")', function() { + // uncomment below and update the code to test the property namespaceInteger + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceBoolean (base name: "namespace_boolean")', function() { + // uncomment below and update the code to test the property namespaceBoolean + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceArray (base name: "namespace_array")', function() { + // uncomment below and update the code to test the property namespaceArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceWrappedArray (base name: "namespace_wrapped_array")', function() { + // uncomment below and update the code to test the property namespaceWrappedArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsString (base name: "prefix_ns_string")', function() { + // uncomment below and update the code to test the property prefixNsString + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsNumber (base name: "prefix_ns_number")', function() { + // uncomment below and update the code to test the property prefixNsNumber + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsInteger (base name: "prefix_ns_integer")', function() { + // uncomment below and update the code to test the property prefixNsInteger + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsBoolean (base name: "prefix_ns_boolean")', function() { + // uncomment below and update the code to test the property prefixNsBoolean + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsArray (base name: "prefix_ns_array")', function() { + // uncomment below and update the code to test the property prefixNsArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsWrappedArray (base name: "prefix_ns_wrapped_array")', function() { + // uncomment below and update the code to test the property prefixNsWrappedArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise-es6/README.md b/samples/client/petstore/javascript-promise-es6/README.md index a6d27772edfb..c7e9d2f03a3f 100644 --- a/samples/client/petstore/javascript-promise-es6/README.md +++ b/samples/client/petstore/javascript-promise-es6/README.md @@ -89,6 +89,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *OpenApiPetstore.AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags +*OpenApiPetstore.FakeApi* | [**createXmlItem**](docs/FakeApi.md#createXmlItem) | **POST** /fake/create_xml_item | creates an XmlItem *OpenApiPetstore.FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | *OpenApiPetstore.FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | *OpenApiPetstore.FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | @@ -163,6 +164,7 @@ Class | Method | HTTP request | Description - [OpenApiPetstore.TypeHolderDefault](docs/TypeHolderDefault.md) - [OpenApiPetstore.TypeHolderExample](docs/TypeHolderExample.md) - [OpenApiPetstore.User](docs/User.md) + - [OpenApiPetstore.XmlItem](docs/XmlItem.md) ## Documentation for Authorization @@ -174,16 +176,19 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header + ### api_key_query - **Type**: API key - **API key parameter name**: api_key_query - **Location**: URL query string + ### http_basic_test - **Type**: HTTP basic authentication + ### petstore_auth - **Type**: OAuth diff --git a/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md b/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md index e0d8f8fcdec5..b1c56717ad7b 100644 --- a/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md +++ b/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md @@ -4,6 +4,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**createXmlItem**](FakeApi.md#createXmlItem) | **POST** /fake/create_xml_item | creates an XmlItem [**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | [**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | [**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | @@ -18,6 +19,47 @@ Method | HTTP request | Description [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data + +# **createXmlItem** +> createXmlItem(xmlItem) + +creates an XmlItem + +this route creates an XmlItem + +### Example +```javascript +import OpenApiPetstore from 'open_api_petstore'; + +let apiInstance = new OpenApiPetstore.FakeApi(); +let xmlItem = new OpenApiPetstore.XmlItem(); // XmlItem | XmlItem Body +apiInstance.createXmlItem(xmlItem).then(() => { + console.log('API called successfully.'); +}, (error) => { + console.error(error); +}); + +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **xmlItem** | [**XmlItem**](XmlItem.md)| XmlItem Body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/xml, application/xml; charset=utf-8, application/xml; charset=utf-16, text/xml, text/xml; charset=utf-8, text/xml; charset=utf-16 + - **Accept**: Not defined + # **fakeOuterBooleanSerialize** > Boolean fakeOuterBooleanSerialize(opts) @@ -325,7 +367,6 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure HTTP basic authorization: http_basic_test let http_basic_test = defaultClient.authentications['http_basic_test']; http_basic_test.username = 'YOUR USERNAME'; diff --git a/samples/client/petstore/javascript-promise-es6/docs/FakeClassnameTags123Api.md b/samples/client/petstore/javascript-promise-es6/docs/FakeClassnameTags123Api.md index 62db4c20b9c3..4009ad4c854a 100644 --- a/samples/client/petstore/javascript-promise-es6/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/javascript-promise-es6/docs/FakeClassnameTags123Api.md @@ -19,7 +19,6 @@ To test class name in snake case ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure API key authorization: api_key_query let api_key_query = defaultClient.authentications['api_key_query']; api_key_query.apiKey = 'YOUR API KEY'; diff --git a/samples/client/petstore/javascript-promise-es6/docs/PetApi.md b/samples/client/petstore/javascript-promise-es6/docs/PetApi.md index 84cf06267317..cd1e2998f547 100644 --- a/samples/client/petstore/javascript-promise-es6/docs/PetApi.md +++ b/samples/client/petstore/javascript-promise-es6/docs/PetApi.md @@ -25,7 +25,6 @@ Add a new pet to the store ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -69,7 +68,6 @@ Deletes a pet ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -119,7 +117,6 @@ Multiple status values can be provided with comma separated strings ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -165,7 +162,6 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -211,7 +207,6 @@ Returns a single pet ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure API key authorization: api_key let api_key = defaultClient.authentications['api_key']; api_key.apiKey = 'YOUR API KEY'; @@ -257,7 +252,6 @@ Update an existing pet ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -301,7 +295,6 @@ Updates a pet in the store with form data ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -351,7 +344,6 @@ uploads an image ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -401,7 +393,6 @@ uploads an image (required) ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; diff --git a/samples/client/petstore/javascript-promise-es6/docs/StoreApi.md b/samples/client/petstore/javascript-promise-es6/docs/StoreApi.md index 96b537a1783e..94ac8c2d44bd 100644 --- a/samples/client/petstore/javascript-promise-es6/docs/StoreApi.md +++ b/samples/client/petstore/javascript-promise-es6/docs/StoreApi.md @@ -63,7 +63,6 @@ Returns a map of status codes to quantities ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure API key authorization: api_key let api_key = defaultClient.authentications['api_key']; api_key.apiKey = 'YOUR API KEY'; diff --git a/samples/client/petstore/javascript-promise-es6/docs/XmlItem.md b/samples/client/petstore/javascript-promise-es6/docs/XmlItem.md new file mode 100644 index 000000000000..f27c0b9c39d6 --- /dev/null +++ b/samples/client/petstore/javascript-promise-es6/docs/XmlItem.md @@ -0,0 +1,36 @@ +# OpenApiPetstore.XmlItem + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**attributeString** | **String** | | [optional] +**attributeNumber** | **Number** | | [optional] +**attributeInteger** | **Number** | | [optional] +**attributeBoolean** | **Boolean** | | [optional] +**wrappedArray** | **[Number]** | | [optional] +**nameString** | **String** | | [optional] +**nameNumber** | **Number** | | [optional] +**nameInteger** | **Number** | | [optional] +**nameBoolean** | **Boolean** | | [optional] +**nameArray** | **[Number]** | | [optional] +**nameWrappedArray** | **[Number]** | | [optional] +**prefixString** | **String** | | [optional] +**prefixNumber** | **Number** | | [optional] +**prefixInteger** | **Number** | | [optional] +**prefixBoolean** | **Boolean** | | [optional] +**prefixArray** | **[Number]** | | [optional] +**prefixWrappedArray** | **[Number]** | | [optional] +**namespaceString** | **String** | | [optional] +**namespaceNumber** | **Number** | | [optional] +**namespaceInteger** | **Number** | | [optional] +**namespaceBoolean** | **Boolean** | | [optional] +**namespaceArray** | **[Number]** | | [optional] +**namespaceWrappedArray** | **[Number]** | | [optional] +**prefixNsString** | **String** | | [optional] +**prefixNsNumber** | **Number** | | [optional] +**prefixNsInteger** | **Number** | | [optional] +**prefixNsBoolean** | **Boolean** | | [optional] +**prefixNsArray** | **[Number]** | | [optional] +**prefixNsWrappedArray** | **[Number]** | | [optional] + + diff --git a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js index 262b13dbbae6..124368795afd 100644 --- a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js @@ -272,6 +272,12 @@ class ApiClient { request.auth(auth.username || '', auth.password || ''); } + break; + case 'bearer': + if (auth.accessToken) { + request.set({'Authorization': 'Bearer ' + auth.accessToken}); + } + break; case 'apiKey': if (auth.apiKey) { 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 ae884f53e911..7495c0b63a74 100644 --- a/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js @@ -17,6 +17,7 @@ import Client from '../model/Client'; import FileSchemaTestClass from '../model/FileSchemaTestClass'; import OuterComposite from '../model/OuterComposite'; import User from '../model/User'; +import XmlItem from '../model/XmlItem'; /** * Fake service. @@ -38,6 +39,56 @@ export default class FakeApi { + /** + * creates an XmlItem + * this route creates an XmlItem + * @param {module:model/XmlItem} xmlItem XmlItem Body + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response + */ + createXmlItemWithHttpInfo(xmlItem) { + let postBody = xmlItem; + + // verify the required parameter 'xmlItem' is set + if (xmlItem === undefined || xmlItem === null) { + throw new Error("Missing the required parameter 'xmlItem' when calling createXmlItem"); + } + + + let pathParams = { + }; + let queryParams = { + }; + let headerParams = { + }; + let formParams = { + }; + + let authNames = []; + let contentTypes = ['application/xml', 'application/xml; charset=utf-8', 'application/xml; charset=utf-16', 'text/xml', 'text/xml; charset=utf-8', 'text/xml; charset=utf-16']; + let accepts = []; + let returnType = null; + + return this.apiClient.callApi( + '/fake/create_xml_item', 'POST', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType + ); + } + + /** + * creates an XmlItem + * this route creates an XmlItem + * @param {module:model/XmlItem} xmlItem XmlItem Body + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + createXmlItem(xmlItem) { + return this.createXmlItemWithHttpInfo(xmlItem) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + + /** * Test serialization of outer boolean types * @param {Object} opts Optional parameters diff --git a/samples/client/petstore/javascript-promise-es6/src/index.js b/samples/client/petstore/javascript-promise-es6/src/index.js index 5c87df51d0fe..07c3b4f5ac82 100644 --- a/samples/client/petstore/javascript-promise-es6/src/index.js +++ b/samples/client/petstore/javascript-promise-es6/src/index.js @@ -49,6 +49,7 @@ import Tag from './model/Tag'; import TypeHolderDefault from './model/TypeHolderDefault'; import TypeHolderExample from './model/TypeHolderExample'; import User from './model/User'; +import XmlItem from './model/XmlItem'; import AnotherFakeApi from './api/AnotherFakeApi'; import FakeApi from './api/FakeApi'; import FakeClassnameTags123Api from './api/FakeClassnameTags123Api'; @@ -311,6 +312,12 @@ export { */ User, + /** + * The XmlItem model constructor. + * @property {module:model/XmlItem} + */ + XmlItem, + /** * The AnotherFakeApi service constructor. * @property {module:api/AnotherFakeApi} diff --git a/samples/client/petstore/javascript-promise-es6/src/model/XmlItem.js b/samples/client/petstore/javascript-promise-es6/src/model/XmlItem.js new file mode 100644 index 000000000000..c40a3f48dd42 --- /dev/null +++ b/samples/client/petstore/javascript-promise-es6/src/model/XmlItem.js @@ -0,0 +1,295 @@ +/** + * OpenAPI 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 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + */ + +import ApiClient from '../ApiClient'; + +/** + * The XmlItem model module. + * @module model/XmlItem + * @version 1.0.0 + */ +class XmlItem { + /** + * Constructs a new XmlItem. + * @alias module:model/XmlItem + */ + constructor() { + + XmlItem.initialize(this); + } + + /** + * Initializes the fields of this object. + * This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins). + * Only for internal use. + */ + static initialize(obj) { + } + + /** + * Constructs a XmlItem from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/XmlItem} obj Optional instance to populate. + * @return {module:model/XmlItem} The populated XmlItem instance. + */ + static constructFromObject(data, obj) { + if (data) { + obj = obj || new XmlItem(); + + if (data.hasOwnProperty('attribute_string')) { + obj['attribute_string'] = ApiClient.convertToType(data['attribute_string'], 'String'); + } + if (data.hasOwnProperty('attribute_number')) { + obj['attribute_number'] = ApiClient.convertToType(data['attribute_number'], 'Number'); + } + if (data.hasOwnProperty('attribute_integer')) { + obj['attribute_integer'] = ApiClient.convertToType(data['attribute_integer'], 'Number'); + } + if (data.hasOwnProperty('attribute_boolean')) { + obj['attribute_boolean'] = ApiClient.convertToType(data['attribute_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('wrapped_array')) { + obj['wrapped_array'] = ApiClient.convertToType(data['wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('name_string')) { + obj['name_string'] = ApiClient.convertToType(data['name_string'], 'String'); + } + if (data.hasOwnProperty('name_number')) { + obj['name_number'] = ApiClient.convertToType(data['name_number'], 'Number'); + } + if (data.hasOwnProperty('name_integer')) { + obj['name_integer'] = ApiClient.convertToType(data['name_integer'], 'Number'); + } + if (data.hasOwnProperty('name_boolean')) { + obj['name_boolean'] = ApiClient.convertToType(data['name_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('name_array')) { + obj['name_array'] = ApiClient.convertToType(data['name_array'], ['Number']); + } + if (data.hasOwnProperty('name_wrapped_array')) { + obj['name_wrapped_array'] = ApiClient.convertToType(data['name_wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_string')) { + obj['prefix_string'] = ApiClient.convertToType(data['prefix_string'], 'String'); + } + if (data.hasOwnProperty('prefix_number')) { + obj['prefix_number'] = ApiClient.convertToType(data['prefix_number'], 'Number'); + } + if (data.hasOwnProperty('prefix_integer')) { + obj['prefix_integer'] = ApiClient.convertToType(data['prefix_integer'], 'Number'); + } + if (data.hasOwnProperty('prefix_boolean')) { + obj['prefix_boolean'] = ApiClient.convertToType(data['prefix_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('prefix_array')) { + obj['prefix_array'] = ApiClient.convertToType(data['prefix_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_wrapped_array')) { + obj['prefix_wrapped_array'] = ApiClient.convertToType(data['prefix_wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('namespace_string')) { + obj['namespace_string'] = ApiClient.convertToType(data['namespace_string'], 'String'); + } + if (data.hasOwnProperty('namespace_number')) { + obj['namespace_number'] = ApiClient.convertToType(data['namespace_number'], 'Number'); + } + if (data.hasOwnProperty('namespace_integer')) { + obj['namespace_integer'] = ApiClient.convertToType(data['namespace_integer'], 'Number'); + } + if (data.hasOwnProperty('namespace_boolean')) { + obj['namespace_boolean'] = ApiClient.convertToType(data['namespace_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('namespace_array')) { + obj['namespace_array'] = ApiClient.convertToType(data['namespace_array'], ['Number']); + } + if (data.hasOwnProperty('namespace_wrapped_array')) { + obj['namespace_wrapped_array'] = ApiClient.convertToType(data['namespace_wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_ns_string')) { + obj['prefix_ns_string'] = ApiClient.convertToType(data['prefix_ns_string'], 'String'); + } + if (data.hasOwnProperty('prefix_ns_number')) { + obj['prefix_ns_number'] = ApiClient.convertToType(data['prefix_ns_number'], 'Number'); + } + if (data.hasOwnProperty('prefix_ns_integer')) { + obj['prefix_ns_integer'] = ApiClient.convertToType(data['prefix_ns_integer'], 'Number'); + } + if (data.hasOwnProperty('prefix_ns_boolean')) { + obj['prefix_ns_boolean'] = ApiClient.convertToType(data['prefix_ns_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('prefix_ns_array')) { + obj['prefix_ns_array'] = ApiClient.convertToType(data['prefix_ns_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_ns_wrapped_array')) { + obj['prefix_ns_wrapped_array'] = ApiClient.convertToType(data['prefix_ns_wrapped_array'], ['Number']); + } + } + return obj; + } + + +} + +/** + * @member {String} attribute_string + */ +XmlItem.prototype['attribute_string'] = undefined; + +/** + * @member {Number} attribute_number + */ +XmlItem.prototype['attribute_number'] = undefined; + +/** + * @member {Number} attribute_integer + */ +XmlItem.prototype['attribute_integer'] = undefined; + +/** + * @member {Boolean} attribute_boolean + */ +XmlItem.prototype['attribute_boolean'] = undefined; + +/** + * @member {Array.} wrapped_array + */ +XmlItem.prototype['wrapped_array'] = undefined; + +/** + * @member {String} name_string + */ +XmlItem.prototype['name_string'] = undefined; + +/** + * @member {Number} name_number + */ +XmlItem.prototype['name_number'] = undefined; + +/** + * @member {Number} name_integer + */ +XmlItem.prototype['name_integer'] = undefined; + +/** + * @member {Boolean} name_boolean + */ +XmlItem.prototype['name_boolean'] = undefined; + +/** + * @member {Array.} name_array + */ +XmlItem.prototype['name_array'] = undefined; + +/** + * @member {Array.} name_wrapped_array + */ +XmlItem.prototype['name_wrapped_array'] = undefined; + +/** + * @member {String} prefix_string + */ +XmlItem.prototype['prefix_string'] = undefined; + +/** + * @member {Number} prefix_number + */ +XmlItem.prototype['prefix_number'] = undefined; + +/** + * @member {Number} prefix_integer + */ +XmlItem.prototype['prefix_integer'] = undefined; + +/** + * @member {Boolean} prefix_boolean + */ +XmlItem.prototype['prefix_boolean'] = undefined; + +/** + * @member {Array.} prefix_array + */ +XmlItem.prototype['prefix_array'] = undefined; + +/** + * @member {Array.} prefix_wrapped_array + */ +XmlItem.prototype['prefix_wrapped_array'] = undefined; + +/** + * @member {String} namespace_string + */ +XmlItem.prototype['namespace_string'] = undefined; + +/** + * @member {Number} namespace_number + */ +XmlItem.prototype['namespace_number'] = undefined; + +/** + * @member {Number} namespace_integer + */ +XmlItem.prototype['namespace_integer'] = undefined; + +/** + * @member {Boolean} namespace_boolean + */ +XmlItem.prototype['namespace_boolean'] = undefined; + +/** + * @member {Array.} namespace_array + */ +XmlItem.prototype['namespace_array'] = undefined; + +/** + * @member {Array.} namespace_wrapped_array + */ +XmlItem.prototype['namespace_wrapped_array'] = undefined; + +/** + * @member {String} prefix_ns_string + */ +XmlItem.prototype['prefix_ns_string'] = undefined; + +/** + * @member {Number} prefix_ns_number + */ +XmlItem.prototype['prefix_ns_number'] = undefined; + +/** + * @member {Number} prefix_ns_integer + */ +XmlItem.prototype['prefix_ns_integer'] = undefined; + +/** + * @member {Boolean} prefix_ns_boolean + */ +XmlItem.prototype['prefix_ns_boolean'] = undefined; + +/** + * @member {Array.} prefix_ns_array + */ +XmlItem.prototype['prefix_ns_array'] = undefined; + +/** + * @member {Array.} prefix_ns_wrapped_array + */ +XmlItem.prototype['prefix_ns_wrapped_array'] = undefined; + + + + + + +export default XmlItem; + diff --git a/samples/client/petstore/javascript-promise-es6/test/model/XmlItem.spec.js b/samples/client/petstore/javascript-promise-es6/test/model/XmlItem.spec.js new file mode 100644 index 000000000000..5b6326b74301 --- /dev/null +++ b/samples/client/petstore/javascript-promise-es6/test/model/XmlItem.spec.js @@ -0,0 +1,233 @@ +/** + * OpenAPI 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 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + * + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.OpenApiPetstore); + } +}(this, function(expect, OpenApiPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new OpenApiPetstore.XmlItem(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('XmlItem', function() { + it('should create an instance of XmlItem', function() { + // uncomment below and update the code to test XmlItem + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be.a(OpenApiPetstore.XmlItem); + }); + + it('should have the property attributeString (base name: "attribute_string")', function() { + // uncomment below and update the code to test the property attributeString + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property attributeNumber (base name: "attribute_number")', function() { + // uncomment below and update the code to test the property attributeNumber + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property attributeInteger (base name: "attribute_integer")', function() { + // uncomment below and update the code to test the property attributeInteger + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property attributeBoolean (base name: "attribute_boolean")', function() { + // uncomment below and update the code to test the property attributeBoolean + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property wrappedArray (base name: "wrapped_array")', function() { + // uncomment below and update the code to test the property wrappedArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameString (base name: "name_string")', function() { + // uncomment below and update the code to test the property nameString + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameNumber (base name: "name_number")', function() { + // uncomment below and update the code to test the property nameNumber + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameInteger (base name: "name_integer")', function() { + // uncomment below and update the code to test the property nameInteger + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameBoolean (base name: "name_boolean")', function() { + // uncomment below and update the code to test the property nameBoolean + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameArray (base name: "name_array")', function() { + // uncomment below and update the code to test the property nameArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameWrappedArray (base name: "name_wrapped_array")', function() { + // uncomment below and update the code to test the property nameWrappedArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixString (base name: "prefix_string")', function() { + // uncomment below and update the code to test the property prefixString + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNumber (base name: "prefix_number")', function() { + // uncomment below and update the code to test the property prefixNumber + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixInteger (base name: "prefix_integer")', function() { + // uncomment below and update the code to test the property prefixInteger + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixBoolean (base name: "prefix_boolean")', function() { + // uncomment below and update the code to test the property prefixBoolean + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixArray (base name: "prefix_array")', function() { + // uncomment below and update the code to test the property prefixArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixWrappedArray (base name: "prefix_wrapped_array")', function() { + // uncomment below and update the code to test the property prefixWrappedArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceString (base name: "namespace_string")', function() { + // uncomment below and update the code to test the property namespaceString + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceNumber (base name: "namespace_number")', function() { + // uncomment below and update the code to test the property namespaceNumber + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceInteger (base name: "namespace_integer")', function() { + // uncomment below and update the code to test the property namespaceInteger + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceBoolean (base name: "namespace_boolean")', function() { + // uncomment below and update the code to test the property namespaceBoolean + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceArray (base name: "namespace_array")', function() { + // uncomment below and update the code to test the property namespaceArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceWrappedArray (base name: "namespace_wrapped_array")', function() { + // uncomment below and update the code to test the property namespaceWrappedArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsString (base name: "prefix_ns_string")', function() { + // uncomment below and update the code to test the property prefixNsString + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsNumber (base name: "prefix_ns_number")', function() { + // uncomment below and update the code to test the property prefixNsNumber + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsInteger (base name: "prefix_ns_integer")', function() { + // uncomment below and update the code to test the property prefixNsInteger + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsBoolean (base name: "prefix_ns_boolean")', function() { + // uncomment below and update the code to test the property prefixNsBoolean + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsArray (base name: "prefix_ns_array")', function() { + // uncomment below and update the code to test the property prefixNsArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsWrappedArray (base name: "prefix_ns_wrapped_array")', function() { + // uncomment below and update the code to test the property prefixNsWrappedArray + //var instane = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript-promise/README.md b/samples/client/petstore/javascript-promise/README.md index b3a275f9e426..2051d2e317b7 100644 --- a/samples/client/petstore/javascript-promise/README.md +++ b/samples/client/petstore/javascript-promise/README.md @@ -95,6 +95,7 @@ Please follow the [installation](#installation) instruction and execute the foll ```javascript var OpenApiPetstore = require('open_api_petstore'); + var api = new OpenApiPetstore.AnotherFakeApi() var body = new OpenApiPetstore.Client(); // {Client} client model api.call123testSpecialTags(body).then(function(data) { @@ -113,6 +114,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *OpenApiPetstore.AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags +*OpenApiPetstore.FakeApi* | [**createXmlItem**](docs/FakeApi.md#createXmlItem) | **POST** /fake/create_xml_item | creates an XmlItem *OpenApiPetstore.FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | *OpenApiPetstore.FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | *OpenApiPetstore.FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | @@ -187,6 +189,7 @@ Class | Method | HTTP request | Description - [OpenApiPetstore.TypeHolderDefault](docs/TypeHolderDefault.md) - [OpenApiPetstore.TypeHolderExample](docs/TypeHolderExample.md) - [OpenApiPetstore.User](docs/User.md) + - [OpenApiPetstore.XmlItem](docs/XmlItem.md) ## Documentation for Authorization @@ -198,16 +201,19 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header + ### api_key_query - **Type**: API key - **API key parameter name**: api_key_query - **Location**: URL query string + ### http_basic_test - **Type**: HTTP basic authentication + ### petstore_auth - **Type**: OAuth diff --git a/samples/client/petstore/javascript-promise/docs/FakeApi.md b/samples/client/petstore/javascript-promise/docs/FakeApi.md index 84eca2e71aed..bddca9408016 100644 --- a/samples/client/petstore/javascript-promise/docs/FakeApi.md +++ b/samples/client/petstore/javascript-promise/docs/FakeApi.md @@ -4,6 +4,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**createXmlItem**](FakeApi.md#createXmlItem) | **POST** /fake/create_xml_item | creates an XmlItem [**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | [**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | [**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | @@ -18,6 +19,47 @@ Method | HTTP request | Description [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data + +# **createXmlItem** +> createXmlItem(xmlItem) + +creates an XmlItem + +this route creates an XmlItem + +### Example +```javascript +var OpenApiPetstore = require('open_api_petstore'); + +var apiInstance = new OpenApiPetstore.FakeApi(); +var xmlItem = new OpenApiPetstore.XmlItem(); // XmlItem | XmlItem Body +apiInstance.createXmlItem(xmlItem).then(function() { + console.log('API called successfully.'); +}, function(error) { + console.error(error); +}); + +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **xmlItem** | [**XmlItem**](XmlItem.md)| XmlItem Body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/xml, application/xml; charset=utf-8, application/xml; charset=utf-16, text/xml, text/xml; charset=utf-8, text/xml; charset=utf-16 + - **Accept**: Not defined + # **fakeOuterBooleanSerialize** > Boolean fakeOuterBooleanSerialize(opts) @@ -325,7 +367,6 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン ```javascript var OpenApiPetstore = require('open_api_petstore'); var defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure HTTP basic authorization: http_basic_test var http_basic_test = defaultClient.authentications['http_basic_test']; http_basic_test.username = 'YOUR USERNAME'; diff --git a/samples/client/petstore/javascript-promise/docs/XmlItem.md b/samples/client/petstore/javascript-promise/docs/XmlItem.md new file mode 100644 index 000000000000..f27c0b9c39d6 --- /dev/null +++ b/samples/client/petstore/javascript-promise/docs/XmlItem.md @@ -0,0 +1,36 @@ +# OpenApiPetstore.XmlItem + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**attributeString** | **String** | | [optional] +**attributeNumber** | **Number** | | [optional] +**attributeInteger** | **Number** | | [optional] +**attributeBoolean** | **Boolean** | | [optional] +**wrappedArray** | **[Number]** | | [optional] +**nameString** | **String** | | [optional] +**nameNumber** | **Number** | | [optional] +**nameInteger** | **Number** | | [optional] +**nameBoolean** | **Boolean** | | [optional] +**nameArray** | **[Number]** | | [optional] +**nameWrappedArray** | **[Number]** | | [optional] +**prefixString** | **String** | | [optional] +**prefixNumber** | **Number** | | [optional] +**prefixInteger** | **Number** | | [optional] +**prefixBoolean** | **Boolean** | | [optional] +**prefixArray** | **[Number]** | | [optional] +**prefixWrappedArray** | **[Number]** | | [optional] +**namespaceString** | **String** | | [optional] +**namespaceNumber** | **Number** | | [optional] +**namespaceInteger** | **Number** | | [optional] +**namespaceBoolean** | **Boolean** | | [optional] +**namespaceArray** | **[Number]** | | [optional] +**namespaceWrappedArray** | **[Number]** | | [optional] +**prefixNsString** | **String** | | [optional] +**prefixNsNumber** | **Number** | | [optional] +**prefixNsInteger** | **Number** | | [optional] +**prefixNsBoolean** | **Boolean** | | [optional] +**prefixNsArray** | **[Number]** | | [optional] +**prefixNsWrappedArray** | **[Number]** | | [optional] + + diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index 2e0105579ec3..dcf4d1342022 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -309,6 +309,11 @@ request.auth(auth.username || '', auth.password || ''); } break; + case 'bearer': + if (auth.accessToken) { + request.set({'Authorization': 'Bearer ' + auth.accessToken}); + } + break; case 'apiKey': if (auth.apiKey) { var data = {}; diff --git a/samples/client/petstore/javascript-promise/src/api/FakeApi.js b/samples/client/petstore/javascript-promise/src/api/FakeApi.js index 43e02c1b8aa5..5479abc51ea0 100644 --- a/samples/client/petstore/javascript-promise/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-promise/src/api/FakeApi.js @@ -16,18 +16,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['ApiClient', 'model/Client', 'model/FileSchemaTestClass', 'model/OuterComposite', 'model/User'], factory); + define(['ApiClient', 'model/Client', 'model/FileSchemaTestClass', 'model/OuterComposite', 'model/User', 'model/XmlItem'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('../ApiClient'), require('../model/Client'), require('../model/FileSchemaTestClass'), require('../model/OuterComposite'), require('../model/User')); + module.exports = factory(require('../ApiClient'), require('../model/Client'), require('../model/FileSchemaTestClass'), require('../model/OuterComposite'), require('../model/User'), require('../model/XmlItem')); } else { // Browser globals (root is window) if (!root.OpenApiPetstore) { root.OpenApiPetstore = {}; } - root.OpenApiPetstore.FakeApi = factory(root.OpenApiPetstore.ApiClient, root.OpenApiPetstore.Client, root.OpenApiPetstore.FileSchemaTestClass, root.OpenApiPetstore.OuterComposite, root.OpenApiPetstore.User); + root.OpenApiPetstore.FakeApi = factory(root.OpenApiPetstore.ApiClient, root.OpenApiPetstore.Client, root.OpenApiPetstore.FileSchemaTestClass, root.OpenApiPetstore.OuterComposite, root.OpenApiPetstore.User, root.OpenApiPetstore.XmlItem); } -}(this, function(ApiClient, Client, FileSchemaTestClass, OuterComposite, User) { +}(this, function(ApiClient, Client, FileSchemaTestClass, OuterComposite, User, XmlItem) { 'use strict'; /** @@ -48,6 +48,58 @@ + /** + * creates an XmlItem + * this route creates an XmlItem + * @param {module:model/XmlItem} xmlItem XmlItem Body + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response + */ + this.createXmlItemWithHttpInfo = function(xmlItem) { + var postBody = xmlItem; + + // verify the required parameter 'xmlItem' is set + if (xmlItem === undefined || xmlItem === null) { + throw new Error("Missing the required parameter 'xmlItem' when calling createXmlItem"); + } + + + var pathParams = { + }; + var queryParams = { + }; + var collectionQueryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = []; + var contentTypes = ['application/xml', 'application/xml; charset=utf-8', 'application/xml; charset=utf-16', 'text/xml', 'text/xml; charset=utf-8', 'text/xml; charset=utf-16']; + var accepts = []; + var returnType = null; + + return this.apiClient.callApi( + '/fake/create_xml_item', 'POST', + pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType + ); + } + + /** + * creates an XmlItem + * this route creates an XmlItem + * @param {module:model/XmlItem} xmlItem XmlItem Body + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.createXmlItem = function(xmlItem) { + return this.createXmlItemWithHttpInfo(xmlItem) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + + /** * Test serialization of outer boolean types * @param {Object} opts Optional parameters diff --git a/samples/client/petstore/javascript-promise/src/index.js b/samples/client/petstore/javascript-promise/src/index.js index 4852ce5fe3a7..2a1a973cea64 100644 --- a/samples/client/petstore/javascript-promise/src/index.js +++ b/samples/client/petstore/javascript-promise/src/index.js @@ -16,12 +16,12 @@ (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['ApiClient', 'model/AdditionalPropertiesClass', 'model/Animal', 'model/ApiResponse', 'model/ArrayOfArrayOfNumberOnly', 'model/ArrayOfNumberOnly', 'model/ArrayTest', 'model/Capitalization', 'model/Cat', 'model/Category', 'model/ClassModel', 'model/Client', 'model/Dog', 'model/EnumArrays', 'model/EnumClass', 'model/EnumTest', 'model/File', 'model/FileSchemaTestClass', 'model/FormatTest', 'model/HasOnlyReadOnly', 'model/List', 'model/MapTest', 'model/MixedPropertiesAndAdditionalPropertiesClass', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/NumberOnly', 'model/Order', 'model/OuterComposite', 'model/OuterEnum', 'model/Pet', 'model/ReadOnlyFirst', 'model/SpecialModelName', 'model/Tag', 'model/TypeHolderDefault', 'model/TypeHolderExample', 'model/User', 'api/AnotherFakeApi', 'api/FakeApi', 'api/FakeClassnameTags123Api', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory); + define(['ApiClient', 'model/AdditionalPropertiesClass', 'model/Animal', 'model/ApiResponse', 'model/ArrayOfArrayOfNumberOnly', 'model/ArrayOfNumberOnly', 'model/ArrayTest', 'model/Capitalization', 'model/Cat', 'model/Category', 'model/ClassModel', 'model/Client', 'model/Dog', 'model/EnumArrays', 'model/EnumClass', 'model/EnumTest', 'model/File', 'model/FileSchemaTestClass', 'model/FormatTest', 'model/HasOnlyReadOnly', 'model/List', 'model/MapTest', 'model/MixedPropertiesAndAdditionalPropertiesClass', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/NumberOnly', 'model/Order', 'model/OuterComposite', 'model/OuterEnum', 'model/Pet', 'model/ReadOnlyFirst', 'model/SpecialModelName', 'model/Tag', 'model/TypeHolderDefault', 'model/TypeHolderExample', 'model/User', 'model/XmlItem', 'api/AnotherFakeApi', 'api/FakeApi', 'api/FakeClassnameTags123Api', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('./ApiClient'), require('./model/AdditionalPropertiesClass'), require('./model/Animal'), require('./model/ApiResponse'), require('./model/ArrayOfArrayOfNumberOnly'), require('./model/ArrayOfNumberOnly'), require('./model/ArrayTest'), require('./model/Capitalization'), require('./model/Cat'), require('./model/Category'), require('./model/ClassModel'), require('./model/Client'), require('./model/Dog'), require('./model/EnumArrays'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/File'), require('./model/FileSchemaTestClass'), require('./model/FormatTest'), require('./model/HasOnlyReadOnly'), require('./model/List'), require('./model/MapTest'), require('./model/MixedPropertiesAndAdditionalPropertiesClass'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/NumberOnly'), require('./model/Order'), require('./model/OuterComposite'), require('./model/OuterEnum'), require('./model/Pet'), require('./model/ReadOnlyFirst'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/TypeHolderDefault'), require('./model/TypeHolderExample'), require('./model/User'), require('./api/AnotherFakeApi'), require('./api/FakeApi'), require('./api/FakeClassnameTags123Api'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); + module.exports = factory(require('./ApiClient'), require('./model/AdditionalPropertiesClass'), require('./model/Animal'), require('./model/ApiResponse'), require('./model/ArrayOfArrayOfNumberOnly'), require('./model/ArrayOfNumberOnly'), require('./model/ArrayTest'), require('./model/Capitalization'), require('./model/Cat'), require('./model/Category'), require('./model/ClassModel'), require('./model/Client'), require('./model/Dog'), require('./model/EnumArrays'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/File'), require('./model/FileSchemaTestClass'), require('./model/FormatTest'), require('./model/HasOnlyReadOnly'), require('./model/List'), require('./model/MapTest'), require('./model/MixedPropertiesAndAdditionalPropertiesClass'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/NumberOnly'), require('./model/Order'), require('./model/OuterComposite'), require('./model/OuterEnum'), require('./model/Pet'), require('./model/ReadOnlyFirst'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/TypeHolderDefault'), require('./model/TypeHolderExample'), require('./model/User'), require('./model/XmlItem'), require('./api/AnotherFakeApi'), require('./api/FakeApi'), require('./api/FakeClassnameTags123Api'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); } -}(function(ApiClient, AdditionalPropertiesClass, Animal, ApiResponse, ArrayOfArrayOfNumberOnly, ArrayOfNumberOnly, ArrayTest, Capitalization, Cat, Category, ClassModel, Client, Dog, EnumArrays, EnumClass, EnumTest, File, FileSchemaTestClass, FormatTest, HasOnlyReadOnly, List, MapTest, MixedPropertiesAndAdditionalPropertiesClass, Model200Response, ModelReturn, Name, NumberOnly, Order, OuterComposite, OuterEnum, Pet, ReadOnlyFirst, SpecialModelName, Tag, TypeHolderDefault, TypeHolderExample, User, AnotherFakeApi, FakeApi, FakeClassnameTags123Api, PetApi, StoreApi, UserApi) { +}(function(ApiClient, AdditionalPropertiesClass, Animal, ApiResponse, ArrayOfArrayOfNumberOnly, ArrayOfNumberOnly, ArrayTest, Capitalization, Cat, Category, ClassModel, Client, Dog, EnumArrays, EnumClass, EnumTest, File, FileSchemaTestClass, FormatTest, HasOnlyReadOnly, List, MapTest, MixedPropertiesAndAdditionalPropertiesClass, Model200Response, ModelReturn, Name, NumberOnly, Order, OuterComposite, OuterEnum, Pet, ReadOnlyFirst, SpecialModelName, Tag, TypeHolderDefault, TypeHolderExample, User, XmlItem, AnotherFakeApi, FakeApi, FakeClassnameTags123Api, PetApi, StoreApi, UserApi) { 'use strict'; /** @@ -241,6 +241,11 @@ * @property {module:model/User} */ User: User, + /** + * The XmlItem model constructor. + * @property {module:model/XmlItem} + */ + XmlItem: XmlItem, /** * The AnotherFakeApi service constructor. * @property {module:api/AnotherFakeApi} diff --git a/samples/client/petstore/javascript-promise/src/model/XmlItem.js b/samples/client/petstore/javascript-promise/src/model/XmlItem.js new file mode 100644 index 000000000000..e14315f6f5e2 --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/model/XmlItem.js @@ -0,0 +1,274 @@ +/** + * OpenAPI 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 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * + * OpenAPI Generator version: 4.0.0-SNAPSHOT + * + * Do not edit the class manually. + * + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['ApiClient'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient')); + } else { + // Browser globals (root is window) + if (!root.OpenApiPetstore) { + root.OpenApiPetstore = {}; + } + root.OpenApiPetstore.XmlItem = factory(root.OpenApiPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + /** + * The XmlItem model module. + * @module model/XmlItem + * @version 1.0.0 + */ + + /** + * Constructs a new XmlItem. + * @alias module:model/XmlItem + * @class + */ + var exports = function() { + var _this = this; + + }; + + /** + * Constructs a XmlItem from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/XmlItem} obj Optional instance to populate. + * @return {module:model/XmlItem} The populated XmlItem instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + if (data.hasOwnProperty('attribute_string')) { + obj['attribute_string'] = ApiClient.convertToType(data['attribute_string'], 'String'); + } + if (data.hasOwnProperty('attribute_number')) { + obj['attribute_number'] = ApiClient.convertToType(data['attribute_number'], 'Number'); + } + if (data.hasOwnProperty('attribute_integer')) { + obj['attribute_integer'] = ApiClient.convertToType(data['attribute_integer'], 'Number'); + } + if (data.hasOwnProperty('attribute_boolean')) { + obj['attribute_boolean'] = ApiClient.convertToType(data['attribute_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('wrapped_array')) { + obj['wrapped_array'] = ApiClient.convertToType(data['wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('name_string')) { + obj['name_string'] = ApiClient.convertToType(data['name_string'], 'String'); + } + if (data.hasOwnProperty('name_number')) { + obj['name_number'] = ApiClient.convertToType(data['name_number'], 'Number'); + } + if (data.hasOwnProperty('name_integer')) { + obj['name_integer'] = ApiClient.convertToType(data['name_integer'], 'Number'); + } + if (data.hasOwnProperty('name_boolean')) { + obj['name_boolean'] = ApiClient.convertToType(data['name_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('name_array')) { + obj['name_array'] = ApiClient.convertToType(data['name_array'], ['Number']); + } + if (data.hasOwnProperty('name_wrapped_array')) { + obj['name_wrapped_array'] = ApiClient.convertToType(data['name_wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_string')) { + obj['prefix_string'] = ApiClient.convertToType(data['prefix_string'], 'String'); + } + if (data.hasOwnProperty('prefix_number')) { + obj['prefix_number'] = ApiClient.convertToType(data['prefix_number'], 'Number'); + } + if (data.hasOwnProperty('prefix_integer')) { + obj['prefix_integer'] = ApiClient.convertToType(data['prefix_integer'], 'Number'); + } + if (data.hasOwnProperty('prefix_boolean')) { + obj['prefix_boolean'] = ApiClient.convertToType(data['prefix_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('prefix_array')) { + obj['prefix_array'] = ApiClient.convertToType(data['prefix_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_wrapped_array')) { + obj['prefix_wrapped_array'] = ApiClient.convertToType(data['prefix_wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('namespace_string')) { + obj['namespace_string'] = ApiClient.convertToType(data['namespace_string'], 'String'); + } + if (data.hasOwnProperty('namespace_number')) { + obj['namespace_number'] = ApiClient.convertToType(data['namespace_number'], 'Number'); + } + if (data.hasOwnProperty('namespace_integer')) { + obj['namespace_integer'] = ApiClient.convertToType(data['namespace_integer'], 'Number'); + } + if (data.hasOwnProperty('namespace_boolean')) { + obj['namespace_boolean'] = ApiClient.convertToType(data['namespace_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('namespace_array')) { + obj['namespace_array'] = ApiClient.convertToType(data['namespace_array'], ['Number']); + } + if (data.hasOwnProperty('namespace_wrapped_array')) { + obj['namespace_wrapped_array'] = ApiClient.convertToType(data['namespace_wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_ns_string')) { + obj['prefix_ns_string'] = ApiClient.convertToType(data['prefix_ns_string'], 'String'); + } + if (data.hasOwnProperty('prefix_ns_number')) { + obj['prefix_ns_number'] = ApiClient.convertToType(data['prefix_ns_number'], 'Number'); + } + if (data.hasOwnProperty('prefix_ns_integer')) { + obj['prefix_ns_integer'] = ApiClient.convertToType(data['prefix_ns_integer'], 'Number'); + } + if (data.hasOwnProperty('prefix_ns_boolean')) { + obj['prefix_ns_boolean'] = ApiClient.convertToType(data['prefix_ns_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('prefix_ns_array')) { + obj['prefix_ns_array'] = ApiClient.convertToType(data['prefix_ns_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_ns_wrapped_array')) { + obj['prefix_ns_wrapped_array'] = ApiClient.convertToType(data['prefix_ns_wrapped_array'], ['Number']); + } + } + return obj; + } + + /** + * @member {String} attribute_string + */ + exports.prototype['attribute_string'] = undefined; + /** + * @member {Number} attribute_number + */ + exports.prototype['attribute_number'] = undefined; + /** + * @member {Number} attribute_integer + */ + exports.prototype['attribute_integer'] = undefined; + /** + * @member {Boolean} attribute_boolean + */ + exports.prototype['attribute_boolean'] = undefined; + /** + * @member {Array.} wrapped_array + */ + exports.prototype['wrapped_array'] = undefined; + /** + * @member {String} name_string + */ + exports.prototype['name_string'] = undefined; + /** + * @member {Number} name_number + */ + exports.prototype['name_number'] = undefined; + /** + * @member {Number} name_integer + */ + exports.prototype['name_integer'] = undefined; + /** + * @member {Boolean} name_boolean + */ + exports.prototype['name_boolean'] = undefined; + /** + * @member {Array.} name_array + */ + exports.prototype['name_array'] = undefined; + /** + * @member {Array.} name_wrapped_array + */ + exports.prototype['name_wrapped_array'] = undefined; + /** + * @member {String} prefix_string + */ + exports.prototype['prefix_string'] = undefined; + /** + * @member {Number} prefix_number + */ + exports.prototype['prefix_number'] = undefined; + /** + * @member {Number} prefix_integer + */ + exports.prototype['prefix_integer'] = undefined; + /** + * @member {Boolean} prefix_boolean + */ + exports.prototype['prefix_boolean'] = undefined; + /** + * @member {Array.} prefix_array + */ + exports.prototype['prefix_array'] = undefined; + /** + * @member {Array.} prefix_wrapped_array + */ + exports.prototype['prefix_wrapped_array'] = undefined; + /** + * @member {String} namespace_string + */ + exports.prototype['namespace_string'] = undefined; + /** + * @member {Number} namespace_number + */ + exports.prototype['namespace_number'] = undefined; + /** + * @member {Number} namespace_integer + */ + exports.prototype['namespace_integer'] = undefined; + /** + * @member {Boolean} namespace_boolean + */ + exports.prototype['namespace_boolean'] = undefined; + /** + * @member {Array.} namespace_array + */ + exports.prototype['namespace_array'] = undefined; + /** + * @member {Array.} namespace_wrapped_array + */ + exports.prototype['namespace_wrapped_array'] = undefined; + /** + * @member {String} prefix_ns_string + */ + exports.prototype['prefix_ns_string'] = undefined; + /** + * @member {Number} prefix_ns_number + */ + exports.prototype['prefix_ns_number'] = undefined; + /** + * @member {Number} prefix_ns_integer + */ + exports.prototype['prefix_ns_integer'] = undefined; + /** + * @member {Boolean} prefix_ns_boolean + */ + exports.prototype['prefix_ns_boolean'] = undefined; + /** + * @member {Array.} prefix_ns_array + */ + exports.prototype['prefix_ns_array'] = undefined; + /** + * @member {Array.} prefix_ns_wrapped_array + */ + exports.prototype['prefix_ns_wrapped_array'] = undefined; + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript-promise/test/model/XmlItem.spec.js b/samples/client/petstore/javascript-promise/test/model/XmlItem.spec.js new file mode 100644 index 000000000000..da3c6aa50e5f --- /dev/null +++ b/samples/client/petstore/javascript-promise/test/model/XmlItem.spec.js @@ -0,0 +1,235 @@ +/** + * OpenAPI 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 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * + * OpenAPI Generator version: 4.0.0-SNAPSHOT + * + * Do not edit the class manually. + * + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.OpenApiPetstore); + } +}(this, function(expect, OpenApiPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new OpenApiPetstore.XmlItem(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('XmlItem', function() { + it('should create an instance of XmlItem', function() { + // uncomment below and update the code to test XmlItem + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be.a(OpenApiPetstore.XmlItem); + }); + + it('should have the property attributeString (base name: "attribute_string")', function() { + // uncomment below and update the code to test the property attributeString + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property attributeNumber (base name: "attribute_number")', function() { + // uncomment below and update the code to test the property attributeNumber + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property attributeInteger (base name: "attribute_integer")', function() { + // uncomment below and update the code to test the property attributeInteger + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property attributeBoolean (base name: "attribute_boolean")', function() { + // uncomment below and update the code to test the property attributeBoolean + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property wrappedArray (base name: "wrapped_array")', function() { + // uncomment below and update the code to test the property wrappedArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameString (base name: "name_string")', function() { + // uncomment below and update the code to test the property nameString + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameNumber (base name: "name_number")', function() { + // uncomment below and update the code to test the property nameNumber + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameInteger (base name: "name_integer")', function() { + // uncomment below and update the code to test the property nameInteger + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameBoolean (base name: "name_boolean")', function() { + // uncomment below and update the code to test the property nameBoolean + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameArray (base name: "name_array")', function() { + // uncomment below and update the code to test the property nameArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameWrappedArray (base name: "name_wrapped_array")', function() { + // uncomment below and update the code to test the property nameWrappedArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixString (base name: "prefix_string")', function() { + // uncomment below and update the code to test the property prefixString + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNumber (base name: "prefix_number")', function() { + // uncomment below and update the code to test the property prefixNumber + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixInteger (base name: "prefix_integer")', function() { + // uncomment below and update the code to test the property prefixInteger + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixBoolean (base name: "prefix_boolean")', function() { + // uncomment below and update the code to test the property prefixBoolean + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixArray (base name: "prefix_array")', function() { + // uncomment below and update the code to test the property prefixArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixWrappedArray (base name: "prefix_wrapped_array")', function() { + // uncomment below and update the code to test the property prefixWrappedArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceString (base name: "namespace_string")', function() { + // uncomment below and update the code to test the property namespaceString + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceNumber (base name: "namespace_number")', function() { + // uncomment below and update the code to test the property namespaceNumber + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceInteger (base name: "namespace_integer")', function() { + // uncomment below and update the code to test the property namespaceInteger + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceBoolean (base name: "namespace_boolean")', function() { + // uncomment below and update the code to test the property namespaceBoolean + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceArray (base name: "namespace_array")', function() { + // uncomment below and update the code to test the property namespaceArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceWrappedArray (base name: "namespace_wrapped_array")', function() { + // uncomment below and update the code to test the property namespaceWrappedArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsString (base name: "prefix_ns_string")', function() { + // uncomment below and update the code to test the property prefixNsString + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsNumber (base name: "prefix_ns_number")', function() { + // uncomment below and update the code to test the property prefixNsNumber + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsInteger (base name: "prefix_ns_integer")', function() { + // uncomment below and update the code to test the property prefixNsInteger + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsBoolean (base name: "prefix_ns_boolean")', function() { + // uncomment below and update the code to test the property prefixNsBoolean + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsArray (base name: "prefix_ns_array")', function() { + // uncomment below and update the code to test the property prefixNsArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsWrappedArray (base name: "prefix_ns_wrapped_array")', function() { + // uncomment below and update the code to test the property prefixNsWrappedArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md index ae5f75594cd9..ee50a7e50888 100644 --- a/samples/client/petstore/javascript/README.md +++ b/samples/client/petstore/javascript/README.md @@ -95,6 +95,7 @@ Please follow the [installation](#installation) instruction and execute the foll ```javascript var OpenApiPetstore = require('open_api_petstore'); + var api = new OpenApiPetstore.AnotherFakeApi() var body = new OpenApiPetstore.Client(); // {Client} client model @@ -116,6 +117,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *OpenApiPetstore.AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags +*OpenApiPetstore.FakeApi* | [**createXmlItem**](docs/FakeApi.md#createXmlItem) | **POST** /fake/create_xml_item | creates an XmlItem *OpenApiPetstore.FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | *OpenApiPetstore.FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | *OpenApiPetstore.FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | @@ -190,6 +192,7 @@ Class | Method | HTTP request | Description - [OpenApiPetstore.TypeHolderDefault](docs/TypeHolderDefault.md) - [OpenApiPetstore.TypeHolderExample](docs/TypeHolderExample.md) - [OpenApiPetstore.User](docs/User.md) + - [OpenApiPetstore.XmlItem](docs/XmlItem.md) ## Documentation for Authorization @@ -201,16 +204,19 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header + ### api_key_query - **Type**: API key - **API key parameter name**: api_key_query - **Location**: URL query string + ### http_basic_test - **Type**: HTTP basic authentication + ### petstore_auth - **Type**: OAuth diff --git a/samples/client/petstore/javascript/docs/FakeApi.md b/samples/client/petstore/javascript/docs/FakeApi.md index e7bcd058409e..93ec077e8150 100644 --- a/samples/client/petstore/javascript/docs/FakeApi.md +++ b/samples/client/petstore/javascript/docs/FakeApi.md @@ -4,6 +4,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**createXmlItem**](FakeApi.md#createXmlItem) | **POST** /fake/create_xml_item | creates an XmlItem [**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | [**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | [**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | @@ -18,6 +19,49 @@ Method | HTTP request | Description [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data + +# **createXmlItem** +> createXmlItem(xmlItem) + +creates an XmlItem + +this route creates an XmlItem + +### Example +```javascript +var OpenApiPetstore = require('open_api_petstore'); + +var apiInstance = new OpenApiPetstore.FakeApi(); +var xmlItem = new OpenApiPetstore.XmlItem(); // XmlItem | XmlItem Body +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +apiInstance.createXmlItem(xmlItem, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **xmlItem** | [**XmlItem**](XmlItem.md)| XmlItem Body | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/xml, application/xml; charset=utf-8, application/xml; charset=utf-16, text/xml, text/xml; charset=utf-8, text/xml; charset=utf-16 + - **Accept**: Not defined + # **fakeOuterBooleanSerialize** > Boolean fakeOuterBooleanSerialize(opts) @@ -339,7 +383,6 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン ```javascript var OpenApiPetstore = require('open_api_petstore'); var defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure HTTP basic authorization: http_basic_test var http_basic_test = defaultClient.authentications['http_basic_test']; http_basic_test.username = 'YOUR USERNAME'; diff --git a/samples/client/petstore/javascript/docs/XmlItem.md b/samples/client/petstore/javascript/docs/XmlItem.md new file mode 100644 index 000000000000..f27c0b9c39d6 --- /dev/null +++ b/samples/client/petstore/javascript/docs/XmlItem.md @@ -0,0 +1,36 @@ +# OpenApiPetstore.XmlItem + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**attributeString** | **String** | | [optional] +**attributeNumber** | **Number** | | [optional] +**attributeInteger** | **Number** | | [optional] +**attributeBoolean** | **Boolean** | | [optional] +**wrappedArray** | **[Number]** | | [optional] +**nameString** | **String** | | [optional] +**nameNumber** | **Number** | | [optional] +**nameInteger** | **Number** | | [optional] +**nameBoolean** | **Boolean** | | [optional] +**nameArray** | **[Number]** | | [optional] +**nameWrappedArray** | **[Number]** | | [optional] +**prefixString** | **String** | | [optional] +**prefixNumber** | **Number** | | [optional] +**prefixInteger** | **Number** | | [optional] +**prefixBoolean** | **Boolean** | | [optional] +**prefixArray** | **[Number]** | | [optional] +**prefixWrappedArray** | **[Number]** | | [optional] +**namespaceString** | **String** | | [optional] +**namespaceNumber** | **Number** | | [optional] +**namespaceInteger** | **Number** | | [optional] +**namespaceBoolean** | **Boolean** | | [optional] +**namespaceArray** | **[Number]** | | [optional] +**namespaceWrappedArray** | **[Number]** | | [optional] +**prefixNsString** | **String** | | [optional] +**prefixNsNumber** | **Number** | | [optional] +**prefixNsInteger** | **Number** | | [optional] +**prefixNsBoolean** | **Boolean** | | [optional] +**prefixNsArray** | **[Number]** | | [optional] +**prefixNsWrappedArray** | **[Number]** | | [optional] + + diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index f4591a3f8cdb..cea29d6c28e8 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -309,6 +309,11 @@ request.auth(auth.username || '', auth.password || ''); } break; + case 'bearer': + if (auth.accessToken) { + request.set({'Authorization': 'Bearer ' + auth.accessToken}); + } + break; case 'apiKey': if (auth.apiKey) { var data = {}; diff --git a/samples/client/petstore/javascript/src/api/FakeApi.js b/samples/client/petstore/javascript/src/api/FakeApi.js index 5eae540ee3da..14a66191990f 100644 --- a/samples/client/petstore/javascript/src/api/FakeApi.js +++ b/samples/client/petstore/javascript/src/api/FakeApi.js @@ -16,18 +16,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['ApiClient', 'model/Client', 'model/FileSchemaTestClass', 'model/OuterComposite', 'model/User'], factory); + define(['ApiClient', 'model/Client', 'model/FileSchemaTestClass', 'model/OuterComposite', 'model/User', 'model/XmlItem'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('../ApiClient'), require('../model/Client'), require('../model/FileSchemaTestClass'), require('../model/OuterComposite'), require('../model/User')); + module.exports = factory(require('../ApiClient'), require('../model/Client'), require('../model/FileSchemaTestClass'), require('../model/OuterComposite'), require('../model/User'), require('../model/XmlItem')); } else { // Browser globals (root is window) if (!root.OpenApiPetstore) { root.OpenApiPetstore = {}; } - root.OpenApiPetstore.FakeApi = factory(root.OpenApiPetstore.ApiClient, root.OpenApiPetstore.Client, root.OpenApiPetstore.FileSchemaTestClass, root.OpenApiPetstore.OuterComposite, root.OpenApiPetstore.User); + root.OpenApiPetstore.FakeApi = factory(root.OpenApiPetstore.ApiClient, root.OpenApiPetstore.Client, root.OpenApiPetstore.FileSchemaTestClass, root.OpenApiPetstore.OuterComposite, root.OpenApiPetstore.User, root.OpenApiPetstore.XmlItem); } -}(this, function(ApiClient, Client, FileSchemaTestClass, OuterComposite, User) { +}(this, function(ApiClient, Client, FileSchemaTestClass, OuterComposite, User, XmlItem) { 'use strict'; /** @@ -47,6 +47,52 @@ this.apiClient = apiClient || ApiClient.instance; + /** + * Callback function to receive the result of the createXmlItem operation. + * @callback module:api/FakeApi~createXmlItemCallback + * @param {String} error Error message, if any. + * @param data This operation does not return a value. + * @param {String} response The complete HTTP response. + */ + + /** + * creates an XmlItem + * this route creates an XmlItem + * @param {module:model/XmlItem} xmlItem XmlItem Body + * @param {module:api/FakeApi~createXmlItemCallback} callback The callback function, accepting three arguments: error, data, response + */ + this.createXmlItem = function(xmlItem, callback) { + var postBody = xmlItem; + + // verify the required parameter 'xmlItem' is set + if (xmlItem === undefined || xmlItem === null) { + throw new Error("Missing the required parameter 'xmlItem' when calling createXmlItem"); + } + + + var pathParams = { + }; + var queryParams = { + }; + var collectionQueryParams = { + }; + var headerParams = { + }; + var formParams = { + }; + + var authNames = []; + var contentTypes = ['application/xml', 'application/xml; charset=utf-8', 'application/xml; charset=utf-16', 'text/xml', 'text/xml; charset=utf-8', 'text/xml; charset=utf-16']; + var accepts = []; + var returnType = null; + + return this.apiClient.callApi( + '/fake/create_xml_item', 'POST', + pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + } + /** * Callback function to receive the result of the fakeOuterBooleanSerialize operation. * @callback module:api/FakeApi~fakeOuterBooleanSerializeCallback diff --git a/samples/client/petstore/javascript/src/index.js b/samples/client/petstore/javascript/src/index.js index 4852ce5fe3a7..2a1a973cea64 100644 --- a/samples/client/petstore/javascript/src/index.js +++ b/samples/client/petstore/javascript/src/index.js @@ -16,12 +16,12 @@ (function(factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['ApiClient', 'model/AdditionalPropertiesClass', 'model/Animal', 'model/ApiResponse', 'model/ArrayOfArrayOfNumberOnly', 'model/ArrayOfNumberOnly', 'model/ArrayTest', 'model/Capitalization', 'model/Cat', 'model/Category', 'model/ClassModel', 'model/Client', 'model/Dog', 'model/EnumArrays', 'model/EnumClass', 'model/EnumTest', 'model/File', 'model/FileSchemaTestClass', 'model/FormatTest', 'model/HasOnlyReadOnly', 'model/List', 'model/MapTest', 'model/MixedPropertiesAndAdditionalPropertiesClass', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/NumberOnly', 'model/Order', 'model/OuterComposite', 'model/OuterEnum', 'model/Pet', 'model/ReadOnlyFirst', 'model/SpecialModelName', 'model/Tag', 'model/TypeHolderDefault', 'model/TypeHolderExample', 'model/User', 'api/AnotherFakeApi', 'api/FakeApi', 'api/FakeClassnameTags123Api', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory); + define(['ApiClient', 'model/AdditionalPropertiesClass', 'model/Animal', 'model/ApiResponse', 'model/ArrayOfArrayOfNumberOnly', 'model/ArrayOfNumberOnly', 'model/ArrayTest', 'model/Capitalization', 'model/Cat', 'model/Category', 'model/ClassModel', 'model/Client', 'model/Dog', 'model/EnumArrays', 'model/EnumClass', 'model/EnumTest', 'model/File', 'model/FileSchemaTestClass', 'model/FormatTest', 'model/HasOnlyReadOnly', 'model/List', 'model/MapTest', 'model/MixedPropertiesAndAdditionalPropertiesClass', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/NumberOnly', 'model/Order', 'model/OuterComposite', 'model/OuterEnum', 'model/Pet', 'model/ReadOnlyFirst', 'model/SpecialModelName', 'model/Tag', 'model/TypeHolderDefault', 'model/TypeHolderExample', 'model/User', 'model/XmlItem', 'api/AnotherFakeApi', 'api/FakeApi', 'api/FakeClassnameTags123Api', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('./ApiClient'), require('./model/AdditionalPropertiesClass'), require('./model/Animal'), require('./model/ApiResponse'), require('./model/ArrayOfArrayOfNumberOnly'), require('./model/ArrayOfNumberOnly'), require('./model/ArrayTest'), require('./model/Capitalization'), require('./model/Cat'), require('./model/Category'), require('./model/ClassModel'), require('./model/Client'), require('./model/Dog'), require('./model/EnumArrays'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/File'), require('./model/FileSchemaTestClass'), require('./model/FormatTest'), require('./model/HasOnlyReadOnly'), require('./model/List'), require('./model/MapTest'), require('./model/MixedPropertiesAndAdditionalPropertiesClass'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/NumberOnly'), require('./model/Order'), require('./model/OuterComposite'), require('./model/OuterEnum'), require('./model/Pet'), require('./model/ReadOnlyFirst'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/TypeHolderDefault'), require('./model/TypeHolderExample'), require('./model/User'), require('./api/AnotherFakeApi'), require('./api/FakeApi'), require('./api/FakeClassnameTags123Api'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); + module.exports = factory(require('./ApiClient'), require('./model/AdditionalPropertiesClass'), require('./model/Animal'), require('./model/ApiResponse'), require('./model/ArrayOfArrayOfNumberOnly'), require('./model/ArrayOfNumberOnly'), require('./model/ArrayTest'), require('./model/Capitalization'), require('./model/Cat'), require('./model/Category'), require('./model/ClassModel'), require('./model/Client'), require('./model/Dog'), require('./model/EnumArrays'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/File'), require('./model/FileSchemaTestClass'), require('./model/FormatTest'), require('./model/HasOnlyReadOnly'), require('./model/List'), require('./model/MapTest'), require('./model/MixedPropertiesAndAdditionalPropertiesClass'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/NumberOnly'), require('./model/Order'), require('./model/OuterComposite'), require('./model/OuterEnum'), require('./model/Pet'), require('./model/ReadOnlyFirst'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/TypeHolderDefault'), require('./model/TypeHolderExample'), require('./model/User'), require('./model/XmlItem'), require('./api/AnotherFakeApi'), require('./api/FakeApi'), require('./api/FakeClassnameTags123Api'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi')); } -}(function(ApiClient, AdditionalPropertiesClass, Animal, ApiResponse, ArrayOfArrayOfNumberOnly, ArrayOfNumberOnly, ArrayTest, Capitalization, Cat, Category, ClassModel, Client, Dog, EnumArrays, EnumClass, EnumTest, File, FileSchemaTestClass, FormatTest, HasOnlyReadOnly, List, MapTest, MixedPropertiesAndAdditionalPropertiesClass, Model200Response, ModelReturn, Name, NumberOnly, Order, OuterComposite, OuterEnum, Pet, ReadOnlyFirst, SpecialModelName, Tag, TypeHolderDefault, TypeHolderExample, User, AnotherFakeApi, FakeApi, FakeClassnameTags123Api, PetApi, StoreApi, UserApi) { +}(function(ApiClient, AdditionalPropertiesClass, Animal, ApiResponse, ArrayOfArrayOfNumberOnly, ArrayOfNumberOnly, ArrayTest, Capitalization, Cat, Category, ClassModel, Client, Dog, EnumArrays, EnumClass, EnumTest, File, FileSchemaTestClass, FormatTest, HasOnlyReadOnly, List, MapTest, MixedPropertiesAndAdditionalPropertiesClass, Model200Response, ModelReturn, Name, NumberOnly, Order, OuterComposite, OuterEnum, Pet, ReadOnlyFirst, SpecialModelName, Tag, TypeHolderDefault, TypeHolderExample, User, XmlItem, AnotherFakeApi, FakeApi, FakeClassnameTags123Api, PetApi, StoreApi, UserApi) { 'use strict'; /** @@ -241,6 +241,11 @@ * @property {module:model/User} */ User: User, + /** + * The XmlItem model constructor. + * @property {module:model/XmlItem} + */ + XmlItem: XmlItem, /** * The AnotherFakeApi service constructor. * @property {module:api/AnotherFakeApi} diff --git a/samples/client/petstore/javascript/src/model/XmlItem.js b/samples/client/petstore/javascript/src/model/XmlItem.js new file mode 100644 index 000000000000..e14315f6f5e2 --- /dev/null +++ b/samples/client/petstore/javascript/src/model/XmlItem.js @@ -0,0 +1,274 @@ +/** + * OpenAPI 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 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * + * OpenAPI Generator version: 4.0.0-SNAPSHOT + * + * Do not edit the class manually. + * + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['ApiClient'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(require('../ApiClient')); + } else { + // Browser globals (root is window) + if (!root.OpenApiPetstore) { + root.OpenApiPetstore = {}; + } + root.OpenApiPetstore.XmlItem = factory(root.OpenApiPetstore.ApiClient); + } +}(this, function(ApiClient) { + 'use strict'; + + + + /** + * The XmlItem model module. + * @module model/XmlItem + * @version 1.0.0 + */ + + /** + * Constructs a new XmlItem. + * @alias module:model/XmlItem + * @class + */ + var exports = function() { + var _this = this; + + }; + + /** + * Constructs a XmlItem from a plain JavaScript object, optionally creating a new instance. + * Copies all relevant properties from data to obj if supplied or a new instance if not. + * @param {Object} data The plain JavaScript object bearing properties of interest. + * @param {module:model/XmlItem} obj Optional instance to populate. + * @return {module:model/XmlItem} The populated XmlItem instance. + */ + exports.constructFromObject = function(data, obj) { + if (data) { + obj = obj || new exports(); + if (data.hasOwnProperty('attribute_string')) { + obj['attribute_string'] = ApiClient.convertToType(data['attribute_string'], 'String'); + } + if (data.hasOwnProperty('attribute_number')) { + obj['attribute_number'] = ApiClient.convertToType(data['attribute_number'], 'Number'); + } + if (data.hasOwnProperty('attribute_integer')) { + obj['attribute_integer'] = ApiClient.convertToType(data['attribute_integer'], 'Number'); + } + if (data.hasOwnProperty('attribute_boolean')) { + obj['attribute_boolean'] = ApiClient.convertToType(data['attribute_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('wrapped_array')) { + obj['wrapped_array'] = ApiClient.convertToType(data['wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('name_string')) { + obj['name_string'] = ApiClient.convertToType(data['name_string'], 'String'); + } + if (data.hasOwnProperty('name_number')) { + obj['name_number'] = ApiClient.convertToType(data['name_number'], 'Number'); + } + if (data.hasOwnProperty('name_integer')) { + obj['name_integer'] = ApiClient.convertToType(data['name_integer'], 'Number'); + } + if (data.hasOwnProperty('name_boolean')) { + obj['name_boolean'] = ApiClient.convertToType(data['name_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('name_array')) { + obj['name_array'] = ApiClient.convertToType(data['name_array'], ['Number']); + } + if (data.hasOwnProperty('name_wrapped_array')) { + obj['name_wrapped_array'] = ApiClient.convertToType(data['name_wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_string')) { + obj['prefix_string'] = ApiClient.convertToType(data['prefix_string'], 'String'); + } + if (data.hasOwnProperty('prefix_number')) { + obj['prefix_number'] = ApiClient.convertToType(data['prefix_number'], 'Number'); + } + if (data.hasOwnProperty('prefix_integer')) { + obj['prefix_integer'] = ApiClient.convertToType(data['prefix_integer'], 'Number'); + } + if (data.hasOwnProperty('prefix_boolean')) { + obj['prefix_boolean'] = ApiClient.convertToType(data['prefix_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('prefix_array')) { + obj['prefix_array'] = ApiClient.convertToType(data['prefix_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_wrapped_array')) { + obj['prefix_wrapped_array'] = ApiClient.convertToType(data['prefix_wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('namespace_string')) { + obj['namespace_string'] = ApiClient.convertToType(data['namespace_string'], 'String'); + } + if (data.hasOwnProperty('namespace_number')) { + obj['namespace_number'] = ApiClient.convertToType(data['namespace_number'], 'Number'); + } + if (data.hasOwnProperty('namespace_integer')) { + obj['namespace_integer'] = ApiClient.convertToType(data['namespace_integer'], 'Number'); + } + if (data.hasOwnProperty('namespace_boolean')) { + obj['namespace_boolean'] = ApiClient.convertToType(data['namespace_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('namespace_array')) { + obj['namespace_array'] = ApiClient.convertToType(data['namespace_array'], ['Number']); + } + if (data.hasOwnProperty('namespace_wrapped_array')) { + obj['namespace_wrapped_array'] = ApiClient.convertToType(data['namespace_wrapped_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_ns_string')) { + obj['prefix_ns_string'] = ApiClient.convertToType(data['prefix_ns_string'], 'String'); + } + if (data.hasOwnProperty('prefix_ns_number')) { + obj['prefix_ns_number'] = ApiClient.convertToType(data['prefix_ns_number'], 'Number'); + } + if (data.hasOwnProperty('prefix_ns_integer')) { + obj['prefix_ns_integer'] = ApiClient.convertToType(data['prefix_ns_integer'], 'Number'); + } + if (data.hasOwnProperty('prefix_ns_boolean')) { + obj['prefix_ns_boolean'] = ApiClient.convertToType(data['prefix_ns_boolean'], 'Boolean'); + } + if (data.hasOwnProperty('prefix_ns_array')) { + obj['prefix_ns_array'] = ApiClient.convertToType(data['prefix_ns_array'], ['Number']); + } + if (data.hasOwnProperty('prefix_ns_wrapped_array')) { + obj['prefix_ns_wrapped_array'] = ApiClient.convertToType(data['prefix_ns_wrapped_array'], ['Number']); + } + } + return obj; + } + + /** + * @member {String} attribute_string + */ + exports.prototype['attribute_string'] = undefined; + /** + * @member {Number} attribute_number + */ + exports.prototype['attribute_number'] = undefined; + /** + * @member {Number} attribute_integer + */ + exports.prototype['attribute_integer'] = undefined; + /** + * @member {Boolean} attribute_boolean + */ + exports.prototype['attribute_boolean'] = undefined; + /** + * @member {Array.} wrapped_array + */ + exports.prototype['wrapped_array'] = undefined; + /** + * @member {String} name_string + */ + exports.prototype['name_string'] = undefined; + /** + * @member {Number} name_number + */ + exports.prototype['name_number'] = undefined; + /** + * @member {Number} name_integer + */ + exports.prototype['name_integer'] = undefined; + /** + * @member {Boolean} name_boolean + */ + exports.prototype['name_boolean'] = undefined; + /** + * @member {Array.} name_array + */ + exports.prototype['name_array'] = undefined; + /** + * @member {Array.} name_wrapped_array + */ + exports.prototype['name_wrapped_array'] = undefined; + /** + * @member {String} prefix_string + */ + exports.prototype['prefix_string'] = undefined; + /** + * @member {Number} prefix_number + */ + exports.prototype['prefix_number'] = undefined; + /** + * @member {Number} prefix_integer + */ + exports.prototype['prefix_integer'] = undefined; + /** + * @member {Boolean} prefix_boolean + */ + exports.prototype['prefix_boolean'] = undefined; + /** + * @member {Array.} prefix_array + */ + exports.prototype['prefix_array'] = undefined; + /** + * @member {Array.} prefix_wrapped_array + */ + exports.prototype['prefix_wrapped_array'] = undefined; + /** + * @member {String} namespace_string + */ + exports.prototype['namespace_string'] = undefined; + /** + * @member {Number} namespace_number + */ + exports.prototype['namespace_number'] = undefined; + /** + * @member {Number} namespace_integer + */ + exports.prototype['namespace_integer'] = undefined; + /** + * @member {Boolean} namespace_boolean + */ + exports.prototype['namespace_boolean'] = undefined; + /** + * @member {Array.} namespace_array + */ + exports.prototype['namespace_array'] = undefined; + /** + * @member {Array.} namespace_wrapped_array + */ + exports.prototype['namespace_wrapped_array'] = undefined; + /** + * @member {String} prefix_ns_string + */ + exports.prototype['prefix_ns_string'] = undefined; + /** + * @member {Number} prefix_ns_number + */ + exports.prototype['prefix_ns_number'] = undefined; + /** + * @member {Number} prefix_ns_integer + */ + exports.prototype['prefix_ns_integer'] = undefined; + /** + * @member {Boolean} prefix_ns_boolean + */ + exports.prototype['prefix_ns_boolean'] = undefined; + /** + * @member {Array.} prefix_ns_array + */ + exports.prototype['prefix_ns_array'] = undefined; + /** + * @member {Array.} prefix_ns_wrapped_array + */ + exports.prototype['prefix_ns_wrapped_array'] = undefined; + + + + return exports; +})); + + diff --git a/samples/client/petstore/javascript/test/model/XmlItem.spec.js b/samples/client/petstore/javascript/test/model/XmlItem.spec.js new file mode 100644 index 000000000000..da3c6aa50e5f --- /dev/null +++ b/samples/client/petstore/javascript/test/model/XmlItem.spec.js @@ -0,0 +1,235 @@ +/** + * OpenAPI 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 + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * + * OpenAPI Generator version: 4.0.0-SNAPSHOT + * + * Do not edit the class manually. + * + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. + define(['expect.js', '../../src/index'], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + factory(require('expect.js'), require('../../src/index')); + } else { + // Browser globals (root is window) + factory(root.expect, root.OpenApiPetstore); + } +}(this, function(expect, OpenApiPetstore) { + 'use strict'; + + var instance; + + beforeEach(function() { + instance = new OpenApiPetstore.XmlItem(); + }); + + var getProperty = function(object, getter, property) { + // Use getter method if present; otherwise, get the property directly. + if (typeof object[getter] === 'function') + return object[getter](); + else + return object[property]; + } + + var setProperty = function(object, setter, property, value) { + // Use setter method if present; otherwise, set the property directly. + if (typeof object[setter] === 'function') + object[setter](value); + else + object[property] = value; + } + + describe('XmlItem', function() { + it('should create an instance of XmlItem', function() { + // uncomment below and update the code to test XmlItem + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be.a(OpenApiPetstore.XmlItem); + }); + + it('should have the property attributeString (base name: "attribute_string")', function() { + // uncomment below and update the code to test the property attributeString + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property attributeNumber (base name: "attribute_number")', function() { + // uncomment below and update the code to test the property attributeNumber + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property attributeInteger (base name: "attribute_integer")', function() { + // uncomment below and update the code to test the property attributeInteger + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property attributeBoolean (base name: "attribute_boolean")', function() { + // uncomment below and update the code to test the property attributeBoolean + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property wrappedArray (base name: "wrapped_array")', function() { + // uncomment below and update the code to test the property wrappedArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameString (base name: "name_string")', function() { + // uncomment below and update the code to test the property nameString + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameNumber (base name: "name_number")', function() { + // uncomment below and update the code to test the property nameNumber + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameInteger (base name: "name_integer")', function() { + // uncomment below and update the code to test the property nameInteger + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameBoolean (base name: "name_boolean")', function() { + // uncomment below and update the code to test the property nameBoolean + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameArray (base name: "name_array")', function() { + // uncomment below and update the code to test the property nameArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property nameWrappedArray (base name: "name_wrapped_array")', function() { + // uncomment below and update the code to test the property nameWrappedArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixString (base name: "prefix_string")', function() { + // uncomment below and update the code to test the property prefixString + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNumber (base name: "prefix_number")', function() { + // uncomment below and update the code to test the property prefixNumber + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixInteger (base name: "prefix_integer")', function() { + // uncomment below and update the code to test the property prefixInteger + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixBoolean (base name: "prefix_boolean")', function() { + // uncomment below and update the code to test the property prefixBoolean + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixArray (base name: "prefix_array")', function() { + // uncomment below and update the code to test the property prefixArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixWrappedArray (base name: "prefix_wrapped_array")', function() { + // uncomment below and update the code to test the property prefixWrappedArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceString (base name: "namespace_string")', function() { + // uncomment below and update the code to test the property namespaceString + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceNumber (base name: "namespace_number")', function() { + // uncomment below and update the code to test the property namespaceNumber + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceInteger (base name: "namespace_integer")', function() { + // uncomment below and update the code to test the property namespaceInteger + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceBoolean (base name: "namespace_boolean")', function() { + // uncomment below and update the code to test the property namespaceBoolean + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceArray (base name: "namespace_array")', function() { + // uncomment below and update the code to test the property namespaceArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property namespaceWrappedArray (base name: "namespace_wrapped_array")', function() { + // uncomment below and update the code to test the property namespaceWrappedArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsString (base name: "prefix_ns_string")', function() { + // uncomment below and update the code to test the property prefixNsString + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsNumber (base name: "prefix_ns_number")', function() { + // uncomment below and update the code to test the property prefixNsNumber + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsInteger (base name: "prefix_ns_integer")', function() { + // uncomment below and update the code to test the property prefixNsInteger + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsBoolean (base name: "prefix_ns_boolean")', function() { + // uncomment below and update the code to test the property prefixNsBoolean + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsArray (base name: "prefix_ns_array")', function() { + // uncomment below and update the code to test the property prefixNsArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + it('should have the property prefixNsWrappedArray (base name: "prefix_ns_wrapped_array")', function() { + // uncomment below and update the code to test the property prefixNsWrappedArray + //var instance = new OpenApiPetstore.XmlItem(); + //expect(instance).to.be(); + }); + + }); + +})); diff --git a/samples/openapi3/client/petstore/javascript-es6/README.md b/samples/openapi3/client/petstore/javascript-es6/README.md index 1492b57b41e6..5639cf375877 100644 --- a/samples/openapi3/client/petstore/javascript-es6/README.md +++ b/samples/openapi3/client/petstore/javascript-es6/README.md @@ -183,16 +183,24 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header + ### api_key_query - **Type**: API key - **API key parameter name**: api_key_query - **Location**: URL query string + +### bearer_test + +- **Type**: Bearer authentication (JWT) + + ### http_basic_test - **Type**: HTTP basic authentication + ### petstore_auth - **Type**: OAuth diff --git a/samples/openapi3/client/petstore/javascript-es6/docs/FakeApi.md b/samples/openapi3/client/petstore/javascript-es6/docs/FakeApi.md index b083093050f7..517e90fac983 100644 --- a/samples/openapi3/client/petstore/javascript-es6/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/javascript-es6/docs/FakeApi.md @@ -332,7 +332,6 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure HTTP basic authorization: http_basic_test let http_basic_test = defaultClient.authentications['http_basic_test']; http_basic_test.username = 'YOUR USERNAME'; @@ -465,6 +464,10 @@ Fake endpoint to test group parameters (optional) ### Example ```javascript import OpenApiPetstore from 'open_api_petstore'; +let defaultClient = OpenApiPetstore.ApiClient.instance; +// Configure Bearer (JWT) access token for authorization: bearer_test +let bearer_test = defaultClient.authentications['bearer_test']; +bearer_test.accessToken = "YOUR ACCESS TOKEN" let apiInstance = new OpenApiPetstore.FakeApi(); let requiredStringGroup = 56; // Number | Required String in group parameters @@ -501,7 +504,7 @@ null (empty response body) ### Authorization -No authorization required +[bearer_test](../README.md#bearer_test) ### HTTP request headers diff --git a/samples/openapi3/client/petstore/javascript-es6/docs/FakeClassnameTags123Api.md b/samples/openapi3/client/petstore/javascript-es6/docs/FakeClassnameTags123Api.md index 7414f66e70c2..929885c3d9e8 100644 --- a/samples/openapi3/client/petstore/javascript-es6/docs/FakeClassnameTags123Api.md +++ b/samples/openapi3/client/petstore/javascript-es6/docs/FakeClassnameTags123Api.md @@ -19,7 +19,6 @@ To test class name in snake case ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure API key authorization: api_key_query let api_key_query = defaultClient.authentications['api_key_query']; api_key_query.apiKey = 'YOUR API KEY'; diff --git a/samples/openapi3/client/petstore/javascript-es6/docs/PetApi.md b/samples/openapi3/client/petstore/javascript-es6/docs/PetApi.md index a9457f7ca5c3..554b75396d00 100644 --- a/samples/openapi3/client/petstore/javascript-es6/docs/PetApi.md +++ b/samples/openapi3/client/petstore/javascript-es6/docs/PetApi.md @@ -25,7 +25,6 @@ Add a new pet to the store ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -70,7 +69,6 @@ Deletes a pet ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -121,7 +119,6 @@ Multiple status values can be provided with comma separated strings ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -168,7 +165,6 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -215,7 +211,6 @@ Returns a single pet ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure API key authorization: api_key let api_key = defaultClient.authentications['api_key']; api_key.apiKey = 'YOUR API KEY'; @@ -262,7 +257,6 @@ Update an existing pet ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -307,7 +301,6 @@ Updates a pet in the store with form data ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -358,7 +351,6 @@ uploads an image ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; @@ -409,7 +401,6 @@ uploads an image (required) ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure OAuth2 access token for authorization: petstore_auth let petstore_auth = defaultClient.authentications['petstore_auth']; petstore_auth.accessToken = 'YOUR ACCESS TOKEN'; diff --git a/samples/openapi3/client/petstore/javascript-es6/docs/StoreApi.md b/samples/openapi3/client/petstore/javascript-es6/docs/StoreApi.md index 0f637fefe86e..fc6278c20954 100644 --- a/samples/openapi3/client/petstore/javascript-es6/docs/StoreApi.md +++ b/samples/openapi3/client/petstore/javascript-es6/docs/StoreApi.md @@ -64,7 +64,6 @@ Returns a map of status codes to quantities ```javascript import OpenApiPetstore from 'open_api_petstore'; let defaultClient = OpenApiPetstore.ApiClient.instance; - // Configure API key authorization: api_key let api_key = defaultClient.authentications['api_key']; api_key.apiKey = 'YOUR API KEY'; diff --git a/samples/openapi3/client/petstore/javascript-es6/src/ApiClient.js b/samples/openapi3/client/petstore/javascript-es6/src/ApiClient.js index 117ae6099f27..bb89fd48a7ab 100644 --- a/samples/openapi3/client/petstore/javascript-es6/src/ApiClient.js +++ b/samples/openapi3/client/petstore/javascript-es6/src/ApiClient.js @@ -43,6 +43,7 @@ class ApiClient { this.authentications = { 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'}, 'api_key_query': {type: 'apiKey', 'in': 'query', name: 'api_key_query'}, + 'bearer_test': {type: 'bearer'}, // JWT 'http_basic_test': {type: 'basic'}, 'petstore_auth': {type: 'oauth2'} } @@ -272,6 +273,12 @@ class ApiClient { request.auth(auth.username || '', auth.password || ''); } + break; + case 'bearer': + if (auth.accessToken) { + request.set({'Authorization': 'Bearer ' + auth.accessToken}); + } + break; case 'apiKey': if (auth.apiKey) { diff --git a/samples/openapi3/client/petstore/javascript-es6/src/api/FakeApi.js b/samples/openapi3/client/petstore/javascript-es6/src/api/FakeApi.js index 5c149563e002..051fece75219 100644 --- a/samples/openapi3/client/petstore/javascript-es6/src/api/FakeApi.js +++ b/samples/openapi3/client/petstore/javascript-es6/src/api/FakeApi.js @@ -537,7 +537,7 @@ export default class FakeApi { let formParams = { }; - let authNames = []; + let authNames = ['bearer_test']; let contentTypes = []; let accepts = []; let returnType = null; diff --git a/samples/openapi3/client/petstore/javascript-es6/test/ApiClientTest.js b/samples/openapi3/client/petstore/javascript-es6/test/ApiClientTest.js index ff5814096611..00629d52d2b5 100644 --- a/samples/openapi3/client/petstore/javascript-es6/test/ApiClientTest.js +++ b/samples/openapi3/client/petstore/javascript-es6/test/ApiClientTest.js @@ -13,6 +13,7 @@ describe('ApiClient', function() { expect(apiClient.basePath).to.be('http://petstore.swagger.io:80/v2'); expect(apiClient.authentications).to.eql({ petstore_auth: {type: 'oauth2'}, + bearer_test: {type: 'bearer'}, http_basic_test: {type: 'basic'}, api_key: {type: 'apiKey', 'in': 'header', name: 'api_key'}, api_key_query: {type: 'apiKey', 'in': 'query', name: 'api_key_query'},