Skip to content

[Bug]: Anonymous objects fail to report errors during parsing #2339

@DevonianTeuchter

Description

@DevonianTeuchter

Description

The below Swagger doc passes through the SwaggerParser without generating any error messages. The same doc opened in various code editors [including editor.swagger.io] highlights the issue with the lack of object name. In addition, duplicate object names do not seem to be parsed so setting both objects to a name of "" overwrites the first definition with the second silently - "" being a valid string in Java, even if not valid according to the Swagger spec.

Affected Version

1.0.71
Also using SwaggerConvertor and 2.1.22, the converted doc doesn't flag an issue.

Steps to Reproduce

{
    "swagger": "2.0",
    "info": {
        "title": "info_title",
        "version": "0/0",
        "description": "..",
        "contact": {
            "name": "contactname",
            "url": "contacturl",
            "email": "contact@email.com"
        }
    },
    "produces": [
        "application/json"
    ],
    "consumes": [
        "application/json"
    ],
    "basePath": "/basepath",
    "paths": {
        "/path": {
            "get": {
                "summary": "summary",
                "responses": {
                    "200": {
                        "description": "..",
                        "schema": {
                            "type": "object",
                            "properties": {
                                "AA": {
                                    "type": "string"
                                },
                                "": {
                                  "type": "number"
                                }
                            }
                        }
                    }
                },
                "operationId": "getopid",
                "description": ".."
            }
        }
    }
}

Expected Behavior

Error messages similar to those from editor.swagger.io:

properties members must be schemasapilint(10037)
properties: object
The value of "properties" MUST be an object. Each value of this object MUST be a valid JSON Schema.

Actual Behavior

Document parsed successfully; attempts to reference the "anonymous" fields cause further processing issues

Environment

  • Java version: various
  • Build tool: maven
  • OS: Fedora 43

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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions