Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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"}
        }
    }        
})
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading