-1

Let me know someone way to output header name

I wrote response the following code,

    responses={
    st.HTTP_200_OK: {
        "model": main_response_data,
        "description": "main response data",
        "headers": [{"header_name":"response_key", "description": "Response key", "type": "string"}]
    },

But after run, OpenAPI document output "0" at header name

headers
Name       Description         Type
------------------------------------------
0           Response key         string

1 Answers1

2

headers should be a dictionary with the HTTP-header as a key:

"headers": {"response_key": {"description": "Response key", "type": "string"}}

When you define it as a list instead, the index will be used as the key - i.e. why you're getting 0.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84