-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
fix: csharp generate not null properties #969
fix: csharp generate not null properties #969
Conversation
…d later to support pre-CSharp8 nullable style (`Nullable<T>`)
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a bit of an issue with this change, and I am not sure how to proceed 🤔 Hope you can help @zaytsevand.
First, should the type of the model (model.type
) contain the conditional type ?
🤔 Or is there cases where you would like to only have non-conditional type? For example for method arguments or other cases?
Is optional (non-required properties) the same as nullable types i.e. for inputs such as type: ['string', 'null']
?
Generally, for
Currently, all new projects created for dotnet v6 (release date November 8, 2021) and c# v8+ are, by default, configured to allow nullable reference types. So I guess if we're not striving to support "legacy" projects, we could go for |
@jonaslagoni I checked upd: figured that out. I will re-submit with a new PR later on. |
If it's easy to support legacy projects by a simple change in syntax, I would say we go for that, unless we explicitly wants to add something like a
In #947, it is actually being redesigned to give you access to whether a type is being rendered for a property through My question is, if the type for the property is normally |
@jonaslagoni I don't think that it would be an issue if we implement the addition of '?' in TypeMapping. If somebody will need a plain |
After some code examination: when creating a model for a property, we've no outer context, but it's the outer context where we have that array of all required properties for an outer model. So a simple fix would be to embed a list of all required properties in |
Let me push forward #947 as it will give you access to whether a property is required or not when constraining the type. I don't think you would need access to the entire object model, do you? 🤔 |
@jonaslagoni 💯 correct: the whole model is not needed for it |
@jonaslagoni could you please take another look at this one? #947 is not here yet, but rendering is broken in the |
Description
Related issue(s)
Fixes #941