[PR #18451] [MERGED] Allow primary key for nested models in OpenAPI request schemas #15353

Closed
opened 2025-12-30 00:21:26 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/18451
Author: @mraerino
Created: 1/21/2025
Status: Merged
Merged: 3/5/2025
Merged by: @arthanson

Base: mainHead: fix-openapi-request-pk


📝 Commits (4)

  • c232ca7 Fix request OpenAPI schemas for nested models
  • 640e438 Add none check
  • 7216a0d Change PK type to int
  • 43d21e3 Merge branch 'main' into fix-openapi-request-pk

📊 Changes

1 file changed (+20 additions, -0 deletions)

View changed files

📝 netbox/core/api/schema.py (+20 -0)

📄 Description

Fixes: https://github.com/netbox-community/netbox/issues/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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/18451 **Author:** [@mraerino](https://github.com/mraerino) **Created:** 1/21/2025 **Status:** ✅ Merged **Merged:** 3/5/2025 **Merged by:** [@arthanson](https://github.com/arthanson) **Base:** `main` ← **Head:** `fix-openapi-request-pk` --- ### 📝 Commits (4) - [`c232ca7`](https://github.com/netbox-community/netbox/commit/c232ca7acc1d626f7c6d945faf3cf9db5ecc5401) Fix request OpenAPI schemas for nested models - [`640e438`](https://github.com/netbox-community/netbox/commit/640e438ef6598290162e2f2b24d2b7bc935eb721) Add none check - [`7216a0d`](https://github.com/netbox-community/netbox/commit/7216a0d5ae663231859928f695665292dc8ff2a7) Change PK type to int - [`43d21e3`](https://github.com/netbox-community/netbox/commit/43d21e34119fc2b671565ba20e6add741f81f227) Merge branch 'main' into fix-openapi-request-pk ### 📊 Changes **1 file changed** (+20 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `netbox/core/api/schema.py` (+20 -0) </details> ### 📄 Description ### Fixes: https://github.com/netbox-community/netbox/issues/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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:21:26 +01:00
adam closed this issue 2025-12-30 00:21:27 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15353