elastic/kibana
View on GitHub[OAS] Allow custom sorting/post-processing of OAS properties generated from router
Open
#233797 opened on Sep 2, 2025
Feature:OASTeam:Coreenhancementgood first issue
Description
The OAS converter currently emits properties in the order returned by joi-to-json, with no way to apply custom sorting for user-facing OAS docs.
Current behavior:
- Properties appear in the order provided by
joi-to-json. - OpenAPI/OAS has no built-in support for custom field ordering.
- Modifying the generated YAML is possible but will be overwritten whenever the generator runs.
Possible solutions
- Add a post-processing hook (similar to
postProcessMutationsinparse.ts) or an extension point (e.g.,ObjectTypeOptionsMeta) so we can reorder properties in the final OAS output (not limited to alphabetical sorting). - Alternatively explore safe ways to modify final YAML output without being clobbered by regeneration.
- Something completely different
References:
- Example hook: parse.ts postProcessMutations — https://github.com/elastic/kibana/blob/6f6a42d492aea851c3aaf68830e667491a4660fe/src/platform/packages/shared/kbn-router-to-openapispec/src/oas_converter/kbn_config_schema/parse.ts#L38-L52
Expected outcome:
- A pluggable mechanism to apply custom sorting or other transformations to generated OAS properties before writing the final spec.