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

[Feature request]: Generate nullable properties as required #2969

Closed
Eirenarch opened this issue Jul 3, 2024 · 5 comments
Closed

[Feature request]: Generate nullable properties as required #2969

Eirenarch opened this issue Jul 3, 2024 · 5 comments

Comments

@Eirenarch
Copy link

Eirenarch commented Jul 3, 2024

Is your feature request related to a specific problem? Or an existing feature?

When generating OpenAPI json in most cases it is desirable that non-nullable properties are marked as required. As far as I can tell currently this can be achieved by adding a filter like the one described here. While this is not very hard I think that this feature is desirable for the vast majority of projects so it would be good if it is available out of the box.

Describe the solution you'd like

Maybe a parameter on the SupportNonNullableReferenceTypes method to enable this behavior

@billhong-just
Copy link

billhong-just commented Sep 23, 2024

@Eirenarch Maybe this PR meets your need.

@Eirenarch
Copy link
Author

@Eirenarch Maybe this PR meets your need.

Looks like it. Has it shipped yet?

@martincostello
Copy link
Collaborator

Yes - if you look at the tags on the merged commit you can see the tags for the releases that contain it: 85fefe4

@jgarciadelanoceda
Copy link
Contributor

jgarciadelanoceda commented Oct 22, 2024

@martincostello I think this could be a feature that was added in #2710, unfortunately did not get merged. You don't need to put the required keyword on every non nullable property.
If you think the same I can create other PR to make this new MarkNonNullableReferenceTypesAsRequired.

Ohh wait it was added in #2803.. I have to check if all the usesCases are solved

@jgarciadelanoceda
Copy link
Contributor

@martincostello this can be closed.. You have the required keyword that works as expected (If you mark this over a property makes the property required in the OpenApi).
And the other way, when you want to make all the properties that are not nullable as required with the NonNullableReferenceTypesAsRequired, I think that is more than covered with these two options.

@martincostello martincostello added this to the v6.7.0 milestone Oct 22, 2024
@martincostello martincostello removed the help-wanted A change up for grabs for contributions from the community label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants