swagger-api / swagger-api/swagger-core

java.lang.Object converted to json object (map) type

Open
#4,906 1 comment 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

Duplicate of issue: https://github.com/swagger-api/swagger-core/issues/3834, which was closed without proper resolution.

The issue referenced, still exists with version 2.2.32:

The actual behavior:

  • Swagger model converter maps java.lang.Object to type: object
public class Foo {
        private Object bar;
   

    public static void main(String[] args) throws Exception {
        ResolvedSchema schema = ModelConverters.getInstance()
                .resolveAsResolvedSchema(
                        new AnnotatedType(Foo.class));

        String value = Json.mapper().writerWithDefaultPrettyPrinter().writeValueAsString(schema.schema);

        System.out.println(value);
    }
 }

prints:

{
  "type" : "object"
}

I used the version 2.2.32 and still got same result.

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 with the Foo reproduction using ModelConverters.getInstance().resolveAsResolvedSchema(new AnnotatedType(Foo.class)) and inspect the generated schema through Json.mapper(). Check the existing issue 3834 for prior context, then identify the converter behavior and add or update coverage for java.lang.Object. Done means the schema output matches the intended OpenAPI representation rather than the reported result.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.