Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI 3.1.0 support: bugs in useCircularStructures resolver option support #2755

Closed
char0n opened this issue Jan 4, 2023 · 0 comments
Closed

Comments

@char0n
Copy link
Member

char0n commented Jan 4, 2023

Some structures within OpenAPI 3.1.0 definition are falsely detected as circular structures. This can be seen on the following standard PetStore definition:

{
  "openapi": "3.1.0",
  "info": {
    "version": "1.0.0",
    "title": "Swagger Petstore",
    "license": {
      "name": "MIT"
    }
  },
  "servers": [
    {
      "url": "http://petstore.swagger.io/v1"
    }
  ],
  "paths": {
    "/pets": {
      "get": {
        "summary": "List all pets",
        "operationId": "listPets",
        "tags": [
          "pets"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "How many items to return at one time (max 100)",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A paged array of pets",
            "headers": {
              "x-next": {
                "description": "A link to the next page of responses",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Pets"
                }
              }
            }
          },
          "default": {
            "description": "unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create a pet",
        "operationId": "createPets",
        "tags": [
          "pets"
        ],
        "responses": {
          "201": {
            "description": "Null response"
          },
          "default": {
            "description": "unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/pets/{petId}": {
      "get": {
        "summary": "Info for a specific pet",
        "operationId": "showPetById",
        "tags": [
          "pets"
        ],
        "parameters": [
          {
            "name": "petId",
            "in": "path",
            "required": true,
            "description": "The id of the pet to retrieve",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Expected response to a valid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Pet"
                }
              }
            }
          },
          "default": {
            "description": "unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Pet": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "name": {
            "type": "string"
          },
          "tag": {
            "type": "string"
          }
        }
      },
      "Pets": {
        "type": "array",
        "maxItems": 100,
        "items": {
          "$ref": "#/components/schemas/Pet"
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "integer",
            "format": "int32"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}

Dereferenced:

{
    "$$normalized": true,
    "components": {
      "schemas": {
        "Error": {
          "properties": {
            "code": {
              "format": "int32",
              "type": "integer",
            },
            "message": {
              "type": "string",
            },
          },
          "required": [
            "code",
            "message",
          ],
          "type": "object",
        },
        "Pet": {
          "properties": {
            "id": {
              "format": "int64",
              "type": "integer",
            },
            "name": {
              "type": "string",
            },
            "tag": {
              "type": "string",
            },
          },
          "required": [
            "id",
            "name",
          ],
          "type": "object",
        },
        "Pets": {
          "items": {
            "properties": {
              "id": {
                "format": "int64",
                "type": "integer",
              },
              "name": {
                "type": "string",
              },
              "tag": {
                "type": "string",
              },
            },
            "required": [
              "id",
              "name",
            ],
            "type": "object",
          },
          "maxItems": 100,
          "type": "array",
        },
      },
    },
    "info": {
      "license": {
        "name": "MIT",
      },
      "title": "Swagger Petstore",
      "version": "1.0.0",
    },
    "openapi": "3.1.0",
    "paths": {
      "/pets": {
        "get": {
          "operationId": "listPets",
          "parameters": [
            {
              "description": "How many items to return at one time (max 100)",
              "in": "query",
              "name": "limit",
              "required": false,
              "schema": {
                "format": "int32",
                "maximum": 100,
                "type": "integer",
              },
            },
          ],
          "responses": {
            "200": {
              "content": {
                "application/json": {
                  "schema": {
                    "items": {
                      "properties": {
                        "id": {
                          "format": "int64",
                          "type": "integer",
                        },
                        "name": {
                          "type": "string",
                        },
                        "tag": {
                          "type": "string",
                        },
                      },
                      "required": [
                        "id",
                        "name",
                      ],
                      "type": "object",
                    },
                    "maxItems": 100,
                    "type": "array",
                  },
                },
              },
              "description": "A paged array of pets",
              "headers": {
                "x-next": {
                  "description": "A link to the next page of responses",
                  "schema": {
                    "type": "string",
                  },
                },
              },
            },
            "default": {
              "content": {
                "application/json": {
                  "schema": {
                    "properties": {
                      "code": {
                        "format": "int32",
                        "type": "integer",
                      },
                      "message": {
                        "type": "string",
                      },
                    },
                    "required": [
                      "code",
                      "message",
                    ],
                    "type": "object",
                  },
                },
              },
              "description": "unexpected error",
            },
          },
          "servers": [
            {
              "url": "http://petstore.swagger.io/v1",
            },
          ],
          "summary": "List all pets",
          "tags": [
            "pets",
          ],
        },
        "post": {
          "operationId": "createPets",
          "responses": {
            "201": {
              "description": "Null response",
            },
            "default": {
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "https://example.com/petstore.json#/components/schemas/Error",
                  },
                },
              },
              "description": "unexpected error",
            },
          },
          "servers": [
            {
              "url": "http://petstore.swagger.io/v1",
            },
          ],
          "summary": "Create a pet",
          "tags": [
            "pets",
          ],
        },
        "servers": [
          {
            "url": "http://petstore.swagger.io/v1",
          },
        ],
      },
      "/pets/{petId}": {
        "get": {
          "operationId": "showPetById",
          "parameters": [
            {
              "description": "The id of the pet to retrieve",
              "in": "path",
              "name": "petId",
              "required": true,
              "schema": {
                "type": "string",
              },
            },
          ],
          "responses": {
            "200": {
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "https://example.com/petstore.json#/components/schemas/Pet",
                  },
                },
              },
              "description": "Expected response to a valid request",
            },
            "default": {
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "https://example.com/petstore.json#/components/schemas/Error",
                  },
                },
              },
              "description": "unexpected error",
            },
          },
          "servers": [
            {
              "url": "http://petstore.swagger.io/v1",
            },
          ],
          "summary": "Info for a specific pet",
          "tags": [
            "pets",
          ],
        },
        "servers": [
          {
            "url": "http://petstore.swagger.io/v1",
          },
        ],
      },
    },
    "servers": [
      {
        "url": "http://petstore.swagger.io/v1",
      },
    ],
  },
}

It is apparent from dereferenced definitions that some references remained unresolved (like https://example.com/petstore.json#/components/schemas/Pet) even though the definition contains no circular structures.

@char0n char0n self-assigned this Jan 4, 2023
@char0n char0n closed this as completed Jan 10, 2023
swagger-bot pushed a commit that referenced this issue Jan 23, 2023
# [3.19.0-alpha.1](v3.18.5...v3.19.0-alpha.1) (2023-01-23)

### Bug Fixes

* **resolver:** fix useCircularStructure option support in OpenAPI 3.1 ([d3a73fd](d3a73fd)), closes [#2755](#2755)

### Features

* add OpenAPI 3.1.0 dereference strategy ([#2740](#2740)) ([945bf92](945bf92)), closes [#2717](#2717)
* **normalization:** introduce normalization for OpenAPI 3.1.0 ([58981e4](58981e4)), closes [#2743](#2743)
* **resolve:** add ApiDOM JSON parser ([#2739](#2739)) ([a4e6e52](a4e6e52)), closes [#2717](#2717) [#2718](#2718)
* **resolve:** add ApiDOM OpenAPI 3.1.0 JSON parser ([dc5b833](dc5b833)), closes [#2717](#2717)
* **resolve:** add ApiDOM OpenAPI 3.1.0 YAML 1.2 parser ([77504ec](77504ec)), closes [#2717](#2717)
* **resolve:** add ApiDOM resolver based on SwaggerClient HTTP client ([485bb01](485bb01)), closes [#2717](#2717)
* **resolve:** add ApiDOM YAML 1.2 parser ([db4737f](db4737f)), closes [#2717](#2717)
* **resolver:** add support for mode resolver option ([5e9cf3d](5e9cf3d)), closes [#2750](#2750)
* **resolver:** add support for modelPropertyMacro option ([4f3ceda](4f3ceda)), closes [#2749](#2749)
* **resolver:** add support for OpenAPI 3.1.0 resolution ([e04ead9](e04ead9)), closes [#2744](#2744)
* **resolver:** add support for parameterMacro option ([34f8a4b](34f8a4b)), closes [#2748](#2748)
* **resolver:** add support for pathDiscriminator option ([e71c989](e71c989)), closes [#2753](#2753)
* **resolver:** limit depth of dereference to max 100 ([09c589a](09c589a))
* **subtree-resolver:** adapt to support OpenAPI 3.1.0 ([75083b6](75083b6)), closes [#2738](#2738)
swagger-bot pushed a commit that referenced this issue Jan 23, 2023
# [3.19.0-alpha.1](v3.18.5...v3.19.0-alpha.1) (2023-01-23)

### Bug Fixes

* **resolver:** fix useCircularStructure option support in OpenAPI 3.1 ([f89a60f](f89a60f)), closes [#2755](#2755)

### Features

* add OpenAPI 3.1.0 dereference strategy ([#2740](#2740)) ([62b4745](62b4745)), closes [#2717](#2717)
* **normalization:** introduce normalization for OpenAPI 3.1.0 ([35e53d5](35e53d5)), closes [#2743](#2743)
* **resolve:** add ApiDOM JSON parser ([#2739](#2739)) ([0ce91cc](0ce91cc)), closes [#2717](#2717) [#2718](#2718)
* **resolve:** add ApiDOM OpenAPI 3.1.0 JSON parser ([f231a61](f231a61)), closes [#2717](#2717)
* **resolve:** add ApiDOM OpenAPI 3.1.0 YAML 1.2 parser ([48340c6](48340c6)), closes [#2717](#2717)
* **resolve:** add ApiDOM resolver based on SwaggerClient HTTP client ([551c101](551c101)), closes [#2717](#2717)
* **resolve:** add ApiDOM YAML 1.2 parser ([f9f9222](f9f9222)), closes [#2717](#2717)
* **resolver:** add support for mode resolver option ([5dfaca4](5dfaca4)), closes [#2750](#2750)
* **resolver:** add support for modelPropertyMacro option ([5b76f37](5b76f37)), closes [#2749](#2749)
* **resolver:** add support for OpenAPI 3.1.0 resolution ([19ecbe4](19ecbe4)), closes [#2744](#2744)
* **resolver:** add support for parameterMacro option ([965ca7a](965ca7a)), closes [#2748](#2748)
* **resolver:** add support for pathDiscriminator option ([bf6c109](bf6c109)), closes [#2753](#2753)
* **resolver:** limit depth of dereference to max 100 ([e1aaf54](e1aaf54))
* **subtree-resolver:** adapt to support OpenAPI 3.1.0 ([c20b526](c20b526)), closes [#2738](#2738)
swagger-bot pushed a commit that referenced this issue Jan 23, 2023
# [3.19.0-alpha.1](v3.18.5...v3.19.0-alpha.1) (2023-01-23)

### Bug Fixes

* **resolver:** fix useCircularStructure option support in OpenAPI 3.1 ([f89a60f](f89a60f)), closes [#2755](#2755)

### Features

* add OpenAPI 3.1.0 dereference strategy ([#2740](#2740)) ([62b4745](62b4745)), closes [#2717](#2717)
* bundle ApiDOM dependencies ([85d234f](85d234f))
* **normalization:** introduce normalization for OpenAPI 3.1.0 ([35e53d5](35e53d5)), closes [#2743](#2743)
* **resolve:** add ApiDOM JSON parser ([#2739](#2739)) ([0ce91cc](0ce91cc)), closes [#2717](#2717) [#2718](#2718)
* **resolve:** add ApiDOM OpenAPI 3.1.0 JSON parser ([f231a61](f231a61)), closes [#2717](#2717)
* **resolve:** add ApiDOM OpenAPI 3.1.0 YAML 1.2 parser ([48340c6](48340c6)), closes [#2717](#2717)
* **resolve:** add ApiDOM resolver based on SwaggerClient HTTP client ([551c101](551c101)), closes [#2717](#2717)
* **resolve:** add ApiDOM YAML 1.2 parser ([f9f9222](f9f9222)), closes [#2717](#2717)
* **resolver:** add support for mode resolver option ([5dfaca4](5dfaca4)), closes [#2750](#2750)
* **resolver:** add support for modelPropertyMacro option ([5b76f37](5b76f37)), closes [#2749](#2749)
* **resolver:** add support for OpenAPI 3.1.0 resolution ([19ecbe4](19ecbe4)), closes [#2744](#2744)
* **resolver:** add support for parameterMacro option ([965ca7a](965ca7a)), closes [#2748](#2748)
* **resolver:** add support for pathDiscriminator option ([bf6c109](bf6c109)), closes [#2753](#2753)
* **resolver:** limit depth of dereference to max 100 ([e1aaf54](e1aaf54))
* **subtree-resolver:** adapt to support OpenAPI 3.1.0 ([c20b526](c20b526)), closes [#2738](#2738)
swagger-bot pushed a commit that referenced this issue Feb 15, 2023
# [3.19.0-beta.1](v3.18.5...v3.19.0-beta.1) (2023-02-15)

### Bug Fixes

* **resolver:** fix useCircularStructure option support in OpenAPI 3.1 ([f89a60f](f89a60f)), closes [#2755](#2755)
* **resolver:** remove LinkElement hook main dereference ([ef9d20d](ef9d20d)), closes [#2793](#2793)

### Features

* add OpenAPI 3.1.0 dereference strategy ([#2740](#2740)) ([62b4745](62b4745)), closes [#2717](#2717)
* add support for Node.js >= 12.20.0 ([a79b7f6](a79b7f6))
* bundle ApiDOM dependencies ([85d234f](85d234f))
* expose ApiDOM components as public API ([#2828](#2828)) ([b7ddc50](b7ddc50)), closes [#2827](#2827)
* **normalization:** introduce normalization for OpenAPI 3.1.0 ([35e53d5](35e53d5)), closes [#2743](#2743)
* **resolve:** add ApiDOM JSON parser ([#2739](#2739)) ([0ce91cc](0ce91cc)), closes [#2717](#2717) [#2718](#2718)
* **resolve:** add ApiDOM OpenAPI 3.1.0 JSON parser ([f231a61](f231a61)), closes [#2717](#2717)
* **resolve:** add ApiDOM OpenAPI 3.1.0 YAML 1.2 parser ([48340c6](48340c6)), closes [#2717](#2717)
* **resolve:** add ApiDOM resolver based on SwaggerClient HTTP client ([551c101](551c101)), closes [#2717](#2717)
* **resolve:** add ApiDOM YAML 1.2 parser ([f9f9222](f9f9222)), closes [#2717](#2717)
* **resolver:** add support for mode resolver option ([5dfaca4](5dfaca4)), closes [#2750](#2750)
* **resolver:** add support for modelPropertyMacro option ([5b76f37](5b76f37)), closes [#2749](#2749)
* **resolver:** add support for OpenAPI 3.1.0 resolution ([19ecbe4](19ecbe4)), closes [#2744](#2744)
* **resolver:** add support for parameterMacro option ([965ca7a](965ca7a)), closes [#2748](#2748)
* **resolver:** add support for pathDiscriminator option ([bf6c109](bf6c109)), closes [#2753](#2753)
* **resolver:** collect errors in AllOfVisitor hooks ([#2809](#2809)) ([627ee8d](627ee8d)), closes [#2808](#2808)
* **resolver:** collect errors in ExampleElement visitor hook ([09872a5](09872a5)), closes [#2798](#2798)
* **resolver:** collect errors in ModelPropertyMacro visitor hooks ([#2811](#2811)) ([6cef9ff](6cef9ff)), closes [#2810](#2810)
* **resolver:** collect errors in ParameterMacroVisitor visitor hooks ([#2813](#2813)) ([29ea34d](29ea34d)), closes [#2812](#2812)
* **resolver:** collect errors in PathItemElement visitor hook ([#2805](#2805)) ([fba4bbc](fba4bbc)), closes [#2804](#2804)
* **resolver:** collect errors in ReferenceElement visitor hook ([#2803](#2803)) ([3983953](3983953)), closes [#2802](#2802)
* **resolver:** collect errors in SchemaElement visitor hook ([#2807](#2807)) ([a098d85](a098d85)), closes [#2806](#2806)
* **resolver:** create ApiDOM path -> SwaggerClient path translator ([280f301](280f301)), closes [#2794](#2794)
* **resolver:** limit depth of dereference to max 100 ([e1aaf54](e1aaf54))
* **subtree-resolver:** adapt to support OpenAPI 3.1.0 ([c20b526](c20b526)), closes [#2738](#2738)
swagger-bot pushed a commit that referenced this issue Mar 6, 2023
# [3.19.0](v3.18.5...v3.19.0) (2023-03-06)

### Bug Fixes

* **build:** allow bundlers to process code properly ([#2852](#2852)) ([4eb131e](4eb131e))
* **build:** fix bundling of overridden ApiDOM deps ([#2853](#2853)) ([604cf87](604cf87))
* **build:** fix failing UMD build ([d8948ae](d8948ae))
* **build:** remove @types/ramda from bundled dependencies ([783f1b1](783f1b1))
* **install:** fix local dev setup for npm >= 8.19.3 ([6eee23d](6eee23d))
* **resolver:** fix useCircularStructure option support in OpenAPI 3.1 ([f89a60f](f89a60f)), closes [#2755](#2755)
* **resolver:** remove LinkElement hook main dereference ([ef9d20d](ef9d20d)), closes [#2793](#2793)
* **resolver:** use native error cause syntax with ApiDOM errors ([#2842](#2842)) ([ae0e7e8](ae0e7e8))

### Features

* add OpenAPI 3.1.0 dereference strategy ([#2740](#2740)) ([62b4745](62b4745)), closes [#2717](#2717)
* add support for Node.js >= 12.20.0 ([a79b7f6](a79b7f6))
* **build:** limit the size of UMD build fragment as much as possible ([#2843](#2843)) ([982a858](982a858)), closes [#2837](#2837)
* **build:** limit the size on npm package as much as possible ([#2841](#2841)) ([a6c9f4f](a6c9f4f)), closes [#2837](#2837)
* bundle ApiDOM dependencies ([85d234f](85d234f))
* **deps:** use ApiDOM npmjs.com npm packages ([#2861](#2861)) ([1360993](1360993)), closes [#2860](#2860)
* expose ApiDOM components as public API ([#2828](#2828)) ([b7ddc50](b7ddc50)), closes [#2827](#2827)
* **normalization:** introduce normalization for OpenAPI 3.1.0 ([35e53d5](35e53d5)), closes [#2743](#2743)
* **resolve:** add ApiDOM JSON parser ([#2739](#2739)) ([0ce91cc](0ce91cc)), closes [#2717](#2717) [#2718](#2718)
* **resolve:** add ApiDOM OpenAPI 3.1.0 JSON parser ([f231a61](f231a61)), closes [#2717](#2717)
* **resolve:** add ApiDOM OpenAPI 3.1.0 YAML 1.2 parser ([48340c6](48340c6)), closes [#2717](#2717)
* **resolve:** add ApiDOM resolver based on SwaggerClient HTTP client ([551c101](551c101)), closes [#2717](#2717)
* **resolve:** add ApiDOM YAML 1.2 parser ([f9f9222](f9f9222)), closes [#2717](#2717)
* **resolver:** add support for mode resolver option ([5dfaca4](5dfaca4)), closes [#2750](#2750)
* **resolver:** add support for modelPropertyMacro option ([5b76f37](5b76f37)), closes [#2749](#2749)
* **resolver:** add support for OpenAPI 3.1.0 resolution ([19ecbe4](19ecbe4)), closes [#2744](#2744)
* **resolver:** add support for parameterMacro option ([965ca7a](965ca7a)), closes [#2748](#2748)
* **resolver:** add support for pathDiscriminator option ([bf6c109](bf6c109)), closes [#2753](#2753)
* **resolver:** collect errors in AllOfVisitor hooks ([#2809](#2809)) ([627ee8d](627ee8d)), closes [#2808](#2808)
* **resolver:** collect errors in ExampleElement visitor hook ([09872a5](09872a5)), closes [#2798](#2798)
* **resolver:** collect errors in ModelPropertyMacro visitor hooks ([#2811](#2811)) ([6cef9ff](6cef9ff)), closes [#2810](#2810)
* **resolver:** collect errors in ParameterMacroVisitor visitor hooks ([#2813](#2813)) ([29ea34d](29ea34d)), closes [#2812](#2812)
* **resolver:** collect errors in PathItemElement visitor hook ([#2805](#2805)) ([fba4bbc](fba4bbc)), closes [#2804](#2804)
* **resolver:** collect errors in ReferenceElement visitor hook ([#2803](#2803)) ([3983953](3983953)), closes [#2802](#2802)
* **resolver:** collect errors in SchemaElement visitor hook ([#2807](#2807)) ([a098d85](a098d85)), closes [#2806](#2806)
* **resolver:** create ApiDOM path -> SwaggerClient path translator ([280f301](280f301)), closes [#2794](#2794)
* **resolver:** expose resolve makers ([#2855](#2855)) ([5b88577](5b88577))
* **resolver:** expose resolve strategies ([#2854](#2854)) ([2a39fb4](2a39fb4))
* **resolver:** limit depth of dereference to max 100 ([e1aaf54](e1aaf54))
* **subtree-resolver:** adapt to support OpenAPI 3.1.0 ([c20b526](c20b526)), closes [#2738](#2738)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant