diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java index a9db1b3bfdc..669e145ae00 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java @@ -64,6 +64,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo protected String localVariablePrefix = ""; protected boolean usePromises = false; protected boolean omitModelMethods = false; + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; public JavascriptClientCodegen() { super(); @@ -73,6 +75,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo templateDir = "Javascript"; apiPackage = "api"; modelPackage = "model"; + modelDocTemplateFiles.put("model_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); // reference: http://www.w3schools.com/js/js_reserved.asp setReservedWordsLowerCase( @@ -238,10 +242,15 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo additionalProperties.put(USE_PROMISES, usePromises); additionalProperties.put(OMIT_MODEL_METHODS, omitModelMethods); + // make api and model doc path available in mustache template + additionalProperties.put("apiDocPath", apiDocPath); + additionalProperties.put("modelDocPath", modelDocPath); + supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); supportingFiles.add(new SupportingFile("index.mustache", sourceFolder, "index.js")); supportingFiles.add(new SupportingFile("ApiClient.mustache", sourceFolder, "ApiClient.js")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); } @Override @@ -259,6 +268,26 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar); } + @Override + public String apiDocFileFolder() { + return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar); + } + + @Override + public String modelDocFileFolder() { + return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); + } + + @Override + public String toApiDocFilename(String name) { + return toApiName(name); + } + + @Override + public String toModelDocFilename(String name) { + return toModelName(name); + } + @Override public String toVarName(String name) { // sanitize name @@ -398,6 +427,84 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo } } + @Override + public void setParameterExampleValue(CodegenParameter p) { + String example; + + if (p.defaultValue == null) { + example = p.example; + } else { + example = p.defaultValue; + } + + String type = p.baseType; + if (type == null) { + type = p.dataType; + } + + typeMapping.put("array", "Array"); + typeMapping.put("List", "Array"); + typeMapping.put("map", "Object"); + typeMapping.put("object", "Object"); + typeMapping.put("boolean", "Boolean"); + typeMapping.put("char", "String"); + typeMapping.put("string", "String"); + typeMapping.put("short", "Integer"); + typeMapping.put("int", "Integer"); + typeMapping.put("integer", "Integer"); + typeMapping.put("long", "Integer"); + typeMapping.put("float", "Number"); + typeMapping.put("double", "Number"); + typeMapping.put("number", "Number"); + typeMapping.put("DateTime", "Date"); + typeMapping.put("Date", "Date"); + typeMapping.put("file", "File"); + // binary not supported in JavaScript client right now, using String as a workaround + typeMapping.put("binary", "String"); + + if ("String".equals(type)) { + if (example == null) { + example = p.paramName + "_example"; + } + example = "\"" + escapeText(example) + "\""; + } else if ("Integer".equals(type)) { + if (example == null) { + example = "56"; + } + } else if ("Number".equals(type)) { + if (example == null) { + example = "3.4"; + } + } else if ("Boolean".equals(type)) { + if (example == null) { + example = "true"; + } + } else if ("File".equals(type)) { + if (example == null) { + example = "/path/to/file"; + } + example = "\"" + escapeText(example) + "\""; + } else if ("Date".equals(type)) { + if (example == null) { + example = "2013-10-20T19:20:30+01:00"; + } + example = "new Date(\"" + escapeText(example) + "\")"; + } else if (!languageSpecificPrimitives.contains(type)) { + // type is a model class, e.g. User + example = "new " + moduleName + "." + type + "()"; + } + + if (example == null) { + example = "null"; + } else if (Boolean.TRUE.equals(p.isListContainer)) { + example = "[" + example + "]"; + } else if (Boolean.TRUE.equals(p.isMapContainer)) { + example = "{key: " + example + "}"; + } + + p.example = example; + } + /** * Normalize type by wrapping primitive types with single quotes. * @@ -451,6 +558,32 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo if (op.returnType != null) { op.returnType = normalizeType(op.returnType); } + + // Set vendor-extension to be used in template: + // x-codegen-hasMoreRequired + // x-codegen-hasMoreOptional + // x-codegen-hasRequiredParams + CodegenParameter lastRequired = null; + CodegenParameter lastOptional = null; + for (CodegenParameter p : op.allParams) { + if (p.required != null && p.required) { + lastRequired = p; + } else { + lastOptional = p; + } + } + for (CodegenParameter p : op.allParams) { + if (p == lastRequired) { + p.vendorExtensions.put("x-codegen-hasMoreRequired", false); + } else if (p == lastOptional) { + p.vendorExtensions.put("x-codegen-hasMoreOptional", false); + } else { + p.vendorExtensions.put("x-codegen-hasMoreRequired", true); + p.vendorExtensions.put("x-codegen-hasMoreOptional", true); + } + } + op.vendorExtensions.put("x-codegen-hasRequiredParams", lastRequired != null); + return op; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index 75e2984949d..63d3dc0ae51 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -588,7 +588,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { } else if (Boolean.TRUE.equals(p.isListContainer)) { example = "[" + example + "]"; } else if (Boolean.TRUE.equals(p.isMapContainer)) { - example = "{'key': " + example + "}"; + example = "{'key' => " + example + "}"; } p.example = example; diff --git a/modules/swagger-codegen/src/main/resources/Javascript/README.mustache b/modules/swagger-codegen/src/main/resources/Javascript/README.mustache new file mode 100644 index 00000000000..1b2f02ada81 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Javascript/README.mustache @@ -0,0 +1,103 @@ +# {{projectName}} + +{{moduleName}} - JavaScript client for {{projectName}} + +Version: {{projectVersion}} + +Automatically generated by the JavaScript Swagger Codegen project: + +- Build date: {{generatedDate}} +- Build package: {{generatorClass}} + +## Installation + +### Use in [Node.js](https://nodejs.org/) + +The generated client is valid [npm](https://www.npmjs.com/) package, you can publish it as described +in [Publishing npm packages](https://docs.npmjs.com/getting-started/publishing-npm-packages). + +After that, you can install it into your project via: + +```shell +npm install {{{projectName}}} --save +``` + +You can also host the generated client as a git repository on github, e.g. +https://github.com/YOUR_USERNAME/{{projectName}} + +Then you can install it via: + +```shell +npm install YOUR_USERNAME/{{{projectName}}} --save +``` + +### Use in browser with [browserify](http://browserify.org/) + +The client also works in browser environment via npm and browserify. After following +the above steps with Node.js and installing browserify with `npm install -g browserify`, +you can do this in your project (assuming *main.js* is your entry file): + +```shell +browserify main.js > bundle.js +``` + +The generated *bundle.js* can now be included in your HTML pages. + +## Getting Started + +```javascript +var {{{moduleName}}} = require('{{{projectName}}}'); + +var defaultClient = {{{moduleName}}}.ApiClient.default; +defaultClient.timeout = 10 * 1000; +defaultClient.defaultHeaders['Test-Header'] = 'test_value'; + +// Assuming there's a `PetApi` containing a `getPetById` method +// which returns a model object: +var api = new {{{moduleName}}}.PetApi(); +api.getPetById(2, function(err, pet, resp) { + console.log('HTTP status code: ' + resp.status); + console.log('Response Content-Type: ' + resp.get('Content-Type')); + if (err) { + console.error(err); + } else { + console.log(pet); + } +}); +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{moduleName}}.{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation for Models + +{{#models}}{{#model}} - [{{moduleName}}.{{classname}}]({{modelDocPath}}{{classname}}.md) +{{/model}}{{/models}} + +## Documentation for Authorization + +{{^authMethods}} All endpoints do not require authorization. +{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} +{{#authMethods}}### {{name}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{keyParamName}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{flow}} +- **Authorizatoin URL**: {{authorizationUrl}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - {{scope}}: {{description}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} diff --git a/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache b/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache new file mode 100644 index 00000000000..d1c101d6160 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache @@ -0,0 +1,89 @@ +# {{moduleName}}.{{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} + +# **{{operationId}}** +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}{{#hasParams}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}){{/hasParams}} + +{{summary}}{{#notes}} + +{{notes}}{{/notes}} + +### Example +```javascript +var {{{moduleName}}} = require('{{{projectName}}}'); +{{#hasAuthMethods}} +var defaultClient = {{{moduleName}}}.ApiClient.default; +{{#authMethods}}{{#isBasic}} +// Configure HTTP basic authorization: {{{name}}} +var {{{name}}} = defaultClient.authentications['{{{name}}}']; +{{{name}}}.username = 'YOUR USERNAME' +{{{name}}}.password = 'YOUR PASSWORD'{{/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}} +// Configure OAuth2 access token for authorization: {{{name}}} +var {{{name}}} = defaultClient.authentications['{{{name}}}']; +{{{name}}}.accessToken = "YOUR ACCESS TOKEN"{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} + +var api = new {{{moduleName}}}.{{{classname}}}(){{#hasParams}} +{{#vendorExtensions.x-codegen-hasRequiredParams}}{{#allParams}}{{#required}} +var {{{paramName}}} = {{{example}}}; // {{=< >=}}{<&dataType>}<={{ }}=> {{{description}}} +{{/required}}{{/allParams}}{{/vendorExtensions.x-codegen-hasRequiredParams}}{{#hasOptionalParams}} +var opts = { {{#allParams}}{{^required}} + '{{{paramName}}}': {{{example}}}{{#vendorExtensions.x-codegen-hasMoreOptional}},{{/vendorExtensions.x-codegen-hasMoreOptional}} // {{=< >=}}{<&dataType>}<={{ }}=> {{{description}}}{{/required}}{{/allParams}} +};{{/hasOptionalParams}}{{/hasParams}} +{{#usePromises}} +api.{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}).then(function({{#returnType}}data{{/returnType}}) { + {{#returnType}}console.log('API called successfully. Returned data: ' + data);{{/returnType}}{{^returnType}}console.log('API called successfully.');{{/returnType}} +}, function(error) { + console.error(error); +}); + +{{/usePromises}}{{^usePromises}} +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + {{#returnType}}console.log('API called successfully. Returned data: ' + data);{{/returnType}}{{^returnType}}console.log('API called successfully.');{{/returnType}} + } +}; +api.{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}{{#hasParams}}, {{/hasParams}}callback); +{{/usePromises}} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP reuqest headers + + - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{/operation}} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/Javascript/model_doc.mustache b/modules/swagger-codegen/src/main/resources/Javascript/model_doc.mustache new file mode 100644 index 00000000000..306d8a2b3f7 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Javascript/model_doc.mustache @@ -0,0 +1,9 @@ +{{#models}}{{#model}}# {{moduleName}}.{{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/vars}} + +{{/model}}{{/models}} diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md new file mode 100644 index 00000000000..8ead7f7e7f9 --- /dev/null +++ b/samples/client/petstore/javascript/README.md @@ -0,0 +1,160 @@ +# swagger-petstore + +SwaggerPetstore - JavaScript client for swagger-petstore + +Version: 1.0.0 + +Automatically generated by the JavaScript Swagger Codegen project: + +- Build date: 2016-03-16T19:41:06.099+08:00 +- Build package: class io.swagger.codegen.languages.JavascriptClientCodegen + +## Installation + +### Use in [Node.js](https://nodejs.org/) + +The generated client is valid [npm](https://www.npmjs.com/) package, you can publish it as described +in [Publishing npm packages](https://docs.npmjs.com/getting-started/publishing-npm-packages). + +After that, you can install it into your project via: + +```shell +npm install swagger-petstore --save +``` + +You can also host the generated client as a git repository on github, e.g. +https://github.com/YOUR_USERNAME/swagger-petstore + +Then you can install it via: + +```shell +npm install YOUR_USERNAME/swagger-petstore --save +``` + +### Use in browser with [browserify](http://browserify.org/) + +The client also works in browser environment via npm and browserify. After following +the above steps with Node.js and installing browserify with `npm install -g browserify`, +you can do this in your project (assuming *main.js* is your entry file): + +```shell +browserify main.js > bundle.js +``` + +The generated *bundle.js* can now be included in your HTML pages. + +## Getting Started + +```javascript +var SwaggerPetstore = require('swagger-petstore'); + +var defaultClient = SwaggerPetstore.ApiClient.default; +defaultClient.timeout = 10 * 1000; +defaultClient.defaultHeaders['Test-Header'] = 'test_value'; + +// Assuming there's a `PetApi` containing a `getPetById` method +// which returns a model object: +var api = new SwaggerPetstore.PetApi(); +api.getPetById(2, function(err, pet, resp) { + console.log('HTTP status code: ' + resp.status); + console.log('Response Content-Type: ' + resp.get('Content-Type')); + if (err) { + console.error(err); + } else { + console.log(pet); + } +}); +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*SwaggerPetstore.PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +*SwaggerPetstore.PetApi* | [**addPetUsingByteArray**](docs/PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +*SwaggerPetstore.PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +*SwaggerPetstore.PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +*SwaggerPetstore.PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +*SwaggerPetstore.PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +*SwaggerPetstore.PetApi* | [**getPetByIdInObject**](docs/PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*SwaggerPetstore.PetApi* | [**petPetIdtestingByteArraytrueGet**](docs/PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +*SwaggerPetstore.PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +*SwaggerPetstore.PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +*SwaggerPetstore.PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +*SwaggerPetstore.StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*SwaggerPetstore.StoreApi* | [**findOrdersByStatus**](docs/StoreApi.md#findOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status +*SwaggerPetstore.StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +*SwaggerPetstore.StoreApi* | [**getInventoryInObject**](docs/StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*SwaggerPetstore.StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +*SwaggerPetstore.StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet +*SwaggerPetstore.UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user +*SwaggerPetstore.UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +*SwaggerPetstore.UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +*SwaggerPetstore.UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +*SwaggerPetstore.UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +*SwaggerPetstore.UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +*SwaggerPetstore.UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +*SwaggerPetstore.UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + +## Documentation for Models + + - [SwaggerPetstore.Category](docs/Category.md) + - [SwaggerPetstore.InlineResponse200](docs/InlineResponse200.md) + - [SwaggerPetstore.ModelReturn](docs/ModelReturn.md) + - [SwaggerPetstore.Name](docs/Name.md) + - [SwaggerPetstore.Order](docs/Order.md) + - [SwaggerPetstore.Pet](docs/Pet.md) + - [SwaggerPetstore.SpecialModelName](docs/SpecialModelName.md) + - [SwaggerPetstore.Tag](docs/Tag.md) + - [SwaggerPetstore.User](docs/User.md) + + +## Documentation for Authorization + + +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + +### test_api_client_id + +- **Type**: API key +- **API key parameter name**: x-test_api_client_id +- **Location**: HTTP header + +### test_api_client_secret + +- **Type**: API key +- **API key parameter name**: x-test_api_client_secret +- **Location**: HTTP header + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +### test_http_basic + +- **Type**: HTTP basic authentication + +### test_api_key_query + +- **Type**: API key +- **API key parameter name**: test_api_key_query +- **Location**: URL query string + +### test_api_key_header + +- **Type**: API key +- **API key parameter name**: test_api_key_header +- **Location**: HTTP header + diff --git a/samples/client/petstore/javascript/docs/Category.md b/samples/client/petstore/javascript/docs/Category.md new file mode 100644 index 00000000000..47930eb882c --- /dev/null +++ b/samples/client/petstore/javascript/docs/Category.md @@ -0,0 +1,9 @@ +# SwaggerPetstore.Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**name** | **String** | | [optional] + + diff --git a/samples/client/petstore/javascript/docs/InlineResponse200.md b/samples/client/petstore/javascript/docs/InlineResponse200.md new file mode 100644 index 00000000000..09b88b74e49 --- /dev/null +++ b/samples/client/petstore/javascript/docs/InlineResponse200.md @@ -0,0 +1,13 @@ +# SwaggerPetstore.InlineResponse200 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**photoUrls** | **[String]** | | [optional] +**name** | **String** | | [optional] +**id** | **Integer** | | +**category** | **Object** | | [optional] +**tags** | [**[Tag]**](Tag.md) | | [optional] +**status** | **String** | pet status in the store | [optional] + + diff --git a/samples/client/petstore/javascript/docs/ModelReturn.md b/samples/client/petstore/javascript/docs/ModelReturn.md new file mode 100644 index 00000000000..88412c87197 --- /dev/null +++ b/samples/client/petstore/javascript/docs/ModelReturn.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.ModelReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_return** | **Integer** | | [optional] + + diff --git a/samples/client/petstore/javascript/docs/Name.md b/samples/client/petstore/javascript/docs/Name.md new file mode 100644 index 00000000000..114d6dc980e --- /dev/null +++ b/samples/client/petstore/javascript/docs/Name.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **Integer** | | [optional] + + diff --git a/samples/client/petstore/javascript/docs/Order.md b/samples/client/petstore/javascript/docs/Order.md new file mode 100644 index 00000000000..b34b67d3a56 --- /dev/null +++ b/samples/client/petstore/javascript/docs/Order.md @@ -0,0 +1,13 @@ +# SwaggerPetstore.Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**petId** | **Integer** | | [optional] +**quantity** | **Integer** | | [optional] +**shipDate** | **Date** | | [optional] +**status** | **String** | Order Status | [optional] +**complete** | **Boolean** | | [optional] + + diff --git a/samples/client/petstore/javascript/docs/Pet.md b/samples/client/petstore/javascript/docs/Pet.md new file mode 100644 index 00000000000..f1b049dcadd --- /dev/null +++ b/samples/client/petstore/javascript/docs/Pet.md @@ -0,0 +1,13 @@ +# SwaggerPetstore.Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **String** | | +**photoUrls** | **[String]** | | +**tags** | [**[Tag]**](Tag.md) | | [optional] +**status** | **String** | pet status in the store | [optional] + + diff --git a/samples/client/petstore/javascript/docs/PetApi.md b/samples/client/petstore/javascript/docs/PetApi.md new file mode 100644 index 00000000000..b8a453ef390 --- /dev/null +++ b/samples/client/petstore/javascript/docs/PetApi.md @@ -0,0 +1,619 @@ +# SwaggerPetstore.PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +[**addPetUsingByteArray**](PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +[**getPetByIdInObject**](PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +[**petPetIdtestingByteArraytrueGet**](PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image + + + +# **addPet** +> addPet(opts) + +Add a new pet to the store + + + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure OAuth2 access token for authorization: petstore_auth +var petstore_auth = defaultClient.authentications['petstore_auth']; +petstore_auth.accessToken = "YOUR ACCESS TOKEN" + +var api = new SwaggerPetstore.PetApi() + +var opts = { + 'body': new SwaggerPetstore.Pet() // {Pet} Pet object that needs to be added to the store +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.addPet(opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + + +# **addPetUsingByteArray** +> addPetUsingByteArray(opts) + +Fake endpoint to test byte array in body parameter for adding a new pet to the store + + + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure OAuth2 access token for authorization: petstore_auth +var petstore_auth = defaultClient.authentications['petstore_auth']; +petstore_auth.accessToken = "YOUR ACCESS TOKEN" + +var api = new SwaggerPetstore.PetApi() + +var opts = { + 'body': "B" // {String} Pet object in the form of byte array +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.addPetUsingByteArray(opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **String**| Pet object in the form of byte array | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + + +# **deletePet** +> deletePet(petId, opts) + +Deletes a pet + + + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure OAuth2 access token for authorization: petstore_auth +var petstore_auth = defaultClient.authentications['petstore_auth']; +petstore_auth.accessToken = "YOUR ACCESS TOKEN" + +var api = new SwaggerPetstore.PetApi() + +var petId = 789; // {Integer} Pet id to delete + +var opts = { + 'apiKey': "apiKey_example" // {String} +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.deletePet(petId, opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Integer**| Pet id to delete | + **apiKey** | **String**| | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **findPetsByStatus** +> [Pet] findPetsByStatus(opts) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure OAuth2 access token for authorization: petstore_auth +var petstore_auth = defaultClient.authentications['petstore_auth']; +petstore_auth.accessToken = "YOUR ACCESS TOKEN" + +var api = new SwaggerPetstore.PetApi() + +var opts = { + 'status': ["available"] // {[String]} Status values that need to be considered for query +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.findPetsByStatus(opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**[String]**](String.md)| Status values that need to be considered for query | [optional] [default to available] + +### Return type + +[**[Pet]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **findPetsByTags** +> [Pet] findPetsByTags(opts) + +Finds Pets by tags + +Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure OAuth2 access token for authorization: petstore_auth +var petstore_auth = defaultClient.authentications['petstore_auth']; +petstore_auth.accessToken = "YOUR ACCESS TOKEN" + +var api = new SwaggerPetstore.PetApi() + +var opts = { + 'tags': ["tags_example"] // {[String]} Tags to filter by +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.findPetsByTags(opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**[String]**](String.md)| Tags to filter by | [optional] + +### Return type + +[**[Pet]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **getPetById** +> Pet getPetById(petId) + +Find pet by ID + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure OAuth2 access token for authorization: petstore_auth +var petstore_auth = defaultClient.authentications['petstore_auth']; +petstore_auth.accessToken = "YOUR ACCESS TOKEN" + +// Configure API key authorization: api_key +var api_key = defaultClient.authentications['api_key']; +api_key.apiKey = "YOUR API KEY" +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//api_key.apiKeyPrefix['api_key'] = "Token" + +var api = new SwaggerPetstore.PetApi() + +var petId = 789; // {Integer} ID of pet that needs to be fetched + + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.getPetById(petId, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Integer**| ID of pet that needs to be fetched | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **getPetByIdInObject** +> InlineResponse200 getPetByIdInObject(petId) + +Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure OAuth2 access token for authorization: petstore_auth +var petstore_auth = defaultClient.authentications['petstore_auth']; +petstore_auth.accessToken = "YOUR ACCESS TOKEN" + +// Configure API key authorization: api_key +var api_key = defaultClient.authentications['api_key']; +api_key.apiKey = "YOUR API KEY" +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//api_key.apiKeyPrefix['api_key'] = "Token" + +var api = new SwaggerPetstore.PetApi() + +var petId = 789; // {Integer} ID of pet that needs to be fetched + + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.getPetByIdInObject(petId, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Integer**| ID of pet that needs to be fetched | + +### Return type + +[**InlineResponse200**](InlineResponse200.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **petPetIdtestingByteArraytrueGet** +> 'String' petPetIdtestingByteArraytrueGet(petId) + +Fake endpoint to test byte array return by 'Find pet by ID' + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure OAuth2 access token for authorization: petstore_auth +var petstore_auth = defaultClient.authentications['petstore_auth']; +petstore_auth.accessToken = "YOUR ACCESS TOKEN" + +// Configure API key authorization: api_key +var api_key = defaultClient.authentications['api_key']; +api_key.apiKey = "YOUR API KEY" +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//api_key.apiKeyPrefix['api_key'] = "Token" + +var api = new SwaggerPetstore.PetApi() + +var petId = 789; // {Integer} ID of pet that needs to be fetched + + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.petPetIdtestingByteArraytrueGet(petId, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Integer**| ID of pet that needs to be fetched | + +### Return type + +**'String'** + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **updatePet** +> updatePet(opts) + +Update an existing pet + + + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure OAuth2 access token for authorization: petstore_auth +var petstore_auth = defaultClient.authentications['petstore_auth']; +petstore_auth.accessToken = "YOUR ACCESS TOKEN" + +var api = new SwaggerPetstore.PetApi() + +var opts = { + 'body': new SwaggerPetstore.Pet() // {Pet} Pet object that needs to be added to the store +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.updatePet(opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + + +# **updatePetWithForm** +> updatePetWithForm(petId, opts) + +Updates a pet in the store with form data + + + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure OAuth2 access token for authorization: petstore_auth +var petstore_auth = defaultClient.authentications['petstore_auth']; +petstore_auth.accessToken = "YOUR ACCESS TOKEN" + +var api = new SwaggerPetstore.PetApi() + +var petId = "petId_example"; // {String} ID of pet that needs to be updated + +var opts = { + 'name': "name_example", // {String} Updated name of the pet + 'status': "status_example" // {String} Updated status of the pet +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.updatePetWithForm(petId, opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **String**| ID of pet that needs to be updated | + **name** | **String**| Updated name of the pet | [optional] + **status** | **String**| Updated status of the pet | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/json, application/xml + + +# **uploadFile** +> uploadFile(petId, opts) + +uploads an image + + + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure OAuth2 access token for authorization: petstore_auth +var petstore_auth = defaultClient.authentications['petstore_auth']; +petstore_auth.accessToken = "YOUR ACCESS TOKEN" + +var api = new SwaggerPetstore.PetApi() + +var petId = 789; // {Integer} ID of pet to update + +var opts = { + 'additionalMetadata': "additionalMetadata_example", // {String} Additional data to pass to server + 'file': "/path/to/file.txt" // {File} file to upload +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.uploadFile(petId, opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Integer**| ID of pet to update | + **additionalMetadata** | **String**| Additional data to pass to server | [optional] + **file** | **File**| file to upload | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json, application/xml + diff --git a/samples/client/petstore/javascript/docs/SpecialModelName.md b/samples/client/petstore/javascript/docs/SpecialModelName.md new file mode 100644 index 00000000000..03dffa54c3f --- /dev/null +++ b/samples/client/petstore/javascript/docs/SpecialModelName.md @@ -0,0 +1,8 @@ +# SwaggerPetstore.SpecialModelName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**specialPropertyName** | **Integer** | | [optional] + + diff --git a/samples/client/petstore/javascript/docs/StoreApi.md b/samples/client/petstore/javascript/docs/StoreApi.md new file mode 100644 index 00000000000..fc4f9faf366 --- /dev/null +++ b/samples/client/petstore/javascript/docs/StoreApi.md @@ -0,0 +1,333 @@ +# SwaggerPetstore.StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**findOrdersByStatus**](StoreApi.md#findOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getInventoryInObject**](StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet + + + +# **deleteOrder** +> deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); + +var api = new SwaggerPetstore.StoreApi() + +var orderId = "orderId_example"; // {String} ID of the order that needs to be deleted + + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.deleteOrder(orderId, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **String**| ID of the order that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **findOrdersByStatus** +> [Order] findOrdersByStatus(opts) + +Finds orders by status + +A single status value can be provided as a string + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure API key authorization: test_api_client_id +var test_api_client_id = defaultClient.authentications['test_api_client_id']; +test_api_client_id.apiKey = "YOUR API KEY" +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//test_api_client_id.apiKeyPrefix['x-test_api_client_id'] = "Token" + +// Configure API key authorization: test_api_client_secret +var test_api_client_secret = defaultClient.authentications['test_api_client_secret']; +test_api_client_secret.apiKey = "YOUR API KEY" +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//test_api_client_secret.apiKeyPrefix['x-test_api_client_secret'] = "Token" + +var api = new SwaggerPetstore.StoreApi() + +var opts = { + 'status': "placed" // {String} Status value that needs to be considered for query +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.findOrdersByStatus(opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | **String**| Status value that needs to be considered for query | [optional] [default to placed] + +### Return type + +[**[Order]**](Order.md) + +### Authorization + +[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **getInventory** +> {'String': 'Integer'} getInventory + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure API key authorization: api_key +var api_key = defaultClient.authentications['api_key']; +api_key.apiKey = "YOUR API KEY" +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//api_key.apiKeyPrefix['api_key'] = "Token" + +var api = new SwaggerPetstore.StoreApi() + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.getInventory(callback); +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**{'String': 'Integer'}** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **getInventoryInObject** +> Object getInventoryInObject + +Fake endpoint to test arbitrary object return by 'Get inventory' + +Returns an arbitrary object which is actually a map of status codes to quantities + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure API key authorization: api_key +var api_key = defaultClient.authentications['api_key']; +api_key.apiKey = "YOUR API KEY" +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//api_key.apiKeyPrefix['api_key'] = "Token" + +var api = new SwaggerPetstore.StoreApi() + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.getInventoryInObject(callback); +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**Object** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **getOrderById** +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure API key authorization: test_api_key_query +var test_api_key_query = defaultClient.authentications['test_api_key_query']; +test_api_key_query.apiKey = "YOUR API KEY" +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//test_api_key_query.apiKeyPrefix['test_api_key_query'] = "Token" + +// Configure API key authorization: test_api_key_header +var test_api_key_header = defaultClient.authentications['test_api_key_header']; +test_api_key_header.apiKey = "YOUR API KEY" +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//test_api_key_header.apiKeyPrefix['test_api_key_header'] = "Token" + +var api = new SwaggerPetstore.StoreApi() + +var orderId = "orderId_example"; // {String} ID of pet that needs to be fetched + + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.getOrderById(orderId, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **String**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +[test_api_key_query](../README.md#test_api_key_query), [test_api_key_header](../README.md#test_api_key_header) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **placeOrder** +> Order placeOrder(opts) + +Place an order for a pet + + + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure API key authorization: test_api_client_id +var test_api_client_id = defaultClient.authentications['test_api_client_id']; +test_api_client_id.apiKey = "YOUR API KEY" +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//test_api_client_id.apiKeyPrefix['x-test_api_client_id'] = "Token" + +// Configure API key authorization: test_api_client_secret +var test_api_client_secret = defaultClient.authentications['test_api_client_secret']; +test_api_client_secret.apiKey = "YOUR API KEY" +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//test_api_client_secret.apiKeyPrefix['x-test_api_client_secret'] = "Token" + +var api = new SwaggerPetstore.StoreApi() + +var opts = { + 'body': new SwaggerPetstore.Order() // {Order} order placed for purchasing the pet +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.placeOrder(opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional] + +### Return type + +[**Order**](Order.md) + +### Authorization + +[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + diff --git a/samples/client/petstore/javascript/docs/Tag.md b/samples/client/petstore/javascript/docs/Tag.md new file mode 100644 index 00000000000..6c109046fb3 --- /dev/null +++ b/samples/client/petstore/javascript/docs/Tag.md @@ -0,0 +1,9 @@ +# SwaggerPetstore.Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**name** | **String** | | [optional] + + diff --git a/samples/client/petstore/javascript/docs/User.md b/samples/client/petstore/javascript/docs/User.md new file mode 100644 index 00000000000..071fbb46e47 --- /dev/null +++ b/samples/client/petstore/javascript/docs/User.md @@ -0,0 +1,15 @@ +# SwaggerPetstore.User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**username** | **String** | | [optional] +**firstName** | **String** | | [optional] +**lastName** | **String** | | [optional] +**email** | **String** | | [optional] +**password** | **String** | | [optional] +**phone** | **String** | | [optional] +**userStatus** | **Integer** | User Status | [optional] + + diff --git a/samples/client/petstore/javascript/docs/UserApi.md b/samples/client/petstore/javascript/docs/UserApi.md new file mode 100644 index 00000000000..472a50e6e81 --- /dev/null +++ b/samples/client/petstore/javascript/docs/UserApi.md @@ -0,0 +1,394 @@ +# SwaggerPetstore.UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](UserApi.md#createUser) | **POST** /user | Create user +[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + + +# **createUser** +> createUser(opts) + +Create user + +This can only be done by the logged in user. + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); + +var api = new SwaggerPetstore.UserApi() + +var opts = { + 'body': new SwaggerPetstore.User() // {User} Created user object +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.createUser(opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | [optional] + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **createUsersWithArrayInput** +> createUsersWithArrayInput(opts) + +Creates list of users with given input array + + + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); + +var api = new SwaggerPetstore.UserApi() + +var opts = { + 'body': [new SwaggerPetstore.User()] // {[User]} List of user object +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.createUsersWithArrayInput(opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**[User]**](User.md)| List of user object | [optional] + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **createUsersWithListInput** +> createUsersWithListInput(opts) + +Creates list of users with given input array + + + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); + +var api = new SwaggerPetstore.UserApi() + +var opts = { + 'body': [new SwaggerPetstore.User()] // {[User]} List of user object +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.createUsersWithListInput(opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**[User]**](User.md)| List of user object | [optional] + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **deleteUser** +> deleteUser(username) + +Delete user + +This can only be done by the logged in user. + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); +var defaultClient = SwaggerPetstore.ApiClient.default; + +// Configure HTTP basic authorization: test_http_basic +var test_http_basic = defaultClient.authentications['test_http_basic']; +test_http_basic.username = 'YOUR USERNAME' +test_http_basic.password = 'YOUR PASSWORD' + +var api = new SwaggerPetstore.UserApi() + +var username = "username_example"; // {String} The name that needs to be deleted + + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.deleteUser(username, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + +[test_http_basic](../README.md#test_http_basic) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **getUserByName** +> User getUserByName(username) + +Get user by user name + + + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); + +var api = new SwaggerPetstore.UserApi() + +var username = "username_example"; // {String} The name that needs to be fetched. Use user1 for testing. + + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.getUserByName(username, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **loginUser** +> 'String' loginUser(opts) + +Logs user into the system + + + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); + +var api = new SwaggerPetstore.UserApi() + +var opts = { + 'username': "username_example", // {String} The user name for login + 'password': "password_example" // {String} The password for login in clear text +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully. Returned data: ' + data); + } +}; +api.loginUser(opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The user name for login | [optional] + **password** | **String**| The password for login in clear text | [optional] + +### Return type + +**'String'** + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **logoutUser** +> logoutUser + +Logs out current logged in user session + + + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); + +var api = new SwaggerPetstore.UserApi() + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.logoutUser(callback); +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + + +# **updateUser** +> updateUser(username, opts) + +Updated user + +This can only be done by the logged in user. + +### Example +```javascript +var SwaggerPetstore = require('swagger-petstore'); + +var api = new SwaggerPetstore.UserApi() + +var username = "username_example"; // {String} name that need to be deleted + +var opts = { + 'body': new SwaggerPetstore.User() // {User} Updated user object +}; + +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +api.updateUser(username, opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | [optional] + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + diff --git a/samples/client/petstore/javascript/git_push.sh b/samples/client/petstore/javascript/git_push.sh index 1a36388db02..6ca091b49d9 100644 --- a/samples/client/petstore/javascript/git_push.sh +++ b/samples/client/petstore/javascript/git_push.sh @@ -8,17 +8,17 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="YOUR_GIT_USR_ID" + git_user_id="" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="YOUR_GIT_REPO_ID" + git_repo_id="" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi if [ "$release_note" = "" ]; then - release_note="Minor update" + release_note="" echo "[INFO] No command line input provided. Set \$release_note to $release_note" fi diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index dcc2442232d..de889ee58e4 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -22,12 +22,13 @@ this.basePath = 'http://petstore.swagger.io/v2'.replace(/\/+$/, ''); this.authentications = { - 'test_api_key_header': {type: 'apiKey', in: 'header', name: 'test_api_key_header'}, - 'api_key': {type: 'apiKey', in: 'header', name: 'api_key'}, - 'test_api_client_secret': {type: 'apiKey', in: 'header', name: 'x-test_api_client_secret'}, + 'petstore_auth': {type: 'oauth2'}, 'test_api_client_id': {type: 'apiKey', in: 'header', name: 'x-test_api_client_id'}, + 'test_api_client_secret': {type: 'apiKey', in: 'header', name: 'x-test_api_client_secret'}, + 'api_key': {type: 'apiKey', in: 'header', name: 'api_key'}, + 'test_http_basic': {type: 'basic'}, 'test_api_key_query': {type: 'apiKey', in: 'query', name: 'test_api_key_query'}, - 'petstore_auth': {type: 'oauth2'} + 'test_api_key_header': {type: 'apiKey', in: 'header', name: 'test_api_key_header'} }; /** diff --git a/samples/client/petstore/javascript/src/api/PetApi.js b/samples/client/petstore/javascript/src/api/PetApi.js index 03893624c62..908ffde2ac6 100644 --- a/samples/client/petstore/javascript/src/api/PetApi.js +++ b/samples/client/petstore/javascript/src/api/PetApi.js @@ -224,7 +224,7 @@ var formParams = { }; - var authNames = ['api_key', 'petstore_auth']; + var authNames = ['petstore_auth', 'api_key']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = Pet; @@ -263,7 +263,7 @@ var formParams = { }; - var authNames = ['api_key', 'petstore_auth']; + var authNames = ['petstore_auth', 'api_key']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = InlineResponse200; @@ -302,7 +302,7 @@ var formParams = { }; - var authNames = ['api_key', 'petstore_auth']; + var authNames = ['petstore_auth', 'api_key']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = 'String'; diff --git a/samples/client/petstore/javascript/src/api/StoreApi.js b/samples/client/petstore/javascript/src/api/StoreApi.js index 373ae6f076f..2bb24686904 100644 --- a/samples/client/petstore/javascript/src/api/StoreApi.js +++ b/samples/client/petstore/javascript/src/api/StoreApi.js @@ -184,7 +184,7 @@ var formParams = { }; - var authNames = ['test_api_key_header', 'test_api_key_query']; + var authNames = ['test_api_key_query', 'test_api_key_header']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = Order; diff --git a/samples/client/petstore/javascript/src/api/UserApi.js b/samples/client/petstore/javascript/src/api/UserApi.js index 0a185ab71ae..e6b14e6e45a 100644 --- a/samples/client/petstore/javascript/src/api/UserApi.js +++ b/samples/client/petstore/javascript/src/api/UserApi.js @@ -145,7 +145,7 @@ var formParams = { }; - var authNames = []; + var authNames = ['test_http_basic']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = null; diff --git a/samples/client/petstore/javascript/src/model/InlineResponse200.js b/samples/client/petstore/javascript/src/model/InlineResponse200.js index 99bb688ebef..2afc6996266 100644 --- a/samples/client/petstore/javascript/src/model/InlineResponse200.js +++ b/samples/client/petstore/javascript/src/model/InlineResponse200.js @@ -31,8 +31,12 @@ } var _this = new InlineResponse200(); - if (data['tags']) { - _this['tags'] = ApiClient.convertToType(data['tags'], [Tag]); + if (data['photoUrls']) { + _this['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']); + } + + if (data['name']) { + _this['name'] = ApiClient.convertToType(data['name'], 'String'); } if (data['id']) { @@ -43,35 +47,45 @@ _this['category'] = ApiClient.convertToType(data['category'], Object); } + if (data['tags']) { + _this['tags'] = ApiClient.convertToType(data['tags'], [Tag]); + } + if (data['status']) { _this['status'] = ApiClient.convertToType(data['status'], 'String'); } - if (data['name']) { - _this['name'] = ApiClient.convertToType(data['name'], 'String'); - } - - if (data['photoUrls']) { - _this['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']); - } - return _this; } /** - * @return {[Tag]} + * @return {[String]} **/ - InlineResponse200.prototype.getTags = function() { - return this['tags']; + InlineResponse200.prototype.getPhotoUrls = function() { + return this['photoUrls']; } /** - * @param {[Tag]} tags + * @param {[String]} photoUrls **/ - InlineResponse200.prototype.setTags = function(tags) { - this['tags'] = tags; + InlineResponse200.prototype.setPhotoUrls = function(photoUrls) { + this['photoUrls'] = photoUrls; + } + + /** + * @return {String} + **/ + InlineResponse200.prototype.getName = function() { + return this['name']; + } + + /** + * @param {String} name + **/ + InlineResponse200.prototype.setName = function(name) { + this['name'] = name; } /** @@ -102,6 +116,20 @@ this['category'] = category; } + /** + * @return {[Tag]} + **/ + InlineResponse200.prototype.getTags = function() { + return this['tags']; + } + + /** + * @param {[Tag]} tags + **/ + InlineResponse200.prototype.setTags = function(tags) { + this['tags'] = tags; + } + /** * get pet status in the store * @return {StatusEnum} @@ -118,34 +146,6 @@ this['status'] = status; } - /** - * @return {String} - **/ - InlineResponse200.prototype.getName = function() { - return this['name']; - } - - /** - * @param {String} name - **/ - InlineResponse200.prototype.setName = function(name) { - this['name'] = name; - } - - /** - * @return {[String]} - **/ - InlineResponse200.prototype.getPhotoUrls = function() { - return this['photoUrls']; - } - - /** - * @param {[String]} photoUrls - **/ - InlineResponse200.prototype.setPhotoUrls = function(photoUrls) { - this['photoUrls'] = photoUrls; - } - var StatusEnum = {