Skip to content

Commit 2e9413c

Browse files
authored
Merge pull request #17 from aboutbits/update-swagger
Update swagger
2 parents aba34af + 88cd1c4 commit 2e9413c

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.springframework.boot</groupId>
88
<artifactId>spring-boot-starter-parent</artifactId>
9-
<version>3.3.8</version>
9+
<version>3.4.2</version>
1010
<relativePath/> <!-- lookup parent from repository -->
1111
</parent>
1212

@@ -86,7 +86,7 @@
8686
<dependency>
8787
<groupId>org.springdoc</groupId>
8888
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
89-
<version>2.6.0</version>
89+
<version>2.8.5</version>
9090
</dependency>
9191

9292
<!-- Testing -->

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)