OpenAPITools / OpenAPITools/openapi-generator

ignoreAnyOfInEnum flag is not working properly.

Open
#11,565 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

3GPP R15 has defined a set of standards in the form of OpenAPI Yamls.
This yamls contains enum along with AnyOf.

Currently open api generator is not generating models correctly for ENUM along with AnyOF

RequestTrigger:
  anyOf:
  - type: string
    enum:
      - LOC_CH
      - PRA_CH
      - SERV_AREA_CH
      - RFSP_CH
      - ALLOWED_NSSAI_CH
      - UE_AMBR_CH

I checked it on internet and found out two solution :

  1. [https://github.com/OpenAPITools/openapi-generator/issues/798]
    Where we can delete anyof and run the maven build again.
    But we cannot change the YAML , as its of standard.

  2. [https://github.com/OpenAPITools/openapi-generator/issues/4491]
    Here I see, Jason submitted some code where he added new configuration ignoreAnyOfInEnum ( and making its use in AbstractJavaCodeGen Class ) to ignore the AnyOf Tag.

    But This flag is also not working.
    Seems reasons for that is , ignoreAnyOfInEnum config is not getting set in GeneratorSettings.java like other config properties we do.

Please help , stuck.

@wing328

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing ignoreAnyOfInEnum from AbstractJavaCodeGen into GeneratorSettings.java, using the reported RequestTrigger OpenAPI YAML as the reproduction case. Check the Maven build and generated models to verify that enabling the flag changes enum-plus-anyOf handling without requiring edits to the standard YAML.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.