Description
Issue Description
When Groovy is on the classpath at the same time as springdoc-openapi-starter-webmvc-ui, Map fields do not show up in the generated Open API spec (and therefore, they also don't show up in the Swagger UI). This happens just when Groovy is on the classpath, even if we are not using it.
In the example below, when it works (without Groovy on the classpath), both fields show up in the spec/UI. But adding Groovy causes the Map field to disappear from both.
Reproducing the Issue
For example, if I have this model class, TestRequest.java with two fields and basic getters/setters:
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Map;
public class TestRequest {
@Schema(description = "Joe was here with a tuna melt!")
private String joeWasHere;
@Schema(description = "This is an example of a map that does not work.!")
private Map<String, String> testingTheMap;
public String getJoeWasHere() { return joeWasHere; }
public void setJoeWasHere(String joeWasHere) { this.joeWasHere = joeWasHere; }
public Map<String, String> getTestingTheMap() { return testingTheMap; }
public void setTestingTheMap(Map<String, String> testingTheMap) { this.testingTheMap = testingTheMap; }
}
And a controller that doesn't do much but have one endpoint that takes this request class as a request body (although the same problem applies to responses and other spec generation):
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/test")
public class TestController {
@PostMapping
@ApiResponse(responseCode = "200", description = "Random endpoint.")
@ResponseStatus(HttpStatus.OK)
public void testingMethod(@RequestBody TestRequest testRequest) {
System.out.println("Method was run!");
}
}
This works fine if I run this application with just these two dependencies:
- org.springframework.boot:spring-boot-starter-web:3.0.1
- org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2
But the exact same project does not work if I simply add org.apache.groovy:groovy:4.0.7
to the classpath (and make no other changes). I have confirmed that the issue seems to also exist for 2.0.0 and 2.0.1 of the springdoc-openapi-starter-webmvc-ui modules, and that the problem also exists if I downgrade Groovy to 4.0.6.
I'll also note that this problem doesn't occur if you use the exact same code and Groovy version, but downgrade to Spring-Boot 2.7.7 and springdoc-openapi-ui 1.6.14. So it seems this issue is new with SpringDoc 2.X.