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 recursive assignment of default values to complex properties #54

Merged
merged 6 commits into from
Mar 12, 2025

Conversation

glopesdev
Copy link
Member

Although not strictly mandated by JSON-schema, it is common practice that property default values support arbitrarily nested JSON objects. This PR rearranges the default constructor code generator to support recursive assignment of default values in cases where the default value is an arbitrary JSON object.

It does this by piggybacking on provided JSON schema definitions for the model object properties, and abusing the ValueGenerator.GetDefaultValue to obtain valid code snippets for primitive property assignments.

Fixes #41

@glopesdev glopesdev added the feature New planned feature label Mar 12, 2025
@glopesdev glopesdev requested a review from bruno-f-cruz March 12, 2025 00:37
@glopesdev glopesdev merged commit d5bea4f into main Mar 12, 2025
2 checks passed
@glopesdev glopesdev deleted the property-defaults branch March 12, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New planned feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Class defaults are not honored
1 participant