Skip to content

Commit

Permalink
Describe recursion support in README
Browse files Browse the repository at this point in the history
  • Loading branch information
glowka committed Sep 13, 2020
1 parent a6833e6 commit d02dab4
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ This package makes [drf-yasg Yet Another Swagger Generator](https://github.com/a
- [Extending drg-yasg configuration](#extending-drg-yasg-configuration)
- [Renderers and parsers](#renderers-and-parsers)
- [Features](#features)
- [Main request/response JSON API schema support](#main-requestresponse-json-api-schema-support)
- [`data` field with `id`, `type`, `relationships`, `attributes` structure](#data-field-with-id-type-relationships-attributes-structure)
- [Main request/response JSON API schema support:](#main-requestresponse-json-api-schema-support)
- [`data` field with `id`, `type`, `relationships`, `attributes` structure](#data-field-with-id-type-relationships-attributes-structure)
- [`included` field and `include` query param](#included-field-and-include-query-param)
- [`filter` query param](#filter-query-param)
- [pagination](#pagination)
- [Additional](#additional)
- [Support for `swagger_auto_schema` decorator of `drf-yasg`](#support-for-swagger_auto_schema-decorator-of-drf-yasg)
- [Stripping `write_only` fields from response and `read_only` from request](#stripping-write_only-fields-from-response-and-read_only-from-request)
- [Extra `x-writeOnly` and `x-readOnly` properties](#extra-x-writeonly-and-x-readonly-properties)
- [Coexistence of JSON API views with pure REST API views](#coexistence-of-json-api-views-with-pure-rest-api-views)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -188,6 +191,25 @@ inspector with `drf_yasg_json_api.inspectors.InlineSerializerInspector`
- `x-readOnly` to mark read only fields even if they are nested
- `x-witeOonly` adds missing support for write only fields

### Coexistence of JSON API views with pure REST API views

JSON API docs will be generated by `drf_yasg_json_api.inspectors.JSONAPISerializerInspector`,
**non** JSON API views are ignored by this inspector.

Pure REST API docs will be generated by `drf-yasg` inspectors – either
`drf_yasg.inspectors.ReferencingSerializerInspector` or `drf_yasg.inspectors.InlineSerializerInspector` depending on
which one you prefer to use.

#### RecursiveField

RecursiveField follows different approach from JSON API, so it cannot be used with
`JSONAPISerializerInspector`, but you can still have pure REST API views that will be documented
using `ReferencingSerializerInspector`.

Alternatively, instead of `RecursiveField` you can use [`included_serializers`](https://github.com/django-json-api/django-rest-framework-json-api/blob/9c49b65894a38a185b34737f569785d720eccc67/docs/usage.md#included)
with `self` (e.g. `included_serializers = {'related-obj': 'self'}`) to implement limited in depth recursion
the JSON API way.


[build-status-image]: https://secure.travis-ci.org/glowka/drf-yasg-json-api.svg?branch=master
[travis]: https://travis-ci.org/glowka/drf-yasg-json-api?branch=master
Expand Down

0 comments on commit d02dab4

Please sign in to comment.