fastapi-code-generator
fastapi-code-generator copied to clipboard
Confused how to set up an API key auth using this generator
Hello! This looks very cool.
I can create the server fine, and load the jinja templates, but I'm not sure how to assign the correct Security to operations.
I want to add these:
"BearerAuth": {
"type": "http",
"scheme": "bearer"
},
or
API-key-header:
in: header
name: Authorization
type: apiKey
How do I add this into the jinja template properly?
@maneeshsethi I'm sorry for my late reply.
There is an example template for security.
https://github.com/koxudaxi/fastapi-code-generator/blob/master/tests/data/custom_template/security/main.jinja2
And, this is generated file. https://github.com/koxudaxi/fastapi-code-generator/blob/master/tests/data/expected/openapi/custom_template_security/custom_security/main.py
Does the example help you?