Skip to content

Commit 7dadaf5

Browse files
author
springdoc
committed
project update
1 parent edda650 commit 7dadaf5

File tree

3 files changed

+74
-50
lines changed

3 files changed

+74
-50
lines changed

springdoc-openapi-core/src/main/java/org/springdoc/api/OpenApiResource.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ private boolean isRestController(Map<String, Object> restControllers, HandlerMet
115115

116116
private void calculateServerUrl(HttpServletRequest request, String apiDocsUrl) {
117117
StringBuffer requestUrl = request.getRequestURL();
118+
118119
String serverBaseUrl = requestUrl.substring(0, requestUrl.length() - apiDocsUrl.length());
119120
generalInfoBuilder.setServerBaseUrl(serverBaseUrl);
120121
}
Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,8 @@
11
package test.org.springdoc.api.app4;
22

3-
import static org.hamcrest.Matchers.*;
4-
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
5-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
3+
import test.org.springdoc.api.AbstractSpringDocTest;
64

7-
import org.hamcrest.Matchers;
8-
import org.junit.Test;
9-
import org.junit.runner.RunWith;
10-
import org.springdoc.core.Constants;
11-
import org.springframework.beans.factory.annotation.Autowired;
12-
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
13-
import org.springframework.boot.test.context.SpringBootTest;
14-
import org.springframework.test.context.ActiveProfiles;
15-
import org.springframework.test.context.junit4.SpringRunner;
16-
import org.springframework.test.web.servlet.MockMvc;
5+
public class SpringDocApp4Test extends AbstractSpringDocTest {
176

18-
@RunWith(SpringRunner.class)
19-
@SpringBootTest
20-
@ActiveProfiles("test")
21-
@AutoConfigureMockMvc
22-
public class SpringDocApp4Test {
237

24-
@Autowired
25-
private MockMvc mockMvc;
26-
27-
@Test
28-
public void testApp4() throws Exception {
29-
mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk())
30-
.andExpect(jsonPath("$.openapi", is("3.0.1")))
31-
.andExpect(jsonPath("$.info.title", is("OpenAPI definition")))
32-
.andExpect(jsonPath("$.info.version", is("v0")))
33-
.andExpect(jsonPath("$.paths./values/data.post.operationId", is("list")))
34-
.andExpect(jsonPath("$.paths./values/data.post.requestBody.content.['*/*'].schema.['$ref']",
35-
is("#/components/schemas/TrackerData")))
36-
.andExpect(jsonPath("$.paths./values/data.post.responses.200.content.['*/*'].schema.['$ref']",
37-
is("#/components/schemas/TrackerData")))
38-
.andExpect(
39-
jsonPath("$.paths./values/data.post.responses.200.description", is("default response")))
40-
.andExpect(jsonPath("$.components.schemas.TrackerData.required")
41-
.value(Matchers.containsInAnyOrder("timestamp", "trackerId", "value")))
42-
.andExpect(jsonPath("$.components.schemas.TrackerData.type", is("object")))
43-
.andExpect(jsonPath("$.components.schemas.TrackerData.properties.trackerId.type", is("string")))
44-
.andExpect(jsonPath("$.components.schemas.TrackerData.properties.timestamp.type", is("string")))
45-
.andExpect(jsonPath("$.components.schemas.TrackerData.properties.value.type", is("number")))
46-
.andExpect(jsonPath("$.components.schemas.TrackerData.properties.timestamp.format", is("date-time")))
47-
.andExpect(jsonPath("$.components.schemas.TrackerData.properties.value.format", is("double")))
48-
.andExpect(
49-
jsonPath("$.components.schemas.TrackerData.properties.trackerId.example", is("the-tracker-id")))
50-
.andExpect(jsonPath("$.components.schemas.TrackerData.properties.timestamp.example",
51-
is("2018-01-01T00:00:00Z")))
52-
.andExpect(jsonPath("$.components.schemas.TrackerData.properties.value.example", is(19.0)));
53-
}
54-
55-
}
8+
}
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+
"/values/data": {
15+
"post": {
16+
"operationId": "list",
17+
"requestBody": {
18+
"content": {
19+
"*/*": {
20+
"schema": {
21+
"$ref": "#/components/schemas/TrackerData"
22+
}
23+
}
24+
}
25+
},
26+
"responses": {
27+
"200": {
28+
"description": "default response",
29+
"content": {
30+
"*/*": {
31+
"schema": {
32+
"$ref": "#/components/schemas/TrackerData"
33+
}
34+
}
35+
}
36+
}
37+
}
38+
}
39+
}
40+
},
41+
"components": {
42+
"schemas": {
43+
"TrackerData": {
44+
"required": [
45+
"timestamp",
46+
"trackerId",
47+
"value"
48+
],
49+
"type": "object",
50+
"properties": {
51+
"trackerId": {
52+
"type": "string",
53+
"example": "the-tracker-id"
54+
},
55+
"timestamp": {
56+
"type": "string",
57+
"format": "date-time",
58+
"example": "2018-01-01T00:00:00Z"
59+
},
60+
"value": {
61+
"type": "number",
62+
"description": "The data value",
63+
"format": "double",
64+
"example": 19.0
65+
}
66+
}
67+
}
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)