Skip to content

Commit 62ecbf2

Browse files
limdautoCarlton Gibson
authored andcommitted
Add drf-openapi (#5470)
* Add DRF OpenAPI as a 3rd party tool for DRF doc * Add image * Add third party packages section to schema doc * Add DRF OpenAPI reference
1 parent e6193cf commit 62ecbf2

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

docs/api-guide/schemas.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,10 +765,21 @@ Valid only if a `location="body"` field is included on the `Link`.
765765
A short description of the meaning and intended usage of the input field.
766766

767767

768+
---
769+
770+
# Third party packages
771+
772+
## DRF OpenAPI
773+
774+
[DRF OpenAPI][drf-openapi] renders the schema generated by Django Rest Framework
775+
in [OpenAPI][open-api] format.
776+
777+
768778
[cite]: https://blog.heroku.com/archives/2014/1/8/json_schema_for_heroku_platform_api
769779
[coreapi]: http://www.coreapi.org/
770780
[corejson]: http://www.coreapi.org/specification/encoding/#core-json-encoding
771781
[open-api]: https://openapis.org/
782+
[drf-openapi]: https://github.com/limdauto/drf_openapi
772783
[json-hyperschema]: http://json-schema.org/latest/json-schema-hypermedia.html
773784
[api-blueprint]: https://apiblueprint.org/
774785
[static-files]: https://docs.djangoproject.com/en/stable/howto/static-files/

docs/img/drf-openapi.png

73.6 KB
Loading

docs/topics/documenting-your-api.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ When using viewsets, you should use the relevant action names as delimiters.
7575

7676
There are a number of mature third-party packages for providing API documentation.
7777

78+
#### DRF OpenAPI
79+
80+
[DRF OpenAPI][drf-openapi] bridges the gap between OpenAPI specification and tool chain with the schema exposed
81+
out-of-the-box by Django Rest Framework. Its goals are:
82+
83+
* To be dropped into any existing DRF project without any code change necessary.
84+
* Provide clear disctinction between request schema and response schema.
85+
* Provide a versioning mechanism for each schema. Support defining schema by version range syntax, e.g. >1.0, <=2.0
86+
* Support multiple response codes, not just 200
87+
* All this information should be bound to view methods, not view classes.
88+
89+
It also tries to stay current with the maturing schema generation mechanism provided by DRF.
90+
91+
![Screenshot - DRF OpenAPI][image-drf-openapi]
92+
93+
---
94+
7895
#### DRF Docs
7996

8097
[DRF Docs][drfdocs-repo] allows you to document Web APIs made with Django REST Framework and it is authored by Emmanouil Konstantinidis. It's made to work out of the box and its setup should not take more than a couple of minutes. Complete documentation can be found on the [website][drfdocs-website] while there is also a [demo][drfdocs-demo] available for people to see what it looks like. **Live API Endpoints** allow you to utilize the endpoints from within the documentation in a neat way.
@@ -197,6 +214,8 @@ In this approach, rather than documenting the available API endpoints up front,
197214
To implement a hypermedia API you'll need to decide on an appropriate media type for the API, and implement a custom renderer and parser for that media type. The [REST, Hypermedia & HATEOAS][hypermedia-docs] section of the documentation includes pointers to background reading, as well as links to various hypermedia formats.
198215

199216
[cite]: http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven
217+
[drf-openapi]: https://github.com/limdauto/drf_openapi/
218+
[image-drf-openapi]: ../img/drf-openapi.png
200219
[drfdocs-repo]: https://github.com/ekonstantinidis/django-rest-framework-docs
201220
[drfdocs-website]: http://www.drfdocs.com/
202221
[drfdocs-demo]: http://demo.drfdocs.com/

0 commit comments

Comments
 (0)