Skip to content

How to type/configure the response media type? #1108

Answered by vitalik
stumpylog asked this question in Q&A
Discussion options

You must be logged in to vote

@stumpylog

here is a reference to discussion - #1073

generally for how you can do the following:

BIN_RESPONSE = {
    "responses": {
        200: {
            "description": "OK",
            "content": {"application/octet-stream": {"schema": {"type": "string", "format": "binary"}}},
        }
    }
}


@api.get("/hello", openapi_extra=BIN_RESPONSE)
def hello(request):
    return HttpResponse(b'hello', content_type='application/octet-stream')

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stumpylog
Comment options

Answer selected by stumpylog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants