[API Explorer] Add support for x-req-auth#3168
Merged
Merged
Conversation
Mpdreamz
approved these changes
Apr 22, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds support for the OpenAPI operation extension
x-req-authin the API Explorer.Render the information in a Prerequisites block on each operation page.
NOTE:
x-req-authis implemented in the Elasticsearch specification in elastic/elasticsearch-specification#6007Screenshots
Implementation
OpenApiXReqAuthParser: Readsx-req-authas a JSON array of strings on the operation. Trims each line; non-string JSON values are stringified. Returnsnullif the key is missing, not an array, or all entries are empty—so the UI stays hidden. Logs warnings (when a logger is available) for unexpected shapes or parse issues.ApiRenderContext: New optionalApiExplorerLog(ILogger?) for extension parsing.OpenApiGenerator: WiresApiExplorerLog = _loggerwhen constructingApiRenderContextfor API product generation.ApiViewModel: Exposesprotected ApiRenderContext RenderContextso operation code can use the model and optional logger.OperationViewModel:RequiredAuthItemsfrom the parser.GetTocItems: Inserts Prerequisites (anchorprerequisites) after Paths when there is at least one line; coexists with existing Code Examples /x-codeSamplesTOC behavior.OperationView.cshtml: Renders the Prerequisites section (same general styling as other primary operation sections).Tests
XReqAuthTests: Parser coverage (minimal spec, empty array, Elasticsearch- and Kibana-style TestData JSON fixtures—no dependency on the full repoelasticsearch-openapi.json/kibana-openapi.json).TestData/**/*.jsonto output.Documentation
docs/configure/content-set/api-explorer.md: Documentsx-req-authunder OpenAPI extensions (format, behavior, TOC placement, when the section is omitted, warnings), and lists it in the extensions overview.I've done some minor cleanup in that page as well (re-ordering the sections under "OpenAPI extensions".
Generative AI disclosure
Tool(s) and model(s) used: composer-2