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
python-flask uses re.match for the pattern matching in the generated model code, but it misses the import of re.
Note: I noticed that there seems to be another point in the generated server code where the pattern validation is done. You can see this by calling the following command when the server runs:
{
"detail": "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.",
"status": 500,
"title": "Internal Server Error",
"type": "about:blank"
}
The server now logs an error message
[2018-12-13 12:22:03,113] ERROR in app: Exception on /data [PUT]
Traceback (most recent call last):
File "/home/tom/.local/lib/python3.5/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
...
File "/home/tom/issues/python-flask-string-pattern/openapi_server/util.py", line 111, in deserialize_model
setattr(instance, attr, _deserialize(value, attr_type))
File "/home/tom/issues/python-flask-string-pattern/openapi_server/models/data.py", line 63, in my_item
if my_item is not None and not re.search(r'^[a-zA-Z0-9]+$', my_item): # noqa: E501
NameError: name 're' is not defined
127.0.0.1 - - [13/Dec/2018 12:22:03] "PUT /data HTTP/1.1" 500 -
Check whether duplicate check of the pattern is really required?
Probably setting the field value in the model object is used somewhere else too? Not only when verifying (remote) user input?
The text was updated successfully, but these errors were encountered:
Description
pattern
instring
schemas.python-flask
usesre.match
for the pattern matching in the generatedmodel
code, but it misses the import ofre
.Note: I noticed that there seems to be another point in the generated server code where the
pattern
validation is done. You can see this by calling the following command when the server runs:It will properly return an error:
while the server log the message:
openapi-generator version
I used OpenAPI generator CLI version
4.0.0-SNAPSHOT
:https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/openapi-generator-cli-4.0.0-20181210.103357-85.jar
OpenAPI declaration file content or url
See
python-flask-string-pattern.yaml
in the attached zip-file:python-flask-string-pattern.zip
Command line used for generation
Steps to reproduce
Generate the server code
Start the server
Perform a client request
The server now logs an error message
Related issues/PRs
Suggest a fix
Two things to cover here:
re
Probably setting the field value in the model object is used somewhere else too? Not only when verifying (remote) user input?
The text was updated successfully, but these errors were encountered: