fix the required + nullable issue#3373
Conversation
test/CadlRanchProjects/type/property/nullable/src/Generated/Models/CollectionsByteProperty.cs
Show resolved
Hide resolved
test/CadlRanchProjects/type/property/nullable/src/Generated/Models/CollectionsByteProperty.cs
Show resolved
Hide resolved
|
The assignment for nullable arrays is breaking test cases like this: |
test/TestProjects/ModelShapes/Generated/Models/InputModel.Serialization.cs
Show resolved
Hide resolved
...rojects/type/property/nullable/src/Generated/Models/CollectionsByteProperty.Serialization.cs
Outdated
Show resolved
Hide resolved
|
Let's remove all the Ignore in test\CadlRanchProjects.Tests\type-property-nullable.cs to see if it passes. |
|
Could you add tests in cadl-ranch for cases that the element of array is nullable and non-nullable? |
This comment was marked as outdated.
This comment was marked as outdated.
test/TestProjects/ModelShapes/Generated/Models/InputModel.Serialization.cs
Outdated
Show resolved
Hide resolved
|
I am finding more and more issues when I am trying to "ensure the collection property can never be null". |
|
Add back the null check for collections |
910742a to
1dc3b5a
Compare
|
Note - need to revert the changes on property bags since it is working right now |
…llable-property-issue
…llable-property-issue
…llable-property-issue
|
Hi @m-nash I added a configuration The changes in generated files of openai I believe is expected, here is the corresponding typespec file: https://github.com/Azure/azure-rest-api-specs/blob/a89c3854f2d1cca8c996e00c97af3179ecb9dd72/specification/cognitiveservices/OpenAI.Inference/models/chat.completions.tsp#L196 |
|
@m-nash Therefore in the regen PR,
Other RPs might have API changes (for instance OpenAI) which is expected, because the initial purpose of this PR is fixing some issue around the required nullable properties. I added the corresponding typespec link in a comment in the regen to describe this change is expected. |
src/AutoRest.CSharp/Common/Output/Models/Types/ModelTypeProviderFields.cs
Show resolved
Hide resolved
|
Can we please add a test that will do alias spread with required collections? |
Added |
m-nash
left a comment
There was a problem hiding this comment.
@ArcturusZhang please create a follow up issue to reduce the granularity of the new flag deserialize-null-collection-as-null-value. I imagine there is a small set of models / properties that have this issue and we don't want to proliferate it any further.
The granularity should probably be a list of ModelName.PropertyName to grandfather in.
issue created for this: #3613 |
Fixes #2340
Fixes #3363
Fixes #3440
Fixes #3600
Description
This PR fixes multiple issues around nullable properties, especially when the property is required.
This PR also updates the
InputTypeto makeIsNullableproperty no longer optional. This optional propertyIsNullablecould be problematic because of its optionality, sometimes we forget to give it a value and it causes hidden issues.Checklist
To ensure a quick review and merge, please ensure:
Ready to Land?