apryor6 / flask_accepts

Easy, opinionated Flask input/output handling mixing Marshmallow with flask-restx
BSD 3-Clause "New" or "Revised" License
169 stars 40 forks source link

When using the @responds decorator, X-Fields headers are automatically applied to the swagger request #102

Open preston-infiswift opened 3 years ago

preston-infiswift commented 3 years ago

Without the @responds decorator, my function has no header fields in the request, just a json payload.

When I add @responds along with a schema, X-Fields is added to the request in swagger. I'd like a way to disable this, as it makes my swagger more confusing to my end user.

image

Here's the code in question. Trying to understand how I could disable this, or if it needs a code change.

class UserLogin(Resource):
    @accepts(schema=UserInputSchema, api=api)
    @responds(schema=TokenSchema, api=api)
    def post(self):
        """Login"""
        access_token = UserService.login(request.parsed_obj)
        if access_token is None:
            return {'error': 'invalid username or password'}, 401
        return {'access_token': access_token}

Here's the call in flask_accepts that seems to be adding this

https://github.com/apryor6/flask_accepts/blob/38824c4b4f5ed2a7f6c017351c45d7cd226479de/flask_accepts/decorators/decorators.py#L280

preston-infiswift commented 3 years ago

It does seem like this provides a workaround, but it feels hacky https://github.com/apryor6/flask_accepts/issues/17#issuecomment-645105209

ghost commented 1 year ago

You can add RESTX_MASK_SWAGGER = False to your flask config, and it should disable field masks entirely (including in the swagger docs)