Skip to content

Fix Response Schema Handling with Custom MIME Types #2019

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

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from

Conversation

fosple
Copy link

@fosple fosple commented May 12, 2025

This PR addresses an issue where response schemas weren't properly associated with custom MIME types. In the original code it was marked with a TODO. When using @produce with a custom MIME type (like json-api), schema references weren't being correctly linked to those MIME types in the OpenAPI spec output.

Changes:

  • Modified ResponseSchemaWithCustomMimeTypeV3 implementation to ensure schemas are correctly linked to the specified MIME types in the generated spec
  • Added comprehensive tests to verify correct behavior for:
    • Custom MIME types (json-api)
    • Default fallback to application/json when no MIME type specified
    • Multiple MIME types sharing the same schema reference

The changes ensure that when you specify @Produce json-api followed by a response schema via @Success, the schema is correctly linked to the application/vnd.api+json MIME type in the OpenAPI document, rather than being linked to the default application/json type.

This fixes issues when generated clients need to consume non-standard response content types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant