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

Allow to enable public API explicitly #55

Closed xsveda closed 3 years ago

xsveda commented 3 years ago

This PR adds apiVisibility attribute as a direct replacement for isInternal that allows to explicitly specify generated classes visibility as public. Useful when Kotlin Explicit API mode is used: https://kotlinlang.org/docs/reference/whatsnew14.html#explicit-api-mode-for-library-authors

xsveda commented 3 years ago

The build is failing due to public visibility modifier being applied, even though publicApi property is defined as false.

Even if I hardcode the values in MultiPlatformNetworkGeneratorPlugin, the public modifier is still applied.

                    additionalProperties.set(
                        mutableMapOf(
                            "publicApi" to "false",
                            "nonPublicApi" to "false",
                            "openApiClasses" to "false"
                        )
                    )

Is there something need to be done to make publicApi property work?

xsveda commented 3 years ago

Seems like the openApiClasses flag is also not working. additionalProperties is of type Map<String, String> and when we put "true" it won't handle that as boolean value.

xsveda commented 3 years ago

Confirmed, when I've updated OpenApi Tools Gradle plugin to accept also nonString properties both publicApi and openApiClasses works just fine. Will do PR for OpenApi project soon. This PR is actually OK, just need the OpenAPI gradle plugin update first

xsveda commented 3 years ago

Tracked under https://github.com/icerockdev/moko-network/issues/59

Alex009 commented 3 years ago

this fixed by preprocessing inside KtorGenerator. and if isInternal = false we generate now public classes explicit