Skip to content

Not resolving remote, relative definitions when referenced in remote path #335

@fehguy

Description

@fehguy

From swagger-api/swagger-codegen#4103 (comment), the following specs cause a failure to resolve the definitions in Bar.json:

swagger.json

{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "FooAPI",
    "description": "API for all accesses to the Foo server system",
    "termsOfService": "TBD",
    "contact": {
      "name": "Foo API Team"
    },
    "license": {
      "name": "MIT"
    }
  },
  "host": "api.foo.com",
  "basePath": "",
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/bar": {
      "$ref": "./Bar.json#/bar"
    }
  }
}

Bar.json

{
  "bar": {
    "post": {
      "description": "posts stuff",
      "deprecated": true,
      "operationId": "enrollInBar",
      "produces": [
        "application/json"
      ],
      "parameters": [
        {
          "name": "Authorization",
          "in": "header",
          "required": true,
          "type": "string"
        },
        {
          "name": "barRequest",
          "in": "body",
          "description": "The request body containing the amount",
          "required": true,
          "schema": {
            "$ref": "#/definitions/BarSettingsRequest"
          }
        }
      ],
      "responses": {
        "200": {
          "schema": {
            "$ref": "#/definitions/BarData"
          }
        },
        "default": {}
      }
    }
  },
  "definitions": {
    "BarSettingsRequest": {
      "properties": {
        "stuff": {
          "type": "integer"
        }
      },
      "required": [
        "stuff"
      ]
    },
    "BarData": {
      "properties": {
        "enabled": {
          "type": "boolean"
        }
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions