OpenAPITools / OpenAPITools/openapi-generator

[BUG][JAVA] OpenAPI Generator fails on a recursive oneOf schema (boolean expression tree) when using OpenAPI 3.1.0.

Open
#22,587 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

Description

OpenAPI Generator fails on a recursive oneOf schema (boolean expression tree) when using OpenAPI 3.1.0. The generator crashes with a Jackson StreamWriteConstraints nesting depth error while parsing/traversing the schema (deep copy).
This prevents code generation even though the schema is valid and commonly used (tree recursion).

openapi-generator version

7.17.0 (Maven plugin). Unsure if regression.

OpenAPI declaration file content or url

A recursive schema with oneOf and discriminator. Minimal reproduction still needed, but the relevant pattern is:

openapi: 3.1.0
components:
schemas:
SearchQueryObject:
type: object
discriminator:
propertyName: type
mapping:
'AND': '#/components/schemas/BoolAnd'
'OR': '#/components/schemas/BoolOr'
'NOT': '#/components/schemas/BoolNot'
'search_text': '#/components/schemas/SearchQueryObjectNodeSearchText'
oneOf:
- $ref: '#/components/schemas/SearchQueryObjectNodeSearchText'
- $ref: '#/components/schemas/BoolAnd'
- $ref: '#/components/schemas/BoolOr'
- $ref: '#/components/schemas/BoolNot'

  BoolAnd:
    type: object
    properties:
      type:
        type: string
        enum: ['AND']
      nodes:
        type: array
        items:
          $ref: '#/components/schemas/SearchQueryObject'
    required: [type, nodes]
    additionalProperties: false

  BoolOr:
    type: object
    properties:
      type:
        type: string
        enum: ['OR']
      nodes:
        type: array
        items:
          $ref: '#/components/schemas/SearchQueryObject'
    required: [type, nodes]
    additionalProperties: false

  BoolNot:
    type: object
    properties:
      type:
        type: string
        enum: ['NOT']
      node:
        $ref: '#/components/schemas/SearchQueryObject'
    required: [type, node]
    additionalProperties: false

  SearchQueryObjectNodeSearchText:
    type: object
    properties:
      type:
        type: string
        enum: ['search_text']
      searchText:
        type: string
    required: [type, searchText]
    additionalProperties: false
Generation Details

Maven plugin:

  • org.openapitools:openapi-generator-maven-plugin:7.17.0
  • generatorName: spring
  • inputSpec: ais-backend-api.yaml (includes external $ref to the schema above)
Steps to reproduce
  1. Configure Maven plugin to generate Spring server code from the OpenAPI 3.1.0 spec.
  2. Run mvn generate-sources (or plugin goal).
Actual output vs expected output

Actual: generator fails with Jackson nesting depth error while traversing schema:

java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException:
Document nesting depth (1002) exceeds the maximum allowed (1000, from StreamWriteConstraints.getMaxNestingDepth())
(through reference chain: io.swagger.v3.oas.models.media.JsonSchema["oneOf"] -> ... -> ["nodes"] -> ["items"] -> ["oneOf"] -> ...)

Expected: generator should handle recursive schemas without blowing up (or provide a configuration option to raise max nesting depth).

Related issues/PRs

Not searched yet.

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 reproducing the failure with the Maven plugin, generatorName spring, and the recursive OpenAPI 3.1 schema described in the issue, using mvn generate-sources. Trace the schema deep-copy or traversal path that reaches Jackson's nesting-depth error; done means recursive schemas generate successfully or the supported configuration behavior is clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.