Pavel Gribov
Pavel Gribov

Reputation: 167

The header name "headers" is not set in the GET request processing declaration

I'm trying to set the name of the header in the model description, but it remains empty in the documentation. What am I doing wrong?

Example:

@router.get('/hash_header',response_model=models.hash_out,tags=["use-hash"],responses={
        200: {
            "model": models.hash_out,
            "description": "Return has code",
            "headers": [
                {'name':"Secret-Code","description":"Secret code","type":"string"}
            ]
        }        
})

In the docs: enter image description here

Upvotes: 1

Views: 312

Answers (1)

MatsLindh
MatsLindh

Reputation: 52912

headers should be a dictionary with the name as a key, not a list:

@router.get('/hash_header',response_model=models.hash_out,tags=["use-hash"],responses={
    200: {
        "model": models.hash_out,
        "description": "Return has code",
        "headers": {
            "Secret-Code": {"description":"Secret code","type":"string"}
        }
    }        
})

Upvotes: 1

Related Questions