Skip to content

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

Merged
mfabisiak merged 2 commits into
masterfrom
test/46-compilation-test
Jul 27, 2026
Merged

test(plugin): add compilation test for a feature-rich spec#88
mfabisiak merged 2 commits into
masterfrom
test/46-compilation-test

Conversation

@halotukozak

@halotukozak halotukozak commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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.85% 🍏

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
# Conflicts:
#	plugin/src/functionalTest/kotlin/com/avsystem/justworks/gradle/JustworksPluginFunctionalTest.kt
Copilot AI review requested due to automatic review settings July 27, 2026 14:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@mfabisiak
mfabisiak self-requested a review July 27, 2026 14:34
@mfabisiak
mfabisiak merged commit 1fd9786 into master Jul 27, 2026
2 checks passed
@mfabisiak
mfabisiak deleted the test/46-compilation-test branch July 27, 2026 14:37
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

3 participants