Skip to content

Absent type doesn't imply type object #2113

Closed
@wsalembi

Description

@wsalembi

9a5cd19 introduced the behavior that properties without type defined are implied of type object. I don't think this statement is true. The absence of type means it is any type (object, null, string, etc).

Example

paths:
  /foo:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Foo'
        required: true
      responses:
        200:
          description: ok
components:
  schemas:
    Foo:
      type: object
      allOf:
        - $ref: "#/components/schemas/Goo"
    Goo:
      type: object
      properties:
        goo:
          title: "Goo"

When resolving the schema, the type of property goo cannot be set to type object.

I removed the implication and it didn't break any other tests.

diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/ResolverFully.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/ResolverFully.java
--- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/ResolverFully.java	(revision 0ab2e8a7774b147e7b8c2c75b929089677d1b246)
+++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/ResolverFully.java	(date 1722333547892)
@@ -469,13 +469,13 @@
                 Schema property = updated.get(key);
 
                 if (property.getProperties() != model.getProperties()) {
-                    if (!hasSchemaType(property)) {
+                    /*if (!hasSchemaType(property)) {
                         if (SpecVersion.V30.equals(property.getSpecVersion())) {
                             property.setType("object");
                         } else {
                             property.addType("object");
                         }
-                    }
+                    }*/
                     model.addProperties(key, property);
                 } else {
                     LOGGER.debug("not adding recursive properties, using generic object");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions