Skip to content

Allow adding multiple media types for a response#495

Merged
greyli merged 1 commit intoapiflask:mainfrom
ricardogsilva:494-allow-defining-additional-media-types
Nov 12, 2023
Merged

Allow adding multiple media types for a response#495
greyli merged 1 commit intoapiflask:mainfrom
ricardogsilva:494-allow-defining-additional-media-types

Conversation

@ricardogsilva
Copy link
Copy Markdown
Contributor

This PR modifies the code that handles @app.doc(responses=...). The proposed implementation deals with cases where
a dict is passed.

The previous behavior assumed the passed dict would be used as the OpenAPI definition of the view's responses. This proposed implementation instead merges the contents of the passed dict taking into account the content key of each
status code. This is done in order to preserve whatever information might have already been automatically generated in
previous steps, namely what had been added while processing app.output().

This means that with the current PR, APIFlask would preserve a view's main response media type, while also allowing
the addition of other, secondary media types, thus addressing the contents of issue #494

fixes #494

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code docstring.
  • Add an entry in CHANGES.md summarizing the change and linking to the issue.
  • [] Add *Version changed* or *Version added* note in any relevant docs and docstring. - IMO this doesn't seem relevant for the current PR
  • Run pytest and tox, no tests failed.

@greyli greyli merged commit 09658b2 into apiflask:main Nov 12, 2023
@greyli
Copy link
Copy Markdown
Member

greyli commented Nov 12, 2023

Merged, thanks!

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.

Allow defining additional media types for a response

2 participants