Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] OpenApiNormalizer default setting SIMPLIFY_ONEOF_ANYOF does not simplify oneOf with single non-null subSchema #21042

Open
5 of 6 tasks
Mattias-Sehlstedt opened this issue Apr 6, 2025 · 0 comments · May be fixed by #21043

Comments

@Mattias-Sehlstedt
Copy link
Contributor

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • 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

The normalization setting SIMPLIFY_ONEOF_ANYOF misses to simplify oneOf schemas that has one single non-null subSchema.

This seems to be due to a misconfiguration where the SubSchemas.lengh == 1 is only checked if there was at least one nullable subSchema.

Even if there are no nullable subSchemas we should still check if the schema can be simplified when there is only a single subSchema.

openapi-generator version

7,12

OpenAPI declaration file content or url
ParentWithOneOfProperty:
  type: object
  properties:
    number:
      oneOf:
        - $ref: '#/components/schemas/Number'
Generation Details
Steps to reproduce

Introduce an additional test case to this test that verifies that ParentWithOneOfProperty is properly simplified to:

ParentWithOneOfProperty:
  type: object
  properties:
    number:
      - $ref: '#/components/schemas/Number'

The test will failed since the schema isn't simplified.

Related issues/PRs
Suggest a fix

I will create a PR for a suggested fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant