UNPKG

shins

Version:
2,543 lines (1,928 loc) 80.3 kB
--- title: Swagger Petstore v1.0.0 language_tabs: - shell: Shell - http: HTTP - javascript: JavaScript - ruby: Ruby - python: Python - php: PHP - java: Java - go: Go toc_footers: - <a href="https://mermade.github.io/shins/asyncapi.html">See AsyncAPI example</a> includes: [] search: true highlight_theme: darkula headingLevel: 2 --- <!-- Generator: Widdershins v4.0.1 --> <h1 id="swagger-petstore">Swagger Petstore v1.0.0</h1> > Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu. :dog: :cat: :rabbit: This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. Base URLs: * <a href="http://petstore.swagger.io/v2">http://petstore.swagger.io/v2</a> <a href="http://swagger.io/terms/">Terms of service</a> Email: <a href="mailto:apiteam@swagger.io">Support</a> License: <a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0</a> # Authentication - oAuth2 authentication. - Flow: implicit - Authorization URL = [http://petstore.swagger.io/oauth/dialog](http://petstore.swagger.io/oauth/dialog) |Scope|Scope Description| |---|---| |write:pets|modify pets in your account| |read:pets|read your pets| * API Key (api_key) - Parameter Name: **api_key**, in: header. <h1 id="swagger-petstore-pet">pet</h1> Everything about your Pets <a href="http://swagger.io">Find out more</a> ## addPet <a id="opIdaddPet"></a> > Code samples ```shell # You can also use wget curl -X POST http://petstore.swagger.io/v2/pet \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer {access-token}' ``` ```http POST http://petstore.swagger.io/v2/pet HTTP/1.1 Host: petstore.swagger.io Content-Type: application/json ``` ```javascript const inputBody = '{ "id": 0, "category": { "id": 0, "name": "string" }, "name": "doggie", "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" }'; const headers = { 'Content-Type':'application/json', 'Authorization':'Bearer {access-token}' }; fetch('http://petstore.swagger.io/v2/pet', { method: 'POST', body: inputBody, headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` ```ruby require 'rest-client' require 'json' headers = { 'Content-Type' => 'application/json', 'Authorization' => 'Bearer {access-token}' } result = RestClient.post 'http://petstore.swagger.io/v2/pet', params: { }, headers: headers p JSON.parse(result) ``` ```python import requests headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {access-token}' } r = requests.post('http://petstore.swagger.io/v2/pet', headers = headers) print(r.json()) ``` ```php <?php require 'vendor/autoload.php'; $headers = array( 'Content-Type' => 'application/json', 'Authorization' => 'Bearer {access-token}', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('POST','http://petstore.swagger.io/v2/pet', array( 'headers' => $headers, 'json' => $request_body, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` ```java URL obj = new URL("http://petstore.swagger.io/v2/pet"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Content-Type": []string{"application/json"}, "Authorization": []string{"Bearer {access-token}"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("POST", "http://petstore.swagger.io/v2/pet", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` `POST /pet` *Add a new pet to the store* > Body parameter ```json { "id": 0, "category": { "id": 0, "name": "string" }, "name": "doggie", "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" } ``` ```xml <?xml version="1.0" encoding="UTF-8" ?> <Pet> <id>0</id> <category> <id>0</id> <name>string</name> </category> <name>doggie</name> <photoUrls>string</photoUrls> <tags> <id>0</id> <name>string</name> </tags> <status>available</status> </Pet> ``` <h3 id="addpet-parameters">Parameters</h3> |Name|In|Type|Required|Description| |---|---|---|---|---| |body|body|[Pet](#schemapet)|true|Pet object that needs to be added to the store| <h3 id="addpet-responses">Responses</h3> |Status|Meaning|Description|Schema| |---|---|---|---| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Invalid input|None| <aside class="warning"> To perform this operation, you must be authenticated by means of one of the following methods: petstore_auth ( Scopes: write:pets read:pets ) </aside> ## updatePet <a id="opIdupdatePet"></a> > Code samples ```shell # You can also use wget curl -X PUT http://petstore.swagger.io/v2/pet \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer {access-token}' ``` ```http PUT http://petstore.swagger.io/v2/pet HTTP/1.1 Host: petstore.swagger.io Content-Type: application/json ``` ```javascript const inputBody = '{ "id": 0, "category": { "id": 0, "name": "string" }, "name": "doggie", "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" }'; const headers = { 'Content-Type':'application/json', 'Authorization':'Bearer {access-token}' }; fetch('http://petstore.swagger.io/v2/pet', { method: 'PUT', body: inputBody, headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` ```ruby require 'rest-client' require 'json' headers = { 'Content-Type' => 'application/json', 'Authorization' => 'Bearer {access-token}' } result = RestClient.put 'http://petstore.swagger.io/v2/pet', params: { }, headers: headers p JSON.parse(result) ``` ```python import requests headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {access-token}' } r = requests.put('http://petstore.swagger.io/v2/pet', headers = headers) print(r.json()) ``` ```php <?php require 'vendor/autoload.php'; $headers = array( 'Content-Type' => 'application/json', 'Authorization' => 'Bearer {access-token}', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('PUT','http://petstore.swagger.io/v2/pet', array( 'headers' => $headers, 'json' => $request_body, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` ```java URL obj = new URL("http://petstore.swagger.io/v2/pet"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("PUT"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Content-Type": []string{"application/json"}, "Authorization": []string{"Bearer {access-token}"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("PUT", "http://petstore.swagger.io/v2/pet", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` `PUT /pet` *Update an existing pet* > Body parameter ```json { "id": 0, "category": { "id": 0, "name": "string" }, "name": "doggie", "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" } ``` ```xml <?xml version="1.0" encoding="UTF-8" ?> <Pet> <id>0</id> <category> <id>0</id> <name>string</name> </category> <name>doggie</name> <photoUrls>string</photoUrls> <tags> <id>0</id> <name>string</name> </tags> <status>available</status> </Pet> ``` <h3 id="updatepet-parameters">Parameters</h3> |Name|In|Type|Required|Description| |---|---|---|---|---| |body|body|[Pet](#schemapet)|true|Pet object that needs to be added to the store| <h3 id="updatepet-responses">Responses</h3> |Status|Meaning|Description|Schema| |---|---|---|---| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Invalid ID supplied|None| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Pet not found|None| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Validation exception|None| <aside class="warning"> To perform this operation, you must be authenticated by means of one of the following methods: petstore_auth ( Scopes: write:pets read:pets ) </aside> ## findPetsByStatus <a id="opIdfindPetsByStatus"></a> > Code samples ```shell # You can also use wget curl -X GET http://petstore.swagger.io/v2/pet/findByStatus?status=available \ -H 'Accept: application/xml' \ -H 'Authorization: Bearer {access-token}' ``` ```http GET http://petstore.swagger.io/v2/pet/findByStatus?status=available HTTP/1.1 Host: petstore.swagger.io Accept: application/xml ``` ```javascript const headers = { 'Accept':'application/xml', 'Authorization':'Bearer {access-token}' }; fetch('http://petstore.swagger.io/v2/pet/findByStatus?status=available', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` ```ruby require 'rest-client' require 'json' headers = { 'Accept' => 'application/xml', 'Authorization' => 'Bearer {access-token}' } result = RestClient.get 'http://petstore.swagger.io/v2/pet/findByStatus', params: { 'status' => 'array[string]' }, headers: headers p JSON.parse(result) ``` ```python import requests headers = { 'Accept': 'application/xml', 'Authorization': 'Bearer {access-token}' } r = requests.get('http://petstore.swagger.io/v2/pet/findByStatus', params={ 'status': [ "available" ] }, headers = headers) print(r.json()) ``` ```php <?php require 'vendor/autoload.php'; $headers = array( 'Accept' => 'application/xml', 'Authorization' => 'Bearer {access-token}', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('GET','http://petstore.swagger.io/v2/pet/findByStatus', array( 'headers' => $headers, 'json' => $request_body, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` ```java URL obj = new URL("http://petstore.swagger.io/v2/pet/findByStatus?status=available"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/xml"}, "Authorization": []string{"Bearer {access-token}"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "http://petstore.swagger.io/v2/pet/findByStatus", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` `GET /pet/findByStatus` *Finds Pets by status* Multiple status values can be provided with comma separated strings <h3 id="findpetsbystatus-parameters">Parameters</h3> |Name|In|Type|Required|Description| |---|---|---|---|---| |status|query|array[string]|true|Status values that need to be considered for filter| #### Enumerated Values |Parameter|Value| |---|---| |status|available| |status|pending| |status|sold| > Example responses > 200 Response ```xml <?xml version="1.0" encoding="UTF-8" ?> <id>0</id> <category> <id>0</id> <name>string</name> </category> <name>doggie</name> <photoUrls>string</photoUrls> <tags> <id>0</id> <name>string</name> </tags> <status>available</status> ``` ```json [ { "id": 0, "category": { "id": 0, "name": "string" }, "name": "doggie", "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" } ] ``` <h3 id="findpetsbystatus-responses">Responses</h3> |Status|Meaning|Description|Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|successful operation|Inline| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Invalid status value|None| <h3 id="findpetsbystatus-responseschema">Response Schema</h3> Status Code **200** |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |*anonymous*|[[Pet](#schemapet)]|false|none|none| |» id|integer(int64)|false|none|none| |» category|[Category](#schemacategory)|false|none|none| |»» id|integer(int64)|false|none|none| |»» name|string|false|none|none| |» name|string|true|none|none| |» photoUrls|[string]|true|none|none| |» tags|[[Tag](#schematag)]|false|none|none| |»» id|integer(int64)|false|none|none| |»» name|string|false|none|none| |» status|string|false|none|pet status in the store| #### Enumerated Values |Property|Value| |---|---| |status|available| |status|pending| |status|sold| <aside class="warning"> To perform this operation, you must be authenticated by means of one of the following methods: petstore_auth ( Scopes: write:pets read:pets ) </aside> ## findPetsByTags <a id="opIdfindPetsByTags"></a> > Code samples ```shell # You can also use wget curl -X GET http://petstore.swagger.io/v2/pet/findByTags?tags=string \ -H 'Accept: application/xml' \ -H 'Authorization: Bearer {access-token}' ``` ```http GET http://petstore.swagger.io/v2/pet/findByTags?tags=string HTTP/1.1 Host: petstore.swagger.io Accept: application/xml ``` ```javascript const headers = { 'Accept':'application/xml', 'Authorization':'Bearer {access-token}' }; fetch('http://petstore.swagger.io/v2/pet/findByTags?tags=string', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` ```ruby require 'rest-client' require 'json' headers = { 'Accept' => 'application/xml', 'Authorization' => 'Bearer {access-token}' } result = RestClient.get 'http://petstore.swagger.io/v2/pet/findByTags', params: { 'tags' => 'array[string]' }, headers: headers p JSON.parse(result) ``` ```python import requests headers = { 'Accept': 'application/xml', 'Authorization': 'Bearer {access-token}' } r = requests.get('http://petstore.swagger.io/v2/pet/findByTags', params={ 'tags': [ "string" ] }, headers = headers) print(r.json()) ``` ```php <?php require 'vendor/autoload.php'; $headers = array( 'Accept' => 'application/xml', 'Authorization' => 'Bearer {access-token}', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('GET','http://petstore.swagger.io/v2/pet/findByTags', array( 'headers' => $headers, 'json' => $request_body, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` ```java URL obj = new URL("http://petstore.swagger.io/v2/pet/findByTags?tags=string"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/xml"}, "Authorization": []string{"Bearer {access-token}"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "http://petstore.swagger.io/v2/pet/findByTags", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` `GET /pet/findByTags` *Finds Pets by tags* Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. <h3 id="findpetsbytags-parameters">Parameters</h3> |Name|In|Type|Required|Description| |---|---|---|---|---| |tags|query|array[string]|true|Tags to filter by| > Example responses > 200 Response ```xml <?xml version="1.0" encoding="UTF-8" ?> <id>0</id> <category> <id>0</id> <name>string</name> </category> <name>doggie</name> <photoUrls>string</photoUrls> <tags> <id>0</id> <name>string</name> </tags> <status>available</status> ``` ```json [ { "id": 0, "category": { "id": 0, "name": "string" }, "name": "doggie", "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" } ] ``` <h3 id="findpetsbytags-responses">Responses</h3> |Status|Meaning|Description|Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|successful operation|Inline| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Invalid tag value|None| <h3 id="findpetsbytags-responseschema">Response Schema</h3> Status Code **200** |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |*anonymous*|[[Pet](#schemapet)]|false|none|none| |» id|integer(int64)|false|none|none| |» category|[Category](#schemacategory)|false|none|none| |»» id|integer(int64)|false|none|none| |»» name|string|false|none|none| |» name|string|true|none|none| |» photoUrls|[string]|true|none|none| |» tags|[[Tag](#schematag)]|false|none|none| |»» id|integer(int64)|false|none|none| |»» name|string|false|none|none| |» status|string|false|none|pet status in the store| #### Enumerated Values |Property|Value| |---|---| |status|available| |status|pending| |status|sold| <aside class="warning"> To perform this operation, you must be authenticated by means of one of the following methods: petstore_auth ( Scopes: write:pets read:pets ) </aside> ## getPetById <a id="opIdgetPetById"></a> > Code samples ```shell # You can also use wget curl -X GET http://petstore.swagger.io/v2/pet/{petId} \ -H 'Accept: application/xml' \ -H 'api_key: API_KEY' ``` ```http GET http://petstore.swagger.io/v2/pet/{petId} HTTP/1.1 Host: petstore.swagger.io Accept: application/xml ``` ```javascript const headers = { 'Accept':'application/xml', 'api_key':'API_KEY' }; fetch('http://petstore.swagger.io/v2/pet/{petId}', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` ```ruby require 'rest-client' require 'json' headers = { 'Accept' => 'application/xml', 'api_key' => 'API_KEY' } result = RestClient.get 'http://petstore.swagger.io/v2/pet/{petId}', params: { }, headers: headers p JSON.parse(result) ``` ```python import requests headers = { 'Accept': 'application/xml', 'api_key': 'API_KEY' } r = requests.get('http://petstore.swagger.io/v2/pet/{petId}', headers = headers) print(r.json()) ``` ```php <?php require 'vendor/autoload.php'; $headers = array( 'Accept' => 'application/xml', 'api_key' => 'API_KEY', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('GET','http://petstore.swagger.io/v2/pet/{petId}', array( 'headers' => $headers, 'json' => $request_body, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` ```java URL obj = new URL("http://petstore.swagger.io/v2/pet/{petId}"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/xml"}, "api_key": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "http://petstore.swagger.io/v2/pet/{petId}", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` `GET /pet/{petId}` *Find pet by ID* Returns a single pet <h3 id="getpetbyid-parameters">Parameters</h3> |Name|In|Type|Required|Description| |---|---|---|---|---| |petId|path|integer(int64)|true|ID of pet to return| > Example responses > 200 Response ```xml <?xml version="1.0" encoding="UTF-8" ?> <Pet> <id>0</id> <category> <id>0</id> <name>string</name> </category> <name>doggie</name> <photoUrls>string</photoUrls> <tags> <id>0</id> <name>string</name> </tags> <status>available</status> </Pet> ``` ```json { "id": 0, "category": { "id": 0, "name": "string" }, "name": "doggie", "photoUrls": [ "string" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" } ``` <h3 id="getpetbyid-responses">Responses</h3> |Status|Meaning|Description|Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|successful operation|[Pet](#schemapet)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Invalid ID supplied|None| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Pet not found|None| <aside class="warning"> To perform this operation, you must be authenticated by means of one of the following methods: api_key </aside> ## updatePetWithForm <a id="opIdupdatePetWithForm"></a> > Code samples ```shell # You can also use wget curl -X POST http://petstore.swagger.io/v2/pet/{petId} \ -H 'Content-Type: application/x-www-form-urlencoded' \ -H 'Authorization: Bearer {access-token}' ``` ```http POST http://petstore.swagger.io/v2/pet/{petId} HTTP/1.1 Host: petstore.swagger.io Content-Type: application/x-www-form-urlencoded ``` ```javascript const inputBody = '{ "name": "string", "status": "string" }'; const headers = { 'Content-Type':'application/x-www-form-urlencoded', 'Authorization':'Bearer {access-token}' }; fetch('http://petstore.swagger.io/v2/pet/{petId}', { method: 'POST', body: inputBody, headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` ```ruby require 'rest-client' require 'json' headers = { 'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => 'Bearer {access-token}' } result = RestClient.post 'http://petstore.swagger.io/v2/pet/{petId}', params: { }, headers: headers p JSON.parse(result) ``` ```python import requests headers = { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Bearer {access-token}' } r = requests.post('http://petstore.swagger.io/v2/pet/{petId}', headers = headers) print(r.json()) ``` ```php <?php require 'vendor/autoload.php'; $headers = array( 'Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => 'Bearer {access-token}', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('POST','http://petstore.swagger.io/v2/pet/{petId}', array( 'headers' => $headers, 'json' => $request_body, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` ```java URL obj = new URL("http://petstore.swagger.io/v2/pet/{petId}"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Content-Type": []string{"application/x-www-form-urlencoded"}, "Authorization": []string{"Bearer {access-token}"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("POST", "http://petstore.swagger.io/v2/pet/{petId}", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` `POST /pet/{petId}` *Updates a pet in the store with form data* > Body parameter ```yaml name: string status: string ``` <h3 id="updatepetwithform-parameters">Parameters</h3> |Name|In|Type|Required|Description| |---|---|---|---|---| |petId|path|integer(int64)|true|ID of pet that needs to be updated| |body|body|object|false|none| |» name|body|string|false|Updated name of the pet| |» status|body|string|false|Updated status of the pet| <h3 id="updatepetwithform-responses">Responses</h3> |Status|Meaning|Description|Schema| |---|---|---|---| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Invalid input|None| <aside class="warning"> To perform this operation, you must be authenticated by means of one of the following methods: petstore_auth ( Scopes: write:pets read:pets ) </aside> ## deletePet <a id="opIddeletePet"></a> > Code samples ```shell # You can also use wget curl -X DELETE http://petstore.swagger.io/v2/pet/{petId} \ -H 'api_key: string' \ -H 'Authorization: Bearer {access-token}' ``` ```http DELETE http://petstore.swagger.io/v2/pet/{petId} HTTP/1.1 Host: petstore.swagger.io api_key: string ``` ```javascript const headers = { 'api_key':'string', 'Authorization':'Bearer {access-token}' }; fetch('http://petstore.swagger.io/v2/pet/{petId}', { method: 'DELETE', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` ```ruby require 'rest-client' require 'json' headers = { 'api_key' => 'string', 'Authorization' => 'Bearer {access-token}' } result = RestClient.delete 'http://petstore.swagger.io/v2/pet/{petId}', params: { }, headers: headers p JSON.parse(result) ``` ```python import requests headers = { 'api_key': 'string', 'Authorization': 'Bearer {access-token}' } r = requests.delete('http://petstore.swagger.io/v2/pet/{petId}', headers = headers) print(r.json()) ``` ```php <?php require 'vendor/autoload.php'; $headers = array( 'api_key' => 'string', 'Authorization' => 'Bearer {access-token}', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('DELETE','http://petstore.swagger.io/v2/pet/{petId}', array( 'headers' => $headers, 'json' => $request_body, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` ```java URL obj = new URL("http://petstore.swagger.io/v2/pet/{petId}"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("DELETE"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "api_key": []string{"string"}, "Authorization": []string{"Bearer {access-token}"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("DELETE", "http://petstore.swagger.io/v2/pet/{petId}", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` `DELETE /pet/{petId}` *Deletes a pet* <h3 id="deletepet-parameters">Parameters</h3> |Name|In|Type|Required|Description| |---|---|---|---|---| |api_key|header|string|false|none| |petId|path|integer(int64)|true|Pet id to delete| <h3 id="deletepet-responses">Responses</h3> |Status|Meaning|Description|Schema| |---|---|---|---| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Invalid ID supplied|None| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Pet not found|None| <aside class="warning"> To perform this operation, you must be authenticated by means of one of the following methods: petstore_auth ( Scopes: write:pets read:pets ) </aside> ## uploadFile <a id="opIduploadFile"></a> > Code samples ```shell # You can also use wget curl -X POST http://petstore.swagger.io/v2/pet/{petId}/uploadImage \ -H 'Content-Type: multipart/form-data' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' ``` ```http POST http://petstore.swagger.io/v2/pet/{petId}/uploadImage HTTP/1.1 Host: petstore.swagger.io Content-Type: multipart/form-data Accept: application/json ``` ```javascript const inputBody = '{ "additionalMetadata": "string", "file": "string" }'; const headers = { 'Content-Type':'multipart/form-data', 'Accept':'application/json', 'Authorization':'Bearer {access-token}' }; fetch('http://petstore.swagger.io/v2/pet/{petId}/uploadImage', { method: 'POST', body: inputBody, headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` ```ruby require 'rest-client' require 'json' headers = { 'Content-Type' => 'multipart/form-data', 'Accept' => 'application/json', 'Authorization' => 'Bearer {access-token}' } result = RestClient.post 'http://petstore.swagger.io/v2/pet/{petId}/uploadImage', params: { }, headers: headers p JSON.parse(result) ``` ```python import requests headers = { 'Content-Type': 'multipart/form-data', 'Accept': 'application/json', 'Authorization': 'Bearer {access-token}' } r = requests.post('http://petstore.swagger.io/v2/pet/{petId}/uploadImage', headers = headers) print(r.json()) ``` ```php <?php require 'vendor/autoload.php'; $headers = array( 'Content-Type' => 'multipart/form-data', 'Accept' => 'application/json', 'Authorization' => 'Bearer {access-token}', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('POST','http://petstore.swagger.io/v2/pet/{petId}/uploadImage', array( 'headers' => $headers, 'json' => $request_body, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` ```java URL obj = new URL("http://petstore.swagger.io/v2/pet/{petId}/uploadImage"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Content-Type": []string{"multipart/form-data"}, "Accept": []string{"application/json"}, "Authorization": []string{"Bearer {access-token}"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("POST", "http://petstore.swagger.io/v2/pet/{petId}/uploadImage", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` `POST /pet/{petId}/uploadImage` *uploads an image* > Body parameter ```yaml additionalMetadata: string file: string ``` <h3 id="uploadfile-parameters">Parameters</h3> |Name|In|Type|Required|Description| |---|---|---|---|---| |petId|path|integer(int64)|true|ID of pet to update| |body|body|object|false|none| |» additionalMetadata|body|string|false|Additional data to pass to server| |» file|body|string(binary)|false|file to upload| > Example responses > 200 Response ```json { "code": 0, "type": "string", "message": "string" } ``` <h3 id="uploadfile-responses">Responses</h3> |Status|Meaning|Description|Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|successful operation|[ApiResponse](#schemaapiresponse)| <aside class="warning"> To perform this operation, you must be authenticated by means of one of the following methods: petstore_auth ( Scopes: write:pets read:pets ) </aside> <h1 id="swagger-petstore-store">store</h1> Access to Petstore orders ## getInventory <a id="opIdgetInventory"></a> > Code samples ```shell # You can also use wget curl -X GET http://petstore.swagger.io/v2/store/inventory \ -H 'Accept: application/json' \ -H 'api_key: API_KEY' ``` ```http GET http://petstore.swagger.io/v2/store/inventory HTTP/1.1 Host: petstore.swagger.io Accept: application/json ``` ```javascript const headers = { 'Accept':'application/json', 'api_key':'API_KEY' }; fetch('http://petstore.swagger.io/v2/store/inventory', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` ```ruby require 'rest-client' require 'json' headers = { 'Accept' => 'application/json', 'api_key' => 'API_KEY' } result = RestClient.get 'http://petstore.swagger.io/v2/store/inventory', params: { }, headers: headers p JSON.parse(result) ``` ```python import requests headers = { 'Accept': 'application/json', 'api_key': 'API_KEY' } r = requests.get('http://petstore.swagger.io/v2/store/inventory', headers = headers) print(r.json()) ``` ```php <?php require 'vendor/autoload.php'; $headers = array( 'Accept' => 'application/json', 'api_key' => 'API_KEY', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('GET','http://petstore.swagger.io/v2/store/inventory', array( 'headers' => $headers, 'json' => $request_body, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` ```java URL obj = new URL("http://petstore.swagger.io/v2/store/inventory"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "api_key": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "http://petstore.swagger.io/v2/store/inventory", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` `GET /store/inventory` *Returns pet inventories by status* Returns a map of status codes to quantities > Example responses > 200 Response ```json { "property1": 0, "property2": 0 } ``` <h3 id="getinventory-responses">Responses</h3> |Status|Meaning|Description|Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|successful operation|Inline| <h3 id="getinventory-responseschema">Response Schema</h3> Status Code **200** |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |» **additionalProperties**|integer(int32)|false|none|none| <aside class="warning"> To perform this operation, you must be authenticated by means of one of the following methods: api_key </aside> ## placeOrder <a id="opIdplaceOrder"></a> > Code samples ```shell # You can also use wget curl -X POST http://petstore.swagger.io/v2/store/order \ -H 'Content-Type: application/json' \ -H 'Accept: application/xml' ``` ```http POST http://petstore.swagger.io/v2/store/order HTTP/1.1 Host: petstore.swagger.io Content-Type: application/json Accept: application/xml ``` ```javascript const inputBody = '{ "id": 0, "petId": 0, "quantity": 0, "shipDate": "2020-03-30T14:38:05Z", "status": "placed", "complete": false }'; const headers = { 'Content-Type':'application/json', 'Accept':'application/xml' }; fetch('http://petstore.swagger.io/v2/store/order', { method: 'POST', body: inputBody, headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` ```ruby require 'rest-client' require 'json' headers = { 'Content-Type' => 'application/json', 'Accept' => 'application/xml' } result = RestClient.post 'http://petstore.swagger.io/v2/store/order', params: { }, headers: headers p JSON.parse(result) ``` ```python import requests headers = { 'Content-Type': 'application/json', 'Accept': 'application/xml' } r = requests.post('http://petstore.swagger.io/v2/store/order', headers = headers) print(r.json()) ``` ```php <?php require 'vendor/autoload.php'; $headers = array( 'Content-Type' => 'application/json', 'Accept' => 'application/xml', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('POST','http://petstore.swagger.io/v2/store/order', array( 'headers' => $headers, 'json' => $request_body, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` ```java URL obj = new URL("http://petstore.swagger.io/v2/store/order"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Content-Type": []string{"application/json"}, "Accept": []string{"application/xml"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("POST", "http://petstore.swagger.io/v2/store/order", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` `POST /store/order` *Place an order for a pet* > Body parameter ```json { "id": 0, "petId": 0, "quantity": 0, "shipDate": "2020-03-30T14:38:05Z", "status": "placed", "complete": false } ``` <h3 id="placeorder-parameters">Parameters</h3> |Name|In|Type|Required|Description| |---|---|---|---|---| |body|body|[Order](#schemaorder)|true|order placed for purchasing the pet| > Example responses > 200 Response ```xml <?xml version="1.0" encoding="UTF-8" ?> <Order> <id>0</id> <petId>0</petId> <quantity>0</quantity> <shipDate>2020-03-30T14:38:05Z</shipDate> <status>placed</status> <complete>false</complete> </Order> ``` ```json { "id": 0, "petId": 0, "quantity": 0, "shipDate": "2020-03-30T14:38:05Z", "status": "placed", "complete": false } ``` <h3 id="placeorder-responses">Responses</h3> |Status|Meaning|Description|Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|successful operation|[Order](#schemaorder)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Invalid Order|None| <aside class="success"> This operation does not require authentication </aside> ## getOrderById <a id="opIdgetOrderById"></a> > Code samples ```shell # You can also use wget curl -X GET http://petstore.swagger.io/v2/store/order/{orderId} \ -H 'Accept: application/xml' ``` ```http GET http://petstore.swagger.io/v2/store/order/{orderId} HTTP/1.1 Host: petstore.swagger.io Accept: application/xml ``` ```javascript const headers = { 'Accept':'application/xml' }; fetch('http://petstore.swagger.io/v2/store/order/{orderId}', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` ```ruby require 'rest-client' require 'json' headers = { 'Accept' => 'application/xml' } result = RestClient.get 'http://petstore.swagger.io/v2/store/order/{orderId}', params: { }, headers: headers p JSON.parse(result) ``` ```python import requests headers = { 'Accept': 'application/xml' } r = requests.get('http://petstore.swagger.io/v2/store/order/{orderId}', headers = headers) print(r.json()) ``` ```php <?php require 'vendor/autoload.php'; $headers = array( 'Accept' => 'application/xml', ); $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('GET','http://petstore.swagger.io/v2/store/order/{orderId}', array( 'headers' => $headers, 'json' => $request_body, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` ```java URL obj = new URL("http://petstore.swagger.io/v2/store/order/{orderId}"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/xml"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "http://petstore.swagger.io/v2/store/order/{orderId}", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` `GET /store/order/{orderId}` *Find purchase order by ID* For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions <h3 id="getorderbyid-parameters">Parameters</h3> |Name|In|Type|Required|Description| |---|---|---|---|---| |orderId|path|integer(int64)|true|ID of pet that needs to be fetched| > Example responses > 200 Response ```xml <?xml version="1.0" encoding="UTF-8" ?> <Order> <id>0</id> <petId>0</petId> <quantity>0</quantity> <shipDate>2020-03-30T14:38:05Z</shipDate> <status>placed</status> <complete>false</complete> </Order> ``` ```json { "id": 0, "petId": 0, "quantity": 0, "shipDate": "2020-03-30T14:38:05Z", "status": "placed", "complete": false } ``` <h3 id="getorderbyid-responses">Responses</h3> |Status|Meaning|Description|Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|successful operation|[Order](#schemaorder)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Invalid ID supplied|None| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Order not found|None| <aside class="success"> This operation does not require authentication </aside> ## deleteOrder <a id="opIddeleteOrder"></a> > Code samples ```shell # You can also use wget curl -X DELETE http://petstore.swagger.io/v2/store/order/{orderId} ``` ```http DELETE http://petstore.swagger.io/v2/store/order/{orderId} HTTP/1.1 Host: petstore.swagger.io ``` ```javascript fetch('http://petstore.swagger.io/v2/store/order/{orderId}', { method: 'DELETE' }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` ```ruby require 'rest-client' require 'json' result = RestClient.delete 'http://petstore.swagger.io/v2/store/order/{orderId}', params: { } p JSON.parse(result) ``` ```python import requests r = requests.delete('http://petstore.swagger.io/v2/store/order/{orderId}') print(r.json()) ``` ```php <?php require 'vendor/autoload.php'; $client = new \GuzzleHttp\Client(); // Define array of request body. $request_body = array(); try { $response = $client->request('DELETE','http://petstore.swagger.io/v2/store/order/{orderId}', array( 'headers' => $headers, 'json' => $request_body, ) ); print_r($response->getBody()->getContents()); } catch (\GuzzleHttp\Exception\BadResponseException $e) { // handle exception or api errors. print_r($e->getMessage()); } // ... ``` ```java URL obj = new URL("http://petstore.swagger.io/v2/store/order/{orderId}"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("DELETE"); int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); ``` ```go package main import ( "bytes" "net/http" ) func main() { data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("DELETE", "http://petstore.swagger.io/v2/store/order/{orderId}", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` `DELETE /store/order/{orderId}` *Delete purchase order by ID* For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors <h3 id="deleteorder-parameters">Parameters</h3> |Name|In|Type|Required|Description| |---|---|---|---|---| |orderId|path|integer(int64)|true|ID of the order that needs to be deleted| <h3 id="deleteorder-responses">Responses</h3> |Status|Meaning|Description|Schema| |---|---|---|---| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Invalid ID supplied|None| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Order not found|None| <aside class="success"> This operation does not require authentication </aside> <h1 id="swagger-petstore-user">user</h1> Operations about user <a href="http://swagger.io">Find out more about our store</a> ## createUser <a id="opIdcreateUser"></a> > Code samples ```shell # You can also use wget curl -X POST http://petstore.swagger.io/v2/user \ -H 'Content-Type: application/json' ``` ```http POST http://petstore.swagger.io/v2/user HTTP/1.1 Host: petstore.swagger.io Content-Type: application/json ``` ```javasc