Skip to content

Commit 98e00f0

Browse files
committed
Treat java.nio.charset.Charset as string type by default. fixes #1348
1 parent 62a4e7b commit 98e00f0

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package org.springdoc.core;
2222

23+
import java.nio.charset.Charset;
2324
import java.util.Collections;
2425
import java.util.List;
2526
import java.util.Locale;
@@ -101,6 +102,7 @@ public class SpringDocConfiguration {
101102

102103
static {
103104
getConfig().replaceWithSchema(ObjectNode.class, new ObjectSchema())
105+
.replaceWithClass(Charset.class, String.class)
104106
.addResponseWrapperToIgnore(DeferredResult.class);
105107
}
106108

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app10/HelloController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package test.org.springdoc.api.app10;
2020

21+
import java.nio.charset.Charset;
2122
import java.util.Locale;
2223

2324
import javax.servlet.http.HttpServletRequest;
@@ -38,6 +39,9 @@ public void test(HttpSession header, HttpServletRequest request, HttpServletResp
3839

3940
@GetMapping("/testreq")
4041
public void testRequestAttribute(@RequestAttribute String sample, String s) {
42+
}
4143

44+
@GetMapping(value = {"/employee"})
45+
public void getEmployee(Charset test) {
4246
}
4347
}

springdoc-openapi-webmvc-core/src/test/resources/results/app10.json

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,29 @@
1111
}
1212
],
1313
"paths": {
14+
"/testreq": {
15+
"get": {
16+
"tags": [
17+
"hello-controller"
18+
],
19+
"operationId": "testRequestAttribute",
20+
"parameters": [
21+
{
22+
"name": "s",
23+
"in": "query",
24+
"required": true,
25+
"schema": {
26+
"type": "string"
27+
}
28+
}
29+
],
30+
"responses": {
31+
"200": {
32+
"description": "OK"
33+
}
34+
}
35+
}
36+
},
1437
"/test": {
1538
"get": {
1639
"tags": [
@@ -34,15 +57,15 @@
3457
}
3558
}
3659
},
37-
"/testreq": {
60+
"/employee": {
3861
"get": {
3962
"tags": [
4063
"hello-controller"
4164
],
42-
"operationId": "testRequestAttribute",
65+
"operationId": "getEmployee",
4366
"parameters": [
4467
{
45-
"name": "s",
68+
"name": "test",
4669
"in": "query",
4770
"required": true,
4871
"schema": {

0 commit comments

Comments
 (0)