-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[generators] Give clients a way to inject vendor overrides #24571
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: master
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 |
|---|---|---|
|
|
@@ -883,6 +883,19 @@ protected void patchProperty(Map<String, CodegenModel> enumRefs, CodegenModel mo | |
| if (property.datatypeWithEnum.equals("decimal")) { | ||
| property.isDecimal = true; | ||
| } | ||
|
|
||
| // Normalize x-setter-visibility: | ||
| // "public" -> remove extension, set isReadOnly=false (public setter = default, no modifier needed) | ||
| // any other value -> set isReadOnly=true (template emits "{{.}} set;" using the extension value) | ||
| Object setterVisibilityObj = property.vendorExtensions.get("x-setter-visibility"); | ||
| if (setterVisibilityObj instanceof String) { | ||
| if ("public".equals(setterVisibilityObj)) { | ||
| property.vendorExtensions.remove("x-setter-visibility"); | ||
| property.isReadOnly = false; | ||
|
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. P2: The model's mutability flag (X_MODEL_IS_MUTABLE), which controls whether the generated C# model gets a public or internal constructor, is computed in postProcessModels() at line 647 before patchProperty() runs, so the new x-setter-visibility normalization that flips property.isReadOnly isn't reflected in that decision. For the 'public' override direction (a spec readOnly property turned into a public setter), the model can still be generated with an internal constructor even though its property now has a public setter, preventing external callers from actually using it. Consider recomputing model mutability after this normalization (or computing it after the per-property patches) so the constructor visibility matches the effective setter access. Prompt for AI agents |
||
| } else { | ||
| property.isReadOnly = true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.