Home > front end >  The header name "headers" is not set in the GET request processing declaration
The header name "headers" is not set in the GET request processing declaration

Time:09-09

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

CodePudding user response:

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