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
  • #9151
Closed
Open
Issue created Apr 01, 2021 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG][Java] ApiClient.java: error: no suitable method found for create(byte[],MediaType)

Created by: toby-murray-snow-software

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • [] What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Using the java generator against a basic spec, the generated project fails to compile.

openapi-generator version

5.1.0 and latest master (docker image 3c6b0382cd49)

Regression from 5.0.1

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  version: 1.0.0
  title: Api

paths:
  /version:
    get:
      tags:
      - version
      summary: Gets the system version check
      operationId: getVersion
      responses:
        200:
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VersionGetResponse'

components:
  schemas:
    VersionGetResponse:
      type: string
      description: The version of this service
      required:
        - status
      properties:
        status:
          type: string
          description: OK
Generation Details

java -jar openapi-generator-cli-5.1.0.jar generate -g java -i service.yaml

Steps to reproduce
  1. Run the generator as described above
  2. Try to compile the code with ./gradlew compileJava or similar
Expected:

It will compile

Actual:

A bunch of:

out\java\src\main\java\org\openapitools\client\ApiClient.java:818: error: no suitable method found for create(byte[],MediaType)
            return RequestBody.create((byte[]) obj, MediaType.parse(contentType));
                              ^
    method RequestBody.create(MediaType,String) is not applicable
      (argument mismatch; byte[] cannot be converted to MediaType)
    method RequestBody.create(MediaType,ByteString) is not applicable
      (argument mismatch; byte[] cannot be converted to MediaType)
    method RequestBody.create(MediaType,byte[]) is not applicable
      (argument mismatch; byte[] cannot be converted to MediaType)
    method RequestBody.create(MediaType,File) is not applicable
      (argument mismatch; byte[] cannot be converted to MediaType)
Related issues/PRs
Suggest a fix
Assignee
Assign to
Time tracking