-
Notifications
You must be signed in to change notification settings - Fork 31
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 Documention To The API #2227
Conversation
* add django-rest-swagger to document the public API * add markdown to allow using markdown in the docstrings that show up in swagger * setup an initial swagger config with docs available at /api/docs
Taking a look now. |
In addition to |
Thanks, I've updated the testing instructions to include the Not sure what's up with the markdown. Maybe check if the |
I do seem to have it: vagrant@app:/vagrant/src/mmw/requirements$ sudo pip list | grep -i markdown
Markdown (2.6.9) |
A hard refresh fixed it. It may have been a leftover from when I loaded the page with bad JavaScript before running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"displayName": "Land", | ||
"name": "land", | ||
"categories": [ | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll normalize these before merging.
Thanks for reviewing! I am also not sure where the |
* Write up an initial pass for the API views' documentation. Includes job descriptions as well as example requests, request types and formats, and example responses. * NB: The example responses make the docstrings incredibly lengthy. While they appear nicely in Swagger under <details> elements, we may need to consider declaring them outside the views file
1fc13e5
to
c89db87
Compare
I've prettified the JSON in the docstrings. Will merge when the build completes. |
The user namespace is added to the user URLs, which, because of our Swagger configuration, prevents the URLs from showing up in the documentation. This was originally added in #2227, but it broke compatiability with ITSI and was removed in #2377. The namespace is readded here along with a fix to the ITSI login view. When calling reverse on a URL which is included in a namespace, the namespace must also be added to the reverse parameter. See https://stackoverflow.com/a/38390178/217378. Refs #2401
The user namespace is added to the user URLs, which, because of our Swagger configuration, prevents the URLs from showing up in the documentation. This was originally added in #2227, but it broke compatibility with ITSI and was removed in #2377. The namespace is added here again along with a fix to the ITSI login view. When calling reverse on a URL which is included in a namespace, the namespace must also be added to the reverse parameter. See https://stackoverflow.com/a/38390178/217378. Refs #2401
Overview
django-rest-swagger
to the project/analyze
s and/rwd
)Connects #2185
Demo
Notes
The example outputs make the docstrings real lengthy. I'll open an issue to look into moving them out of the implementation files, but for now we can make like @rajadain and set our editors to auto-collapse them.
The example responses are shown as regular json, but the response currently returns stringified json. We'll fix the response type in Geoprocessing API: Responses should be proper json #2200
Testing Instructions
vagrant ssh app -c 'cd /vagrant/src/mmw/requirements && sudo pip install -r development.txt'
./scripts/manage.sh collectstatic
localhost:8000/api/docs/
Here's an example
analyze
aoi: