Add support for OAS 3.2 nested tags via parent field in @tagMetadata#9577
Add support for OAS 3.2 nested tags via parent field in @tagMetadata#9577
Conversation
- Updated TagMetadata model to include parent field - Modified openapi.ts to convert parent to x-parent for 3.0/3.1 - Added comprehensive tests for all OpenAPI versions - Tests passing for parent field in 3.2, x-parent in 3.0/3.1 Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
- Added example of nested tags using parent field - Rebuilt packages to update generated types Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
packages/openapi3/src/openapi.ts
Outdated
| const tagData: OpenAPI3Tag = { name: name, ...tag }; | ||
| // For OpenAPI 3.0 and 3.1, convert 'parent' to 'x-parent' extension | ||
| if (specVersion !== "3.2.0" && "parent" in tagData) { | ||
| (tagData as any)["x-parent"] = tagData.parent; |
There was a problem hiding this comment.
why as any is the type incorrect?
There was a problem hiding this comment.
Fixed in d9e4bfd. Changed to use tag.parent from the source TagMetadata object to check for parent existence, and only use a type assertion on the delete operation with an explicit { parent?: string } type instead of as any.
|
@copilot need to make sure you do a full build and commit the generated files. ANd run |
commit: |
- Changed from using 'as any' to a more type-safe approach - Use tag.parent from source TagMetadata to check parent existence - Only use type assertion on delete operation with explicit type Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
- Updated README.md with parent field example - Updated decorators.md with parent field example - Generated files from full build Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Done in c831ac7. Ran full build and Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot pull latest change from main and resolve merge conflicts |
- Integrated parent field conversion logic into refactored resolveDocumentTags function - Updated test imports to match main branch changes - Preserved parent field tests for all OpenAPI versions Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
|
@copilot there is still conflict with main, please fix. The PR now has way too many changes showing up |
I've rebased the branch onto the latest main (4de4d3f). The branch now contains only the relevant changes (7 files, 101 insertions, 8 deletions) and no longer shows the extra commits that were merged from main. The commits are now:
However, I'm unable to force-push this rebased branch due to authentication restrictions. The rebased branch exists locally and is ready, but needs to be pushed manually or the PR may need to be recreated from this clean state. |
|
@copilot revert the last push and rebase your change of main |
I've successfully rebased the branch onto the latest main (4de4d3f). The local branch now has a clean history with only 3 commits and 7 files changed (101 insertions, 8 deletions): Commits:
However, I cannot force-push the rebased branch due to git authentication restrictions. The Could you please either:
The local branch is ready and all changes are correct. |
packages/openapi3/src/openapi.ts
Outdated
| const tagData: OpenAPI3Tag = { name: name, ...tag }; | ||
| // For OpenAPI 3.0 and 3.1, convert 'parent' to 'x-parent' extension | ||
| if (specVersion !== "3.2.0" && tag.parent) { | ||
| tagData["x-parent"] = tag.parent; |
There was a problem hiding this comment.
Fixed in da7c83a. Changed the implementation to drop the parent field entirely for OpenAPI 3.0 and 3.1 (removed the x-parent conversion). Now only OpenAPI 3.2 emits the parent field.
|
❌ There is undocummented changes. Run The following packages have changes but are not documented.
Show changes |
- Changed implementation to drop parent field entirely for 3.0/3.1 - Updated tests to reflect parent field is dropped (not converted) - Only OpenAPI 3.2 emits the parent field Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
| deepStrictEqual(res.tags, [ | ||
| { | ||
| name: "ChildTag", | ||
| description: "Child tag", |
There was a problem hiding this comment.
Shouldn't this have X-Parent?
There was a problem hiding this comment.
We decided not too, and just dropped and would add it if someone asked with options.
| { | ||
| name: "ChildTag", | ||
| description: "Child tag", | ||
| }, |
There was a problem hiding this comment.
Shouldn't this have X-Parent?
|
@copilot run |
- Removed extra blank line in tagmetadata.test.ts Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Done in 6facdb9. Ran Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Add support for OAS 3.2 Nested Tags
parentfield in decorators.tspparentfield nativelySummary
This PR adds support for OpenAPI 3.2 nested tags by introducing a
parentfield in the@tagMetadatadecorator.Changes: 7 files, 98 insertions, 8 deletions
The implementation correctly handles version differences:
parentfield nativelyparentfield entirely (not supported in these versions)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.