[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
- Run the generator as described above
- 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)