Skip to content

Commit 2e7d271

Browse files
committed
Merge backport of #3351 - swagger-core 2.2.54
swagger-core now resolves java.time.Duration, LocalTime and OffsetTime itself (swagger-api/swagger-core#5184), so the corresponding entries of initExtraSchemas can be dropped.
2 parents f05b1fc + c772cdc commit 2e7d271

11 files changed

Lines changed: 10 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
- **The Scalar starters no longer register forwarded-header handling.** Set `server.forward-headers-strategy=framework` (or `native`) behind a trusted proxy
2424
- Add `springdoc.cache.max-entries` (default `100`) to bound the per-locale OpenAPI cache
2525
- Document the security policy and the release versioning scheme
26-
- Upgrade swagger-core to version **2.2.53**
26+
- #3351`java.time.Duration`, `LocalTime` and `OffsetTime` are now resolved by swagger-core instead of being forced to a bare `string`, so they carry a `format` (`duration` and `partial-time` respectively for the first two)
27+
- Upgrade swagger-core to version **2.2.54**
2728
- Upgrade swagger-ui to version **5.32.14**
2829

2930
### Fixed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<central-publishing-maven-plugin.version>0.11.0
5757
</central-publishing-maven-plugin.version>
5858
<flatten-maven-plugin.version>1.5.0</flatten-maven-plugin.version>
59-
<swagger-api.version>2.2.53</swagger-api.version>
59+
<swagger-api.version>2.2.54</swagger-api.version>
6060
<swagger-ui.version>5.32.14</swagger-ui.version>
6161
<gmavenplus-plugin.version>1.13.1</gmavenplus-plugin.version>
6262
<jjwt.version>0.9.1</jjwt.version>

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,13 +563,10 @@ public SpringDocUtils addParentType(String... parentTypes) {
563563
* Init extra schemas.
564564
*/
565565
public SpringDocUtils initExtraSchemas() {
566-
customClasses().put("java.time.Duration", PrimitiveType.STRING);
567-
customClasses().put("java.time.LocalTime", PrimitiveType.STRING);
568566
customClasses().put("java.time.YearMonth", PrimitiveType.STRING);
569567
customClasses().put("java.time.MonthDay", PrimitiveType.STRING);
570568
customClasses().put("java.time.Year", PrimitiveType.STRING);
571569
customClasses().put("java.time.Period", PrimitiveType.STRING);
572-
customClasses().put("java.time.OffsetTime", PrimitiveType.STRING);
573570
customClasses().put("java.time.ZoneId", PrimitiveType.STRING);
574571
customClasses().put("java.time.ZoneOffset", PrimitiveType.STRING);
575572
customClasses().put("java.util.TimeZone", PrimitiveType.STRING);
@@ -584,13 +581,10 @@ public SpringDocUtils initExtraSchemas() {
584581
* @return the spring doc utils
585582
*/
586583
public SpringDocUtils resetExtraSchemas() {
587-
customClasses().remove("java.time.Duration");
588-
customClasses().remove("java.time.LocalTime");
589584
customClasses().remove("java.time.YearMonth");
590585
customClasses().remove("java.time.MonthDay");
591586
customClasses().remove("java.time.Year");
592587
customClasses().remove("java.time.Period");
593-
customClasses().remove("java.time.OffsetTime");
594588
customClasses().remove("java.time.ZoneId");
595589
customClasses().remove("java.time.ZoneOffset");
596590
customClasses().remove("java.util.TimeZone");

springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app115/JavaTimeOperationCustomizer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public Operation customize(Operation operation, HandlerMethod handlerMethod) {
4747
Content content = response.getContent();
4848
if (content.containsKey(MediaType.APPLICATION_JSON_VALUE)) {
4949
Schema schema = content.get(MediaType.APPLICATION_JSON_VALUE).getSchema();
50-
schema.getProperties().clear();
5150
schema.types(Set.of("string"));
5251
}
5352
}

springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app115.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"content": {
2424
"application/json": {
2525
"schema": {
26-
"type": "string"
26+
"type": "string",
27+
"format": "duration"
2728
}
2829
}
2930
}

springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app115.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"application/json": {
2525
"schema": {
2626
"type": "string",
27-
"properties": {}
27+
"format": "duration"
2828
}
2929
}
3030
}

springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app243.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"format": "date"
5757
},
5858
"localTime": {
59-
"type": "string"
59+
"type": "string",
60+
"format": "partial-time"
6061
},
6162
"yearMonth": {
6263
"type": "string"

springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app115/JavaTimeOperationCustomizer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public Operation customize(Operation operation, HandlerMethod handlerMethod) {
5858
Content content = response.getContent();
5959
if (content.containsKey(MediaType.APPLICATION_JSON_VALUE)) {
6060
Schema schema = content.get(MediaType.APPLICATION_JSON_VALUE).getSchema();
61-
schema.getProperties().clear();
6261
schema.setType("string");
6362
}
6463
}

springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app115/JavaTimeOperationCustomizer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public Operation customize(Operation operation, HandlerMethod handlerMethod) {
6060
if (content.containsKey(MediaType.APPLICATION_JSON_VALUE)) {
6161
Schema schema = content.get(MediaType.APPLICATION_JSON_VALUE).getSchema();
6262
schema.types(Set.of("string"));
63-
schema.getProperties().clear();
6463
}
6564
}
6665
}

springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app115.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"application/json": {
3333
"schema": {
3434
"type": "string",
35-
"properties": {}
35+
"format": "duration"
3636
}
3737
}
3838
}

0 commit comments

Comments
 (0)