test(plugin): add compilation test for a feature-rich spec#88
Open
halotukozak wants to merge 1 commit into
Open
test(plugin): add compilation test for a feature-rich spec#88halotukozak wants to merge 1 commit into
halotukozak wants to merge 1 commit into
Conversation
Generates code from a spec exercising models, enums, oneOf polymorphism, allOf, all parameter locations, a JSON request body, UUID/date formats, and bearer security, then runs `compileKotlin` in a real Gradle project (TestKit) to prove the output compiles against the actual Ktor / kotlinx-serialization / kotlinx-datetime dependencies and the serialization compiler plugin. This uses the existing functionalTest harness (real compiler + real plugins) rather than kotlin-compile-testing, which does not yet support Kotlin 2.4. functionalTest runs as part of `./gradlew check` and CI. Closes #46 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3 tasks
Coverage Report
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a compilation test that generates code from a feature-rich OpenAPI spec and compiles it in a real Gradle project (TestKit
compileKotlin). Covers: data classes, enums,oneOfdiscriminated polymorphism,allOf, path/query/header params, JSON request body, UUID & date formats, and bearer security.The test fails on syntax errors, missing imports, or type/serializer mismatches — caught against the actual Ktor / kotlinx-serialization / kotlinx-datetime runtime and the serialization compiler plugin.
Why functionalTest instead of kotlin-compile-testing
kotlin-compile-testingdoes not yet support Kotlin 2.4 (this project's version) and wiring the kotlinx-serialization compiler plugin through it is fragile. The existingfunctionalTestharness compiles with the real Kotlin compiler and real Gradle plugins — a stronger guarantee. It runs as part of./gradlew checkand CI.Note — bug found
While writing this test, including a
date-timefield surfaced a real generator defect:kotlin.time.Instantis emitted without a serializer, so@Serializableclasses with date-time properties fail to compile (Serializer has not been found for type 'Instant?'). UUID gets a generated serializer but date-time does not. Out of scope here — filed separately as #89; the test spec omitsdate-timeuntil that is fixed.Closes #46
🤖 Generated with Claude Code