Skip to content

Commit cb375d5

Browse files
authored
Revise API versioning and specs documentation
Updated API versioning and specifications sections for clarity and accuracy, to accompany UX for API Versions.
1 parent 2fc30b2 commit cb375d5

File tree

1 file changed

+14
-46
lines changed

1 file changed

+14
-46
lines changed

app/catalog/apis.md

Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -92,62 +92,28 @@ resource "konnect_api" "my_api" {
9292
{% endnavtab %}
9393
{% endnavtabs %}
9494

95-
## API versioning
95+
## API versions
9696

97-
When you create your API, you can choose to keep it unversioned or version it using a free text string. This allows you to follow the versioning system of your choice:
98-
* Semantic versioning (examples: `v1`, `v2`)
99-
* Date-based versioning (examples: `2024-05-10`, `2024-10-22`)
100-
* Custom naming scheme (example: `a1b2c3-internal-xxyyzz00`)
97+
When you create your API, version can be optionally specified as a free text string. Semantic versioning (examples: `1.0`, `2.0`) is best supported by Catalog and Dev Portal (in areas such as default order), but there are no constraints on the version style.
10198

102-
Each API is identified using the combination of `name+version`. For example, if your API is named `My Test API` and it has a version of `v3`, then it will be accessible via the API as `my-test-api-v3` in your [list of APIs](/api/konnect/api-builder/v3/#/operations/list-apis). If a `version` isn't specified, then `name` is used as the unique identifier.
99+
APIs have a unique constraint based on the combination of `name+version`. It is generally recommended to create a unique API for each major version, although there is no constraint.
103100

104-
To version an API, do one of the following:
105-
{% navtabs "api-version" %}
106-
{% navtab "{{site.konnect_short_name}} UI" %}
107-
Navigate to **Catalog > APIs** in the sidebar, and then click [**New API**](https://cloud.konghq.com/apis/create). Enter a version in the **API version** field. You can also add a version on existing APIs by editing them.
108-
{% endnavtab %}
109-
{% navtab "{{site.konnect_short_name}} API" %}
110-
Send a POST request to the [`/apis/{apiId}/versions` endpoint](/api/konnect/api-builder/v3/#/operations/create-api-version):
111-
{% konnect_api_request %}
112-
url: /v3/apis/$API_ID/versions
113-
status_code: 201
114-
method: POST
115-
body:
116-
version: 1.0.0
117-
spec:
118-
content: '{"openapi":"3.0.3","info":{"title":"Example API","version":"1.0.0"},"paths":{"/example":{"get":{"summary":"Example endpoint","responses":{"200":{"description":"Successful response"}}}}}}'
119-
{% endkonnect_api_request %}
120-
{% endnavtab %}
121-
{% navtab "Terraform" %}
122-
Use the [`konnect_api_version` resource](https://github.com/Kong/terraform-provider-konnect/blob/main/examples/resources/konnect_api_version.tf):
123-
```hcl
124-
echo '
125-
resource "konnect_api_version" "my_apiversion" {
126-
api_id = "9f5061ce-78f6-4452-9108-ad7c02821fd5"
127-
spec = {
128-
content = "{\"openapi\":\"3.0.3\",\"info\":{\"title\":\"Example API\",\"version\":\"1.0.0\"},\"paths\":{\"/example\":{\"get\":{\"summary\":\"Example endpoint\",\"responses\":{\"200\":{\"description\":\"Successful response\"}}}}}}"
129-
type = "oas3"
130-
}
131-
version = "1.0.0"
132-
}
133-
' >> main.tf
134-
```
135-
{% endnavtab %}
136-
{% endnavtabs %}
101+
The API `slug` determines Dev Portal URl routing in your [list of APIs](/api/konnect/api-builder/v3/#/operations/list-apis), which defaults to a slugified name and version (major version if semver), e.g. `my-test-api-3`. If a `version` isn't specified, then `name` is used as the unique identifier.
137102

103+
### API Specifications in Versions
138104

139-
## API specs
105+
If OpenAPI or AsyncAPI specifications are used when the API is created, the API version will default and be constrained to the version in the specification. Multiple versions of API specifications can be specified within the API entity. This is best supported when used for minor versions of an API. When multiple `versions` are specified, a selector will be provided in the generated API reference to switch between versions of the API specification.
106+
107+
The API entity's `version` property is treated as "current", meaning it is the version that will be listed in your your [list of APIs](/api/konnect/api-builder/v3/#/operations/list-apis).
140108

141-
All API specification files are validated during upload, although invalid specifications are permitted. If specifications are invalid, features like generated documentation and search may be degraded.
142109

143-
To upload a spec to an API, do one of the following:
144-
{% navtabs "api-specs" %}
110+
To version an API, do one of the following:
111+
{% navtabs "api-version" %}
145112
{% navtab "{{site.konnect_short_name}} UI" %}
146-
Navigate to [**Catalog > APIs**](https://cloud.konghq.com/apis) in the sidebar and click your API. Click the **API specification** tab, and then click **Upload Spec**.
113+
Navigate to **Catalog > APIs** in the sidebar, and then click [**New API**](https://cloud.konghq.com/apis/create). Enter a version in the **API version** field, or upload an API specification, which will set the version to match the API spec version. You can also add a version on existing APIs when editing, if no API specifications are in use. To manage multiple versions of the API specification navigate to [**Catalog > APIs**](https://cloud.konghq.com/apis) in the sidebar and click your API. Click the **API specification** tab, and then click **Add or Upload Spec**. If a newer version is in the API Specification, you will be prompted to add a new `version`, and set the current version.
147114
{% endnavtab %}
148115
{% navtab "{{site.konnect_short_name}} API" %}
149116
Send a POST request to the [`/apis/{apiId}/versions` endpoint](/api/konnect/api-builder/v3/#/operations/create-api-version):
150-
<!--vale off-->
151117
{% konnect_api_request %}
152118
url: /v3/apis/$API_ID/versions
153119
status_code: 201
@@ -157,7 +123,6 @@ body:
157123
spec:
158124
content: '{"openapi":"3.0.3","info":{"title":"Example API","version":"1.0.0"},"paths":{"/example":{"get":{"summary":"Example endpoint","responses":{"200":{"description":"Successful response"}}}}}}'
159125
{% endkonnect_api_request %}
160-
<!--vale on-->
161126
{% endnavtab %}
162127
{% navtab "Terraform" %}
163128
Use the [`konnect_api_version` resource](https://github.com/Kong/terraform-provider-konnect/blob/main/examples/resources/konnect_api_version.tf):
@@ -176,8 +141,11 @@ resource "konnect_api_version" "my_apiversion" {
176141
{% endnavtab %}
177142
{% endnavtabs %}
178143

144+
179145
### API spec validation
180146

147+
All API specification files are validated during upload, although invalid specifications are permitted. If specifications are invalid, features like generated documentation and search may be degraded.
148+
181149
{{site.konnect_short_name}} looks for the following during spec validation:
182150

183151
* Specs must be valid JSON or YAML.

0 commit comments

Comments
 (0)