swagger-api / swagger-api/swagger-core

Wrong schema generation of `Object[]` for OpenAPI 3.1

Open
#4,774 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog
Dominant language
Java
Stars
7.5k
Forks
2.3k
Avg merge
18h 1m
Merged PRs (30d)
10

Description

Schema generation for object array is broken in OpenAPI 3.1.

Create a class with an object array field and resolve the schema for it:

private Object[] objectArray;

Set a breakpoint here and inspect the schema before and after. After the call items of the ArraySchema has no more information (e.g. type = object).

The serialized schema looks like this:

          "objectArray": {
            "type": "array",
            "items": {

            }
          }

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 in modules/swagger-core/src/main/java/io/swagger/v3/core/util/AnnotationsUtils.java at the linked line, then reproduce schema resolution with a class containing an Object[] field. Inspect the ArraySchema before and after the call and compare the serialized OpenAPI 3.1 output. Done means the items schema retains its object information instead of serializing as an empty object.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.