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

>Solution :

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"}
        }
    }        
})

Leave a Reply