luolingchun / flask-openapi3

Generate REST API and OpenAPI documentation for your Flask project.
https://luolingchun.github.io/flask-openapi3/
MIT License
189 stars 29 forks source link

Required header is not found #42

Closed elirud closed 2 years ago

elirud commented 2 years ago

Environment:

Not sure what is going wrong here. I followed the documentation for adding path parameters and json body information. I then noticed there was no example for headers, but I just made the same as the path.

class AuthHeader(BaseModel): api_key: str = Field(..., description="API Key")

and added it to the function as header: AuthHeader.

Checked the swagger UI and sure enough it showed up as a required field under parameters, and the generated curl command looks logical enough, adding it as expected -H "api_key: supersecretapikey". But it keep getting the following back if I keep the api_key field required.

[ { "loc": [ "api_key" ], "msg": "field required", "type": "value_error.missing" } ]

I get it from the "Try it out" on swagger UI, and from the curl command as well.

luolingchun commented 2 years ago

@elirud I did a test, api_key be converted to Api-Key.

So you can use apikey instead of api_key before this bug is fixed.