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

[spring] [v3] @RequestPart should use "{{basename}}" instead of "file" and observe "required" attribute #11935

Closed
mladenlukic opened this issue Oct 26, 2022 · 0 comments · Fixed by swagger-api/swagger-codegen-generators#1099

Comments

@mladenlukic
Copy link

mladenlukic commented Oct 26, 2022

Description

When generating code for Spring for file upload, it's not possible to make the file optional and not mandatory and the name is fixed to 'file'

Swagger-codegen version

3.0.35

Swagger declaration file content or url
/url:
    post:
      operationId: create
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              required: [ name ]
              properties:
                name:
                  type: string
                  minLength: 2
                  maxLength: 20
                graphic:
                  type: string
                  format: binary
Command line used for generation

swagger-codegen generate -i api.yml -l spring

Steps to reproduce

execute the codegen-generate command on a file with multipart/form-data and what you get is:
ResponseEntity<UUID> create(@Parameter(in = ParameterIn.DEFAULT, description = "",schema=@Schema()) @RequestParam(value="name", required=false) String name, @Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile graphic);

it should be:
ResponseEntity<UUID> create(@Parameter(in = ParameterIn.DEFAULT, description = "",schema=@Schema()) @RequestParam(value="name", required=false) String name, @Parameter(description = "file detail") @Valid @RequestPart("graphic", required=false) MultipartFile graphic);

Related issues/PRs

It's the same issue as this one: #9250

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant