Closed xsveda closed 3 years ago
@xsveda maybe we should generate interface in addition to implementation? to not override generated implementation, but implement fake implementation. what do you think about it?
example:
interface ProfileApi {
suspend fun getProfile(profileId: Int): Profile
}
class ProfileApiImpl(...): ProfileApi {
override suspend fun getProfile(profileId: Int): Profile
}
Sure, until they will be generics-free (for better Swift interoperability) I don't see an issue.
On the other hand, there is a completely re-write of KMP client in openapi-generator
itself (https://github.com/OpenAPITools/openapi-generator/pull/7353) coming hopefully soon, that will also solve this.
thanks for link! i will follow the updates of this PR. later already openapi-generator got multiplatform support, but with kotlin updates it was not updated so we continue using moko-network..maybe in this time multiplatform support will be better
your suggestion with open class implemented in #52
interfaces idea moved to #53
We were used to generate Retrofit interfaces from swagger and to make development easier (server is not always available) we created fake implementation of those Retrofit interfaces that serve static hardcoded responses without touching the server.
Now when we generate Api classes based on Ktor it is not possible to sub-class them for stubs anymore.
It would be great to have an optional switch to make both Api classes and all its functions
open
inapi.mustache
.Current class definition:
{{#nonPublicApi}}internal {{/nonPublicApi}}class {{classname}}
Suggested class definition:
{{#openApi}}open {{/openApi}}{{#nonPublicApi}}internal {{/nonPublicApi}}class {{classname}}