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
  • #14527
Closed
Open
Issue created Jan 25, 2023 by Administrator@rootContributor

[REQ][jaxrs-spec] Config option to generate StreamingOutput instead of File as response type

Created by: kariem

Instead of using java.io.File as response type, I would like the generator to use javax.ws.rs.core.StreamingOutput. Except for actually serving files, this option would simplify implementation and improve performance by wrapping an OutputStream.

Solution

It would be great to add a configuration option similar to returnResponse:

Name: returnStreamingOutput or returnStreamingOutputForBinary

Description: Whether the generated API interface should return javax.ws.rs.core.StreamingOutput instead of java.util.File for a binary response type.

Alternatives

I currently extend JavaJAXRSSpecServerCodegen and override importMapping and typeMapping. These are actually only two lines of code. See this response on StackOverflow for the details and more context.

Additional context

I currently use jaxrs-spec generator with the following settings (via maven plugin, formatted for readability):

Name Value
hideGenerationTimestamp true
interfaceOnly true
useSwaggerAnnotations false

A schema definition of something like this

/{id}:
  get:
    summary: Get the given document as PDF
    operationId: getDocument
    parameters:
    - name: id
      in: path
      required: true
      schema:
        type: string
    responses:
      200:
        description: Get the PDF document
        content:
        application/pdf:
          schema:
          type: string
          format: binary

will generate a java interface with this method

@GET
@Path("/{id}")
@Produces({"application/pdf"})
File getDocument(@PathParam("id") String id)

I would prefer this

@GET
@Path("/{id}")
@Produces({"application/pdf"})
StreamingOutput getDocument(@PathParam("id") String id)
Assignee
Assign to
Time tracking