-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Authz] Fix description generation for Open API spec for an API #198054
Merged
SiddharthMantri
merged 16 commits into
elastic:main
from
SiddharthMantri:fix-process-router-route-description
Nov 4, 2024
Merged
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e1c54a3
[Authz] Fix how description was added to OAS spec
SiddharthMantri 8bf8290
add test to ensure correct description
SiddharthMantri 4adfa2b
Merge branch 'main' into fix-process-router-route-description
elasticmachine aa1fcf4
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine c6cfa1d
fix title and add linebreak in description generation
SiddharthMantri cad2242
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine 6958eb7
fix description
SiddharthMantri ae6cd6b
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine 422e823
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine 78d8449
fix description
SiddharthMantri 9dbfb2c
fix versioned router tests
SiddharthMantri 8d20aa7
fix unit test
SiddharthMantri 5f674ec
address PR comments: add test
SiddharthMantri ed079d0
Merge branch 'main' into fix-process-router-route-description
elasticmachine 66817c9
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine 7203e2a
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine 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 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 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 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 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 |
---|---|---|
|
@@ -64,11 +64,13 @@ export const processRouter = ( | |
parameters.push(...pathObjects, ...queryObjects); | ||
} | ||
|
||
let description = ''; | ||
let description = `${route.options.description ?? ''}`; | ||
if (route.security) { | ||
const authzDescription = extractAuthzDescription(route.security); | ||
|
||
description = `${route.options.description ?? ''}${authzDescription ?? ''}`; | ||
description += `${route.options.description && authzDescription ? `<br/><br/>` : ''}${ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
authzDescription ?? '' | ||
}`; | ||
} | ||
|
||
const hasDeprecations = !!route.options.deprecated; | ||
|
@@ -77,7 +79,6 @@ export const processRouter = ( | |
summary: route.options.summary ?? '', | ||
tags: route.options.tags ? extractTags(route.options.tags) : [], | ||
...(description ? { description } : {}), | ||
...(route.options.description ? { description: route.options.description } : {}), | ||
...(hasDeprecations ? { deprecated: true } : {}), | ||
...(route.options.discontinued ? { 'x-discontinued': route.options.discontinued } : {}), | ||
requestBody: !!validationSchemas?.body | ||
|
This file contains 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 |
---|---|---|
|
@@ -157,7 +157,7 @@ describe('processVersionedRouter', () => { | |
expect(results.paths['/foo']!.get).toBeDefined(); | ||
|
||
expect(results.paths['/foo']!.get!.description).toBe( | ||
'[Authz] Route required privileges: ALL of [manage_spaces].' | ||
'[Required authorization] Route required privileges: ALL of [manage_spaces].' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: would it make sense to have the same set of test cases as |
||
); | ||
}); | ||
}); | ||
|
This file contains 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
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.
Nit: I wonder if "Authorization" is enough, given that we always follow it with "Route required privileges:"