Skip to content

Commit 5bd85e1

Browse files
authored
Merge pull request springdoc#1718 from shardt68/javadoc-_of_JsonUnwrapped_fields_not_set
fixes springdoc#1717 javadoc of JsonUnwrapped fields not set
2 parents af47269 + 14a463d commit 5bd85e1

File tree

6 files changed

+210
-0
lines changed

6 files changed

+210
-0
lines changed

springdoc-openapi-javadoc/src/main/java/org/springdoc/openapi/javadoc/JavadocPropertyCustomizer.java

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import java.util.Map;
2929
import java.util.Optional;
3030

31+
import com.fasterxml.jackson.databind.JavaType;
32+
import com.fasterxml.jackson.annotation.JsonUnwrapped;
3133
import com.fasterxml.jackson.databind.JavaType;
3234
import io.swagger.v3.core.converter.AnnotatedType;
3335
import io.swagger.v3.core.converter.ModelConverter;
@@ -125,6 +127,8 @@ private void setJavadocDescription(Class<?> cls, List<Field> fields, Schema exis
125127
stringSchemaEntry.getValue().setDescription(fieldJavadoc);
126128
});
127129
});
130+
fields.stream().filter(f -> f.isAnnotationPresent(JsonUnwrapped.class))
131+
.forEach(f -> setJavadocDescription(f.getType(), FieldUtils.getAllFieldsList(f.getType()), existingSchema));
128132

129133
}
130134
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.api.app165;
20+
21+
/**
22+
* The type Bar.
23+
*/
24+
public class Bar {
25+
/**
26+
* The BarField.
27+
*/
28+
public String barField = "bar";
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.api.app165;
20+
21+
import com.fasterxml.jackson.annotation.JsonUnwrapped;
22+
23+
/**
24+
* The type Foo.
25+
*/
26+
public class Foo {
27+
/**
28+
* The Bar.
29+
*/
30+
@JsonUnwrapped
31+
public Bar bar;
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.api.app165;
20+
21+
import org.springframework.web.bind.annotation.PostMapping;
22+
import org.springframework.web.bind.annotation.RestController;
23+
24+
import io.swagger.v3.oas.annotations.parameters.RequestBody;
25+
26+
/**
27+
* The type Hello controller.
28+
*/
29+
@RestController("/api")
30+
public class HelloController {
31+
32+
/**
33+
* Process foo.
34+
*
35+
* @param a the a
36+
* @return the foo
37+
*/
38+
@PostMapping
39+
public Foo process(@RequestBody Foo a) {
40+
return a;
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.api.app165;
20+
21+
import org.springframework.boot.autoconfigure.SpringBootApplication;
22+
23+
import test.org.springdoc.api.AbstractSpringDocTest;
24+
25+
/**
26+
* The type Spring doc app 165 test.
27+
*/
28+
public class SpringDocApp165Test extends AbstractSpringDocTest {
29+
30+
/**
31+
* The type Spring doc test app.
32+
*/
33+
@SpringBootApplication
34+
static class SpringDocTestApp {
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"openapi": "3.0.1",
3+
"info": {
4+
"title": "OpenAPI definition",
5+
"version": "v0"
6+
},
7+
"servers": [
8+
{
9+
"url": "http://localhost",
10+
"description": "Generated server url"
11+
}
12+
],
13+
"tags": [
14+
{
15+
"name": "hello-controller",
16+
"description": "The type Hello controller."
17+
}
18+
],
19+
"paths": {
20+
"/": {
21+
"post": {
22+
"tags": [
23+
"hello-controller"
24+
],
25+
"summary": "Process foo.",
26+
"description": "Process foo.",
27+
"operationId": "process",
28+
"requestBody": {
29+
"description": "the a",
30+
"content": {
31+
"application/json": {
32+
"schema": {
33+
"$ref": "#/components/schemas/Foo"
34+
}
35+
}
36+
}
37+
},
38+
"responses": {
39+
"200": {
40+
"description": "the foo",
41+
"content": {
42+
"*/*": {
43+
"schema": {
44+
"$ref": "#/components/schemas/Foo"
45+
}
46+
}
47+
}
48+
}
49+
}
50+
}
51+
}
52+
},
53+
"components": {
54+
"schemas": {
55+
"Foo": {
56+
"type": "object",
57+
"properties": {
58+
"barField": {
59+
"type": "string",
60+
"description": "The BarField."
61+
}
62+
},
63+
"description": "The type Foo."
64+
}
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)