Skip to content

Commit

Permalink
Update JavaScript samples
Browse files Browse the repository at this point in the history
  • Loading branch information
hisener committed Oct 2, 2017
1 parent a368218 commit 07c0810
Show file tree
Hide file tree
Showing 36 changed files with 1,780 additions and 48 deletions.
12 changes: 6 additions & 6 deletions samples/client/petstore/javascript-es6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ Please follow the [installation](#installation) instruction and execute the foll
```javascript
var SwaggerPetstore = require('swagger_petstore');

var api = new SwaggerPetstore.FakeApi()
var api = new SwaggerPetstore.AnotherFakeApi()

var body = new SwaggerPetstore.Client(); // {Client} client model

var opts = {
'body': new SwaggerPetstore.OuterBoolean() // {OuterBoolean} Input boolean as post body
};

var callback = function(error, data, response) {
if (error) {
Expand All @@ -83,7 +82,7 @@ var callback = function(error, data, response) {
console.log('API called successfully. Returned data: ' + data);
}
};
api.fakeOuterBooleanSerialize(opts, callback);
api.testSpecialTags(body, callback);

```

Expand All @@ -93,6 +92,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*SwaggerPetstore.AnotherFakeApi* | [**testSpecialTags**](docs/AnotherFakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
*SwaggerPetstore.FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
*SwaggerPetstore.FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
*SwaggerPetstore.FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
Expand All @@ -101,7 +101,7 @@ Class | Method | HTTP request | Description
*SwaggerPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*SwaggerPetstore.FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters
*SwaggerPetstore.FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
*SwaggerPetstore.Fake_classname_tags123Api* | [**testClassname**](docs/Fake_classname_tags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
*SwaggerPetstore.FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
*SwaggerPetstore.PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
*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
Expand Down
54 changes: 54 additions & 0 deletions samples/client/petstore/javascript-es6/docs/AnotherFakeApi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# SwaggerPetstore.AnotherFakeApi

All URIs are relative to *http://petstore.swagger.io:80/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
[**testSpecialTags**](AnotherFakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags


<a name="testSpecialTags"></a>
# **testSpecialTags**
> Client testSpecialTags(body)
To test special tags

To test special tags

### Example
```javascript
import SwaggerPetstore from 'swagger_petstore';

let apiInstance = new SwaggerPetstore.AnotherFakeApi();

let body = new SwaggerPetstore.Client(); // Client | client model


apiInstance.testSpecialTags(body, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
```

### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Client**](Client.md)| client model |

### Return type

[**Client**](Client.md)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# SwaggerPetstore.FakeClassnameTags123Api

All URIs are relative to *http://petstore.swagger.io:80/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case


<a name="testClassname"></a>
# **testClassname**
> Client testClassname(body)
To test class name in snake case

### Example
```javascript
import SwaggerPetstore from 'swagger_petstore';
let defaultClient = SwaggerPetstore.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';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key_query.apiKeyPrefix = 'Token';

let apiInstance = new SwaggerPetstore.FakeClassnameTags123Api();

let body = new SwaggerPetstore.Client(); // Client | client model


apiInstance.testClassname(body, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
});
```

### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Client**](Client.md)| client model |

### Return type

[**Client**](Client.md)

### Authorization

[api_key_query](../README.md#api_key_query)

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json

2 changes: 1 addition & 1 deletion samples/client/petstore/javascript-es6/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "swagger_petstore",
"version": "1.0.0",
"description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters__",
"license": "Unlicense",
"license": "Apache 2.0",
"main": "src/index.js",
"scripts": {
"test": "mocha --compilers js:babel-core/register --recursive"
Expand Down
83 changes: 83 additions & 0 deletions samples/client/petstore/javascript-es6/src/api/AnotherFakeApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
*/


import ApiClient from "../ApiClient";
import Client from '../model/Client';

/**
* AnotherFake service.
* @module api/AnotherFakeApi
* @version 1.0.0
*/
export default class AnotherFakeApi {

/**
* Constructs a new AnotherFakeApi.
* @alias module:api/AnotherFakeApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
constructor(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
}


/**
* Callback function to receive the result of the testSpecialTags operation.
* @callback module:api/AnotherFakeApi~testSpecialTagsCallback
* @param {String} error Error message, if any.
* @param {module:model/Client} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/

/**
* To test special tags
* To test special tags
* @param {module:model/Client} body client model
* @param {module:api/AnotherFakeApi~testSpecialTagsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/Client}
*/
testSpecialTags(body, callback) {
let postBody = body;

// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling testSpecialTags");
}


let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};

let authNames = [];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = Client;

return this.apiClient.callApi(
'/another-fake/dummy', 'PATCH',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
*/


import ApiClient from "../ApiClient";
import Client from '../model/Client';

/**
* FakeClassnameTags123 service.
* @module api/FakeClassnameTags123Api
* @version 1.0.0
*/
export default class FakeClassnameTags123Api {

/**
* Constructs a new FakeClassnameTags123Api.
* @alias module:api/FakeClassnameTags123Api
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
constructor(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
}


/**
* Callback function to receive the result of the testClassname operation.
* @callback module:api/FakeClassnameTags123Api~testClassnameCallback
* @param {String} error Error message, if any.
* @param {module:model/Client} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/

/**
* To test class name in snake case
* @param {module:model/Client} body client model
* @param {module:api/FakeClassnameTags123Api~testClassnameCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/Client}
*/
testClassname(body, callback) {
let postBody = body;

// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling testClassname");
}


let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};

let authNames = ['api_key_query'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = Client;

return this.apiClient.callApi(
'/fake_classname_test', 'PATCH',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}


}
15 changes: 11 additions & 4 deletions samples/client/petstore/javascript-es6/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ import Tag from './model/Tag';
import User from './model/User';
import Cat from './model/Cat';
import Dog from './model/Dog';
import AnotherFakeApi from './api/AnotherFakeApi';
import FakeApi from './api/FakeApi';
import Fake_classname_tags123Api from './api/Fake_classname_tags123Api';
import FakeClassnameTags123Api from './api/FakeClassnameTags123Api';
import PetApi from './api/PetApi';
import StoreApi from './api/StoreApi';
import UserApi from './api/UserApi';
Expand Down Expand Up @@ -310,17 +311,23 @@ export {
*/
Dog,

/**
* The AnotherFakeApi service constructor.
* @property {module:api/AnotherFakeApi}
*/
AnotherFakeApi,

/**
* The FakeApi service constructor.
* @property {module:api/FakeApi}
*/
FakeApi,

/**
* The Fake_classname_tags123Api service constructor.
* @property {module:api/Fake_classname_tags123Api}
* The FakeClassnameTags123Api service constructor.
* @property {module:api/FakeClassnameTags123Api}
*/
Fake_classname_tags123Api,
FakeClassnameTags123Api,

/**
* The PetApi service constructor.
Expand Down
Loading

0 comments on commit 07c0810

Please sign in to comment.