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
  • #3905
Closed
Open
Issue created Sep 17, 2019 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG][SPRING]compilation errors due to different request body type in api and apiDelegate files

Created by: anuhyapolisetti

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

We have encountered this problem generated Api and ApiDelegate files have different request body types (Resource/MultipartFile), which is resulting in compilation errors.

Issue seemed to have addressed in v4.0.0-beta3 version, but issue still persists when we tried with the cli version of v4.0.0-beta3.

openapi-generator version

v4.0.2

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: testapp
  version: 0.0.1
servers:
  - url: 'http://localhost:8081/api'
    description: Development server
paths:
  '/foo':
    post:
      operationId: foo
      requestBody:
        content:
          image/png:
            schema:
              type: string
              format: binary
      responses:
        default:
          description: successful operation
Command line used for generation

java -jar openapi-generator-cli.jar generate -g spring -i api.yml -o ./out --additional-properties delegatePattern=true

Steps to reproduce
  1. Run the command above with provided api.yml.
  2. Open out/src/main/java/org/openapitools/api/FooApi.java, look at generated foo method
    default ResponseEntity<Void> foo(@ApiParam(value = ""  )  @Valid @RequestBody Resource body) {
        return getDelegate().foo(body);
    }
  1. Open out/src/main/java/org/openapitools/api/FooApiDelegate.java, look at generated apiDelegate method
    default ResponseEntity<Void> foo(MultipartFile body) {
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
    }

foo from FooApiDelegate consumes MultipartFile whereas FooApi passes Resource as request body type.

Related issues/PRs
  1. https://github.com/OpenAPITools/openapi-generator/pull/2271

Issue seemed to have addressed in v4.0.0-beta3 version per above PR, but issue still persists when we tried with the cli version of v4.0.0-beta3.

  1. https://github.com/OpenAPITools/openapi-generator/issues/2191
Suggest a fix

Use either Multipartfile or Resource in both api and apidelegate

Assignee
Assign to
Time tracking