-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
@Size
annotation on List<String>
causes incorrect openapi spec to be generated.
#2337
Comments
This looks to be correct. public class DemoApplication {
record TestDTO(@Size(min = 1, max = 5)
@Schema(description = "List of values.")
List<String> values) {
}
public static void main(String[] args) {
ResolvedSchema resolvedSchema = ModelConverters.getInstance()
.resolveAsResolvedSchema(
new AnnotatedType(TestDTO.class).resolveAsRef(false));
resolvedSchema.schema.getMinLength();
Assert.isTrue(((ArraySchema) resolvedSchema.schema.getProperties().get("values")).getMaxItems().equals(5));
Assert.isTrue(((ArraySchema) resolvedSchema.schema.getProperties().get("values")).getItems().getMaxLength().equals(5));
}
} |
Thanks for the quick response! -- I'll log an issue at swagger-core.
Can you explain this to me, though? The item maxLength relates to the String itself. The (Also note this just started occurring after the 2.2.0 update). Is there something I'm misunderstanding here? |
You have already been answered. |
Using a simple DTO can reproduce this issue:
The
@Size
validation is only (correctly) applied to the list size. However, the api spec itself is showing this:The generated API spec is stating that:
You can also see that the description is also being duplicated from the array down to the element as well. I am uncertain if this is intentional and or desirable so not sure if that should also be considered a bug as well.
The text was updated successfully, but these errors were encountered: