-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to get a constant/static value for a field? #144
Labels
question
Open question
Comments
Seems to be an open issue: OAI/OpenAPI-Specification#1313. So not currently possible, and most likely never will be possible in OpenAPI 2. Best you could do would probably be adding a result_type = serializers.ModelField(model_field='result_type', default=ModelClass.result_type, help_text='Always "' + ModelClass.result_type + '"') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's my use case:
I'd like to define a field on a Django model like
result_type = 'staff'
, expose it in a DRF serializer by including it infields = (..., 'result_type')
, and have the static value 'staff' exposed in the schema.I want this because we use the schema to generate flowtypes for our project, and we sometimes need to do type refinements between models, and a static value would help tremendously here.
The text was updated successfully, but these errors were encountered: