Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort request methods #1878

Merged
merged 1 commit into from Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -42,6 +42,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -397,7 +398,7 @@ protected void calculatePath(HandlerMethod handlerMethod,
routerOperation = customizeRouterOperation(routerOperation, handlerMethod);

String operationPath = routerOperation.getPath();
Set<RequestMethod> requestMethods = new HashSet<>(Arrays.asList(routerOperation.getMethods()));
Set<RequestMethod> requestMethods = new TreeSet<>(Arrays.asList(routerOperation.getMethods()));
io.swagger.v3.oas.annotations.Operation apiOperation = routerOperation.getOperation();
String[] methodConsumes = routerOperation.getConsumes();
String[] methodProduces = routerOperation.getProduces();
Expand Down
@@ -0,0 +1,34 @@
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/

package test.org.springdoc.api.app167;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* The type Hello controller.
*/
@RestController("/api")
public class HelloController {

@RequestMapping("/process")
public void process() {

}
}
@@ -0,0 +1,36 @@
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/

package test.org.springdoc.api.app167;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import test.org.springdoc.api.AbstractSpringDocTest;

/**
* The type Spring doc app 167 test.
*/
public class SpringDocApp167Test extends AbstractSpringDocTest {

/**
* The type Spring doc test app.
*/
@SpringBootApplication
static class SpringDocTestApp {
}
}
101 changes: 101 additions & 0 deletions springdoc-openapi-javadoc/src/test/resources/results/app167.json
@@ -0,0 +1,101 @@
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost",
"description": "Generated server url"
}
],
"tags": [
{
"name": "hello-controller",
"description": "The type Hello controller."
}
],
"paths": {
"/process": {
"get": {
"tags": [
"hello-controller"
],
"operationId": "process",
"responses": {
"200": {
"description": "OK"
}
}
},
"put": {
"tags": [
"hello-controller"
],
"operationId": "process_3",
"responses": {
"200": {
"description": "OK"
}
}
},
"post": {
"tags": [
"hello-controller"
],
"operationId": "process_2",
"responses": {
"200": {
"description": "OK"
}
}
},
"delete": {
"tags": [
"hello-controller"
],
"operationId": "process_5",
"responses": {
"200": {
"description": "OK"
}
}
},
"options": {
"tags": [
"hello-controller"
],
"operationId": "process_6",
"responses": {
"200": {
"description": "OK"
}
}
},
"head": {
"tags": [
"hello-controller"
],
"operationId": "process_1",
"responses": {
"200": {
"description": "OK"
}
}
},
"patch": {
"tags": [
"hello-controller"
],
"operationId": "process_4",
"responses": {
"200": {
"description": "OK"
}
}
}
}
},
"components": {}
}