swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

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

Open Rivatus opened this issue 7 months ago • 1 comments

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.

Rivatus avatar May 27 '25 09:05 Rivatus

Can confirm, I also set explicit-object-schema to false and it still doesn't work.

WorkProg avatar Jul 11 '25 13:07 WorkProg