Skip to content

Fix Response Schema Handling with Custom MIME Types - #2019

Merged
ubogdan merged 3 commits into
swaggo:v2from
fosple:fix-mime-type-operation-v3-todo
Sep 11, 2025
Merged

ubogdan merged 3 commits into
swaggo:v2from
fosple:fix-mime-type-operation-v3-todo

Conversation

@fosple

@fosple fosple commented May 12, 2025

Copy link
Copy Markdown

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.

@ubogdan

ubogdan commented Aug 19, 2025

Copy link
Copy Markdown
Contributor

@fosple please fix conflicts.

@fosple

fosple commented Sep 4, 2025

Copy link
Copy Markdown
Author

@ubogdan done

@ubogdan
ubogdan merged commit 88e5892 into swaggo:v2 Sep 11, 2025
@ubogdan

ubogdan commented Sep 11, 2025

Copy link
Copy Markdown
Contributor

@fosple Thanks for your contribution.

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.

2 participants

⌂ 换网址