-
Notifications
You must be signed in to change notification settings - Fork 73
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
How do I provide example values for PaginationParameterSchema? #363
Comments
I suppose I could add those two "example" lines to the core, I don't think it would hurt. This wouldn't address the root issue (#327) which is pagination customization. Subclassing and overriding Why did you have to duplicate |
I duplicated If that helper function was converted into an instance method of |
Oh, right. My comment above assumed it was a class or instance method. We should make it a class or instance method, indeed. I'm open to other suggestions about pagination mixin rework. |
I really like adding example data to my OpenAPI spec. It helps some of my users understand my API endpoints more easily, and Rapidoc UI has a convenient "Fill Example" button to autofill example data when playing with the API interactively.
In general, I can add the
example=
orexamples=
keyword arguments to blueprint decorators to provide OpenAPI example data for parameters, return values, etc. I've also noticed that I can put these keywords in themarshmallow.field()
definition to get the same effect. However, I can't find a way to specify example values for the automatic paging parameters added with theBlueprint.paginate
decorator. The decorator itself doesn't expose a**kwargs
parameter, and the schema of the generated object is created on the fly in a private helper function.So far, the only way I've found to add examples to these values is by subclassing Blueprint, copy/pasting both
paginate
and the helper function_pagination_parameters_schema_factory
, and adding example values to the anonymous class in that helper, like this:I'm opening this as an issue rather than just submitting a PR for that change because I'm new to flask-smorest and Marshmallow, and I could just be missing something obvious. This seems similar to #327, but not identical.
Is there an easier / better way to provide example data for these pagination fields?
The text was updated successfully, but these errors were encountered: