OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.22k stars 6.43k forks source link

[BUG] no test code generated for Java #6272

Open grexe opened 4 years ago

grexe commented 4 years ago
Description

Despite correct options and reading the docs, no test sources are generated for valid yaml with the Java spring/spring-boot generator.

openapi-generator version

openapi-generator(-maven-plugin) 4.3.1

OpenAPI declaration file content or url

cannot post without confirmation from company, but models are generated just fine, only tests are missing.

Command line used for generation

Using Maven 3.6.1, AdoptOpenJDK 11.0.4 and version above.

Steps to reproduce

options used:

<configuration>
    <inputSpec>${project.basedir}/src/main/resources/openapi/my-api.yml</inputSpec>
    <generatorName>spring</generatorName>
    <apiPackage>at.my.api</apiPackage>
    <modelPackage>a.my.model</modelPackage>
    <configOptions>
        <dateLibrary>java8</dateLibrary>
        <library>spring-boot</library>
        <useOptional>true</useOptional>
        <useTags>true</useTags>
        <serializableModel>true</serializableModel>
        <booleanGetterPrefix>is</booleanGetterPrefix>
        <performBeanValidation>true</performBeanValidation>
        <useBeanValidation>true</useBeanValidation>
        <serializationLibrary>jackson</serializationLibrary>
        <additionalModelTypeAnnotations>
            @lombok.experimental.SuperBuilder
            @lombok.NoArgsConstructor
            @lombok.AllArgsConstructor
        </additionalModelTypeAnnotations>
    </configOptions>
</configuration>
Suggest a fix

quickly glanced the source of the Java generator and saw that api test folders are set, but did not check further.

wing328 commented 4 years ago

We've not yet added auto-generated API test files to the spring generator: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java#L145

and we would appreciate the contribution to add the enhancement.

May I know if you've time to file a PR?

We can take the Java client/server test mustache templates to start with and update accordingly.