From d02dab47a837a85f916d4767cafc027318fb34b6 Mon Sep 17 00:00:00 2001 From: Tomasz Glowka Date: Sun, 13 Sep 2020 19:50:26 +0200 Subject: [PATCH] Describe recursion support in README --- README.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 198f438..4c0a57c 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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