Answer the question
In order to leave comments, you need to log in
Django Rest Framework: What is SCHEMAS used for?
I'm reading the DRF manual and I can't figure out what the ability to generate Schemas is for ? It says what is used by dynamic client libraries that can interact with the API. Who can provide an example of use?
{
"_type": "document",
"_meta": {
"url": "http://127.0.0.1:8000/schema/",
"title": "Pastebin API"
},
"snippets": {
"list": {
"_type": "link",
"url": "/snippets/",
"action": "get",
"description": "This viewset automatically provides `list`, `create`, `retrieve`,\n`update` and `destroy` actions.\n\nAdditionally we also provide an extra `highlight` action.",
"fields": [
{
"name": "page",
"location": "query",
"schema": {
"_type": "integer",
"title": "Page",
"description": "A page number within the paginated result set."
}
}
]
},
...
Answer the question
In order to leave comments, you need to log in
This is used to avoid hardcoding form fields.
For example, if the model changes, it requires a front change to add, change, or remove a field.
And with the help of the scheme, this process can be automated. That is, before creating the form, a scheme is obtained, fields and their types are taken from it, and certain inputs are built.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question