Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2923
Closed
Open
Issue created May 17, 2019 by Administrator@rootContributor

[BUG] enum parameters are no longer enum types since 4.0.0-beta3

Created by: mboogerd

Description

I am using a custom mustache template to generate an alternative controller whose operations use nullable enums for optional enum query parameters. This has been working fine until 4.0.0 beta2, but has started breaking from beta3 (and is still broken in the 4.0.0 release). As far as I have narrowed down the issue, the {{isEnum}} expression no longer evaluates to true. This happens at least when used in the context of a query parameter, but still works fine for models. From the code differences between the two releases I could not find out why it has stopped working for (query) parameters

As a result of the above, my custom mustache template dataTypeNullable: {{&dataType}}{{#isEnum}}{{^required}}?{{/required}}{{/isEnum}}

no longer functions as desired when used in the context of generating operation parameters for my controllers. If this isn't a bug, it would be much appreciated if someone could point me in the direction of a fix!

openapi-generator version

OK <= 4.0.0-beta2 NOK > 4.0.0-beta2

Minimal OpenAPI declaration to reproduce
openapi: "3.0.0"
info:
  version: 1.0.0
  title: "Example API"
servers:
  - url: http://example/
paths:
  /:
    get:
      parameters:
        - in: query
          name: param
          schema:
            $ref: "#/components/schemas/SomeEnum"
          required: false
      operationId: exampleOperation
      responses:
        default:
          description: "not implemented error"
components:
  schemas:
    SomeEnum:
      type: string
      enum:
        - item1
        - item2
Command line used for generation

We have been using the generator as part of a multi-stage docker build, as follows (although I am pretty sure this doesn't matter).

FROM openapitools/openapi-generator-cli:v4.0.0-beta2 AS generator

WORKDIR /local
COPY . .

RUN /usr/local/bin/docker-entrypoint.sh generate \
    -DpackageName=TestService \
    -DdebugOperations=true \
    -i test-service.yaml \
    -g aspnetcore \
    -o out/
Steps to reproduce
  • Run the 4.0.0-beta2 generator with debugOperations set to true and capture the debug log
  • Run the 4.0.0-beta3 generator with debugOperations set to true and capture the debug log
  • Diff the log and obtain something like this.
  • Observe that the isEnum property of the param parameter has moved from true to false between beta2 and beta3.
Suggest a fix
Assignee
Assign to
Time tracking