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

Omit id field from OpenAPI schema attributes #1156

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

Merged
sliverc merged 1 commit into django-json-api:main from arttuperala:autoschema-skip-id
Jun 13, 2023
Merged

Omit id field from OpenAPI schema attributes #1156

sliverc merged 1 commit into django-json-api:main from arttuperala:autoschema-skip-id
Jun 13, 2023

Conversation

Copy link
Contributor

@arttuperala arttuperala commented Jun 8, 2023

Description of the Change

Omits the "id" field from /data/attributes the OpenAPI schema, as the JSONRenderer explicitly removes it from the attributes.

{
 "type": "object",
 "required": ["type", "id"],
 "additionalProperties": False,
 "properties": {
 "type": {"$ref": "#/components/schemas/type"},
 "id": {"$ref": "#/components/schemas/id"},
 "links": { ... },
 "attributes": {
 "type": "object",
 "properties": {
 "id": {"type": "integer", "readOnly": True}, # <- Not real
 "name": {"type": "string", "maxLength": 100},
 },
 "required": ["name"],
 },
 "relationships": { ... },
 },
}

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this change. Could you resolve the merge conflict? I am then happy to merge it.

@sliverc sliverc self-requested a review June 13, 2023 05:53
Copy link
Member

sliverc commented Jun 13, 2023

Thanks for working on this. In case others stumble upon this as well and as I mentioned in #1157. OpenAPI schema support will be deprecated soon in DJA (reason being is that DRF has also deprecated it). We will still add small changes like this, we do recommend to use drf-spectecular-json-api though. That library is just getting started, so it would certainly be great to support it.

@sliverc sliverc merged commit 66d2de4 into django-json-api:main Jun 13, 2023
Copy link
Contributor Author

I'll have to look at migrating to that library at some point. We're currently only using the built-in DJA schema generation at my workplace and we figured that we'd contribute some of the fixes we've had to do during our implementation to upstream as well.

Copy link
Member

sliverc commented Jun 13, 2023

That is great. Very much appreciated your contribution. It would be great if you could take a look at drf-spectecular-json-api as it could certainly need some support.

auvipy reacted with thumbs up emoji

@arttuperala arttuperala deleted the autoschema-skip-id branch June 27, 2023 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@sliverc sliverc sliverc approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /