-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenAPI generator new properties (#807)
* OpenAPI generator 6.1.0 new properties * Fix OpenAPI Kotlin integration - moves tests to functional tests, since we want to make sure that the plugins can work _without_ the Kotlin plugin on classpath. The tests which involve external plugins must live in `functionalTests` - fixes missing integration with Kotlin plugin * Fix tests * Fix openapi tests --------- Co-authored-by: Cedric Champeau <[email protected]>
- Loading branch information
Showing
22 changed files
with
1,534 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...al-tests/src/test/groovy/io/micronaut/gradle/openapi/AbstractOpenApiWithKotlinSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.micronaut.gradle.openapi | ||
|
||
import io.micronaut.gradle.fixtures.AbstractEagerConfiguringFunctionalTest | ||
import spock.lang.Shared | ||
|
||
class AbstractOpenApiWithKotlinSpec extends AbstractEagerConfiguringFunctionalTest { | ||
@Shared | ||
protected final String kotlinVersion = System.getProperty("kotlinVersion") | ||
|
||
@Shared | ||
protected final String kspVersion = System.getProperty("kspVersion") | ||
|
||
protected void withPetstore() { | ||
file("petstore.json").text = this.class.getResourceAsStream("/petstore.json").getText("UTF-8") | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
...onal-tests/src/test/groovy/io/micronaut/gradle/openapi/OpenApiClientWithKotlinSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package io.micronaut.gradle.openapi | ||
|
||
|
||
import org.gradle.testkit.runner.TaskOutcome | ||
|
||
class OpenApiClientWithKotlinSpec extends AbstractOpenApiWithKotlinSpec { | ||
|
||
def "can generate an kotlin OpenAPI client implementation with some properties (KAPT)"() { | ||
given: | ||
settingsFile << "rootProject.name = 'openapi-client'" | ||
buildFile << """ | ||
plugins { | ||
id "io.micronaut.minimal.application" | ||
id "io.micronaut.openapi" | ||
id "org.jetbrains.kotlin.jvm" version "$kotlinVersion" | ||
id "org.jetbrains.kotlin.plugin.allopen" version "$kotlinVersion" | ||
id "org.jetbrains.kotlin.kapt" version "$kotlinVersion" | ||
} | ||
|
||
micronaut { | ||
version "$micronautVersion" | ||
openapi { | ||
client(file("petstore.json")) { | ||
lang = "kotlin" | ||
useReactive = true | ||
generatedAnnotation = false | ||
fluxForArrays = true | ||
} | ||
} | ||
} | ||
|
||
$repositoriesBlock | ||
|
||
dependencies { | ||
|
||
kapt "io.micronaut.serde:micronaut-serde-processor" | ||
|
||
implementation "io.micronaut.serde:micronaut-serde-jackson" | ||
implementation "io.micronaut.reactor:micronaut-reactor" | ||
implementation "io.micronaut:micronaut-inject-kotlin" | ||
} | ||
|
||
""" | ||
withPetstore() | ||
when: | ||
def result = build('test') | ||
then: | ||
result.task(":generateClientOpenApiApis").outcome == TaskOutcome.SUCCESS | ||
result.task(":generateClientOpenApiModels").outcome == TaskOutcome.SUCCESS | ||
result.task(":compileKotlin").outcome == TaskOutcome.SUCCESS | ||
and: | ||
file("build/generated/openapi/generateClientOpenApiModels/src/main/kotlin/io/micronaut/openapi/model/Pet.kt").exists() | ||
} | ||
def "can generate an kotlin OpenAPI client implementation with some properties (KSP)"() { | ||
given: | ||
settingsFile << "rootProject.name = 'openapi-client'" | ||
buildFile << """ | ||
plugins { | ||
id "io.micronaut.minimal.application" | ||
id "io.micronaut.openapi" | ||
id "org.jetbrains.kotlin.jvm" version "$kotlinVersion" | ||
id "org.jetbrains.kotlin.plugin.allopen" version "$kotlinVersion" | ||
id "com.google.devtools.ksp" version "$kspVersion" | ||
} | ||
|
||
micronaut { | ||
version "$micronautVersion" | ||
openapi { | ||
client(file("petstore.json")) { | ||
lang = "kotlin" | ||
useReactive = true | ||
generatedAnnotation = false | ||
fluxForArrays = true | ||
} | ||
} | ||
} | ||
|
||
$repositoriesBlock | ||
|
||
dependencies { | ||
|
||
ksp "io.micronaut.serde:micronaut-serde-processor" | ||
|
||
implementation "io.micronaut.serde:micronaut-serde-jackson" | ||
implementation "io.micronaut.reactor:micronaut-reactor" | ||
implementation "io.micronaut:micronaut-inject-kotlin" | ||
} | ||
|
||
""" | ||
withPetstore() | ||
when: | ||
def result = build('test') | ||
then: | ||
result.task(":generateClientOpenApiApis").outcome == TaskOutcome.SUCCESS | ||
result.task(":generateClientOpenApiModels").outcome == TaskOutcome.SUCCESS | ||
result.task(":compileKotlin").outcome == TaskOutcome.SUCCESS | ||
and: | ||
file("build/generated/openapi/generateClientOpenApiModels/src/main/kotlin/io/micronaut/openapi/model/Pet.kt").exists() | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
...onal-tests/src/test/groovy/io/micronaut/gradle/openapi/OpenApiServerWithKotlinSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package io.micronaut.gradle.openapi | ||
|
||
|
||
import org.gradle.testkit.runner.TaskOutcome | ||
|
||
class OpenApiServerWithKotlinSpec extends AbstractOpenApiWithKotlinSpec { | ||
|
||
def "can generate an kotlin OpenAPI server implementation with properties (KAPT)"() { | ||
given: | ||
settingsFile << "rootProject.name = 'openapi-server'" | ||
buildFile << """ | ||
plugins { | ||
id "io.micronaut.minimal.application" | ||
id "io.micronaut.openapi" | ||
id "org.jetbrains.kotlin.jvm" version "$kotlinVersion" | ||
id "org.jetbrains.kotlin.plugin.allopen" version "$kotlinVersion" | ||
id "org.jetbrains.kotlin.kapt" version "$kotlinVersion" | ||
} | ||
|
||
micronaut { | ||
version "$micronautVersion" | ||
runtime "netty" | ||
testRuntime "junit5" | ||
openapi { | ||
server(file("petstore.json")) { | ||
lang = "kotlin" | ||
useReactive = true | ||
generatedAnnotation = false | ||
fluxForArrays = true | ||
aot = true | ||
} | ||
} | ||
} | ||
|
||
$repositoriesBlock | ||
mainClassName="example.Application" | ||
|
||
dependencies { | ||
|
||
kapt "io.micronaut.serde:micronaut-serde-processor" | ||
|
||
implementation "io.micronaut.security:micronaut-security" | ||
implementation "io.micronaut.serde:micronaut-serde-jackson" | ||
} | ||
""" | ||
withPetstore() | ||
when: | ||
def result = build('test') | ||
then: | ||
result.task(":generateServerOpenApiApis").outcome == TaskOutcome.SUCCESS | ||
result.task(":generateServerOpenApiModels").outcome == TaskOutcome.SUCCESS | ||
result.task(":compileKotlin").outcome == TaskOutcome.SUCCESS | ||
and: | ||
file("build/generated/openapi/generateServerOpenApiApis/src/main/kotlin/io/micronaut/openapi/api/PetApi.kt").exists() | ||
file("build/generated/openapi/generateServerOpenApiModels/src/main/kotlin/io/micronaut/openapi/model/Pet.kt").exists() | ||
file("build/classes/kotlin/main/io/micronaut/openapi/api/PetApi.class").exists() | ||
file("build/classes/kotlin/main/io/micronaut/openapi/model/Pet.class").exists() | ||
} | ||
def "can generate an kotlin OpenAPI server implementation with properties (KSP)"() { | ||
given: | ||
settingsFile << "rootProject.name = 'openapi-server'" | ||
buildFile << """ | ||
plugins { | ||
id "io.micronaut.minimal.application" | ||
id "io.micronaut.openapi" | ||
id "org.jetbrains.kotlin.jvm" version "$kotlinVersion" | ||
id "org.jetbrains.kotlin.plugin.allopen" version "$kotlinVersion" | ||
id "com.google.devtools.ksp" version "$kspVersion" | ||
} | ||
|
||
micronaut { | ||
version "$micronautVersion" | ||
runtime "netty" | ||
testRuntime "junit5" | ||
openapi { | ||
server(file("petstore.json")) { | ||
lang = "kotlin" | ||
useReactive = true | ||
generatedAnnotation = false | ||
fluxForArrays = true | ||
aot = true | ||
} | ||
} | ||
} | ||
|
||
$repositoriesBlock | ||
mainClassName="example.Application" | ||
|
||
dependencies { | ||
|
||
ksp "io.micronaut.serde:micronaut-serde-processor" | ||
|
||
implementation "io.micronaut.security:micronaut-security" | ||
implementation "io.micronaut.serde:micronaut-serde-jackson" | ||
} | ||
""" | ||
withPetstore() | ||
when: | ||
def result = build('test') | ||
then: | ||
result.task(":generateServerOpenApiApis").outcome == TaskOutcome.SUCCESS | ||
result.task(":generateServerOpenApiModels").outcome == TaskOutcome.SUCCESS | ||
result.task(":compileKotlin").outcome == TaskOutcome.SUCCESS | ||
and: | ||
file("build/generated/openapi/generateServerOpenApiApis/src/main/kotlin/io/micronaut/openapi/api/PetApi.kt").exists() | ||
file("build/generated/openapi/generateServerOpenApiModels/src/main/kotlin/io/micronaut/openapi/model/Pet.kt").exists() | ||
file("build/classes/kotlin/main/io/micronaut/openapi/api/PetApi.class").exists() | ||
file("build/classes/kotlin/main/io/micronaut/openapi/model/Pet.class").exists() | ||
} | ||
} |
Oops, something went wrong.