icerockdev / moko-network

Network components with codegeneration of rest api for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev
Apache License 2.0
151 stars 29 forks source link

Support header arguments in generated requests #141

Closed nothingelsematters closed 2 years ago

nothingelsematters commented 3 years ago

If there is a header parameter in swagger.json, then the gradle code generation plugin generates a code for the corresponding endpoint with a function argument of this header, but it does not add this header to a request.

Using openAPI generation directly you can face the same issue when using "kotlin-ktor-client" generator (there is no such bug using "kotlin" generator with "multiplatform" library, but this code seems to be outdated for new kotlin version).

The generated code looks like this:

override public suspend fun endpoint(authorization: kotlin.String) : Response {
    ...
    with(builder.headers) {
        append("Accept", "application/json")
    }
    ...
}

There is no usage of an "authorization" parameter in a function body.

Alex009 commented 2 years ago

will be released in 0.18.0