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

Nullable AdditionalProperties? #1543

Closed
ackginger opened this issue Jul 29, 2022 · 0 comments · Fixed by #1552
Closed

Nullable AdditionalProperties? #1543

ackginger opened this issue Jul 29, 2022 · 0 comments · Fixed by #1552

Comments

@ackginger
Copy link
Contributor

I can't figure out a way to specify this in an OpenApi schema, but would really like the generated C# code for AdditionalProperties to go from this:

        private System.Collections.Generic.IDictionary<string, object> _additionalProperties = new System.Collections.Generic.Dictionary<string, object>();

        [System.Text.Json.Serialization.JsonExtensionData]
        public System.Collections.Generic.IDictionary<string, object> AdditionalProperties
        {
            get { return _additionalProperties; }
            set { _additionalProperties = value; }
        }

to this:

        private System.Collections.Generic.IDictionary<string, object>? _additionalProperties = default!;

        [System.Text.Json.Serialization.JsonExtensionData]
        public System.Collections.Generic.IDictionary<string, object>? AdditionalProperties
        {
            get { return _additionalProperties; }
            set { _additionalProperties = value; }
        }

Specifically to stop masses of unnecessary allocations when there are no additional properties. Would you accept an MR for this as an opt in feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant