File tree Expand file tree Collapse file tree 4 files changed +8
-5
lines changed
example/tests/__snapshots__
rest_framework_json_api/schemas Expand file tree Collapse file tree 4 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ Safa AlFulaij <safa1996alfulaij@gmail.com>
3939santiavenda <santiavenda2@gmail.com>
4040Sergey Kolomenkin <https://kolomenkin.com>
4141Stas S. <stas@nerd.ro>
42+ Steven A. <sha0160@protonmail.com>
4243Swaraj Baral <baralswaraj40@gmail.com>
4344Tim Selman <timcbaoth@gmail.com>
4445Tom Glowka <glowka.tom@gmail.com>
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ any parts of the framework not mentioned in the documentation should generally b
1616* Avoid error when ` parser_context ` is ` None ` while parsing.
1717* Raise comprehensible error when reserved field names ` meta ` and ` results ` are used.
1818* Use ` relationships ` in the error object ` pointer ` when the field is actually a relationship.
19+ * Added missing inflection to the generated OpenAPI schema.
1920
2021### Changed
2122
Original file line number Diff line number Diff line change 133133 "entries": {
134134 "$ref": "#/components/schemas/reltomany"
135135 },
136- "first_entry ": {
136+ "firstEntry ": {
137137 "$ref": "#/components/schemas/reltoone"
138138 },
139139 "type": {
541541 "entries": {
542542 "$ref": "#/components/schemas/reltomany"
543543 },
544- "first_entry ": {
544+ "firstEntry ": {
545545 "$ref": "#/components/schemas/reltoone"
546546 },
547547 "type": {
Original file line number Diff line number Diff line change 77from rest_framework .schemas .utils import is_list_view
88
99from rest_framework_json_api import serializers , views
10+ from rest_framework_json_api .utils import format_field_name
1011
1112
1213class SchemaGenerator (drf_openapi .SchemaGenerator ):
@@ -655,12 +656,12 @@ def map_serializer(self, serializer):
655656 if isinstance (field , serializers .HiddenField ):
656657 continue
657658 if isinstance (field , serializers .RelatedField ):
658- relationships [field .field_name ] = {
659+ relationships [format_field_name ( field .field_name ) ] = {
659660 "$ref" : "#/components/schemas/reltoone"
660661 }
661662 continue
662663 if isinstance (field , serializers .ManyRelatedField ):
663- relationships [field .field_name ] = {
664+ relationships [format_field_name ( field .field_name ) ] = {
664665 "$ref" : "#/components/schemas/reltomany"
665666 }
666667 continue
@@ -682,7 +683,7 @@ def map_serializer(self, serializer):
682683 schema ["description" ] = str (field .help_text )
683684 self .map_field_validators (field , schema )
684685
685- attributes [field .field_name ] = schema
686+ attributes [format_field_name ( field .field_name ) ] = schema
686687
687688 result = {
688689 "type" : "object" ,
You can’t perform that action at this time.
0 commit comments