Skip to content

Commit c655c42

Browse files
committed
Changes report: Sort request methods #1878
1 parent c14234f commit c655c42

File tree

4 files changed

+173
-1
lines changed

4 files changed

+173
-1
lines changed

springdoc-openapi-starter-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.util.Objects;
4545
import java.util.Optional;
4646
import java.util.Set;
47+
import java.util.TreeSet;
4748
import java.util.concurrent.Executors;
4849
import java.util.stream.Collectors;
4950

@@ -397,7 +398,7 @@ protected void calculatePath(HandlerMethod handlerMethod, RouterOperation router
397398
routerOperation = customizeRouterOperation(routerOperation, handlerMethod);
398399

399400
String operationPath = routerOperation.getPath();
400-
Set<RequestMethod> requestMethods = new HashSet<>(Arrays.asList(routerOperation.getMethods()));
401+
Set<RequestMethod> requestMethods = new TreeSet<>(Arrays.asList(routerOperation.getMethods()));
401402
io.swagger.v3.oas.annotations.Operation apiOperation = routerOperation.getOperation();
402403
String[] methodConsumes = routerOperation.getConsumes();
403404
String[] methodProduces = routerOperation.getProduces();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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.app167;
20+
21+
import org.springframework.web.bind.annotation.RequestMapping;
22+
import org.springframework.web.bind.annotation.RestController;
23+
24+
/**
25+
* The type Hello controller.
26+
*/
27+
@RestController("/api")
28+
public class HelloController {
29+
30+
@RequestMapping("/process")
31+
public void process() {
32+
33+
}
34+
}
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.app167;
20+
21+
import test.org.springdoc.api.AbstractSpringDocTest;
22+
23+
import org.springframework.boot.autoconfigure.SpringBootApplication;
24+
25+
/**
26+
* The type Spring doc app 167 test.
27+
*/
28+
public class SpringDocApp167Test 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,101 @@
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+
"/process": {
21+
"get": {
22+
"tags": [
23+
"hello-controller"
24+
],
25+
"operationId": "process",
26+
"responses": {
27+
"200": {
28+
"description": "OK"
29+
}
30+
}
31+
},
32+
"put": {
33+
"tags": [
34+
"hello-controller"
35+
],
36+
"operationId": "process_3",
37+
"responses": {
38+
"200": {
39+
"description": "OK"
40+
}
41+
}
42+
},
43+
"post": {
44+
"tags": [
45+
"hello-controller"
46+
],
47+
"operationId": "process_2",
48+
"responses": {
49+
"200": {
50+
"description": "OK"
51+
}
52+
}
53+
},
54+
"delete": {
55+
"tags": [
56+
"hello-controller"
57+
],
58+
"operationId": "process_5",
59+
"responses": {
60+
"200": {
61+
"description": "OK"
62+
}
63+
}
64+
},
65+
"options": {
66+
"tags": [
67+
"hello-controller"
68+
],
69+
"operationId": "process_6",
70+
"responses": {
71+
"200": {
72+
"description": "OK"
73+
}
74+
}
75+
},
76+
"head": {
77+
"tags": [
78+
"hello-controller"
79+
],
80+
"operationId": "process_1",
81+
"responses": {
82+
"200": {
83+
"description": "OK"
84+
}
85+
}
86+
},
87+
"patch": {
88+
"tags": [
89+
"hello-controller"
90+
],
91+
"operationId": "process_4",
92+
"responses": {
93+
"200": {
94+
"description": "OK"
95+
}
96+
}
97+
}
98+
}
99+
},
100+
"components": {}
101+
}

0 commit comments

Comments
 (0)