[kotlin-spring] Tests only - Add regression tests and samples for generic interfaces in implements

PI
3d ago
+93-3

Description

x-kotlin-implements and schemaImplements in kotlin-spring already work with generic interfaces, because the interface string is emitted verbatim. Nothing guarded that behavior, so this PR adds regression coverage. There are no generator changes.

Unit test: generateModelsImplementingGenericInterfaces uses a new spec, generic-interfaces-implements.yaml. It asserts the full supertype line for these cases:

  • one type argument
  • several type arguments (commas are not split)
  • nested generics
  • nullable arguments
  • a plain interface alongside generic ones
  • both x-kotlin-implements and schemaImplements (single-string and list values)

Compile-checked samples:

  • Tag in petstore-with-x-kotlin-implements.yaml uses x-kotlin-implements with GenericRepo<Category> and GenericPair<kotlin.String, org.openapitools.model.Category>.
  • Order in the kotlin-springboot-x-kotlin-implements sample uses schemaImplements with BoundedRepo<kotlin.Long>, VariantSource<kotlin.collections.List<Tag>> and TwoBounds<kotlin.Int>.
  • The hand-written interfaces cover declaration forms with bounds, out variance and where clauses.
  • Samples kotlin-springboot-x-kotlin-implements and kotlin-springboot-include-http-request-context-delegate were regenerated (the latter shares the spec). Both compile with mvnw compile.

Known limitation (not changed here): no imports are generated for implemented interfaces or their type arguments. Types outside the model package must be fully qualified.

Testing

  • ./mvnw test -pl modules/openapi-generator -Dtest='KotlinSpringServerCodegenTest#generateModelsImplementingGenericInterfaces+generateSerializableModelWithSchemaImplements': passed (2 tests).
  • ./mvnw -f samples/server/petstore/kotlin-springboot-x-kotlin-implements/pom.xml compile: success.
  • ./mvnw -f samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/pom.xml compile: success.
  • I regenerated the two affected samples with the CLI batch command. I did not run the full generate-samples.sh or export_docs_generators.sh; no option descriptions changed.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request. Tagging @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10) @AndreyVMarkelov (2026/11)

Summary by cubic

Adds regression coverage proving x-kotlin-implements and schemaImplements in kotlin-spring emit generic interface strings verbatim. No generator changes; the behavior already worked but was unguarded.

  • New unit test asserts the full supertype line for one and several type arguments, nested and nullable generics, plain interfaces alongside generic ones, and both single-string and list values for x-kotlin-implements and schemaImplements.
  • Compile-checked samples exercise generic interfaces via x-kotlin-implements (Tag) and schemaImplements (Order), with hand-written interfaces covering bounds, out variance, and where clauses.
  • Imports are still not generated for implemented interfaces or their type arguments; types outside the model package must be fully qualified.