Skip to content
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
/onlyApiKey

Authorizations

apiKey
TypeAPI Key (header: api_key)

Samples

Bruno
get {
  url: https://localhost:3000/onlyApiKey
}

headers {
  Content-Type: application/json
}
Bruno
get {
  url: https://localhost:3000/onlyApiKey
}

headers {
  Content-Type: application/json
}
cURL
curl -X GET \
'https://localhost:3000/onlyApiKey' \
 -H "Content-Type: application/json"
JavaScript
fetch('https://localhost:3000/onlyApiKey', {headers:{'Content-Type':'application/json'}})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?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;
?>
Python
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
/onlyBearerAuth

Authorizations

bearerAuth
TypeHTTP (bearer)

Samples

Bruno
post {
  url: https://localhost:3000/onlyBearerAuth
}

headers {
  Content-Type: application/json
}
Bruno
post {
  url: https://localhost:3000/onlyBearerAuth
}

headers {
  Content-Type: application/json
}
cURL
curl -X POST \
'https://localhost:3000/onlyBearerAuth' \
 -H "Content-Type: application/json"
JavaScript
fetch('https://localhost:3000/onlyBearerAuth', {method:'POST',headers:{'Content-Type':'application/json'}})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?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;
?>
Python
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
/apiKeyAndBearerAuth

Authorizations

apiKey
TypeAPI Key (header: api_key)
+
bearerAuth
TypeHTTP (bearer)

Parameters

Header Parameters

headerParam*

Header parameter description

Typestring
Required
Examplevalue

Samples

Bruno
put {
  url: https://localhost:3000/apiKeyAndBearerAuth
}

headers {
  Content-Type: application/json
  headerparam: value
}
Bruno
put {
  url: https://localhost:3000/apiKeyAndBearerAuth
}

headers {
  Content-Type: application/json
  headerparam: value
}
cURL
curl -X PUT \
'https://localhost:3000/apiKeyAndBearerAuth' \
 -H "Content-Type: application/json" \
 -H "headerparam: value"
JavaScript
fetch('https://localhost:3000/apiKeyAndBearerAuth', {method:'PUT',headers:{'Content-Type':'application/json','headerparam':'value'}})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?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;
?>
Python
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
Required

Samples

Bruno
get {
  url: https://localhost:3000/apiKeyOrBearerAuth/{pathParam}
}

headers {
  Content-Type: application/json
}
Bruno
get {
  url: https://localhost:3000/apiKeyOrBearerAuth/{pathParam}
}

headers {
  Content-Type: application/json
}
cURL
curl -X GET \
'https://localhost:3000/apiKeyOrBearerAuth/{pathParam}' \
 -H "Content-Type: application/json"
JavaScript
fetch('https://localhost:3000/apiKeyOrBearerAuth/{pathParam}', {headers:{'Content-Type':'application/json'}})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?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;
?>
Python
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
/noSecurity

Samples

Bruno
get {
  url: https://localhost:3000/noSecurity
}

headers {
  Content-Type: application/json
}
Bruno
get {
  url: https://localhost:3000/noSecurity
}

headers {
  Content-Type: application/json
}
cURL
curl -X GET \
'https://localhost:3000/noSecurity' \
 -H "Content-Type: application/json"
JavaScript
fetch('https://localhost:3000/noSecurity', {headers:{'Content-Type':'application/json'}})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?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;
?>
Python
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)
Examplespecial-key

Parameters

Path Parameters

pathParam*

Path parameter description

Typestring
Required

Query Parameters

param1*

Query parameter description

Typestring
Required
Enum
value1value2
defaultvalue1
param2*

Another query parameter description

Typestring
Required

Request Body

JSON
{
"prop1": "string",
"prop2": 0,
"prop3": [
[
"value1",
"value2"
]
]
}

Samples

Bruno
post {
  url: https://localhost:3000/multipleSecurity/{pathParam}
}

headers {
  Content-Type: application/json
}
Bruno
post {
  url: https://localhost:3000/multipleSecurity/{pathParam}
}

headers {
  Content-Type: application/json
}
cURL
curl -X POST \
'https://localhost:3000/multipleSecurity/{pathParam}' \
 -H "Content-Type: application/json"
JavaScript
fetch('https://localhost:3000/multipleSecurity/{pathParam}', {method:'POST',headers:{'Content-Type':'application/json'}})
  .then(response => response.json())
  .then(data => console.log(data));
PHP
<?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;
?>
Python
import requests

url = 'https://localhost:3000/multipleSecurity/{pathParam}'

headers = {
    'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers)
print(response.json())

Powered by VitePress OpenAPI