Skip to content

[Feature]: I want to configure the default value of @Schema RequiredMode to other value, than AUTO #5041

@VOJAKIS

Description

@VOJAKIS

Feature Description

I want to configure the RequiredMode for annotation @Schema programatically to REQUIRED. Right now, most of the attributes we use are required, like 95%, and other are not required.

Use Case

When I am making an application with backend and frontend, most of the times the frontend wants to see every attribute as a response from the backend.
Right now we have to configure that (or use another annotations, like @NotNull) to do that.

Suggested Solution (optional)

There should be a way to overload the default value to a specified value, when not stated otherwise.

If a value is declared in the annotation, e.g.
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED
then Swagger should ignore the default value and use the one declared.
Otherwise use the default value.

Alternatives Considered

I have tried to do this with Spring Boot annotation @NotNull, OpenAPICustomizer and a custom meta-annotation.

Additional Context

I use Spring Boot v4.

SpringDOC OpenAPI Starter WebMVC UI v2.8.10

Checklist

  • I have searched the existing issues to ensure this is not a duplicate.
  • This feature would be useful to more than just my use case.
  • I have provided enough detail for the maintainers to understand the scope of the request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions