Enhanced OpenAPI Export Options (components/responses)
R
Ryan Sondgeroth
Problem:
When exporting to OpenAPI, only the responses that are actively used in existing endpoints are included under components/responses. Additionally, the exporter automatically inlines response schemas in the path definitions, rather than keeping them as reusable references.
This limits the usefulness of the export for creating base API templates or boilerplate definitions, since many pre-built responses and standard components are excluded.
Proposed Enhancements:
- Option to include all pre-built components in export
• Add a setting that allows all pre-defined responses to be included in the components/responses section of the OpenAPI JSON/YAML export.
• This ensures consistency across projects and enables teams to build a “base API template” with shared assets, even if some responses aren’t currently tied to endpoints.
- Option to use $ref references in paths
• Add a setting to prevent automatic inlining of responses under paths.
• Instead, export them as $ref references to #/components/responses/....
Example:
"/provision": {
"post": {
"responses": {
"200": {
"$ref": "#/components/responses/OK"
},
"207": {
"$ref": "#/components/responses/MultiStatus"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"422": {
"$ref": "#/components/responses/UnprocessableEntity"
}
}
}
}
Benefits:
• Enables the creation of reusable base API templates.
• Improves consistency across different projects.
• Makes the exported OpenAPI spec cleaner and more maintainable.
• Aligns with OpenAPI best practices by favoring $ref reuse instead of inlining.
Evans
Thank you very much for your feedback!
We are continuously working to enhance our compatibility with OpenAPI Spec components. Recently, we added support for importing and exporting security schemes. Right now, we are focused on improving compatibility for response components. Very soon, Apidog will support importing and exporting reusable response components and allow endpoints to reference them via $ref, instead of inlining them directly.
Your suggestions are very helpful, and we appreciate your suggestion as we continue to improve our tool.