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

Make require-default configurable #2926

Open
spalberg opened this issue Feb 28, 2025 · 0 comments
Open

Make require-default configurable #2926

spalberg opened this issue Feb 28, 2025 · 0 comments

Comments

@spalberg
Copy link

Is your feature request related to a problem? Please describe.

We have a strict no-null policy for all of our spring boot based java applications.
This means that we use javas Optional<T> everywhere where a value does not have to be, even in our api layer and records.
Since all properties are not required by default when generating the openapi spec using springdoc, we have to annotate almost everything in our api layer with @NotNull. This is very verbose and only needed for our api layer which leads to many properties that are not nullable in our application but are nullable in our openapi spec since the @NotNull annotation was forgotten.

Describe the solution you'd like

It would be great if we could specify a default required mode, i.e. everything is required unless stated otherwise.
Perfect would be if a field with Optional<?> would result in a not required property in the openapi spec.

Describe alternatives you've considered

We dabbled in extending springdoc using ModelConverts and so on but did not manage to achieve the desired behavior.
We are also looking into migrating to graphql simple because code generation from a graphql schema seems to be much easier, especially when combined with sealed types in java (algebraic data types) that have to be mapped to discriminated unions in typescript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant