You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I'm using the csharp-netcore generator and running into issues with additional properties. I have a model with some fixed properties, and you could add additional dynamic properties. When in the spec I set additionalProperties: true for that specific model, the generated class extends from a dictionary which causes issues with json serialization. However, when I remove additionalProperties: true from the spec and use "disallowAdditionalPropertiesIfNotPresent": false the generated model looks as I expected; The generated class doesn't extend from a dictionary, and an AdditionalProperties property is generated. Why disallowAdditionalPropertiesIfNotPresent:false is not equivalent to explicitly set additionalProperties:true?
Using "disallowAdditionalPropertiesIfNotPresent": false
/// <summary>/// Template: ModelGeneric/// UserProfile/// </summary>[DataContract(Name="UserProfile")]publicpartialclassUserProfile:Dictionary<String,Object>,IEquatable<UserProfile>/// It now extends from Dictionary{/// <summary>/// Gets or Sets City/// </summary>[DataMember(Name="city",EmitDefaultValue=true)]publicstringCity{get;set;}/// <summary>/// Gets or Sets additional properties/// </summary>[JsonExtensionData]publicIDictionary<string,object>AdditionalProperties{get;set;}
Is there any reason I don't get the same output for equivalent configuration?
I would expect equivalent output for equivalent spec configuration. If I have a model with fixed properties AND additionalProperties:true the generated model should not extend from Dictionary since it causes serialization issues. Note that using "disallowAdditionalPropertiesIfNotPresent": false only and not additionalProperties:true behaves as expected.
The text was updated successfully, but these errors were encountered:
Representing the DATEX-standard (CEN-16157) we are moving to support JSON-schema in addition to XML-schema. We noticed this BUG as a potensial fix to som issues raised in our tests we have done so far with the generator. Whats the bearing on getting this fixed?
Bug Report Checklist
Description
I'm using the csharp-netcore generator and running into issues with additional properties. I have a model with some fixed properties, and you could add additional dynamic properties. When in the spec I set
additionalProperties: true
for that specific model, the generated class extends from a dictionary which causes issues with json serialization. However, when I removeadditionalProperties: true
from the spec and use"disallowAdditionalPropertiesIfNotPresent": false
the generated model looks as I expected; The generated class doesn't extend from a dictionary, and anAdditionalProperties
property is generated. WhydisallowAdditionalPropertiesIfNotPresent:false
is not equivalent to explicitly setadditionalProperties:true
?Using "disallowAdditionalPropertiesIfNotPresent": false
Spec YAML:
Debug Model metadata
Generated class
Using
additionalProperties: true
spec YAML
Debug Model Metadata
Generated class
Is there any reason I don't get the same output for equivalent configuration?
openapi-generator version
6.0.1
OpenAPI declaration file content or URL
PRovided above
Generation Details
openapi-generator-cli version
6.0.0-beta
Steps to reproduce
Run >openapi-generator-cli generate -g csharp-netcore --skip-validate-spec
Related issues/PRs
#9798
#9727
#7396
Suggest a fix
I would expect equivalent output for equivalent spec configuration. If I have a model with fixed properties AND additionalProperties:true the generated model should not extend from Dictionary since it causes serialization issues. Note that using
"disallowAdditionalPropertiesIfNotPresent": false
only and not additionalProperties:true behaves as expected.The text was updated successfully, but these errors were encountered: