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

Add Swagger for supported marshmallow validators #54

Open
BenC14 opened this issue Dec 17, 2019 · 8 comments
Open

Add Swagger for supported marshmallow validators #54

BenC14 opened this issue Dec 17, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@BenC14
Copy link

BenC14 commented Dec 17, 2019

I am trying to add a string field to my Schema which uses the validate.OneOf() from marshmallow. I see the correct error response if I pass a bad option to this field but the Swagger UI does not have the helpful options in model description. Are there plans to add maps from the native marshmallow validators to the supported Flask-Restplus validators.

Screen Shot 2019-12-17 at 2 14 43 PM

I was able to achieve this behavior using the api.model from Restplus
@BenC14
Copy link
Author

BenC14 commented Dec 17, 2019

As a side thought one of the reasons this is so frustrating is the limitation that you cannot modify the fields generated by the for_swagger method if they come from a marshmallow schema. Obviously this is the main feature of the whole library so I can understand why it isn't a feature yet. However if there was a way to override or extend fields from the schema using the dict() parameters you would preserve the convenience of marshmallow schema's for the common case while allowing for slight modifications when you need to make a single field change. Just a thought.

@apryor6
Copy link
Owner

apryor6 commented Dec 21, 2019

There is also some semi-relevant discussion in #16

@apryor6
Copy link
Owner

apryor6 commented Dec 21, 2019

I am completely open to enabling this functionality. It was deprioritized previously due to being an outsized amount of work versus a smallish unlock, but if a increasing number of users have need for this then that priority goes up.

My bandwidth is nonexistent as of late, but if you’d like to take a stab I’m happy to comment/mentor/discuss through it.

@apryor6 apryor6 added the enhancement New feature or request label Apr 1, 2020
@azzamsa
Copy link
Contributor

azzamsa commented Jun 5, 2020

My point of using swagger is that for internal/private app, I don't need to write docs alongside the app.

My web app had many fields with validate.OneOf() schema. They didn't show up in swagger. So the end-user can't know what are available options.

+1

@yujinyuz
Copy link

+1 for this feature

@yujinyuz
Copy link

Are there any workarounds for this to work?

@apryor6
Copy link
Owner

apryor6 commented Jun 12, 2020

I don't see any way for a workaround without implementing the above mapping. If we mapped the validators in a similar fashion to how the fields are mapped from marshmallow to restx, then the docs should work. It will require a bit of dev work which I can't provide right now - but would be a great contribution opportunity.

@eduardovra
Copy link

+1 for this feature

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

No branches or pull requests

5 participants