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

Implement configuration of plugin with multiple specs support #45

Closed Alex009 closed 3 years ago

Alex009 commented 3 years ago

configuration spec should be changed to:

mokoNetwork {
    spec("petstore") {
        inputSpec = file("src/swagger")
        packageName = "com.icerockdev.library"
        isInternal = false
        isOpen = true
        configureTask { // here block that will be called at creating of generate task
            inputSpec.set(file("src/profile_openapi.yaml").path)
            generatorName.set("kotlin-ktor-client")
        }
    }
    spec("profile") {
        inputSpec = file("src/profile_openapi.yaml")
        packageName = "com.icerockdev.library.d2"
        isInternal = false
        isOpen = true
    }
}

inside plugin we should generate task by:

tasks.create("profileOpenApiGenerate", org.openapitools.generator.gradle.plugin.tasks.GenerateTask::class.java) {
    group = "openapi"

    inputSpec.set(file("src/profile_openapi.yaml").path)
    generatorName.set("kotlin-ktor-client")
}