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
  • #12412
Closed
Open
Issue created May 20, 2022 by Administrator@rootContributor

[REQ][JAVA] oneOf discriminator type string with enum defined

Created by: tedberg

Description

Using version 6 beta, oneOf is working well, generating POJOs. We get the interface with public String getType(); and the impl classes. The type we want to use had previously been defined as a string/enum, so it would be nice if we could define teh discriminator string to also be an enum.

openapi-generator version

6.0.0-beta

OpenAPI declaration file content or url
title: Type
type: string
default: "A"
enum:
  - "A"
  - "B"
  - "C"

Our discriminator is setup like this.

title: Example
type: object
discriminator:
  propertyName: type
  type: string
  mapping:
    A: './A.yaml'
    B: './B.yaml'
    C: './C.yaml'
oneOf:
  - $ref: './A.yaml'
  - $ref: './B.yaml'
  - $ref: './C.yaml'

The A object adds the type property, referencing the string with enum above.


title: A
type: object
properties:
  type:
    $ref: './Type.yaml'
...

If we remove the enum part, everything generates properly and works with type as a String object. Seeing that the mapping is essentially an enum itself, it would be nice, if the above would work, generating public Type getType(); in the interface. (It already generates nicely with enum in the implementing classes.)

Command line used for generation

Maven plugin,
<openapi.generator.maven.plugin.templateResourcePath>JavaSpring</openapi.generator.maven.plugin.templateResourcePath>

Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
Assignee
Assign to
Time tracking