-
Notifications
You must be signed in to change notification settings - Fork 217
feat: setup the post-bundle decorators #2733
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
366010a
feat: setup the postbundle decorators and refactor remove-unused-comp…
AlbinaBlazhko17 3fd15ae
fix: type missmatch
AlbinaBlazhko17 2cfefc4
chore: add changeset and remove folder
AlbinaBlazhko17 dccfbbf
refactor: getContainingComponentKey for oas2
AlbinaBlazhko17 449d6bb
feat: add escape pointer
AlbinaBlazhko17 f69d84d
refactor: remove undefined from return
AlbinaBlazhko17 e3edba7
Merge branch 'main' into feat/add-post-decorator-phase
AlbinaBlazhko17 70f1fa3
refactor: remove runPostBundleDecorators and use directly in bundle
AlbinaBlazhko17 a3e8b04
refactor: use parsePointer and remove undefinder check
AlbinaBlazhko17 d061de2
feat: cover case with recursive ref
AlbinaBlazhko17 0bfa67f
refactor: use parseRef for pointers
AlbinaBlazhko17 9cc466c
refactor: add to oas2 proper key
AlbinaBlazhko17 b4f9dc4
chore: add line brake to yaml
AlbinaBlazhko17 c7c9b29
feat: remove global postBundleDecorators to local implementation for …
AlbinaBlazhko17 e144213
chore: change changeset
AlbinaBlazhko17 07c806a
chore: remove postBundleDecorators from configs
AlbinaBlazhko17 21fd468
feat: add missing check in oas2 for local pointer
AlbinaBlazhko17 3510d4c
Merge branch 'main' into feat/add-post-decorator-phase
AlbinaBlazhko17 f86a295
refactor: function and statement naming
AlbinaBlazhko17 ce1e678
chore: add cli to changeset
AlbinaBlazhko17 cdbc842
Apply suggestion from @JLekawa
JLekawa 83d363a
Merge branch 'main' into feat/add-post-decorator-phase
AlbinaBlazhko17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@redocly/openapi-core": minor | ||
| --- | ||
|
|
||
| Moved the `remove-unused-components` decorator to a post-bundle phase so that components that become unused only after `$ref` resolution are correctly removed. | ||
|
JLekawa marked this conversation as resolved.
Outdated
|
||
| Decorators can now be registered as post-bundle decorators via the `postBundleDecorators` field in the plugin definition. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { resolveDocument, type Document, type BaseResolver } from '../resolve.js'; | ||
| import { type NormalizedNodeType } from '../types/index.js'; | ||
| import { normalizeVisitors } from '../visitors.js'; | ||
| import { walkDocument, type WalkContext, type ProblemSeverity } from '../walk.js'; | ||
|
|
||
| export async function runPostBundleDecorators(opts: { | ||
| document: Document; | ||
| normalizedTypes: Record<string, NormalizedNodeType>; | ||
| postBundleDecorators: { severity: ProblemSeverity; ruleId: string; visitor: any }[]; | ||
| externalRefResolver: BaseResolver; | ||
| ctx: WalkContext; | ||
| }): Promise<void> { | ||
| const { document, normalizedTypes, postBundleDecorators, externalRefResolver, ctx } = opts; | ||
|
|
||
| if (postBundleDecorators.length === 0) return; | ||
|
|
||
| const postBundleRefMap = await resolveDocument({ | ||
| rootDocument: document, | ||
| rootType: normalizedTypes.Root, | ||
| externalRefResolver, | ||
| }); | ||
| const postBundleVisitors = normalizeVisitors(postBundleDecorators, normalizedTypes); | ||
|
|
||
| walkDocument({ | ||
| document, | ||
| rootType: normalizedTypes.Root, | ||
| normalizedVisitors: postBundleVisitors, | ||
| resolvedRefMap: postBundleRefMap, | ||
| ctx, | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also affects how the CLI behaves and I think it would be useful to specify it directly in it's changelog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, will add it.