Skip to content

[BUG] spring generator using maven plugin generates correct code, while cli/gradle generates wrong code #6591

@rivasdiaz

Description

@rivasdiaz

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

I have a simple sample spec. When invoking the generator from maven plugin, code is generated as expected. But both gradle plugin and cli generate a different code.

on the generated interface com.example.api.DefaultApi, when running from Gradle/CLI, this code is generated:

    ResponseEntity<InlineResponse200> getGreetingsMessage(ServerWebExchange exchange);

Which is wrong as it is using reactive classes, which are disabled on the config file.

When using maven plugin, the following code is generated instead:

    ResponseEntity<InlineResponse200> getGreetingsMessage();

which seems to be the correct code.

openapi-generator version

4.3.1

OpenAPI declaration file content or url
openapi: '3.0.3'
info:
  title: 'Greetings API'
  version: '1.0.0'
paths:
  /api/v1/greetings:
    get:
      operationId: getGreetingsMessage
      responses:
        200:
          description: 'A greetings message'
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
Command line used for generation
openapi-generator generate \
    --input-spec spec.yaml \
    --config config.json \
    --generator-name spring \
    --output . \
    --invoker-package com.example \
    --api-package com.example.api \
    --model-package com.example.model
Config file used for generation
{
  "useTags": "true",
  "interfaceOnly": "true",
  "hideGenerationTimestamp": "true",
  "sourceFolder": "src/gen/java",
  "java8": "true",
  "library": "spring-boot",
  "dateLibrary": "java8",
  "reactive": "false",
  "useOptional": "true",
  "useBeanValidation": "true",
  "skipDefaultInterface": "true"
}
Steps to reproduce

copy both spec.yaml and config.json to a folder and run open-api-generator-cli as described above.

Related issues/PRs

No related issues I could find.

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