Exposing Deployment Information #53
Description
This is an issue to propose / discuss how we should expose information on where a particular API is deployed.
Current Support
API Blueprint
The API Blueprint does not include any support for describing the deployment information. API Blueprint does allow metadata at the top of an API Blueprint. Many tools use the metadata HOST
which can be a URL to where the API may be deployed.
HOST: https://example.com/v2/
This is translated to metadata
attribute for an API Category in API Elements:
{
"element": "member",
"meta": {
"classes": {
"element": "array",
"content": [
{
"element": "string",
"content": "user"
}
]
}
},
"content": {
"key": {
"element": "string",
"content": "HOST"
},
"value": {
"element": "string",
"content": "https://example.com/v2/"
}
}
}
Swagger 2
Swagger 2 provides support for deployment information with schemes
(array) host
and basePath
. Our adapter takes the first schema and host and places that in the same metadata section as API Blueprint so that the value is in a format that is already used by tooling and didn't require tooling updates.
schemes: [https]
host: example.com
basePath: /v2/
The above Swagger 2 structure would result in a HOST
metadata of https://example.com
and basePath
would be prepended into every href found in the parse result which perhaps isn't the most ideal way to handle it. The problem is that the basePath
may be supplied without a host
and thus couldn't be exposed as HOST
metadata.
{
"element": "member",
"meta": {
"classes": {
"element": "array",
"content": [
{
"element": "string",
"content": "user"
}
]
}
},
"content": {
"key": {
"element": "string",
"content": "HOST"
},
"value": {
"element": "string",
"content": "https://example.com"
}
}
}
basePath: /v2/
paths:
/user
{
"element": "resource",
"attributes": {
"href": {
"element": "string",
"content": "/v2/user"
}
},
"content": [...]
}
OpenAPI 3
In OpenAPI 3 a lot of server information including server variables may be described. See https://github.com/OAI/OpenAPI-Specification/blob/50c152549263cda0f05608d514ba78546b390d0e/versions/3.0.0.md#server-object or more details.