v1.0.0
Example of an OpenAPI document with security
This is an example of an OpenAPI document with security definitions and security requirements.
Servers
https://localhost:3000Local server
Default
ID: onlyApiKey
GET /onlyApiKey
GET
/onlyApiKeyAuthorizations
apiKey
TypeAPI Key (header: api_key)
GET
/onlyApiKeySamples
get {
url: https://localhost:3000/onlyApiKey
}
headers {
Content-Type: application/json
}
get {
url: https://localhost:3000/onlyApiKey
}
headers {
Content-Type: application/json
}
curl -X GET \
'https://localhost:3000/onlyApiKey' \
-H "Content-Type: application/json"
fetch('https://localhost:3000/onlyApiKey', {headers:{'Content-Type':'application/json'}})
.then(response => response.json())
.then(data => console.log(data));
<?php
$url = 'https://localhost:3000/onlyApiKey';
$method = 'GET';
$headers = [
'Content-Type' => 'application/json',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import requests
url = 'https://localhost:3000/onlyApiKey'
headers = {
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
print(response.json())
ID: onlyBearerAuth
POST /onlyBearerAuth
POST
/onlyBearerAuthAuthorizations
bearerAuth
TypeHTTP (bearer)
POST
/onlyBearerAuthSamples
post {
url: https://localhost:3000/onlyBearerAuth
}
headers {
Content-Type: application/json
}
post {
url: https://localhost:3000/onlyBearerAuth
}
headers {
Content-Type: application/json
}
curl -X POST \
'https://localhost:3000/onlyBearerAuth' \
-H "Content-Type: application/json"
fetch('https://localhost:3000/onlyBearerAuth', {method:'POST',headers:{'Content-Type':'application/json'}})
.then(response => response.json())
.then(data => console.log(data));
<?php
$url = 'https://localhost:3000/onlyBearerAuth';
$method = 'POST';
$headers = [
'Content-Type' => 'application/json',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import requests
url = 'https://localhost:3000/onlyBearerAuth'
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers)
print(response.json())
ID: apiKeyAndBearerAuth
PUT /apiKeyAndBearerAuth
PUT
/apiKeyAndBearerAuthAuthorizations
apiKey
TypeAPI Key (header: api_key)
bearerAuth
TypeHTTP (bearer)
Parameters
Header Parameters
headerParam*
Header parameter description
Typestring
RequiredExample
value
PUT
/apiKeyAndBearerAuthSamples
put {
url: https://localhost:3000/apiKeyAndBearerAuth
}
headers {
Content-Type: application/json
headerparam: value
}
put {
url: https://localhost:3000/apiKeyAndBearerAuth
}
headers {
Content-Type: application/json
headerparam: value
}
curl -X PUT \
'https://localhost:3000/apiKeyAndBearerAuth' \
-H "Content-Type: application/json" \
-H "headerparam: value"
fetch('https://localhost:3000/apiKeyAndBearerAuth', {method:'PUT',headers:{'Content-Type':'application/json','headerparam':'value'}})
.then(response => response.json())
.then(data => console.log(data));
<?php
$url = 'https://localhost:3000/apiKeyAndBearerAuth';
$method = 'PUT';
$headers = [
'Content-Type' => 'application/json',
'headerparam' => 'value',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import requests
url = 'https://localhost:3000/apiKeyAndBearerAuth'
headers = {
'Content-Type': 'application/json',
'headerparam': 'value'
}
response = requests.put(url, headers=headers)
print(response.json())
ID: apiKeyOrBearerAuth
GET /apiKeyOrBearerAuth/{pathParam}
GET
/apiKeyOrBearerAuth/{pathParam}Authorizations
apiKey
TypeAPI Key (header: api_key)
or
bearerAuth
TypeHTTP (bearer)
Parameters
Path Parameters
pathParam*
Path parameter description
Typestring
RequiredGET
/apiKeyOrBearerAuth/{pathParam}Samples
get {
url: https://localhost:3000/apiKeyOrBearerAuth/{pathParam}
}
headers {
Content-Type: application/json
}
get {
url: https://localhost:3000/apiKeyOrBearerAuth/{pathParam}
}
headers {
Content-Type: application/json
}
curl -X GET \
'https://localhost:3000/apiKeyOrBearerAuth/{pathParam}' \
-H "Content-Type: application/json"
fetch('https://localhost:3000/apiKeyOrBearerAuth/{pathParam}', {headers:{'Content-Type':'application/json'}})
.then(response => response.json())
.then(data => console.log(data));
<?php
$url = 'https://localhost:3000/apiKeyOrBearerAuth/{pathParam}';
$method = 'GET';
$headers = [
'Content-Type' => 'application/json',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import requests
url = 'https://localhost:3000/apiKeyOrBearerAuth/{pathParam}'
headers = {
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
print(response.json())
ID: noSecurity
GET /noSecurity
GET
/noSecurityGET
/noSecuritySamples
get {
url: https://localhost:3000/noSecurity
}
headers {
Content-Type: application/json
}
get {
url: https://localhost:3000/noSecurity
}
headers {
Content-Type: application/json
}
curl -X GET \
'https://localhost:3000/noSecurity' \
-H "Content-Type: application/json"
fetch('https://localhost:3000/noSecurity', {headers:{'Content-Type':'application/json'}})
.then(response => response.json())
.then(data => console.log(data));
<?php
$url = 'https://localhost:3000/noSecurity';
$method = 'GET';
$headers = [
'Content-Type' => 'application/json',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import requests
url = 'https://localhost:3000/noSecurity'
headers = {
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
print(response.json())
ID: multipleSecurity
POST /multipleSecurity/{pathParam}
POST
/multipleSecurity/{pathParam}Authorizations
apiKey|bearerAuth +
apiKey
TypeAPI Key (header: api_key)
bearerAuth
TypeHTTP (bearer)
or
basicAuth|internalApiKey +
basicAuth
Basic authentication with username and password
TypeHTTP (basic)
internalApiKey
Internal API key for special customers
TypeAPI Key (header: internal_api_key)
Example
special-key
Parameters
Path Parameters
pathParam*
Path parameter description
Typestring
RequiredQuery Parameters
param1*
Query parameter description
Typestring
RequiredEnum
value1
value2
default
value1
param2*
Another query parameter description
Typestring
RequiredRequest Body
{
"prop1": "string",
"prop2": 0,
"prop3": [
[
"value1",
"value2"
]
]
}
POST
/multipleSecurity/{pathParam}Samples
post {
url: https://localhost:3000/multipleSecurity/{pathParam}
}
headers {
Content-Type: application/json
}
post {
url: https://localhost:3000/multipleSecurity/{pathParam}
}
headers {
Content-Type: application/json
}
curl -X POST \
'https://localhost:3000/multipleSecurity/{pathParam}' \
-H "Content-Type: application/json"
fetch('https://localhost:3000/multipleSecurity/{pathParam}', {method:'POST',headers:{'Content-Type':'application/json'}})
.then(response => response.json())
.then(data => console.log(data));
<?php
$url = 'https://localhost:3000/multipleSecurity/{pathParam}';
$method = 'POST';
$headers = [
'Content-Type' => 'application/json',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import requests
url = 'https://localhost:3000/multipleSecurity/{pathParam}'
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers)
print(response.json())