Skip to content

Support multiple media types under the same status code #207

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

Conversation

iongion
Copy link

@iongion iongion commented Nov 29, 2024

Checklist

  • Run pytest tests and none is failing - They failed because they were already failing
  • Run ruff check flask_openapi3 tests examples and no failed.
  • Run mypy flask_openapi3 and no failed.
  • Run mkdocs serve and no failed.

This PR is to be able to support multiple media types for the same status code of an endpoint

# Endpoints
api = APIBlueprint(
    "default",
    __name__,
    doc_ui=True,
)

class Project(BaseModel):
    Version: str
    Environment: str


@api.get(
    "/",
    responses={
        HTTPStatus.OK: {
            "description": "Health check",
            "content": {
                # Content type
                "application/json": Project,
                "application/bson": Project,
            },
        },
    },
)
def get_home():
    """Check status.

    Gets health status of the api.
    """
    output = Project(Version="1.0.0", Environment="dev")
    return output

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