Skip to content

[BUG][OpenAPINormalizer] Specification content lost #22571

@JPPortier

Description

@JPPortier

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

OpenAPINormalizer is discarding information from specification when using OAS 3.1 "const" to list enum values based onto oneOf.

Resetting the oneOf, means enums mist and related metadata are lost (e.g. deprecated values).

openapi-generator version

pre-V7.19.0: commit id: 23eff66

OpenAPI declaration file content
    Enum:
      description: xxx
      oneOf:
        - const: 'AAA'
          description: 'AAA description'
        - const: 'BBB'
          description: 'BBB description'
          deprecated: true
Generation Details

Any generator "out of the box"

Steps to reproduce

Use generator with OAS 3.1 file containing following fragment

Related issues/PRs

Issue is coming from OpenAPINormalizer file:

            if (ModelUtils.isIntegerSchema(schema) || ModelUtils.isNumberSchema(schema) || ModelUtils.isStringSchema(schema)) {
                // TODO convert oneOf const to enum
                schema.setOneOf(null);
            }
Suggest a fix

Remove the line resetting the information coming from specifications

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions