go-openapi / spec

openapi specification object model

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expand of Pathitem with local definition

tuzkov opened this issue · comments

PathItem reference can be used with local definition, but OpenAPI 2.0 spec allows only external references for this object.

For example:

{
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "swagger": "2.0",
  "info": {
    "description": "Test def with param Ref",
    "title": "ref",
    "version": "0.1.0"
  },
  "basePath": "/data/ref/beta1",
  "paths": {
    "/": {
      "$ref": "#/definitions/pi"
    }
  },
  "definitions": {
    "error": {
      "type": "object",
      "required": [
        "error"
      ],
      "properties": {
        "error": {
          "description": "Error object",
          "type": "object"
        }
      }
    },
    "pi": {
      "get": {
        "responses": {
          "200": {
            "description": "Generic response",
            "schema": {
              "$ref": "#/definitions/resp"
            }
          },
          "default": {
            "description": "Generic error response",
            "schema": {
              "$ref": "#/definitions/error"
            }
          }
        }
      }
    },
    "resp": {
      "type": "array",
      "items": {
        "type": "object"
      }
    }
  },
  "securityDefinitions": {
    "auth": {
      "type": "oauth2",
      "flow": "password",
      "tokenUrl": "/auth/token",
      "scopes": {
        "data.test": "default scope"
      }
    }
  },
  "security": [
    {
      "auth": [
        "data.test"
      ]
    }
  ]
}

This spec will be loaded and expanded but it shouldn't.

pi isn't a valid schema, so we have no idea how to deal with it.
This is according to the spec that says definitions should only contain schemas.
Your property definitions.pi is not that, it's a free form json structure, where we don't know in which positions a $ref would occur