From ab1254ef4c1f306db91916020ed442907af83464 Mon Sep 17 00:00:00 2001 From: "aaron.pritzlaff" Date: Mon, 2 Dec 2024 16:35:32 +0000 Subject: [PATCH] Started test case for issue 20214, Added underscore for numeric enumerations --- .../resources/scala-cask/modelClass.mustache | 4 +-- .../resources/scala-cask/modelEnum.mustache | 13 ++++---- .../resources/3_0/scala-cask/petstore.yaml | 30 +++++++++++++++++++ 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/scala-cask/modelClass.mustache b/modules/openapi-generator/src/main/resources/scala-cask/modelClass.mustache index 12f4ced6b084..aec0ab27aa94 100644 --- a/modules/openapi-generator/src/main/resources/scala-cask/modelClass.mustache +++ b/modules/openapi-generator/src/main/resources/scala-cask/modelClass.mustache @@ -34,11 +34,9 @@ enum Fields(val fieldName : String) extends Field(fieldName) { {{#vars}} {{#isEnum}} - // baseName={{{baseName}}} - // nameInCamelCase = {{{nameInCamelCase}}} enum {{datatypeWithEnum}} derives ReadWriter { {{#_enum}} - case {{.}} + case {{#isNumeric}}_{{/isNumeric}}{{.}} {{/_enum}} } {{/isEnum}} diff --git a/modules/openapi-generator/src/main/resources/scala-cask/modelEnum.mustache b/modules/openapi-generator/src/main/resources/scala-cask/modelEnum.mustache index 211717b54a96..4dfc03690a23 100644 --- a/modules/openapi-generator/src/main/resources/scala-cask/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/scala-cask/modelEnum.mustache @@ -1,6 +1,7 @@ -enum {{classname}} derives RW : -{{#allowableValues}} - {{#values}} - case {{.}} - {{/values}} -{{/allowableValues}} \ No newline at end of file +enum {{classname}} derives RW { + {{#allowableValues}} + {{#values}} + case {{.}} + {{/values}} + {{/allowableValues}} +} \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/scala-cask/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/scala-cask/petstore.yaml index 2249f5342c8e..6b9f123d9628 100644 --- a/modules/openapi-generator/src/test/resources/3_0/scala-cask/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/scala-cask/petstore.yaml @@ -18,6 +18,36 @@ tags: - name: user description: Operations about user paths: + /issue-20214-int-enums: + post: + tags: + - intEnums + operationId: intEnumExample + summary: added to reproduce + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + enumFilter: + type: integer + format: int32 + enum: + - 0 + - 1 + - 2 + required: + - enumFilter + responses: + '200': + description: Success + content: + application/json: + schema: + type: object + additionalProperties: true /complex-types: post: tags: