Closed
Description
Describe the bug
When using method consuming MediaType.MULTIPART_FORM_DATA_VALUE, schemas for RequestPart objects are generated based on JsonView from method level, which should be related only to response schema, instead of parameter level
To Reproduce
Steps to reproduce the behavior:
- spring-boot version: 2.7.3
- springodc-openapi-ui version: 1.6.11
HelloController:
@PostMapping(value = "/foo", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@JsonView(ViewB.class)
public Foo postFoo(@RequestPart("input") @JsonView(ViewA.class) Foo foo) {
return null;
}
Foo:
@Data
public class Foo {
@JsonView(ViewA.class)
private String a;
@JsonView(ViewB.class)
private String b;
}
/v3/api-docs:
paths": {
"/foo": {
"post": {
"tags": [
"hello-controller"
],
"operationId": "postFoo",
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"required": [
"input"
],
"type": "object",
"properties": {
"input": {
"$ref": "#/components/schemas/Foo_ViewB"
}}}}}},
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/Foo_ViewB"
}}}}}}}},
"components": {
"schemas": {
"Foo_ViewB": {
"type": "object",
"properties": {
"b": {
"type": "string"
}}}}}
Analogically, when no JsonView annotation is present on method level then the only generated shema is Foo with properties a and b and both input and response objects refer to that schema, ignoring JsonView(ViewA.class) on parameter
Expected behavior
- 2 schemas are generated: Foo_ViewA with property a and Foo_ViewB with property b
- response schema should refer to Foo_ViewB and input object should refer to Foo_ViewA