Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2062
Closed
Open
Issue created Feb 05, 2019 by Administrator@rootContributor

[BUG] Failed to add required=false

Created by: lzmthscarvalho

Description: There is not required=false in in RequestPart from generated API source code.

We call API without file (possibly by specification of API), then we receive: 2019-01-31 13:18:52.506 WARN 13343 --- [nio-2004-exec-5] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'file' is not present]

When replace RequestPart("file") to @RequestPart(value="file", required=false), I do not receive this error, how previous expected. In this way, we add to pom.xml: <replacement> <token>RequestPart\(\"file\"\)</token> <value>RequestPart\(value=\"file\"\, required=false\)</value> </replacement>

openapi-generator version: 3.3.4

OpenAPI declaration file content:

` summary: 'Create a marker'
  description: 'Create a new Marker with a optional media, that can be audio or image'
  requestBody:
    content:
      multipart/form-data:
        schema:
          type: object
          required:
            - marker
          properties:
            marker:
              type: object
              $ref: '#/components/schemas/Marker'
            file:
              type: string
              format: binary

` link: https://github.com/lztcf/bug-openapi3/blob/master/src/main/resources/api.yaml

Command line used for generation: mvn generate-sources Part of generated code:

    default ResponseEntity<Marker> markerPost(@ApiParam(value = "", required=true, defaultValue="null") @RequestParam(value="marker", required=true)  Marker marker,@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file) {

Steps to reproduce:

I made a little project that reproduce the bug: https://github.com/lztcf/bug-openapi3

Related issues/PRs:

Like described in https://github.com/OpenAPITools/openapi-generator/issues/1646, we replaced RequestParam to RequestPart: @RequestParam(value="marker", required=true) to @RequestPart(value="marker", required=true).

Assignee
Assign to
Time tracking