python-restx / flask-restx

Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
https://flask-restx.readthedocs.io/en/latest/
Other
2.16k stars 335 forks source link

On fields if `pattern` parameter is added swagger execute request button when clicked has no effect #415

Open ClimenteA opened 2 years ago

ClimenteA commented 2 years ago

Here is the minimum code required to replay the error:


from flask import Flask, request
from flask_restx import Resource, Api, fields

app = Flask(__name__)
api = Api(app)

simple_email_model = api.model("email_model", dict(
    email=fields.String(required=True, pattern=".+@.+")
))

@api.route('/email')
class TestEmail(Resource):

    @api.expect(simple_email_model, validate=True)
    def post(self):
        return request.json

if __name__ == '__main__':
    app.run(debug=True)

I expect if pattern doesn't match the validation should fail.

But, when I go to swagger-ui, complete the field and click on Execute button - nothing happens (the request is not made, button is freezed).

Environment