shins
Version:
Shins Is Not Slate
1,308 lines (1,095 loc) • 191 kB
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Swagger Petstore v1.0.0</title>
<style>
</style>
<link rel="stylesheet" media="screen" href="pub/css/screen.css">
<link rel="stylesheet" media="print" href="pub/css/print.css">
<link rel="stylesheet" media="screen" href="pub/css/darkula.css">
<script src="source/javascripts/lib/_jquery.js"></script>
<script src="source/javascripts/lib/_jquery.highlight.js"></script>
<script src="source/javascripts/lib/_lunr.js"></script>
<script src="source/javascripts/lib/_imagesloaded.min.js"></script>
<script src="source/javascripts/lib/_energize.js"></script>
<script src="source/javascripts/app/_lang.js"></script>
<script src="source/javascripts/app/_search.js"></script>
<script src="source/javascripts/app/_toc.js"></script>
<script type="text/javascript">
$(function() {
loadToc($('#toc'), '.toc-link', '.toc-list-h2, .toc-list-h3, .toc-list-h4, .toc-list-h5, .toc-list-h6', 10);
setupLanguages($('body').data('languages'));
$('.content').imagesLoaded( function() {
recacheHeights();
refreshToc();
});
});
window.onpopstate = function() {
activateLanguage(getLanguageFromQueryString());
};
</script>
<!-- shins; content for the head element from source/includes/_head.md -->
<meta name="theme-color" content="#F3F7F9">
<!-- Renderer: Shins v2.4.1-0 -->
<!-- Generator: Widdershins v4.0.1 -->
<!-- backwards compatibility -->
<!-- backwards compatibility -->
<!-- backwards compatibility -->
<!-- backwards compatibility -->
<!-- backwards compatibility -->
<!-- backwards compatibility -->
</head>
<body data-languages="["shell","http","javascript","ruby","python","php","java","go"]">
<a href="#" id="nav-button">
<span>
NAV
<img src="source/images/navbar.png" class="undefined" alt="Navigation">
</span>
</a>
<div class="toc-wrapper">
<img src="source/images/logo.png" class="logo" alt="Logo">
<div class="lang-selector">
<a href="#" data-language-name="shell">Shell</a>
<a href="#" data-language-name="http">HTTP</a>
<a href="#" data-language-name="javascript">JavaScript</a>
<a href="#" data-language-name="ruby">Ruby</a>
<a href="#" data-language-name="python">Python</a>
<a href="#" data-language-name="php">PHP</a>
<a href="#" data-language-name="java">Java</a>
<a href="#" data-language-name="go">Go</a>
</div>
<div class="search">
<input type="text" class="search" id="input-search" placeholder="Search">
</div>
<ul class="search-results"></ul>
<div id="toc" class="toc-list-h1">
<ul class="toc-list-h1">
<li>
<a href="#swagger-petstore" class="toc-h1 toc-link" data-title="Swagger Petstore v1.0.0">Swagger Petstore v1.0.0</a>
</li>
<li>
<a href="#authentication" class="toc-h1 toc-link" data-title="Authentication">Authentication</a>
</li>
<li>
<a href="#swagger-petstore-pet" class="toc-h1 toc-link" data-title="pet">pet</a>
<ul class="toc-list-h2">
<li>
<a href="#addpet" class="toc-h2 toc-link" data-title="">addPet</a>
</li>
<li>
<a href="#updatepet" class="toc-h2 toc-link" data-title="">updatePet</a>
</li>
<li>
<a href="#findpetsbystatus" class="toc-h2 toc-link" data-title="">findPetsByStatus</a>
</li>
<li>
<a href="#findpetsbytags" class="toc-h2 toc-link" data-title="">findPetsByTags</a>
</li>
<li>
<a href="#getpetbyid" class="toc-h2 toc-link" data-title="">getPetById</a>
</li>
<li>
<a href="#updatepetwithform" class="toc-h2 toc-link" data-title="">updatePetWithForm</a>
</li>
<li>
<a href="#deletepet" class="toc-h2 toc-link" data-title="">deletePet</a>
</li>
<li>
<a href="#uploadfile" class="toc-h2 toc-link" data-title="">uploadFile</a>
</li>
</ul>
</li>
<li>
<a href="#swagger-petstore-store" class="toc-h1 toc-link" data-title="store">store</a>
<ul class="toc-list-h2">
<li>
<a href="#getinventory" class="toc-h2 toc-link" data-title="">getInventory</a>
</li>
<li>
<a href="#placeorder" class="toc-h2 toc-link" data-title="">placeOrder</a>
</li>
<li>
<a href="#getorderbyid" class="toc-h2 toc-link" data-title="">getOrderById</a>
</li>
<li>
<a href="#deleteorder" class="toc-h2 toc-link" data-title="">deleteOrder</a>
</li>
</ul>
</li>
<li>
<a href="#swagger-petstore-user" class="toc-h1 toc-link" data-title="user">user</a>
<ul class="toc-list-h2">
<li>
<a href="#createuser" class="toc-h2 toc-link" data-title="">createUser</a>
</li>
<li>
<a href="#createuserswitharrayinput" class="toc-h2 toc-link" data-title="">createUsersWithArrayInput</a>
</li>
<li>
<a href="#createuserswithlistinput" class="toc-h2 toc-link" data-title="">createUsersWithListInput</a>
</li>
<li>
<a href="#loginuser" class="toc-h2 toc-link" data-title="">loginUser</a>
</li>
<li>
<a href="#logoutuser" class="toc-h2 toc-link" data-title="">logoutUser</a>
</li>
<li>
<a href="#getuserbyname" class="toc-h2 toc-link" data-title="">getUserByName</a>
</li>
<li>
<a href="#updateuser" class="toc-h2 toc-link" data-title="">updateUser</a>
</li>
<li>
<a href="#deleteuser" class="toc-h2 toc-link" data-title="">deleteUser</a>
</li>
</ul>
</li>
<li>
<a href="#schemas" class="toc-h1 toc-link" data-title="Schemas">Schemas</a>
<ul class="toc-list-h2">
<li>
<a href="#tocs_order" class="toc-h2 toc-link" data-title="">Order</a>
</li>
<li>
<a href="#tocs_category" class="toc-h2 toc-link" data-title="">Category</a>
</li>
<li>
<a href="#tocs_user" class="toc-h2 toc-link" data-title="">User</a>
</li>
<li>
<a href="#tocs_tag" class="toc-h2 toc-link" data-title="">Tag</a>
</li>
<li>
<a href="#tocs_pet" class="toc-h2 toc-link" data-title="">Pet</a>
</li>
<li>
<a href="#tocs_apiresponse" class="toc-h2 toc-link" data-title="">ApiResponse</a>
</li>
</ul>
</li>
</ul>
</div>
<ul class="toc-footer">
<li><a href="https://mermade.github.io/shins/asyncapi.html">See AsyncAPI example</a></li>
</ul>
</div>
<div class="page-wrapper">
<div class="dark-box"></div>
<div class="content">
<!-- Generator: Widdershins v4.0.1 -->
<h1 id="swagger-petstore">Swagger Petstore v1.0.0</h1>
<blockquote>
<p>Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.</p>
</blockquote>
<p>🐶 🐱 🐰 This is a sample server Petstore server. You can find out more about Swagger at <a href="http://swagger.io">http://swagger.io</a> or on <a href="http://swagger.io/irc/">irc.freenode.net, #swagger</a>. For this sample, you can use the api key <code>special-key</code> to test the authorization filters.</p>
<p>Base URLs:</p>
<ul>
<li><a href="http://petstore.swagger.io/v2">http://petstore.swagger.io/v2</a></li>
</ul>
<p><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></p>
<h1 id="authentication">Authentication</h1>
<ul>
<li>
<p>oAuth2 authentication.</p>
<ul>
<li>Flow: implicit</li>
<li>Authorization URL = <a href="http://petstore.swagger.io/oauth/dialog">http://petstore.swagger.io/oauth/dialog</a></li>
</ul>
</li>
</ul>
<table>
<thead>
<tr>
<th>Scope</th>
<th>Scope Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>write:pets</td>
<td>modify pets in your account</td>
</tr>
<tr>
<td>read:pets</td>
<td>read your pets</td>
</tr>
</tbody>
</table>
<ul>
<li>API Key (api_key)
<ul>
<li>Parameter Name: <strong>api_key</strong>, in: header.</li>
</ul>
</li>
</ul>
<h1 id="swagger-petstore-pet">pet</h1>
<p>Everything about your Pets</p>
<p><a href="http://swagger.io">Find out more</a></p>
<h2 id="addpet">addPet</h2>
<p><a id="opIdaddPet"></a></p>
<blockquote>
<p>Code samples</p>
</blockquote>
<pre class="highlight tab tab-shell"><code><span class="hljs-comment"># You can also use wget</span>
curl -X POST http://petstore.swagger.io/v2/pet \
-H <span class="hljs-string">'Content-Type: application/json'</span> \
-H <span class="hljs-string">'Authorization: Bearer {access-token}'</span>
</code></pre>
<pre class="highlight tab tab-http"><code><span class="hljs-keyword">POST</span> <span class="hljs-string">http://petstore.swagger.io/v2/pet</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: petstore.swagger.io
<span class="hljs-attribute">Content-Type</span>: application/json
</code></pre>
<pre class="highlight tab tab-javascript"><code><span class="hljs-keyword">const</span> inputBody = <span class="hljs-string">'{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}'</span>;
<span class="hljs-keyword">const</span> headers = {
<span class="hljs-string">'Content-Type'</span>:<span class="hljs-string">'application/json'</span>,
<span class="hljs-string">'Authorization'</span>:<span class="hljs-string">'Bearer {access-token}'</span>
};
fetch(<span class="hljs-string">'http://petstore.swagger.io/v2/pet'</span>,
{
<span class="hljs-attr">method</span>: <span class="hljs-string">'POST'</span>,
<span class="hljs-attr">body</span>: inputBody,
<span class="hljs-attr">headers</span>: headers
})
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">res</span>) </span>{
<span class="hljs-keyword">return</span> res.json();
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">body</span>) </span>{
<span class="hljs-built_in">console</span>.log(body);
});
</code></pre>
<pre class="highlight tab tab-ruby"><code><span class="hljs-keyword">require</span> <span class="hljs-string">'rest-client'</span>
<span class="hljs-keyword">require</span> <span class="hljs-string">'json'</span>
headers = {
<span class="hljs-string">'Content-Type'</span> => <span class="hljs-string">'application/json'</span>,
<span class="hljs-string">'Authorization'</span> => <span class="hljs-string">'Bearer {access-token}'</span>
}
result = RestClient.post <span class="hljs-string">'http://petstore.swagger.io/v2/pet'</span>,
<span class="hljs-symbol">params:</span> {
}, <span class="hljs-symbol">headers:</span> headers
p JSON.parse(result)
</code></pre>
<pre class="highlight tab tab-python"><code><span class="hljs-keyword">import</span> requests
headers = {
<span class="hljs-string">'Content-Type'</span>: <span class="hljs-string">'application/json'</span>,
<span class="hljs-string">'Authorization'</span>: <span class="hljs-string">'Bearer {access-token}'</span>
}
r = requests.post(<span class="hljs-string">'http://petstore.swagger.io/v2/pet'</span>, headers = headers)
print(r.json())
</code></pre>
<pre class="highlight tab tab-php"><code><span class="hljs-meta"><?php</span>
<span class="hljs-keyword">require</span> <span class="hljs-string">'vendor/autoload.php'</span>;
$headers = <span class="hljs-keyword">array</span>(
<span class="hljs-string">'Content-Type'</span> => <span class="hljs-string">'application/json'</span>,
<span class="hljs-string">'Authorization'</span> => <span class="hljs-string">'Bearer {access-token}'</span>,
);
$client = <span class="hljs-keyword">new</span> \GuzzleHttp\Client();
<span class="hljs-comment">// Define array of request body.</span>
$request_body = <span class="hljs-keyword">array</span>();
<span class="hljs-keyword">try</span> {
$response = $client->request(<span class="hljs-string">'POST'</span>,<span class="hljs-string">'http://petstore.swagger.io/v2/pet'</span>, <span class="hljs-keyword">array</span>(
<span class="hljs-string">'headers'</span> => $headers,
<span class="hljs-string">'json'</span> => $request_body,
)
);
print_r($response->getBody()->getContents());
}
<span class="hljs-keyword">catch</span> (\GuzzleHttp\<span class="hljs-built_in">Exception</span>\BadResponseException $e) {
<span class="hljs-comment">// handle exception or api errors.</span>
print_r($e->getMessage());
}
<span class="hljs-comment">// ...</span>
</code></pre>
<pre class="highlight tab tab-java"><code>URL obj = <span class="hljs-keyword">new</span> URL(<span class="hljs-string">"http://petstore.swagger.io/v2/pet"</span>);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod(<span class="hljs-string">"POST"</span>);
<span class="hljs-keyword">int</span> responseCode = con.getResponseCode();
BufferedReader in = <span class="hljs-keyword">new</span> BufferedReader(
<span class="hljs-keyword">new</span> InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = <span class="hljs-keyword">new</span> StringBuffer();
<span class="hljs-keyword">while</span> ((inputLine = in.readLine()) != <span class="hljs-keyword">null</span>) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
</code></pre>
<pre class="highlight tab tab-go"><code><span class="hljs-keyword">package</span> main
<span class="hljs-keyword">import</span> (
<span class="hljs-string">"bytes"</span>
<span class="hljs-string">"net/http"</span>
)
<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
headers := <span class="hljs-keyword">map</span>[<span class="hljs-keyword">string</span>][]<span class="hljs-keyword">string</span>{
<span class="hljs-string">"Content-Type"</span>: []<span class="hljs-keyword">string</span>{<span class="hljs-string">"application/json"</span>},
<span class="hljs-string">"Authorization"</span>: []<span class="hljs-keyword">string</span>{<span class="hljs-string">"Bearer {access-token}"</span>},
}
data := bytes.NewBuffer([]<span class="hljs-keyword">byte</span>{jsonReq})
req, err := http.NewRequest(<span class="hljs-string">"POST"</span>, <span class="hljs-string">"http://petstore.swagger.io/v2/pet"</span>, data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
<span class="hljs-comment">// ...</span>
}
</code></pre>
<p><code>POST /pet</code></p>
<p><em>Add a new pet to the store</em></p>
<blockquote>
<p>Body parameter</p>
</blockquote>
<pre class="highlight tab tab-json"><code>{
<span class="hljs-attr">"id"</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">"category"</span>: {
<span class="hljs-attr">"id"</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"string"</span>
},
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"doggie"</span>,
<span class="hljs-attr">"photoUrls"</span>: [
<span class="hljs-string">"string"</span>
],
<span class="hljs-attr">"tags"</span>: [
{
<span class="hljs-attr">"id"</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"string"</span>
}
],
<span class="hljs-attr">"status"</span>: <span class="hljs-string">"available"</span>
}
</code></pre>
<pre class="highlight tab tab-xml"><code><span class="hljs-meta"><?xml version="1.0" encoding="UTF-8" ?></span>
<span class="hljs-tag"><<span class="hljs-name">Pet</span>></span>
<span class="hljs-tag"><<span class="hljs-name">id</span>></span>0<span class="hljs-tag"></<span class="hljs-name">id</span>></span>
<span class="hljs-tag"><<span class="hljs-name">category</span>></span>
<span class="hljs-tag"><<span class="hljs-name">id</span>></span>0<span class="hljs-tag"></<span class="hljs-name">id</span>></span>
<span class="hljs-tag"><<span class="hljs-name">name</span>></span>string<span class="hljs-tag"></<span class="hljs-name">name</span>></span>
<span class="hljs-tag"></<span class="hljs-name">category</span>></span>
<span class="hljs-tag"><<span class="hljs-name">name</span>></span>doggie<span class="hljs-tag"></<span class="hljs-name">name</span>></span>
<span class="hljs-tag"><<span class="hljs-name">photoUrls</span>></span>string<span class="hljs-tag"></<span class="hljs-name">photoUrls</span>></span>
<span class="hljs-tag"><<span class="hljs-name">tags</span>></span>
<span class="hljs-tag"><<span class="hljs-name">id</span>></span>0<span class="hljs-tag"></<span class="hljs-name">id</span>></span>
<span class="hljs-tag"><<span class="hljs-name">name</span>></span>string<span class="hljs-tag"></<span class="hljs-name">name</span>></span>
<span class="hljs-tag"></<span class="hljs-name">tags</span>></span>
<span class="hljs-tag"><<span class="hljs-name">status</span>></span>available<span class="hljs-tag"></<span class="hljs-name">status</span>></span>
<span class="hljs-tag"></<span class="hljs-name">Pet</span>></span>
</code></pre>
<h3 id="addpet-parameters">Parameters</h3>
<table>
<thead>
<tr>
<th>Name</th>
<th>In</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>body</td>
<td>body</td>
<td><a href="#schemapet">Pet</a></td>
<td>true</td>
<td>Pet object that needs to be added to the store</td>
</tr>
</tbody>
</table>
<h3 id="addpet-responses">Responses</h3>
<table>
<thead>
<tr>
<th>Status</th>
<th>Meaning</th>
<th>Description</th>
<th>Schema</th>
</tr>
</thead>
<tbody>
<tr>
<td>405</td>
<td><a href="https://tools.ietf.org/html/rfc7231#section-6.5.5">Method Not Allowed</a></td>
<td>Invalid input</td>
<td>None</td>
</tr>
</tbody>
</table>
<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>
<h2 id="updatepet">updatePet</h2>
<p><a id="opIdupdatePet"></a></p>
<blockquote>
<p>Code samples</p>
</blockquote>
<pre class="highlight tab tab-shell"><code><span class="hljs-comment"># You can also use wget</span>
curl -X PUT http://petstore.swagger.io/v2/pet \
-H <span class="hljs-string">'Content-Type: application/json'</span> \
-H <span class="hljs-string">'Authorization: Bearer {access-token}'</span>
</code></pre>
<pre class="highlight tab tab-http"><code><span class="hljs-keyword">PUT</span> <span class="hljs-string">http://petstore.swagger.io/v2/pet</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: petstore.swagger.io
<span class="hljs-attribute">Content-Type</span>: application/json
</code></pre>
<pre class="highlight tab tab-javascript"><code><span class="hljs-keyword">const</span> inputBody = <span class="hljs-string">'{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}'</span>;
<span class="hljs-keyword">const</span> headers = {
<span class="hljs-string">'Content-Type'</span>:<span class="hljs-string">'application/json'</span>,
<span class="hljs-string">'Authorization'</span>:<span class="hljs-string">'Bearer {access-token}'</span>
};
fetch(<span class="hljs-string">'http://petstore.swagger.io/v2/pet'</span>,
{
<span class="hljs-attr">method</span>: <span class="hljs-string">'PUT'</span>,
<span class="hljs-attr">body</span>: inputBody,
<span class="hljs-attr">headers</span>: headers
})
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">res</span>) </span>{
<span class="hljs-keyword">return</span> res.json();
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">body</span>) </span>{
<span class="hljs-built_in">console</span>.log(body);
});
</code></pre>
<pre class="highlight tab tab-ruby"><code><span class="hljs-keyword">require</span> <span class="hljs-string">'rest-client'</span>
<span class="hljs-keyword">require</span> <span class="hljs-string">'json'</span>
headers = {
<span class="hljs-string">'Content-Type'</span> => <span class="hljs-string">'application/json'</span>,
<span class="hljs-string">'Authorization'</span> => <span class="hljs-string">'Bearer {access-token}'</span>
}
result = RestClient.put <span class="hljs-string">'http://petstore.swagger.io/v2/pet'</span>,
<span class="hljs-symbol">params:</span> {
}, <span class="hljs-symbol">headers:</span> headers
p JSON.parse(result)
</code></pre>
<pre class="highlight tab tab-python"><code><span class="hljs-keyword">import</span> requests
headers = {
<span class="hljs-string">'Content-Type'</span>: <span class="hljs-string">'application/json'</span>,
<span class="hljs-string">'Authorization'</span>: <span class="hljs-string">'Bearer {access-token}'</span>
}
r = requests.put(<span class="hljs-string">'http://petstore.swagger.io/v2/pet'</span>, headers = headers)
print(r.json())
</code></pre>
<pre class="highlight tab tab-php"><code><span class="hljs-meta"><?php</span>
<span class="hljs-keyword">require</span> <span class="hljs-string">'vendor/autoload.php'</span>;
$headers = <span class="hljs-keyword">array</span>(
<span class="hljs-string">'Content-Type'</span> => <span class="hljs-string">'application/json'</span>,
<span class="hljs-string">'Authorization'</span> => <span class="hljs-string">'Bearer {access-token}'</span>,
);
$client = <span class="hljs-keyword">new</span> \GuzzleHttp\Client();
<span class="hljs-comment">// Define array of request body.</span>
$request_body = <span class="hljs-keyword">array</span>();
<span class="hljs-keyword">try</span> {
$response = $client->request(<span class="hljs-string">'PUT'</span>,<span class="hljs-string">'http://petstore.swagger.io/v2/pet'</span>, <span class="hljs-keyword">array</span>(
<span class="hljs-string">'headers'</span> => $headers,
<span class="hljs-string">'json'</span> => $request_body,
)
);
print_r($response->getBody()->getContents());
}
<span class="hljs-keyword">catch</span> (\GuzzleHttp\<span class="hljs-built_in">Exception</span>\BadResponseException $e) {
<span class="hljs-comment">// handle exception or api errors.</span>
print_r($e->getMessage());
}
<span class="hljs-comment">// ...</span>
</code></pre>
<pre class="highlight tab tab-java"><code>URL obj = <span class="hljs-keyword">new</span> URL(<span class="hljs-string">"http://petstore.swagger.io/v2/pet"</span>);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod(<span class="hljs-string">"PUT"</span>);
<span class="hljs-keyword">int</span> responseCode = con.getResponseCode();
BufferedReader in = <span class="hljs-keyword">new</span> BufferedReader(
<span class="hljs-keyword">new</span> InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = <span class="hljs-keyword">new</span> StringBuffer();
<span class="hljs-keyword">while</span> ((inputLine = in.readLine()) != <span class="hljs-keyword">null</span>) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
</code></pre>
<pre class="highlight tab tab-go"><code><span class="hljs-keyword">package</span> main
<span class="hljs-keyword">import</span> (
<span class="hljs-string">"bytes"</span>
<span class="hljs-string">"net/http"</span>
)
<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
headers := <span class="hljs-keyword">map</span>[<span class="hljs-keyword">string</span>][]<span class="hljs-keyword">string</span>{
<span class="hljs-string">"Content-Type"</span>: []<span class="hljs-keyword">string</span>{<span class="hljs-string">"application/json"</span>},
<span class="hljs-string">"Authorization"</span>: []<span class="hljs-keyword">string</span>{<span class="hljs-string">"Bearer {access-token}"</span>},
}
data := bytes.NewBuffer([]<span class="hljs-keyword">byte</span>{jsonReq})
req, err := http.NewRequest(<span class="hljs-string">"PUT"</span>, <span class="hljs-string">"http://petstore.swagger.io/v2/pet"</span>, data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
<span class="hljs-comment">// ...</span>
}
</code></pre>
<p><code>PUT /pet</code></p>
<p><em>Update an existing pet</em></p>
<blockquote>
<p>Body parameter</p>
</blockquote>
<pre class="highlight tab tab-json"><code>{
<span class="hljs-attr">"id"</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">"category"</span>: {
<span class="hljs-attr">"id"</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"string"</span>
},
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"doggie"</span>,
<span class="hljs-attr">"photoUrls"</span>: [
<span class="hljs-string">"string"</span>
],
<span class="hljs-attr">"tags"</span>: [
{
<span class="hljs-attr">"id"</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"string"</span>
}
],
<span class="hljs-attr">"status"</span>: <span class="hljs-string">"available"</span>
}
</code></pre>
<pre class="highlight tab tab-xml"><code><span class="hljs-meta"><?xml version="1.0" encoding="UTF-8" ?></span>
<span class="hljs-tag"><<span class="hljs-name">Pet</span>></span>
<span class="hljs-tag"><<span class="hljs-name">id</span>></span>0<span class="hljs-tag"></<span class="hljs-name">id</span>></span>
<span class="hljs-tag"><<span class="hljs-name">category</span>></span>
<span class="hljs-tag"><<span class="hljs-name">id</span>></span>0<span class="hljs-tag"></<span class="hljs-name">id</span>></span>
<span class="hljs-tag"><<span class="hljs-name">name</span>></span>string<span class="hljs-tag"></<span class="hljs-name">name</span>></span>
<span class="hljs-tag"></<span class="hljs-name">category</span>></span>
<span class="hljs-tag"><<span class="hljs-name">name</span>></span>doggie<span class="hljs-tag"></<span class="hljs-name">name</span>></span>
<span class="hljs-tag"><<span class="hljs-name">photoUrls</span>></span>string<span class="hljs-tag"></<span class="hljs-name">photoUrls</span>></span>
<span class="hljs-tag"><<span class="hljs-name">tags</span>></span>
<span class="hljs-tag"><<span class="hljs-name">id</span>></span>0<span class="hljs-tag"></<span class="hljs-name">id</span>></span>
<span class="hljs-tag"><<span class="hljs-name">name</span>></span>string<span class="hljs-tag"></<span class="hljs-name">name</span>></span>
<span class="hljs-tag"></<span class="hljs-name">tags</span>></span>
<span class="hljs-tag"><<span class="hljs-name">status</span>></span>available<span class="hljs-tag"></<span class="hljs-name">status</span>></span>
<span class="hljs-tag"></<span class="hljs-name">Pet</span>></span>
</code></pre>
<h3 id="updatepet-parameters">Parameters</h3>
<table>
<thead>
<tr>
<th>Name</th>
<th>In</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>body</td>
<td>body</td>
<td><a href="#schemapet">Pet</a></td>
<td>true</td>
<td>Pet object that needs to be added to the store</td>
</tr>
</tbody>
</table>
<h3 id="updatepet-responses">Responses</h3>
<table>
<thead>
<tr>
<th>Status</th>
<th>Meaning</th>
<th>Description</th>
<th>Schema</th>
</tr>
</thead>
<tbody>
<tr>
<td>400</td>
<td><a href="https://tools.ietf.org/html/rfc7231#section-6.5.1">Bad Request</a></td>
<td>Invalid ID supplied</td>
<td>None</td>
</tr>
<tr>
<td>404</td>
<td><a href="https://tools.ietf.org/html/rfc7231#section-6.5.4">Not Found</a></td>
<td>Pet not found</td>
<td>None</td>
</tr>
<tr>
<td>405</td>
<td><a href="https://tools.ietf.org/html/rfc7231#section-6.5.5">Method Not Allowed</a></td>
<td>Validation exception</td>
<td>None</td>
</tr>
</tbody>
</table>
<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>
<h2 id="findpetsbystatus">findPetsByStatus</h2>
<p><a id="opIdfindPetsByStatus"></a></p>
<blockquote>
<p>Code samples</p>
</blockquote>
<pre class="highlight tab tab-shell"><code><span class="hljs-comment"># You can also use wget</span>
curl -X GET http://petstore.swagger.io/v2/pet/findByStatus?status=available \
-H <span class="hljs-string">'Accept: application/xml'</span> \
-H <span class="hljs-string">'Authorization: Bearer {access-token}'</span>
</code></pre>
<pre class="highlight tab tab-http"><code><span class="hljs-keyword">GET</span> <span class="hljs-string">http://petstore.swagger.io/v2/pet/findByStatus?status=available</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: petstore.swagger.io
<span class="hljs-attribute">Accept</span>: application/xml
</code></pre>
<pre class="highlight tab tab-javascript"><code>
<span class="hljs-keyword">const</span> headers = {
<span class="hljs-string">'Accept'</span>:<span class="hljs-string">'application/xml'</span>,
<span class="hljs-string">'Authorization'</span>:<span class="hljs-string">'Bearer {access-token}'</span>
};
fetch(<span class="hljs-string">'http://petstore.swagger.io/v2/pet/findByStatus?status=available'</span>,
{
<span class="hljs-attr">method</span>: <span class="hljs-string">'GET'</span>,
<span class="hljs-attr">headers</span>: headers
})
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">res</span>) </span>{
<span class="hljs-keyword">return</span> res.json();
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">body</span>) </span>{
<span class="hljs-built_in">console</span>.log(body);
});
</code></pre>
<pre class="highlight tab tab-ruby"><code><span class="hljs-keyword">require</span> <span class="hljs-string">'rest-client'</span>
<span class="hljs-keyword">require</span> <span class="hljs-string">'json'</span>
headers = {
<span class="hljs-string">'Accept'</span> => <span class="hljs-string">'application/xml'</span>,
<span class="hljs-string">'Authorization'</span> => <span class="hljs-string">'Bearer {access-token}'</span>
}
result = RestClient.get <span class="hljs-string">'http://petstore.swagger.io/v2/pet/findByStatus'</span>,
<span class="hljs-symbol">params:</span> {
<span class="hljs-string">'status'</span> => <span class="hljs-string">'array[string]'</span>
}, <span class="hljs-symbol">headers:</span> headers
p JSON.parse(result)
</code></pre>
<pre class="highlight tab tab-python"><code><span class="hljs-keyword">import</span> requests
headers = {
<span class="hljs-string">'Accept'</span>: <span class="hljs-string">'application/xml'</span>,
<span class="hljs-string">'Authorization'</span>: <span class="hljs-string">'Bearer {access-token}'</span>
}
r = requests.get(<span class="hljs-string">'http://petstore.swagger.io/v2/pet/findByStatus'</span>, params={
<span class="hljs-string">'status'</span>: [
<span class="hljs-string">"available"</span>
]
}, headers = headers)
print(r.json())
</code></pre>
<pre class="highlight tab tab-php"><code><span class="hljs-meta"><?php</span>
<span class="hljs-keyword">require</span> <span class="hljs-string">'vendor/autoload.php'</span>;
$headers = <span class="hljs-keyword">array</span>(
<span class="hljs-string">'Accept'</span> => <span class="hljs-string">'application/xml'</span>,
<span class="hljs-string">'Authorization'</span> => <span class="hljs-string">'Bearer {access-token}'</span>,
);
$client = <span class="hljs-keyword">new</span> \GuzzleHttp\Client();
<span class="hljs-comment">// Define array of request body.</span>
$request_body = <span class="hljs-keyword">array</span>();
<span class="hljs-keyword">try</span> {
$response = $client->request(<span class="hljs-string">'GET'</span>,<span class="hljs-string">'http://petstore.swagger.io/v2/pet/findByStatus'</span>, <span class="hljs-keyword">array</span>(
<span class="hljs-string">'headers'</span> => $headers,
<span class="hljs-string">'json'</span> => $request_body,
)
);
print_r($response->getBody()->getContents());
}
<span class="hljs-keyword">catch</span> (\GuzzleHttp\<span class="hljs-built_in">Exception</span>\BadResponseException $e) {
<span class="hljs-comment">// handle exception or api errors.</span>
print_r($e->getMessage());
}
<span class="hljs-comment">// ...</span>
</code></pre>
<pre class="highlight tab tab-java"><code>URL obj = <span class="hljs-keyword">new</span> URL(<span class="hljs-string">"http://petstore.swagger.io/v2/pet/findByStatus?status=available"</span>);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod(<span class="hljs-string">"GET"</span>);
<span class="hljs-keyword">int</span> responseCode = con.getResponseCode();
BufferedReader in = <span class="hljs-keyword">new</span> BufferedReader(
<span class="hljs-keyword">new</span> InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = <span class="hljs-keyword">new</span> StringBuffer();
<span class="hljs-keyword">while</span> ((inputLine = in.readLine()) != <span class="hljs-keyword">null</span>) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
</code></pre>
<pre class="highlight tab tab-go"><code><span class="hljs-keyword">package</span> main
<span class="hljs-keyword">import</span> (
<span class="hljs-string">"bytes"</span>
<span class="hljs-string">"net/http"</span>
)
<span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span> {
headers := <span class="hljs-keyword">map</span>[<span class="hljs-keyword">string</span>][]<span class="hljs-keyword">string</span>{
<span class="hljs-string">"Accept"</span>: []<span class="hljs-keyword">string</span>{<span class="hljs-string">"application/xml"</span>},
<span class="hljs-string">"Authorization"</span>: []<span class="hljs-keyword">string</span>{<span class="hljs-string">"Bearer {access-token}"</span>},
}
data := bytes.NewBuffer([]<span class="hljs-keyword">byte</span>{jsonReq})
req, err := http.NewRequest(<span class="hljs-string">"GET"</span>, <span class="hljs-string">"http://petstore.swagger.io/v2/pet/findByStatus"</span>, data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
<span class="hljs-comment">// ...</span>
}
</code></pre>
<p><code>GET /pet/findByStatus</code></p>
<p><em>Finds Pets by status</em></p>
<p>Multiple status values can be provided with comma separated strings</p>
<h3 id="findpetsbystatus-parameters">Parameters</h3>
<table>
<thead>
<tr>
<th>Name</th>
<th>In</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>status</td>
<td>query</td>
<td>array[string]</td>
<td>true</td>
<td>Status values that need to be considered for filter</td>
</tr>
</tbody>
</table>
<h4 id="enumerated-values">Enumerated Values</h4>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>status</td>
<td>available</td>
</tr>
<tr>
<td>status</td>
<td>pending</td>
</tr>
<tr>
<td>status</td>
<td>sold</td>
</tr>
</tbody>
</table>
<blockquote>
<p>Example responses</p>
</blockquote>
<blockquote>
<p>200 Response</p>
</blockquote>
<pre class="highlight tab tab-xml"><code><span class="hljs-meta"><?xml version="1.0" encoding="UTF-8" ?></span>
<span class="hljs-tag"><<span class="hljs-name">id</span>></span>0<span class="hljs-tag"></<span class="hljs-name">id</span>></span>
<span class="hljs-tag"><<span class="hljs-name">category</span>></span>
<span class="hljs-tag"><<span class="hljs-name">id</span>></span>0<span class="hljs-tag"></<span class="hljs-name">id</span>></span>
<span class="hljs-tag"><<span class="hljs-name">name</span>></span>string<span class="hljs-tag"></<span class="hljs-name">name</span>></span>
<span class="hljs-tag"></<span class="hljs-name">category</span>></span>
<span class="hljs-tag"><<span class="hljs-name">name</span>></span>doggie<span class="hljs-tag"></<span class="hljs-name">name</span>></span>
<span class="hljs-tag"><<span class="hljs-name">photoUrls</span>></span>string<span class="hljs-tag"></<span class="hljs-name">photoUrls</span>></span>
<span class="hljs-tag"><<span class="hljs-name">tags</span>></span>
<span class="hljs-tag"><<span class="hljs-name">id</span>></span>0<span class="hljs-tag"></<span class="hljs-name">id</span>></span>
<span class="hljs-tag"><<span class="hljs-name">name</span>></span>string<span class="hljs-tag"></<span class="hljs-name">name</span>></span>
<span class="hljs-tag"></<span class="hljs-name">tags</span>></span>
<span class="hljs-tag"><<span class="hljs-name">status</span>></span>available<span class="hljs-tag"></<span class="hljs-name">status</span>></span>
</code></pre>
<pre class="highlight tab tab-json"><code>[
{
<span class="hljs-attr">"id"</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">"category"</span>: {
<span class="hljs-attr">"id"</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"string"</span>
},
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"doggie"</span>,
<span class="hljs-attr">"photoUrls"</span>: [
<span class="hljs-string">"string"</span>
],
<span class="hljs-attr">"tags"</span>: [
{
<span class="hljs-attr">"id"</span>: <span class="hljs-number">0</span>,
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"string"</span>
}
],
<span class="hljs-attr">"status"</span>: <span class="hljs-string">"available"</span>
}
]
</code></pre>
<h3 id="findpetsbystatus-responses">Responses</h3>
<table>
<thead>
<tr>
<th>Status</th>
<th>Meaning</th>
<th>Description</th>
<th>Schema</th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td><a href="https://tools.ietf.org/html/rfc7231#section-6.3.1">OK</a></td>
<td>successful operation</td>
<td>Inline</td>
</tr>
<tr>
<td>400</td>
<td><a href="https://tools.ietf.org/html/rfc7231#section-6.5.1">Bad Request</a></td>
<td>Invalid status value</td>
<td>None</td>
</tr>
</tbody>
</table>
<h3 id="findpetsbystatus-responseschema">Response Schema</h3>
<p>Status Code <strong>200</strong></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Required</th>
<th>Restrictions</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><em>anonymous</em></td>
<td>[<a href="#schemapet">Pet</a>]</td>
<td>false</td>
<td>none</td>
<td>none</td>
</tr>
<tr>
<td>» id</td>
<td>integer(int64)</td>
<td>false</td>
<td>none</td>
<td>none</td>
</tr>
<tr>
<td>» category</td>
<td><a href="#schemacategory">Category</a></td>
<td>false</td>
<td>none</td>
<td>none</td>
</tr>
<tr>
<td>»» id</td>
<td>integer(int64)</td>
<td>false</td>
<td>none</td>
<td>none</td>
</tr>
<tr>
<td>»» name</td>
<td>string</td>
<td>false</td>
<td>none</td>
<td>none</td>
</tr>
<tr>
<td>» name</td>
<td>string</td>
<td>true</td>
<td>none</td>
<td>none</td>
</tr>
<tr>
<td>» photoUrls</td>
<td>[string]</td>
<td>true</td>
<td>none</td>
<td>none</td>
</tr>
<tr>
<td>» tags</td>
<td>[<a href="#schematag">Tag</a>]</td>
<td>false</td>
<td>none</td>
<td>none</td>
</tr>
<tr>
<td>»» id</td>
<td>integer(int64)</td>
<td>false</td>
<td>none</td>
<td>none</td>
</tr>
<tr>
<td>»» name</td>
<td>string</td>
<td>false</td>
<td>none</td>
<td>none</td>
</tr>
<tr>
<td>» status</td>
<td>string</td>
<td>false</td>
<td>none</td>
<td>pet status in the store</td>
</tr>
</tbody>
</table>
<h4 id="enumerated-values-2">Enumerated Values</h4>
<table>
<thead>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>status</td>
<td>available</td>
</tr>
<tr>
<td>status</td>
<td>pending</td>
</tr>
<tr>
<td>status</td>
<td>sold</td>
</tr>
</tbody>
</table>
<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>
<h2 id="findpetsbytags">findPetsByTags</h2>
<p><a id="opIdfindPetsByTags"></a></p>
<blockquote>
<p>Code samples</p>
</blockquote>
<pre class="highlight tab tab-shell"><code><span class="hljs-comment"># You can also use wget</span>
curl -X GET http://petstore.swagger.io/v2/pet/findByTags?tags=string \
-H <span class="hljs-string">'Accept: application/xml'</span> \
-H <span class="hljs-string">'Authorization: Bearer {access-token}'</span>
</code></pre>
<pre class="highlight tab tab-http"><code><span class="hljs-keyword">GET</span> <span class="hljs-string">http://petstore.swagger.io/v2/pet/findByTags?tags=string</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: petstore.swagger.io
<span class="hljs-attribute">Accept</span>: application/xml
</code></pre>
<pre class="highlight tab tab-javascript"><code>
<span class="hljs-keyword">const</span> headers = {
<span class="hljs-string">'Accept'</span>:<span class="hljs-string">'application/xml'</span>,
<span class="hljs-string">'Authorization'</span>:<span class="hljs-string">'Bearer {access-token}'</span>
};
fetch(<span class="hljs-string">'http://petstore.swagger.io/v2/pet/findByTags?tags=string'</span>,
{
<span class="hljs-attr">method</span>: <span class="hljs-string">'GET'</span>,
<span class="hljs-attr">headers</span>: headers
})
.then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">res</span>) </span>{
<span class="hljs-keyword">return</span> res.json();
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">body</span>) </span>{
<span class="hljs-built_in">console</span>.log(body);
});
</code></pre>
<pre class="highlight tab tab-ruby"><code><span class="hljs-keyword">require</span> <span class="hljs-string">'rest-client'</span>
<span class="hljs-keyword">require</span> <span class="hljs-string">'json'</span>
headers = {
<span class="hljs-string">'Accept'</span> => <span class="hljs-string">'application/xml'</span>,
<span class="hljs-string">'Authorization'</span> => <span class="hljs-string">'Bearer {access-token}'</span>
}
result = RestClient.get <span class="hljs-string">'http://petstore.swagger.io/v2/pet/findByTags'</span>,
<span class="hljs-symbol">params:</span> {
<span class="hljs-string">'tags'</span> => <span class="hljs-string">'array[string]'</span>
}, <span class="hljs-symbol">headers:</span> headers
p JSON.parse(result)
</code></pre>
<pre class="highlight tab tab-python"><code><span class="hljs-keyword">import</span> requests
headers = {
<span class="hljs-string">'Accept'</span>: <span class="hljs-string">'application/xml'</span>,
<span class="hljs-string">'Authorization'</span>: <span class="hljs-string">'Bearer {access-token}'</span>
}
r = requests.get(<span class="hljs-string">'http://petstore.swagger.io/v2/pet/findByTags'</span>, params={
<span class="hljs-string">'tags'</span>: [
<span class="hljs-string">"string"</span>
]
}, headers = headers)
print(r.json())
</code></pre>
<pre class="highlight tab tab-php"><code><span class="hljs-meta"><?php</span>
<span class="hljs-keyword">require</span> <span class="hljs-string">'vendor/autoload.php'</span>;
$headers = <span class="hljs-keyword">array</span>(
<span class="hljs-string">'Accept'</span> => <span class="hljs-string">'application/xml'</span>,
<span class="hljs-string">'Authorization'</span> => <span class="hljs-string">'Bearer {access-token}'</span>,
);
$client = <span class="hljs-keyword">new</span> \GuzzleHttp\Client();
<span class="hljs-comment">// Define array of request body.</span>
$request_body = <span class="hljs-keyword">array</span>();
<span class="hljs-keyword">try</span> {
$response = $client->request(<span class="hljs-string">'GET'</span>,<span class="hljs-string">'http://petstore.swagger.io/v2/pet/findByTags'</span>, <span class="hljs-keyword">array</span>(
<span class="hljs-string">'headers'</span> => $headers,
<span class="hljs-string">'json'</span> => $request_body,
)
);
print_r($response->getBody()->getContents());
}
<span class="hljs-keyword">catch</span> (\GuzzleHttp\<span class="hljs-built_in">Exception</span>\BadResponseException $e) {
<span class="hljs-comment">// handle exception or api errors.</span>
print_r($e->getMessage());
}
<span class="hljs-comment">// ...</span>
</code></pre>
<pre class="highlight tab tab-java"><code>URL obj = <span class="hljs-keyword">new</span> URL(<span class="hljs-string">"http://petstore.swagger.io/v2/pet/findByTags?tags=string"</span>);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod(<span class="hljs-string">"GET"</span>);
<span class="hljs-keyword">int</span> responseCode = con.getResponseCode();
BufferedReader in = <span class="hljs-keyword">new</span> BufferedReader(
<span class="hljs-keyword">new</span> InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = <span class="hljs-keyword">new</span> StringBuffer();
<span class="hljs-keyword">while</span> ((inputLine = in.readLine()) != <span class="hljs-keyword">null</span>) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
</code></pre>
<pre class="highlight tab tab-go"><code><span class="hljs-keyword">package</span> main
<span class="hljs-keyword">import</span> (
<span class="hljs-string">"bytes"</span>
<span class="hljs-string">"net/http"</span>
)
<span class="hljs-function"><span class="hljs-keyword">fu