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

[Open API 3.1] Json31 is incorrectly assuming that property containing `anyOf` is of type: object

Open daniel-urrutia opened this issue 10 months ago • 0 comments

Using Json31.pretty() I'm getting back properties with anyOf containing "type": "object"

"image" : {
      "type" : "object",
      "anyOf" : [ {
        "type" : "string"
      }, {
        "type" : "null"
      } ],
      "title" : "Image"
    },

but this doesn't match my schema below, image doesn't contain "type": "object" :

"PreviewProduct": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "handle": {
            "type": "string",
            "title": "Handle"
          },
          "title": {
            "type": "string",
            "title": "Title"
          },
          "productType": {
            "type": "string",
            "title": "Producttype"
          },
          "image": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Image"
          },
          "size": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Size"
          },
          "color": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Color"
          }
        },
        "type": "object",
        "required": [
          "id",
          "handle",
          "title",
          "productType"
        ],
        "title": "PreviewProduct",
        "description": "NOTE: This class is auto generated by OpenAPI Generator ([https://openapi-generator.tech).\n\nDo](https://openapi-generator.tech)./n/nDo) not edit the class manually.\n\nPreviewProduct - a model defined in OpenAPI\n\n    id: The id of this PreviewProduct.\n    handle: The handle of this PreviewProduct.\n    title: The title of this PreviewProduct.\n    product_type: The product_type of this PreviewProduct.\n    image: The image of this PreviewProduct [Optional].\n    size: The size of this PreviewProduct [Optional].\n    color: The color of this PreviewProduct [Optional]."
      }

daniel-urrutia avatar Dec 13 '24 00:12 daniel-urrutia