Skip to content
New issue

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

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

Open
preston-infiswift opened this issue Mar 28, 2021 · 2 comments

Comments

@preston-infiswift
Copy link

preston-infiswift commented Mar 28, 2021

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

serialized = _apply_restx_mask(serialized)

@preston-infiswift preston-infiswift changed the title When using the @response decorator, X-Fields headers are automatically applied to the swagger request When using the @responds decorator, X-Fields headers are automatically applied to the swagger request Mar 28, 2021
@preston-infiswift
Copy link
Author

preston-infiswift commented Mar 28, 2021

It does seem like this provides a workaround, but it feels hacky
#17 (comment)

@ghost
Copy link

ghost commented Feb 12, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant