Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional fields for the tag object #4288

Merged
merged 4 commits into from
Jan 16, 2025
Merged

Conversation

lornajane
Copy link
Contributor

Implementation of the proposal to extend the functionality offered by tags. The main features:

  • tags get a summary field in addition to their description
  • tags can have a parent tag, enabling building a tree-ish hierarchy
  • tags can have a kind to say what sort of tag they are, so we can use tags for many; Add tag kinds registry to the spec site #4287 adds a registry for the most common types

Pull request still in draft because I would like to link to the registry but it doesn't exist yet so we should not merge - review feedback very welcome though!

src/oas.md Outdated Show resolved Hide resolved
miqui
miqui previously approved these changes Jan 9, 2025
@karenetheridge
Copy link
Member

Love this. As an implementor, the first thing that comes to mind is "now I need to write an interface "get me a list of all the operations with a particular tag kind".

mikekistler
mikekistler previously approved these changes Jan 9, 2025
Copy link
Contributor

@mikekistler mikekistler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍

src/oas.md Show resolved Hide resolved
@karenetheridge
Copy link
Member

karenetheridge commented Jan 9, 2025

  • Schema changes are required for this PR and are not done yet

@lornajane lornajane dismissed stale reviews from mikekistler and miqui via a055eca January 10, 2025 12:19
@lornajane lornajane marked this pull request as ready for review January 10, 2025 12:23
@lornajane lornajane requested review from a team as code owners January 10, 2025 12:23
mikekistler
mikekistler previously approved these changes Jan 10, 2025
Copy link
Contributor

@mikekistler mikekistler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍

I left a couple minor comments but nothing serious enough to block merging.

src/oas.md Outdated Show resolved Hide resolved
src/oas.md Show resolved Hide resolved
Co-authored-by: Mike Kistler <[email protected]>
@ralfhandl ralfhandl requested review from a team and removed request for baywet January 10, 2025 15:47
| <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. |
| <a name="tag-external-docs"></a>externalDocs | [External Documentation Object](#external-documentation-object) | Additional external documentation for this tag. |
| <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. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The named tag MUST exist in the API description,

This interacts with the following text in 3.1.1:

For resolving component and tag name connections from a referenced (non-entry) document, it is RECOMMENDED that tools resolve from the entry document, rather than the current document. This allows Security Scheme Objects and Tag Objects to be defined next to the API’s deployment information (the top-level array of Server Objects), and treated as an interface for referenced documents to access.

However, that was written to resolve Operation Object tags fields to Tag Objects, which means you need to locate a particular OpenAPI Object with Tag Objects under its tags field. For this parent field, if we follow the same guidance, a Tag Object in a referenced document would search for its parent in the entry document.

Resolving to the entry document would be the most consistent thing, but not necessarily the most intuitive.

On the one hand, making parent only resolve within the current document feels more intuitive. On the other hand, it's also limiting if for some reason you wanted to break tags across multiple OpenAPI Documents in a single OpenAPI Description, and it would make two fields that reference via a tag name behave differently, which is confusing as well.

A third option that ends up being more problematic than it seems at first would be to make parent take a URI-reference, but since the OpenAPI Object's tags field is an array, JSON Pointers end up being cryptic and fragile.

A fourth option, which would be annoyingly complex, would be to offer both parent (resolves to the entry document, since that could be different if the same other document is reference from multiple entry documents) and parentRef (like operationRef) which could be used with a URI-ref, e.g. #/tags/4.

A fifth option would be to define plain name fragments for tags, e.g "tag.{tagname}" so that URI-references would not have to have a numerical index. But we've avoided doing that sort of thing (although JSON Schema's $anchor keyword does it).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm playing around with writing up a tagRefs field to allow tags to resolve by URI, and if that works out then maybe parentRef would be the consistent option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're in agreement here, although perhaps the wording needs work. An OpenAPI description has the tags defined in its entry document, because there's nowhere else to define them. They don't need to be refs, because like the info section, tags are a document-level thing and I don't see how they can be ref'd in. Operations can use tags that are not defined, but if the tag is defined and has a parent, then I think that parent should be defined too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if the tag is defined and has a parent, then I think that parent should be defined too.
+1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lornajane I agree with the decision to merge this, and I'll pick up the subtleties elsewhere since I need to do so for tags in the Operation Object.

This gets tricky when you have multiple OpenAPI Documents (capital D) in your OAD, each of which can have a list of Tag Objects. Similar problems exist for the Security Requirement and Security Scheme Objects.

src/oas.md Show resolved Hide resolved
@lornajane lornajane merged commit 0571af7 into OAI:v3.2-dev Jan 16, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants