OpenAPITools / OpenAPITools/openapi-generator

[BUG] no test code generated for Java

Open
#6,272 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue points to the Java generator, its API test folders, and the Maven plugin configuration for the spring-boot library. Start by inspecting the Java generator's test-generation templates and reproduce the problem with a minimal valid YAML, since the original specification is unavailable. Done means Java test sources are generated while model generation still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
backend, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.