Add OpenAPI JSON representation of Hiccup API
hiccup-api.json is generated using a Swagger endpoint introduced in
commit 126b0cc (Add API Documentation Endpoint; 2018-03-12)
In particular:
1. Get CSRF token from cookies:
TOKEN=$(curl \
-I http://localhost:8000/hiccup/admin/login/ \
-c django_cookies.txt \
| grep 'Set-Cookie:.*csrftoken' \
| sed 's/^.*csrftoken=\([^;]*\);.*$/\1/')
2. Login with token, username, password, and login page as referrer. We
are only interested in the side effect stored in djange_cookies.txt
curl http://localhost:8000/hiccup/admin/login/ \
-c django_cookies.txt -b django_cookies.txt \
-e http://localhost:8000/hiccup/admin/login \
-d "csrfmiddlewaretoken=${TOKEN}&username=admin&password=pw" \
-s -o /dev/null
3. Request OpenAPI JSON from /docs
curl http://localhost:8000/hiccup/docs/?format=openapi \
-c django_cookies.txt -b django_cookies.txt \
-H "Content-Type: application/openapi+json" |
> documentation/hiccup-api.json
HIC-101
(cherry-picked from commit 9ee379b7ab1a5fe07452b6de503e95e5a2da3955)
Change-Id: I0de64618ed5970cfd78c6fe89c7ad2b3392216da
1 file changed