-
Notifications
You must be signed in to change notification settings - Fork 195
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
Required.AllowNull does not mark property as required #402
Comments
@basilfx Thanks for the issue. I intepreted both
|
@justinyoo Any update on this issue? Anything I can do to help? |
I'm also seeing this issue. Our API relies heavily on |
The documentation for azure-functions-openapi-extensions states that From Src/Newtonsoft.Json/Required.cs
It looks like the change should be pretty trivial in both src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/ObjectTypeVisitor.cs and src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/Visitors/RecursiveObjectTypeVisitor.cs. I'd be happy to make the updates if you agree it should be changed. |
#336 relates to this issue. |
@justinyoo any chance you can take a look at the PR of @William-Froelich? For us this really prevents production-ready usage of this extension, because our generated client marks everything as optional even though the JsonProperty is correct. Changing it to Required.Always would break serialization. |
I'm still trying to understand whether my interpretation of those properties From the Newtonsoft.Json point of view, your change makes sense, but the OpenAPI spec perspective, I'm still thinking my interpretation is more appropriate.
|
@justinyoo I just looked over OpenAPI spec for parameters and I disagree with that assessment. There's a These two parameters are not mutually-exclusive. A field can be marked I also found an interesting discussion from 2017 on Stack Overflow about the concepts and I think some confusion may come from I don't think it makes sense to add any other meaning to
My PR only addresses the |
@justinyoo have you had any time to look into this further and look over what I posted? How can I help get this resolved faster? |
@William-Froelich Now I understand your assessment, and I should update my interpretation. Then, we should also take care of both |
Sure, I'll update the PR. Would you prefer I add it to the |
|
Describe the issue
According to the documentation, only
Required.Always
andRequired.DisallowNull
in aJsonProperty
attribute will mark a property as required in the schema.Required.AllowNull
should also mark it as required. The documentation states: "The property must be defined in JSON but can be a null value." It must be present in the JSON, therefore it must be marked as required.Required.DisallowNull
should not mark it as required. The documentation states: "The property is not required but it cannot be a null value." It may be present in the JSON, therefore it should not be marked as required.To Reproduce
See this demonstration project: https://github.com/basilfx/azure-functions-openapi-function-timespan (yes, same project as #401).
Note how
MyInstance.MyNullableTimeSpan
hasRequired = Required.AllowNull
, yet it is not marked as required in the schema. As a work-around, add theRequired
attribute.Expected behavior
The property is marked as required in the inferred schema.
Screenshots
Environment (please complete the following information, if applicable):
The text was updated successfully, but these errors were encountered: