Schema generator: ReadOnlyField missing #8066
Unanswered
peterthomassen
asked this question in
Question & Answer
Replies: 1 comment
-
Anyone available to help Peter dig into this? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context
I have an endpoint to create an API token, which is stored in the database in hashed form. When GET'ing a token, the plain value is therefore not included. However, when the token is being created via POST, the response should contain an extra field (
token
) with the plain value. This field is dropped when not needed. The schema generator does not seem to handle this case properly.urls.py contains:
views.py has the following view:
serializers.py has the following serializer:
models.py has the following model:
Problem
According to the serializer's Meta.fields setting, the response contains
is_valid
andtoken
.I generated a schema with
./manage.py generateschema --file openapi-schema.yml
. The schema has the fieldis_valid
, but nottoken
.get_fields()
?Beta Was this translation helpful? Give feedback.
All reactions