Skip to content

Commit 017a0b3

Browse files
author
bnasslahsen
committed
Added test for required param object is not marked as required. Fixes #156.
1 parent 9f1a5a0 commit 017a0b3

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package test.org.springdoc.api.app107;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import io.swagger.v3.oas.annotations.media.Schema;
5+
6+
import org.springframework.web.bind.annotation.GetMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
9+
@RestController
10+
public class HelloController {
11+
12+
@GetMapping(path = "/entity-b", produces = { "application/json", "application/xml" })
13+
public EntityB getEntityB(){
14+
return new EntityB();
15+
}
16+
17+
public class EntityB {
18+
19+
@Schema(required = true)
20+
@JsonProperty("fieldB")
21+
private String fieldB;
22+
23+
@Schema(required = true)
24+
@JsonProperty("entityA")
25+
private EntityA entityA;
26+
//Getters and setters...
27+
}
28+
29+
public class EntityA {
30+
@Schema(required = true)
31+
@JsonProperty("fieldA")
32+
private String fieldA;
33+
//Getters and setters...
34+
}
35+
}
36+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package test.org.springdoc.api.app107;
2+
3+
import test.org.springdoc.api.AbstractSpringDocTest;
4+
5+
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
7+
public class SpringDocApp107Test extends AbstractSpringDocTest {
8+
@SpringBootApplication
9+
static class SpringDocTestApp {}
10+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
"paths": {
14+
"/entity-b": {
15+
"get": {
16+
"tags": [
17+
"hello-controller"
18+
],
19+
"operationId": "getEntityB",
20+
"responses": {
21+
"200": {
22+
"description": "default response",
23+
"content": {
24+
"application/json": {
25+
"schema": {
26+
"$ref": "#/components/schemas/EntityB"
27+
}
28+
},
29+
"application/xml": {
30+
"schema": {
31+
"$ref": "#/components/schemas/EntityB"
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}
38+
}
39+
},
40+
"components": {
41+
"schemas": {
42+
"EntityA": {
43+
"required": [
44+
"fieldA"
45+
],
46+
"type": "object",
47+
"properties": {
48+
"fieldA": {
49+
"type": "string"
50+
}
51+
}
52+
},
53+
"EntityB": {
54+
"required": [
55+
"entityA",
56+
"fieldB"
57+
],
58+
"type": "object",
59+
"properties": {
60+
"fieldB": {
61+
"type": "string"
62+
},
63+
"entityA": {
64+
"$ref": "#/components/schemas/EntityA"
65+
}
66+
}
67+
}
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)