Skip to content

Commit 3bb7907

Browse files
committed
Strawperson proposal for URI-based tag resolution
Tag resolution is difficult to do with URIs because tags are ordered in the OpenAPI Object, and the order is significant. This change takes the approach of adding an OpenAPI Document URI to determine which OpenAPI Object is used to look up the named tag. In the Operation Object, this is a parallel field called `tagRefs`, that groups tags under URIs. In the Tag Object, the `parentRef` field provides the context for the existing `parent` field.
1 parent ca59b57 commit 3bb7907

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/oas.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ In some cases, an unambiguous URI-based alternative is available, and OAD author
195195
| ---- | ---- | ---- |
196196
| [Security Requirement Object](#security-requirement-object) `{name}` | [Security Scheme Object](#security-scheme-object) name under the [Components Object](#components-object) | _n/a_ |
197197
| [Discriminator Object](#discriminator-object) `mapping` _(implicit, or explicit name syntax)_ | [Schema Object](#schema-object) name under the Components Object | `mapping` _(explicit URI syntax)_ |
198-
| [Operation Object](#operation-object) `tags` | [Tag Object](#tag-object) `name` (in the [OpenAPI Object](#openapi-object)'s `tags` array) | _n/a_ |
198+
| [Tag Object](#tag-object) `parent` | [Tag Object](#tag-object) `name` (in the [OpenAPI Object](#openapi-object)'s `tags` array) | `parentDocument` |
199+
| [Operation Object](#operation-object) `tags` | [Tag Object](#tag-object) `name` (in the [OpenAPI Object](#openapi-object)'s `tags` array) | `tagRefs` |
199200
| [Link Object](#link-object) `operationId` | [Path Item Object](#path-item-object) `operationId` | `operationRef` |
200201

201202
A fifth implicit connection involves appending the templated URL paths of the [Paths Object](#paths-object) to the appropriate [Server Object](#server-object)'s `url` field.
@@ -214,9 +215,6 @@ This allows Security Scheme Objects and Tag Objects to be defined next to the AP
214215

215216
The interface approach can also work for Discriminator Objects and Schema Objects, but it is also possible to keep the Discriminator Object's behavior within a single document using the relative URI-reference syntax of `mapping`.
216217

217-
There are no URI-based alternatives for the Security Requirement Object or for the Operation Object's `tags` field.
218-
These limitations are expected to be addressed in a future release.
219-
220218
See [Appendix F: Resolving Security Requirements in a Referenced Document](#appendix-f-resolving-security-requirements-in-a-referenced-document) for an example of the possible resolutions, including which one is recommended by this section.
221219
The behavior for Discrimator Object non-URI mappings and for the Operation Object's `tags` field operate on the same principles.
222220

@@ -1019,6 +1017,7 @@ Describes a single API operation on a path.
10191017
| Field Name | Type | Description |
10201018
| ---- | :----: | ---- |
10211019
| <a name="operation-tags"></a>tags | [`string`] | A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier. |
1020+
| <a name="operation-tag-refs"></a>tagRefs | Map[`string`, [`string`]] | A map of OpenAPI Document URIs to lists of tags. Each tag is resolved within the OpenAPI Document identified by the URI under which it appears. |
10221021
| <a name="operation-summary"></a>summary | `string` | A short summary of what the operation does. |
10231022
| <a name="operation-description"></a>description | `string` | A verbose explanation of the operation behavior. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. |
10241023
| <a name="operation-external-docs"></a>externalDocs | [External Documentation Object](#external-documentation-object) | Additional external documentation for this operation. |
@@ -1033,6 +1032,8 @@ Describes a single API operation on a path.
10331032

10341033
This object MAY be extended with [Specification Extensions](#specification-extensions).
10351034

1035+
Note that either or both of `tags` and `tagRefs` MAY be specified. The `tags` field is useful when the URI of the entry document is not known or may change, as long as the implementation follows the tag resolution guidance recommended under [Resolving Implicit Connections](#resolving-implicit-connections).
1036+
10361037
##### Operation Object Example
10371038

10381039
```json
@@ -2696,6 +2697,7 @@ It is not mandatory to have a Tag Object per tag defined in the Operation Object
26962697
| <a name="tag-description"></a>description | `string` | A description for the tag. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. |
26972698
| <a name="tag-external-docs"></a>externalDocs | [External Documentation Object](#external-documentation-object) | Additional external documentation for this tag. |
26982699
| <a name="tag-parent"></a>parent | `string` | The `name` of a tag that this tag is nested under. The named tag MUST exist in the API description, and circular references between parent and child tags MUST NOT be used. |
2700+
| <a name="tag-parent-document"></a>parentDocument | `string` | The URI of the OpenAPI Document in which to locate the tag given in the `parent` field. If this field is present, then `parent` MUST also be present. |
26992701
| <a name="tag-kind"></a>kind | `string` | A machine-readable string to categorize what sort of tag it is. Any string value can be used; common uses are `nav` for Navigation, `badge` for visible badges, `audience` for APIs used by different groups. A [registry of the most commonly used values](https://spec.openapis.org/registry/tag-kind/) is available. |
27002702

27012703
This object MAY be extended with [Specification Extensions](#specification-extensions).

src/schemas/validation/schema.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,15 @@ $defs:
255255
type: array
256256
items:
257257
type: string
258+
tagRefs:
259+
type: object
260+
propertyNames:
261+
type: string
262+
format: uri-reference
263+
additionalProperties:
264+
type: array
265+
items:
266+
type: string
258267
summary:
259268
type: string
260269
description:
@@ -710,10 +719,15 @@ $defs:
710719
$ref: '#/$defs/external-documentation'
711720
parent:
712721
type: string
722+
parentDocument:
723+
type: string
724+
format: uri-reference
713725
kind:
714726
type: string
715727
required:
716728
- name
729+
dependentRequired:
730+
parentDocument: [parent]
717731
$ref: '#/$defs/specification-extensions'
718732
unevaluatedProperties: false
719733

0 commit comments

Comments
 (0)