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
jsonapi_rpc parameters and swagger #36
Comments
However, for now this can only be used to add or override existing swagger.json. It's quite tedious too atm because you have to export the swagger.json, edit it, extract the path and "feed" it back.
|
I reformatted the example, new link: https://github.com/thomaxxl/safrs/blob/master/examples/demo_pythonanywhere_com.py#L188 The swagger editor is included when you clone the repo and run this example (like in http://thomaxxl.pythonanywhere.com/swagger_editor/index.html?url=/swagger.json ) |
Alright thanks, I'll poke around some more next week and see if I can come up with a suggestion. I think just getting the docstring parsing working would get me most of the way. |
I could parse the docstring and add the arguments to swagger. GL |
That would be great! But I think I'd need some more examples/docs as well to get the format right..
It looks like pageable and filterable are already intended to be configurable, no? Reusing some logic from |
Yeah, I will remove them: these parameters are supposed to be used for jsonapi responses. But the "jsonapi_rpc" is kind of a hack to implement rpc on top of jsonapi (hence the results in "meta"). On a different note, I think it's better to use POST for jsonapi_rpc most of the time for security reasons (easier to defend against csrf) but GET works. |
so, I commited something (a612c0b), but I'm not really happy about this atm. @jsonapi_rpc(http_methods=["GET"])
def get_by_name(cls, *args, **kwargs):
"""
description : Generate and return a Thing based on name
args:
- name: name
type: string
default: xx
pageable: false
"""
return { "result" : 1} ( https://github.com/thomaxxl/safrs/blob/master/examples/demo_pythonanywhere_com.py#L65 ) this definition is different from the "body" args in
to be continued... |
This is great! I'm able to get a properly documented custom endpoint now :) |
v2.2.2 |
I'm trying to expose a custom endpoint related to a model. It's an endpoint for generating a new object given a value, so I created something like this:
An endpoint is created and it does appear in the swagger ui, but the swagger docs are rather confusing; containing references to "page[offset]", "include", "sort", "filter" etc. It doesn't seem to be picking up on my docstring here.
It also seems like only one parameter, called "varargs", is supported?
Is there any way I can better control the docs generated and get a properly named parameter working? I could probably get parameters from the request instead of method args, but I'd still need to get the docs under control.
The text was updated successfully, but these errors were encountered: