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

Javadoc description of the @RequestPart param of multipart/form-data goes to requestBody description, not to parameter description #1923

Closed
vlad-ogol opened this issue Nov 2, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@vlad-ogol
Copy link

Describe the bug
Javadoc description of the @RequestPart param of multipart/form-data request is treated as the description of the whole RequestBody, not as the description of the concrete part of the request.

To Reproduce
Steps to reproduce the behavior:

  • spring-boot version: 2.7.5
  • springdoc-openapi modules: 1.6.12
  • therapi-runtime-javadoc version: 0.13.0

HelloController.java

@RestController
@RequestMapping(produces = APPLICATION_JSON_VALUE)
public class HelloController {
    /**
     * Creates some item.
     *
     * @param id          item ID
     * @param code        item code
     * @param description item description
     * @param file        item model file
     * @return Data of the created item.
     */
    @PostMapping(path = "/{id}", consumes = MULTIPART_FORM_DATA_VALUE)
    public ItemData createSomeItem(
            @PathVariable @NotNull Long id,
            @RequestPart(required = false) Integer code,
            @Parameter(description = "item description (@parameter)")
            @RequestPart(required = false) String description,
            @RequestPart(required = false) MultipartFile file) {
        return new ItemData(id, code, description, file);
    }

    /**
     * Item data
     */
    @lombok.Value
    public static class ItemData {
        /**
         * Item ID.
         */
        Long id;
        /**
         * Item code.
         */
        Integer code;
        /**
         * Item description.
         */
        String description;
        /**
         * Item model file.
         */
        MultipartFile file;
    }
}

(full project reproducing the bug)

Actual result
(requestBody part only)

  "requestBody": {
    "description": "item code",
    "content": {
      "multipart/form-data": {
        "schema": {
          "type": "object",
          "properties": {
            "code": {
              "type": "integer",
              "format": "int32"
            },
            "description": {
              "type": "string",
              "description": "item description (parameter"
            },
            "file": {
              "type": "string",
              "format": "binary"
            }
          }
        }
      }
    }
  }

Expected result
(requestBody part only)

  "requestBody": {
    "content": {
      "multipart/form-data": {
        "schema": {
          "type": "object",
          "properties": {
            "code": {
              "type": "integer",
              "format": "int32"
              "description": "item code"
            },
            "description": {
              "type": "string",
              "description": "item description (@parameter)"
            },
            "file": {
              "type": "string",
              "format": "binary"
              "description": "item model file"
            }
          }
        }
      }
    }
  }

Additional context
Despite this being related to the javadoc feature, it seems that the bug is somewhere in the springdoc-openapi-common, this is why I'm reporting it here.

bnasslahsen added a commit that referenced this issue Nov 16, 2022
…goes to requestBody description, not to parameter description. Fixes #1923
@bnasslahsen
Copy link
Contributor

@vlad-ogol,

The fix is now available and can be tested with the latest SNAPSHOT.

@bnasslahsen bnasslahsen added the enhancement New feature or request label Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants