OpenAPI support for flex fields
See original GitHub issueI am using drf-spectacular for schema generation; using the @extend_schema
decorator to add docs to my views.
Say I have a serializer named PersonSerializer
that inherits from FlexFieldsModelSerializer
. If I pass it the fields
argument, I expect it to show only those fields in the schema. Example code:
@extend_schema(
responses={201: PersonSerializer(fields=["id", "username"])},
)
@api_view(["POST"])
def my_view(request):
But the schema picks up all the default fields from the PersonSerializer
class.
I do not know if this is something that needs to be solved in this project or drf-spectacular but any help is greatly appreciated.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Issues · rsinger86/drf-flex-fields - GitHub
Dynamically set fields and expand nested resources in Django REST Framework ... Issues · rsinger86/drf-flex-fields. ... OpenAPI support for query parameters.
Read more >OpenAPI extensions | Cloud Endpoints with OpenAPI
Cloud Endpoints accepts a set of Google-specific extensions to the OpenAPI specification that configure the behaviors of the Extensible Service Proxy (ESP) ...
Read more >REST API for Oracle Fusion Cloud SCM - Create flexfields
Last Updated November 2022 You can use Oracle REST APIs to view and manage data stored in Oracle Supply Chain Management Cloud.
Read more >How OpenAPI Data Types Enable Robust APIs - Stoplight Blog
OpenAPI Provides Context to Your Schemas. The JSON data format simply declares what data types can be described. JSON Schema defines fields, ...
Read more >Describing Request Body - Swagger
If you used OpenAPI 2.0 before, here is a summary of changes to help you get ... The requestBody is more flexible in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mzanki So glad I could help!
Sure, but I was hoping for feedback from the owner before opening a PR on the repo. I guess I should open one.
@rsinger86 I’m wondering why didn’t you use get_fields instead of to_representation in FlexFieldsSerializerMixin? by taking advantage of overriding fields, drf-spectacular could also generate a proper schema. Actually, I forked your code and changed it so and is working pretty fine in my project.