Skip to content

[Bug]: A Java raw Object is always resolved to OAS 3.1 object #5111

@Mattias-Sehlstedt

Description

@Mattias-Sehlstedt

Description of the problem/issue

With PR #5034 the default behavior of how a Java Object for OAS 3.1 is resolved was changed from being an empty type definition to always being type object. This can cause incorrect schema generation, since Object is not necessary a JSON-object (e.g., "string" is a valid Java Object, but not a valid JSON-object).

The interpretation of a Java Object should instead be tied to explicit-object-schema, which was introduced and described in #4868. It also correctly states that this behavior should be an explicit opt-in (and also highlights that the current behavior of 3.0 is incorrect, but that it is kept/not corrected due to backwards compatibility concerns).

Affected Version

2.2.45

Earliest version the bug appears in (if known):
2.2.44

Steps to Reproduce

Have a class that have a property with type Object. E.g.

private static class PojoUsingObjectField {
  private Object myField;

  public Object getMyField() {
    return myField;
  }

  public void setMyField(Object myField) {
    this.myField = myField;
  }
}

Expected Behavior

A Java Object should be resolved to an empty type.

Actual Behavior

A Java Object is resolved to type object.

Logs / Stack Traces

Additional Context

Checklist

  • I have searched the existing issues and this is not a duplicate.
  • I have provided sufficient information for maintainers to reproduce the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions