-
-
Notifications
You must be signed in to change notification settings - Fork 145
implement delegateMap attribute #2676
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: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -381,6 +381,11 @@ export function getDiscriminatorField(schema: SchemaDef, model: string) { | |
| return discriminator.value.field; | ||
| } | ||
|
|
||
| export function getDelegateDiscriminatorValue(schema: SchemaDef, model: string) { | ||
| const modelDef = requireModel(schema, model); | ||
| return modelDef.delegateMap ?? model; | ||
| } | ||
|
Comment on lines
+384
to
+387
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use canonical model name for default discriminator fallback. Line 386 falls back to the input Proposed fix export function getDelegateDiscriminatorValue(schema: SchemaDef, model: string) {
const modelDef = requireModel(schema, model);
- return modelDef.delegateMap ?? model;
+ return modelDef.delegateMap ?? modelDef.name;
}🤖 Prompt for AI Agents |
||
|
|
||
| export function getDelegateDescendantModels( | ||
| schema: SchemaDef, | ||
| model: string, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make
@@delegateMapsingle-use to avoid ambiguous mappings.Without
@@@once, multiple@@delegateMapentries on one model are accepted, while downstream resolution reads only one and silently ignores others.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents