-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Labels
Description
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
Since Ktor needs the request to set a content type for the ContentNegotiation
plugin to be activated, ktor fails with the following message:
Fail to prepare request body for sending.
The body type is: class generated.MyClass, with Content-Type: null.
Configuration is:
generatorName: kotlin
library: jvm-ktor
Workaround
You can manually set the content type for all requests doing something like:
private val myApi = ConsentApi(baseUrl = "https://myapi.com/") {
it.defaultRequest {
contentType(ContentType.Application.Json) // This shoud have been generated by the library
}
it.install(ContentNegotiation) {
json() // This line should have been generated as well
}
}
openapi-generator version
maven plugin 6.6.0
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
- Generate code for any spec containing a post/put method with a payload that needs to be serialized, using
generatorName: kotlin
andlibrary: jvm-ktor
. - Call the post/put method
- Error will be thrown