Skip to content

Commit 88cd1c4

Browse files
committed
fix nullability hack for new swagger version
1 parent fb8ca5f commit 88cd1c4

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/main/java/it/aboutbits/springboot/toolbox/swagger/customization/default_not_null/NullableCustomizer.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ public void customise(OpenAPI openApi) {
1818
if (((Schema<?>) schema).getProperties() != null) {
1919
var requiredProperties = new ArrayList<String>();
2020
((Schema<?>) schema).getProperties().forEach((propertyName, property) -> {
21-
if (property.getNullable() == null || !property.getNullable()) {
21+
if (property.getTitle() == null || !property.getTitle().equals("NULLABLE")) {
2222
requiredProperties.add(propertyName);
2323
}
24+
if (property.getTitle() != null && property.getTitle().equals("NULLABLE")) {
25+
property.setTitle(null);
26+
}
2427
});
2528
schema.setRequired(requiredProperties);
2629
}

src/main/java/it/aboutbits/springboot/toolbox/swagger/customization/default_not_null/NullablePropertyCustomizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public Schema<?> customize(Schema property, AnnotatedType annotatedType) {
3131

3232
if (annotatedType.getCtxAnnotations() != null && Arrays.stream(annotatedType.getCtxAnnotations())
3333
.anyMatch(a -> "Nullable".equals(a.annotationType().getSimpleName()))) {
34-
property.setNullable(true);
34+
property.setTitle("NULLABLE");
3535
}
3636

3737
return property;

0 commit comments

Comments
 (0)