papsign / Ktor-OpenAPI-Generator

Ktor OpenAPI/Swagger 3 Generator
Apache License 2.0
241 stars 42 forks source link

Is there a way to determine request content type/media type? #73

Closed sigmanil closed 3 years ago

sigmanil commented 4 years ago

I can't seem to figure out how to specify that an incoming post body, with "String" as the body type, should be something like "text/plain; charset=utf-8" instead of application/json.

sigmanil commented 4 years ago

Using BinaryRequest in the following way, and then using the data class as the input, seems to work:

const val contentType = "text/plain; charset=utf-8"
@BinaryRequest([contentType])
data class ImportParam(val stream: InputStream)

Is that the intended use? (Just confused because of the "binary" in the name.)

Wicpar commented 4 years ago

These things are handled by the BodyParser and ResponseSerializer, there is none for plain text, but you can create your own. Copying BinaryContentTypeParser would be a good start.

Wicpar commented 4 years ago

just make sure the module is registered in the context or the annotations won't work.

Wicpar commented 3 years ago

Since there is a solution and no further questions i am closing the issue.