Skip to content

Commit 522d453

Browse files
axnsan12carltongibson
authored andcommitted
Add drf-yasg to documentation and schema 3rd party packages (#5720)
Also fixed broken `swagger` link.
1 parent 68519c0 commit 522d453

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

docs/api-guide/schemas.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,12 @@ A short description of the meaning and intended usage of the input field.
806806

807807
# Third party packages
808808

809+
## drf-yasg - Yet Another Swagger Generator
810+
811+
[drf-yasg][drf-yasg] generates [OpenAPI][open-api] documents suitable for code generation - nested schemas,
812+
named models, response bodies, enum/pattern/min/max validators, form parameters, etc.
813+
814+
809815
## DRF OpenAPI
810816

811817
[DRF OpenAPI][drf-openapi] renders the schema generated by Django Rest Framework
@@ -815,6 +821,7 @@ in [OpenAPI][open-api] format.
815821
[cite]: https://blog.heroku.com/archives/2014/1/8/json_schema_for_heroku_platform_api
816822
[coreapi]: http://www.coreapi.org/
817823
[corejson]: http://www.coreapi.org/specification/encoding/#core-json-encoding
824+
[drf-yasg]: https://github.com/axnsan12/drf-yasg/
818825
[open-api]: https://openapis.org/
819826
[drf-openapi]: https://github.com/limdauto/drf_openapi
820827
[json-hyperschema]: http://json-schema.org/latest/json-schema-hypermedia.html

docs/img/drf-yasg.png

58.5 KB
Loading

docs/topics/documenting-your-api.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,21 @@ The `rest_framework.documentation` module provides three helper functions to hel
136136

137137
There are a number of mature third-party packages for providing API documentation.
138138

139+
#### drf-yasg - Yet Another Swagger Generator
140+
141+
[drf-yasg][drf-yasg] is a [Swagger][swagger] generation tool implemented without using the schema generation provided
142+
by Django Rest Framework.
143+
144+
It aims to implement as much of the [OpenAPI][open-api] specification as possible - nested schemas, named models,
145+
response bodies, enum/pattern/min/max validators, form parameters, etc. - and to generate documents usable with code
146+
generation tools like `swagger-codegen`.
147+
148+
This also translates into a very useful interactive documentation viewer in the form of `swagger-ui`:
149+
150+
151+
![Screenshot - drf-yasg][image-drf-yasg]
152+
153+
139154
#### DRF OpenAPI
140155

141156
[DRF OpenAPI][drf-openapi] bridges the gap between OpenAPI specification and tool chain with the schema exposed
@@ -278,14 +293,17 @@ In this approach, rather than documenting the available API endpoints up front,
278293
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.
279294

280295
[cite]: http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven
296+
[drf-yasg]: https://github.com/axnsan12/drf-yasg/
297+
[image-drf-yasg]: ../img/drf-yasg.png
281298
[drf-openapi]: https://github.com/limdauto/drf_openapi/
282299
[image-drf-openapi]: ../img/drf-openapi.png
283300
[drfdocs-repo]: https://github.com/ekonstantinidis/django-rest-framework-docs
284301
[drfdocs-website]: http://www.drfdocs.com/
285302
[drfdocs-demo]: http://demo.drfdocs.com/
286303
[drfautodocs-repo]: https://github.com/iMakedonsky/drf-autodocs
287304
[django-rest-swagger]: https://github.com/marcgibbons/django-rest-swagger
288-
[swagger]: https://developers.helloreverb.com/swagger/
305+
[swagger]: https://swagger.io/
306+
[open-api]: https://openapis.org/
289307
[rest-framework-docs]: https://github.com/marcgibbons/django-rest-framework-docs
290308
[apiary]: http://apiary.io/
291309
[markdown]: http://daringfireball.net/projects/markdown/

0 commit comments

Comments
 (0)