|
| 1 | +# open_api_petstore |
| 2 | + |
| 3 | +OpenApiPetstore - JavaScript client for open_api_petstore |
| 4 | +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. |
| 5 | +This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: |
| 6 | + |
| 7 | +- API version: 1.0.0 |
| 8 | +- Package version: 1.0.0 |
| 9 | +- Build package: org.openapitools.codegen.languages.JavascriptApolloClientCodegen |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +### For [Node.js](https://nodejs.org/) |
| 14 | + |
| 15 | +#### npm |
| 16 | + |
| 17 | +To publish the library as a [npm](https://www.npmjs.com/), please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages). |
| 18 | + |
| 19 | +Then install it via: |
| 20 | + |
| 21 | +```shell |
| 22 | +npm install open_api_petstore --save |
| 23 | +``` |
| 24 | + |
| 25 | +Finally, you need to build the module: |
| 26 | + |
| 27 | +```shell |
| 28 | +npm run build |
| 29 | +``` |
| 30 | + |
| 31 | +##### Local development |
| 32 | + |
| 33 | +To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run: |
| 34 | + |
| 35 | +```shell |
| 36 | +npm install |
| 37 | +``` |
| 38 | + |
| 39 | +Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`: |
| 40 | + |
| 41 | +```shell |
| 42 | +npm link |
| 43 | +``` |
| 44 | + |
| 45 | +To use the link you just defined in your project, switch to the directory you want to use your open_api_petstore from, and run: |
| 46 | + |
| 47 | +```shell |
| 48 | +npm link /path/to/<JAVASCRIPT_CLIENT_DIR> |
| 49 | +``` |
| 50 | + |
| 51 | +Finally, you need to build the module: |
| 52 | + |
| 53 | +```shell |
| 54 | +npm run build |
| 55 | +``` |
| 56 | + |
| 57 | +#### git |
| 58 | + |
| 59 | +If the library is hosted at a git repository, e.g.https://github.com/GIT_USER_ID/GIT_REPO_ID |
| 60 | +then install it via: |
| 61 | + |
| 62 | +```shell |
| 63 | + npm install GIT_USER_ID/GIT_REPO_ID --save |
| 64 | +``` |
| 65 | + |
| 66 | +### For browser |
| 67 | + |
| 68 | +The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following |
| 69 | +the above steps with Node.js and installing browserify with `npm install -g browserify`, |
| 70 | +perform the following (assuming *main.js* is your entry file): |
| 71 | + |
| 72 | +```shell |
| 73 | +browserify main.js > bundle.js |
| 74 | +``` |
| 75 | + |
| 76 | +Then include *bundle.js* in the HTML pages. |
| 77 | + |
| 78 | +### Webpack Configuration |
| 79 | + |
| 80 | +Using Webpack you may encounter the following error: "Module not found: Error: |
| 81 | +Cannot resolve module", most certainly you should disable AMD loader. Add/merge |
| 82 | +the following section to your webpack config: |
| 83 | + |
| 84 | +```javascript |
| 85 | +module: { |
| 86 | + rules: [ |
| 87 | + { |
| 88 | + parser: { |
| 89 | + amd: false |
| 90 | + } |
| 91 | + } |
| 92 | + ] |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +## Getting Started |
| 97 | + |
| 98 | +Please follow the [installation](#installation) instruction and execute the following JS code: |
| 99 | + |
| 100 | +```javascript |
| 101 | +var OpenApiPetstore = require('open_api_petstore'); |
| 102 | + |
| 103 | +var defaultClient = OpenApiPetstore.ApiClient.instance; |
| 104 | +// Configure OAuth2 access token for authorization: petstore_auth |
| 105 | +var petstore_auth = defaultClient.authentications['petstore_auth']; |
| 106 | +petstore_auth.accessToken = "YOUR ACCESS TOKEN" |
| 107 | + |
| 108 | +var api = new OpenApiPetstore.PetApi() |
| 109 | +var body = new OpenApiPetstore.Pet(); // {Pet} Pet object that needs to be added to the store |
| 110 | +var callback = function(error, data, response) { |
| 111 | + if (error) { |
| 112 | + console.error(error); |
| 113 | + } else { |
| 114 | + console.log('API called successfully.'); |
| 115 | + } |
| 116 | +}; |
| 117 | +api.addPet(body, callback); |
| 118 | + |
| 119 | +``` |
| 120 | + |
| 121 | +## Documentation for API Endpoints |
| 122 | + |
| 123 | +All URIs are relative to *http://petstore.swagger.io/v2* |
| 124 | + |
| 125 | +Class | Method | HTTP request | Description |
| 126 | +------------ | ------------- | ------------- | ------------- |
| 127 | +*OpenApiPetstore.PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store |
| 128 | +*OpenApiPetstore.PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet |
| 129 | +*OpenApiPetstore.PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status |
| 130 | +*OpenApiPetstore.PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags |
| 131 | +*OpenApiPetstore.PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID |
| 132 | +*OpenApiPetstore.PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet |
| 133 | +*OpenApiPetstore.PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data |
| 134 | +*OpenApiPetstore.PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image |
| 135 | +*OpenApiPetstore.StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID |
| 136 | +*OpenApiPetstore.StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status |
| 137 | +*OpenApiPetstore.StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID |
| 138 | +*OpenApiPetstore.StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet |
| 139 | +*OpenApiPetstore.UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user |
| 140 | +*OpenApiPetstore.UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array |
| 141 | +*OpenApiPetstore.UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array |
| 142 | +*OpenApiPetstore.UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user |
| 143 | +*OpenApiPetstore.UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name |
| 144 | +*OpenApiPetstore.UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system |
| 145 | +*OpenApiPetstore.UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session |
| 146 | +*OpenApiPetstore.UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user |
| 147 | + |
| 148 | + |
| 149 | +## Documentation for Models |
| 150 | + |
| 151 | + - [OpenApiPetstore.ApiResponse](docs/ApiResponse.md) |
| 152 | + - [OpenApiPetstore.Category](docs/Category.md) |
| 153 | + - [OpenApiPetstore.Order](docs/Order.md) |
| 154 | + - [OpenApiPetstore.Pet](docs/Pet.md) |
| 155 | + - [OpenApiPetstore.Tag](docs/Tag.md) |
| 156 | + - [OpenApiPetstore.User](docs/User.md) |
| 157 | + |
| 158 | + |
| 159 | +## Documentation for Authorization |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | +### api_key |
| 164 | + |
| 165 | + |
| 166 | +- **Type**: API key |
| 167 | +- **API key parameter name**: api_key |
| 168 | +- **Location**: HTTP header |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | +### petstore_auth |
| 173 | + |
| 174 | + |
| 175 | +- **Type**: OAuth |
| 176 | +- **Flow**: implicit |
| 177 | +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog |
| 178 | +- **Scopes**: |
| 179 | + - write:pets: modify pets in your account |
| 180 | + - read:pets: read your pets |
| 181 | + |
0 commit comments