-
-
Notifications
You must be signed in to change notification settings - Fork 122
fix(plugin-oas): prevent circular type references when child extends discriminator parent via allOf #2074
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
base: main
Are you sure you want to change the base?
Conversation
|
The preview deployment for kubb-labs/kubb:main is ready. 🟢 Open Preview | Open Build Logs Last updated at: 2025-11-28 23:14:56 CET |
🦋 Changeset detectedLatest commit: 677b44e The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…discriminator parent via allOf Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
More templates
@kubb/cli
@kubb/core
kubb
@kubb/mcp
@kubb/oas
@kubb/plugin-client
@kubb/plugin-cypress
@kubb/plugin-faker
@kubb/plugin-mcp
@kubb/plugin-msw
@kubb/plugin-oas
@kubb/plugin-react-query
@kubb/plugin-redoc
@kubb/plugin-solid-query
@kubb/plugin-svelte-query
@kubb/plugin-swr
@kubb/plugin-ts
@kubb/plugin-vue-query
@kubb/plugin-zod
unplugin-kubb
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2074 +/- ##
==========================================
+ Coverage 80.06% 80.09% +0.03%
==========================================
Files 139 139
Lines 5146 5169 +23
Branches 2192 2202 +10
==========================================
+ Hits 4120 4140 +20
- Misses 922 924 +2
- Partials 104 105 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot This does not work, see following openapi example { |
…eferences Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
I've verified the fix works with the full PaymentAccountDetailsResponse spec from the original issue. Added a comprehensive test in commit 6878b2f that uses the exact schema structure (PaymentAccountDetailsResponse with discriminator + ACHDetailsResponse/DomesticWireDetailsResponse/etc extending via allOf). The test passes and shows the circular reference is now correctly avoided - child schemas get a plain reference to the parent instead of the nested discriminator constraint. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
|
@copilot Still does not work with previous swagger file, also double check the typecheck and see if we are not having circularly references itself |
…r parents Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
|
@copilot retry my previous comment/prompt |
Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
… class method Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
|
@copilot Also add changelog in docs/changelog.md based on changeset and changes |
…rcular detection Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
|
@copilot Check typescript issues and fix that |
|
@copilot retry |
|
@copilot retry |
Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
|
@copilot add test case to see if the issue has been resolved in our typescript plugin (see ACHDetailsResponse in examples/advanced) |
Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
allOfto extend a discriminator parentallOfand the parent'soneOf/anyOfreferences the child, including the parent in the child's allOf creates a circular referencewouldCreateCircularReferenceas a reusable private class method#wouldCreateCircularReferenceOriginal prompt
This section details on the original issue you should resolve
<issue_title>Self-referential circular type references</issue_title>
<issue_description>### What version of
kubbis running?4.7.0
What kind of platform do you use?
MacOS
Your
kubb.config.tsconfig file?Swagger/OpenAPI file?
{ "openapi": "3.0.1", "info": { "title": "Payments API", "description": "\nThe payments API allows you to initiate and manage payments and vendors from your Brex business accounts.\n", "contact": { "name": "Admin", "url": "https://brex.com", "email": "developer-support@brex.com" }, "version": "1.0" }, "servers": [ { "url": "https://platform.brexapis.com", "description": "Production" }, { "url": "https://platform.staging.brexapps.com", "description": "Staging (Note: This is not a sandbox. It will not work with customer tokens.)" } ], "security": [ { "OAuth2": [] } ], "tags": [ { "name": "Vendors", "description": "Endpoints to manage vendors" }, { "name": "Transfers", "description": "Endpoints to initiate transfers and view transfer statuses. Note that for all transfer endpoints, the 'money' field is positive or unsigned for outgoing transfers (debits), and negative for incoming transfers (credits)." }, { "name": "Linked Accounts", "description": "Endpoint to view connected linked accounts" } ], "paths": { "/v1/incoming_transfers": { "post": { "tags": [ "Transfers" ], "summary": "\nCreate incoming transfer\n", "description": "\nThis endpoint creates a new incoming transfer. You may use use any eligible bank account connection to fund (ACH Debit) \nany active Brex business account.\n\n**Reminder**: You may not use the Brex API for any activity that requires a license or registration from any \ngovernmental authority without Brex's prior review and approval. This includes but is not limited to any money services\nbusiness or money transmission activity.\n\nPlease review the <a href=\"https://www.brex.com/legal/developer-portal/\">Brex Access Agreement</a> and contact us if \nyou have any questions.\n", "operationId": "createIncomingTransfer", "parameters": [ { "name": "Idempotency-Key", "in": "header", "required": true, "schema": { "type": "string" } } ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateIncomingTransferRequest" } } }, "required": true }, "responses": { "200": { "description": "createIncomingTransfer 200 response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Transfer" } } } } }, "security": [ { "OAuth2": [ "incoming_transfers" ] } ] } }, "/v1/linked_accounts": { "get": { "tags": [ "Linked Accounts" ], "summary": "\nLists linked accounts\n", "description": "\nThis endpoint lists all bank connections that are eligible to make ACH transfers to Brex business account\n", "operationId": "listLinkedAccounts", "parameters": [ { "name": "cursor", "in": "query", "schema": { "type": "string", "nullable": true } }, { "name": "limit", "in": "query", "schema": { "type": "integer", "format": "int32", "nullable": true } } ], "responses": { "200": { "description": "Returns a list of bank connections", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Page_BankConnection_" } } } }, "400": { "description": "Bad request" }, "401": { "description": "Unauthorized" }, "403": { "description": "Forbidden" } ... </details> - Fixes kubb-labs/kubb#2072 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.