I want to make a swagger document of my project, so I tried to generate a dynamic schema for my APIs, using django rest automatic dynamic generated schema, as said in its document.
This is my urls.py:
from django.urls import path, include
from rest_framework.schemas import get_schema_view
schema_view = get_schema_view(title="Example API")
urlpatterns = [
path("schema/", schema_view, name="schema"),
...
]
And this is one of my view serializers:
class BookSerializer(serializers.ModelSerializer):
summary_publisher_name = serializers.ReadOnlyField(source="published_by.name")
authors = AuthorSerializer(many=True)
chapters = ChapterSerializer(many=True, read_only=True)
class Meta:
model = Book
fields = ["title", "summary_publisher_name", "authors", "chapters"]
...
The problem is that in generated schema, there is none of these API parameters. How can I add them to schema? Is there any automation way, or I need to add all fields for any of my views, by myself?