You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have you provided a full/minimal spec to reproduce the issue?
Have you validated the input using an OpenAPI validator (example)?
Have you tested with the latest master to confirm the issue still exists?
Have you searched for related issues/PRs?
What's the actual output vs expected output?
Description
I am attempting to use a spec that I have no control over (I cannot just change the spec). A "step" structure is implemented with from and to properties; however, when the structure is nested, the from keyword does not get escaped. This results in invalid Python code being produced.
Upon importing the models, I am instantly hit with a syntax error:
>>> import openapi_client.models
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/dist-packages/openapi_client/models/__init__.py", line 14, in <module>
from openapi_client.model.my_response import MyResponse
File "/usr/local/lib/python3.8/dist-packages/openapi_client/model/my_response.py", line 45
def from() -> typing.Type['MyResponseData']:
^
SyntaxError: invalid syntax
The associated code looks like (shortened slightly for brevity):
I do not know what the entirety of this code should look like, but I do know that the specific code producing the syntax error should at least look like this:
Bug Report Checklist
Description
I am attempting to use a spec that I have no control over (I cannot just change the spec). A "step" structure is implemented with
from
andto
properties; however, when the structure is nested, thefrom
keyword does not get escaped. This results in invalid Python code being produced.Upon importing the models, I am instantly hit with a syntax error:
The associated code looks like (shortened slightly for brevity):
I do not know what the entirety of this code should look like, but I do know that the specific code producing the syntax error should at least look like this:
openapi-json-schema-generator version
master branch; this is not a regression as the issue was reported here (and it is still an issue): OpenAPITools/openapi-generator#7119
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Built a Docker image from the following Dockerfile:
Then built and ran with:
docker build -t openapi-test -f Dockerfile.openapi . docker run -it --rm openapi-test bash
Then from within docker
And lastly, tried using the generated code:
HOWEVER THIS SPEC WORKS (no nesting)
Related issues/PRs
OpenAPITools/openapi-generator#7119
Suggest a fix
I am not sure how to fix this, but it seems like the
escapeReservedWord
function is not being called properly?Edits
The text was updated successfully, but these errors were encountered: