Skip to content

Problems with enum naming and validation #350

Closed
@andruskutt

Description

@andruskutt

Hello,

I have two problems with enums:

  • not unique name generated for values "_1A", "_2A". Names are out of my control

I'm trying to create workaround using mapping configuration enum-type: string which causes next problem

  • @values annotation is created into List - List<@values(values = {"_1A", "_1B", "_2A"}) String> body
    But @values annotation @target does not contain TYPE_USE and code does not compile

openapi definition:

openapi: 3.0.3
info:
  title: test enum parameters
  version: 1.0.0

paths:

  /endpoint:
    post:
      tags:
        - enum
      requestBody:
        content:
          "application/json":
            schema:
              type: array
              items:
                $ref: '#/components/schemas/Foo'
      responses:
        '204':
          description: Empty

components:
  schemas:

    Foo:
      type: string
      enum:
        - _1A
        - _1B
        - _2A

mapping configuration:

openapi-processor-mapping: v12

options:
  package-name: generated

  target-dir:
    layout: standard

  generated-annotation: false
  json-property-annotation: auto
  format-code: false

  bean-validation: jakarta

  model-type: default
  model-accessors: false

  # generates duplicate enum names
  enum-type: default
  # generates @Values annotation into List, but @Values @Target does not include TYPE_USE
  # enum-type: string
map:
  types:
    - type: array => java.util.List

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions