swagger-api / swagger-api/swagger-codegen

How to add RedirectAttributes through Swagger Documentation

Open
#8,491 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

We're using swagger codegen maven plugin. We have one Api which accepts multipart file. The signatures of the api code generated using the maven plugins are :-

default ResponseEntity<FileInfo> uploadFile(@ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile file)

However what we would want will be an additional parameter with this being the RedirectAttributes from the class org.springframework.web.servlet.mvc.support.RedirectAttributes

Swagger-codegen version

2.3.1

Swagger declaration file content or url
/upload:
    post:
      tags:
      - fileUpload
      produces:
      - application/json
      consumes:
      - multipart/form-data
      operationId: uploadFile
      parameters: 
        - in: formData
          name: file
          type: file
      responses:
        '200':
          schema:
            $ref: '#/definitions/file'

Is there a way we could achieve this using swagger-codegen-maven-plugin?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the swagger-codegen Maven plugin and the supplied Swagger declaration for the multipart /upload operation, then trace how its Java server signature is generated. Done means the generated uploadFile method includes an additional org.springframework.web.servlet.mvc.support.RedirectAttributes parameter while retaining the MultipartFile parameter and declared response.

Written by the indexing model from the issue text.

Assessment

Tech stack
spring
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.