[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 theparam
parameter has moved fromtrue
tofalse
between beta2 and beta3.