Skip to content

Commit

Permalink
buildApiResponses ignores produced ContentType in case of many @opera…
Browse files Browse the repository at this point in the history
…tion. Fixes #2477
  • Loading branch information
bnasslahsen committed Mar 11, 2024
1 parent cb3b772 commit bfc57ab
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 1 deletion.
Expand Up @@ -772,7 +772,7 @@ private boolean isValidHttpCode(String httpCode, MethodParameter methodParameter
if (isHttpCodePresent(httpCode, responseSet))
result = true;
}
else if (httpCode.equals(evaluateResponseStatus(method, method.getClass(), false)))
if (httpCode.equals(evaluateResponseStatus(method, method.getClass(), false)))
result = true;
}
}
Expand Down
@@ -0,0 +1,47 @@
/*
*
* *
* * *
* * * * Copyright 2019-2022 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.v30.app216;



import io.swagger.v3.oas.annotations.Operation;

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


@RestController
public class HelloController {

@Operation(description = "a")
@GetMapping(path = "/", produces = "a/a")
public String a() {
return "A";
}

@Operation(description = "b")
@GetMapping(path = "/", produces = "b/b")
public String b() {
return "B";
}
}
@@ -0,0 +1,38 @@
/*
*
* * Copyright 2019-2023 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.v30.app216;

import org.springdoc.core.customizers.SpecPropertiesCustomizer;
import test.org.springdoc.api.v30.AbstractSpringDocV30Test;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

/**
* <p>
* A test for {@link SpecPropertiesCustomizer}
*/
@SpringBootTest
public class SpringDocApp216Test extends AbstractSpringDocV30Test {

@SpringBootApplication
static class SpringDocTestApp {}

}
@@ -0,0 +1,42 @@
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost",
"description": "Generated server url"
}
],
"paths": {
"/": {
"get": {
"tags": [
"hello-controller"
],
"description": "a",
"operationId": "b_1",
"responses": {
"200": {
"description": "OK",
"content": {
"b/b": {
"schema": {
"type": "string"
}
},
"a/a": {
"schema": {
"type": "string"
}
}
}
}
}
}
}
},
"components": {}
}

0 comments on commit bfc57ab

Please sign in to comment.