We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Users can add additional information with x-fields. But Python does not accept identifiers with dashses.
Here are some common vendor extensions documented: https://github.com/Redocly/redoc/blob/main/docs/redoc-vendor-extensions.md#x-logo
Here is example spec:
openapi: 3.0.0 info: title: Example version: 1.0.0 x-audience: company-internal x-logo: url: https://www.example.com/company-logo.png
The generated code looks like this
app = FastAPI( title='Example', version='1.0.0', x - audience='company-internal', x - logo={'url': 'https://www.example.com/company-logo.png'}, )
I fixed it this way:
--- fastapi_code_generator/template/main.jinja2.orig 2023-02-13 16:11:00.677867572 +0100 +++ fastapi_code_generator/template/main.jinja2 2023-02-13 16:37:28.944897684 +0100 @@ -8,7 +8,9 @@ {% if info %} {% for key,value in info.items() %} {% set info_value= value.__repr__() %} + {%- if not key.startswith("x-") -%} {{ key }} = {{info_value}}, + {%- endif -%} {% endfor %} {% endif %} )
First I tried to add all fields as a dict passed as kwargs:
app = FastAPI(**{ 'title': 'Example', 'version': '1.0.0', 'x-audience': 'company-internal', 'x-logo': {'url': 'https://www.example.com/company-logo.png'}, })
But ignoring these fields seems sufficient because FastAPI ignores them anyway.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Users can add additional information with x-fields. But Python does not accept identifiers with dashses.
Here are some common vendor extensions documented: https://github.com/Redocly/redoc/blob/main/docs/redoc-vendor-extensions.md#x-logo
Here is example spec:
The generated code looks like this
I fixed it this way:
First I tried to add all fields as a dict passed as kwargs:
But ignoring these fields seems sufficient because FastAPI ignores them anyway.
The text was updated successfully, but these errors were encountered: