Skip to content

test(plugin): add compilation test for a feature-rich spec#88

Open
halotukozak wants to merge 1 commit into
masterfrom
test/46-compilation-test
Open

test(plugin): add compilation test for a feature-rich spec#88
halotukozak wants to merge 1 commit into
masterfrom
test/46-compilation-test

Conversation

@halotukozak

@halotukozak halotukozak commented Jun 9, 2026

Copy link
Copy Markdown
Member

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, oneOf discriminated 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-testing does not yet support Kotlin 2.4 (this project's version) and wiring the kotlinx-serialization compiler plugin through it is fragile. The existing functionalTest harness compiles with the real Kotlin compiler and real Gradle plugins — a stronger guarantee. It runs as part of ./gradlew check and CI.

Note — bug found

While writing this test, including a date-time field surfaced a real generator defect: kotlin.time.Instant is emitted without a serializer, so @Serializable classes 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 omits date-time until that is fixed.

Closes #46

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Coverage Report

Overall Project 96.76% 🍏

There is no coverage information present for the Files changed

@halotukozak halotukozak added this to the 1.0.0 milestone Jun 9, 2026
@halotukozak halotukozak self-assigned this Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add compilation test to verify generated code compiles successfully

1 participant