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
  • #2191
Closed
Open
Issue created Feb 19, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][Java][Server:Spring-boot] File upload spec (application/octet-stream) generates MultiPartFile Delegate

Created by: schafdog

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

I am trying to build a simple file upload of any mime-type (application/octet-stream) but the generated code is not valid.

The API class looks right having a Resource body as parameter, but the generated Delegate has a MultipartFile body parameter which is not compatible.

openapi-generator version

I am using version 3.3.4 maven plugin. I haven't tried earlier versions

OpenAPI declaration file content or url
    post:
      operationId: createResource
      summary: Create new resource
      description: create a remote resources
      requestBody:
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary

The Delegate parameters does not match the API parameters and thus the generated code does not compile:

    default ResponseEntity<CreateResponseBody> ResourceDelegate.createResource(String pathFolderId,
        String resourceName,
        ResourceType type,
        MultipartFile body)

 default ResponseEntity<CreateResponseBody> ResourcesApi.createResource(@ApiParam(value = "",required=true) @PathVariable("pathFolderId") String pathFolderId,@ApiParam(value = "",required=true) @PathVariable("resourceName") String resourceName,@ApiParam(value = "", defaultValue = "null") @Valid @RequestParam(value = "type", required = false, defaultValue="null") ResourceType type,@ApiParam(value = ""  )  @Valid @RequestBody Resource body) {
        return getDelegate().createResource(pathFolderId, resourceName, type, body);
Command line used for generation

Using the maven plugin:

<configuration>
   <generatorName>spring</generatorName>
     <configOptions>
       <interfaceOnly>false</interfaceOnly>
       <delegatePattern>true</delegatePattern>
       <java8>true</java8>
     </configOptions>
  <generateSupportingFiles>true</generateSupportingFiles>
</configuration>
Steps to reproduce

Changing the format to base64 creates valid generated code, but not the java methods I am interested in. Changing back to binary and doing a clean build generates again invalid code that doesn't compile.

Related issues/PRs
Suggest a fix

Disabling the generation of Delegate could be a work-around.

Assignee
Assign to
Time tracking