Skip to content

[BUG] kotlin-spring does not generate Serializable models #8317

@michael-wirth

Description

@michael-wirth

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

According to the documentation, the model serialization feature should be available for kotlin-spring
https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/kotlin-spring.md

But the serialization properties don't have an impact on the generated code.

The mustache templates show that the serialization interface is only added for kotlin-server and kotlin-client.
Is this a bug in the code or in the documentation?

Spring itself uses Jackson to serialize the objects returned from the server.
But we would also cache some of the generated models in a distributed cache (HazelCast), which requires the object to be Serializable.

openapi-generator version

5.0.0

OpenAPI declaration file content or URL
Generation Details

Maven Plugin configuration:

        <plugin>
          <groupId>org.openapitools</groupId>
          <artifactId>openapi-generator-maven-plugin</artifactId>
          <version>5.0.0</version>
          <executions>
            <execution>
              <id>generate-kotlin-spring</id>
              <configuration>
                <apiPackage>my.project.web.api</apiPackage>
                <generateApiTests>false</generateApiTests>
                <generateSupportingFiles>false</generateSupportingFiles>
                <generatorName>kotlin-spring</generatorName>
                <modelPackage>my.project.model</modelPackage>
                <skipValidateSpec>false</skipValidateSpec>
                <configOptions>
                  <basePackage>my.project</basePackage>
                  <exceptionHandler>false</exceptionHandler>
                  <enumPropertyNaming>UPPERCASE</enumPropertyNaming>
                  <interfaceOnly>false</interfaceOnly>
                  <serviceInterface>true</serviceInterface>
                  <sourceFolder>src/main/kotlin</sourceFolder>
                </configOptions>
                <additionalProperties>serializableModel=true</additionalProperties>
                <inputSpec>api.yml</inputSpec>
              </configuration>
            </execution>
          </executions>
        </plugin>
Steps to reproduce
Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions