Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] [GROOVY] Enums are generated as empty classes #14420

Closed
mnisius opened this issue Jan 10, 2023 · 2 comments
Closed

[BUG] [GROOVY] Enums are generated as empty classes #14420

mnisius opened this issue Jan 10, 2023 · 2 comments

Comments

@mnisius
Copy link

mnisius commented Jan 10, 2023

Description

I'm trying to generate a groovy model from an openapi spec. Sadly enums are always generated es an empty class. If I use the java generator I get a correct enum with all the defined values inside. So my guess is there is a bug in the groovy generator.

My schema looks like this:

    GreetingType:
      type: string
      enum:
      - FRIENDLY
      - FORMAL

and the generated groovy code looks sadly like this:

@Canonical
class GreetingType {
}

I was expecting something like:

enum GreetingType {
  FRIENDLY, 
  FORMAL
}
openapi-generator version

6.2.1

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: test-bas
  version: 1.0.0-SNAPSHOT
servers:
- url: http://localhost:8080/
  description: Generated server url
paths:
  /rest/greet/{name}:
    get:
      tags:
      - rest-service-app
      operationId: greet
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Greeting'
components:
  schemas:
    Greeting:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/GreetingType'
        text:
          type: string
    GreetingType:
      type: string
      enum:
      - FRIENDLY
      - FORMAL
Generation Details

I use the maven plugin. These are my settings:

         <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>6.2.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/resources/openapi.yml</inputSpec>
                            <generatorName>groovy</generatorName>
                            <generateApis>false</generateApis>
                            <generateSupportingFiles>false</generateSupportingFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
Steps to reproduce

Use the groovy generator to generate models from an openapi spec with enums

Related issues/PRs

I could not find any...

Suggest a fix

Usable enums please 🙂

@wing328
Copy link
Member

wing328 commented Jan 11, 2023

@mnisius thanks for reporting the issue. May I know if you've time to contribute a fix?

I can show you some good starting points.

PM me via Slack (https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g) to discuss further.

@mnisius
Copy link
Author

mnisius commented Sep 2, 2024

I think this bug can be closed now. @dyadyaJora thank you for implementing

@mnisius mnisius closed this as completed Sep 2, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants