Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Resolved inflecting component attributes in OpenAPI SchemaGenerator#1003

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
n2ygk merged 1 commit intodjango-json-api:masterfromsha016:openapi-formatting
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsAUTHORS
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,7 @@ Safa AlFulaij <safa1996alfulaij@gmail.com>
santiavenda <santiavenda2@gmail.com>
Sergey Kolomenkin <https://kolomenkin.com>
Stas S. <stas@nerd.ro>
Steven A. <sha0160@protonmail.com>
Swaraj Baral <baralswaraj40@gmail.com>
Tim Selman <timcbaoth@gmail.com>
Tom Glowka <glowka.tom@gmail.com>
Expand Down
1 change: 1 addition & 0 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ any parts of the framework not mentioned in the documentation should generally b
* Avoid error when `parser_context` is `None` while parsing.
* Raise comprehensible error when reserved field names `meta` and `results` are used.
* Use `relationships` in the error object `pointer` when the field is actually a relationship.
* Added missing inflection to the generated OpenAPI schema.

### Changed

Expand Down
4 changes: 2 additions & 2 deletionsexample/tests/__snapshots__/test_openapi.ambr
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -133,7 +133,7 @@
"entries": {
"$ref": "#/components/schemas/reltomany"
},
"first_entry": {
"firstEntry": {
"$ref": "#/components/schemas/reltoone"
},
"type": {
Expand DownExpand Up@@ -541,7 +541,7 @@
"entries": {
"$ref": "#/components/schemas/reltomany"
},
"first_entry": {
"firstEntry": {
"$ref": "#/components/schemas/reltoone"
},
"type": {
Expand Down
7 changes: 4 additions & 3 deletionsrest_framework_json_api/schemas/openapi.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@
from rest_framework.schemas.utils import is_list_view

from rest_framework_json_api import serializers, views
from rest_framework_json_api.utils import format_field_name


class SchemaGenerator(drf_openapi.SchemaGenerator):
Expand DownExpand Up@@ -655,12 +656,12 @@ def map_serializer(self, serializer):
if isinstance(field, serializers.HiddenField):
continue
if isinstance(field, serializers.RelatedField):
relationships[field.field_name] = {
relationships[format_field_name(field.field_name)] = {
"$ref": "#/components/schemas/reltoone"
}
continue
if isinstance(field, serializers.ManyRelatedField):
relationships[field.field_name] = {
relationships[format_field_name(field.field_name)] = {
"$ref": "#/components/schemas/reltomany"
}
continue
Expand All@@ -682,7 +683,7 @@ def map_serializer(self, serializer):
schema["description"] = str(field.help_text)
self.map_field_validators(field, schema)

attributes[field.field_name] = schema
attributes[format_field_name(field.field_name)] = schema

result = {
"type": "object",
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp