---
title: Demonstrate oneOf, allOf, and anyOf
slug: mihai-tests/demonstrate-oneof-allof-and-anyof
createdAt: 2024-06-27T06:31:58.719Z
---

{
  "id": "VntD9-uGdGZls7ABxFsxv",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "/example",
    "servers": [],
    "name": "Demonstrate oneOf, allOf, and anyOf",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "schema": [
            {
              "name": "oneOfExample",
              "kind": "required",
              "type": "object",
              "complexType": "oneOf",
              "complexItems": [
                {
                  "name": "Cat",
                  "description": "",
                  "modelRef": "#/components/schemas/Cat",
                  "schema": [
                    {
                      "name": "name",
                      "kind": "required",
                      "type": "string",
                      "example": ""
                    },
                    {
                      "name": "meows",
                      "kind": "required",
                      "type": "boolean",
                      "example": ""
                    }
                  ]
                },
                {
                  "name": "Dog",
                  "description": "",
                  "modelRef": "#/components/schemas/Dog",
                  "schema": [
                    {
                      "name": "name",
                      "kind": "required",
                      "type": "string",
                      "example": ""
                    },
                    {
                      "name": "barks",
                      "kind": "required",
                      "type": "boolean",
                      "example": ""
                    }
                  ]
                }
              ],
              "schema": []
            },
            {
              "name": "allOfExample",
              "kind": "required",
              "type": "object",
              "complexType": "allOf",
              "complexItems": [
                {
                  "name": "Animal",
                  "description": "",
                  "modelRef": "#/components/schemas/Animal",
                  "schema": [
                    {
                      "name": "name",
                      "kind": "required",
                      "type": "string",
                      "example": ""
                    },
                    {
                      "name": "age",
                      "kind": "optional",
                      "type": "integer",
                      "example": 0
                    }
                  ]
                },
                {
                  "name": "object",
                  "description": "",
                  "schema": [
                    {
                      "name": "petType",
                      "kind": "required",
                      "type": "string<Cat | Dog>",
                      "example": ""
                    }
                  ]
                }
              ],
              "schema": []
            },
            {
              "name": "anyOfExample",
              "kind": "required",
              "type": "object",
              "complexType": "anyOf",
              "complexItems": [
                {
                  "name": "Car",
                  "description": "",
                  "modelRef": "#/components/schemas/Car",
                  "schema": [
                    {
                      "name": "brand",
                      "kind": "required",
                      "type": "string",
                      "example": ""
                    },
                    {
                      "name": "model",
                      "kind": "required",
                      "type": "string",
                      "example": ""
                    }
                  ]
                },
                {
                  "name": "Bike",
                  "description": "",
                  "modelRef": "#/components/schemas/Bike",
                  "schema": [
                    {
                      "name": "brand",
                      "kind": "required",
                      "type": "string",
                      "example": ""
                    },
                    {
                      "name": "type",
                      "kind": "required",
                      "type": "string",
                      "example": ""
                    }
                  ]
                }
              ],
              "schema": []
            }
          ],
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful response",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "example": ""
              }
            ],
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "QDZKN9BRCfxfchk1GJTlj",
          "language": "curl",
          "label": "cURL",
          "code": "curl --location '/example' \\\n--header 'Accept: application/json' \\\n--header 'Content-Type: application/json' \\\n--data '{\n  \"oneOfExample\": {},\n  \"allOfExample\": {},\n  \"anyOfExample\": {}\n}'"
        },
        {
          "id": "CgDOJnFzxAvrSDNTIRGk7",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"Accept\", \"application/json\");\nmyHeaders.append(\"Content-Type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"oneOfExample\": {},\n   \"allOfExample\": {},\n   \"anyOfExample\": {}\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"/example\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "F-XAC8SOoYc1NMLite3vM",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"/example\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"Accept\"] = \"application/json\"\nrequest[\"Content-Type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"oneOfExample\": {},\n   \"allOfExample\": {},\n   \"anyOfExample\": {}\n})\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "jPq8bh7S0AhmID-tfsAO1",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"/example\"\n\npayload = json.dumps({\n   \"oneOfExample\": {},\n   \"allOfExample\": {},\n   \"anyOfExample\": {}\n})\nheaders = {\n   'Accept': 'application/json',\n   'Content-Type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "QDZKN9BRCfxfchk1GJTlj"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successful response\n{\n  \"message\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}