scottie1984 / swagger-ui-express

Adds middleware to your express app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.
MIT License
1.43k stars 228 forks source link

No operations defined in spec using $ref for paths #375

Open MathieuRA opened 1 month ago

MathieuRA commented 1 month ago

It looks like that file users.json is not resolved.. Archi:

// swagger.json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Mon API",
    "version": "1.0.0"
  },
  "paths": {
      "/users": {
          "$ref": "users.json"
      }
  }
}
// users.json

{
  "get": {
    "tags": ["pet"],
    "summary": "Finds Pets by status",
    "description": "Multiple status values can be provided with comma separated strings",
    "operationId": "findPetsByStatus",
    "parameters": [
      {
        "name": "status",
        "in": "query",
        "description": "Status values that need to be considered for filter",
        "required": false,
        "explode": true,
        "schema": {
          "type": "string",
          "default": "available",
          "enum": ["available", "pending", "sold"]
        }
      }
    ],
    "responses": {
      "200": {
        "description": "successful operation",
        "content": {
          "application/xml": {
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/Pet"
              }
            }
          },
          "application/json": {
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/Pet"
              }
            }
          }
        }
      },
      "400": {
        "description": "Invalid status value"
      }
    },
    "security": [
      {
        "petstore_auth": ["write:pets", "read:pets"]
      }
    ]
  }
}