Skip to content
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

Allow primary key for nested models in OpenAPI request schemas #18451

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mraerino
Copy link
Contributor

@mraerino mraerino commented Jan 21, 2025

Fixes: #17709

The logic for passing a primary key when specifying a nested model on creation or update is hidden in some special logic in BaseModelSerializer and cannot be detected by drf-spectacular.

I'm introducing an extension that patches the write request schemas to allow for either the primary key as a number or an object with fields (what was already present).

This aligns the schema with reality.

@mraerino mraerino changed the title Fix request OpenAPI schemas for nested models Allow PK for nested models in OpenAPI request schemas Jan 22, 2025
@mraerino mraerino marked this pull request as ready for review January 22, 2025 12:54
@mraerino mraerino changed the title Allow PK for nested models in OpenAPI request schemas Allow primary key for nested models in OpenAPI request schemas Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenAPI Specification Does Not Allow Numeric IDs for Related Objects, Contrary to Documentation
1 participant