Skip to content
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

Support request body and multiple media types under the same status code #208

Closed
wants to merge 1 commit into from

Conversation

iongion
Copy link

@iongion iongion commented Nov 30, 2024

Checklist:

  • Run pytest tests and no failed.
  • Run ruff check flask_openapi3 tests examples and no failed.
  • Run mypy flask_openapi3 and no failed.
  • Run mkdocs serve and no failed.

Goals:

@api.post(
    "/inference",
    request_body={
        "content": {
            # Content type
            "application/json": SAM2InferenceInput,
            "application/bson": SAM2InferenceInput,
        },
        "required": True,
    },
    responses={
        HTTPStatus.OK: {
            "description": "Inference output",
            "content": {
                # Content type
                "application/json": SAM2InferenceOutput,
                "application/bson": SAM2InferenceOutput,
            },
        },
    },
)
@tracer.capture_method
def create_sam2_inference(body: SAM2InferenceInput):
    """Perform inference with SAM2 model.

    Perform inference with SAM2 model using the given input.
    """
    output = perform_sam2_inference(body)
    return respond(output)

And also brings support for the swagger docs

image

@iongion iongion force-pushed the support-requestBody branch 2 times, most recently from cbb6d67 to 2ac3c74 Compare November 30, 2024 12:59
@iongion iongion changed the title Support request body Support request body and multiple media types under the same status code Nov 30, 2024
fix

Fix source of spec

Use snake case

Fix tests

Fix types

Fix all tests and typings

Remove unused imports
@iongion iongion force-pushed the support-requestBody branch from 751108e to 52236d4 Compare November 30, 2024 14:07
@iongion iongion closed this Dec 2, 2024
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