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 Support #532

Open
revnode opened this issue Feb 21, 2023 · 4 comments
Open

OpenAPI 3.1 Support #532

revnode opened this issue Feb 21, 2023 · 4 comments

Comments

@revnode
Copy link

revnode commented Feb 21, 2023

It looks like OpenAPI 3.1 support was added a few years back? I'm having trouble with it.

When executing:

const definition = `{
  "openapi": "3.1.0",
  "info": {
    "version": "1.0.0",
    "title": "test",
    "description": "test",
    "contact": {
      "email": "[email protected]"
    },
    "license": {
      "name": "UNLICENSED",
      "url": "https://test.com/terms-conditions/"
    }
  },
  "servers": [
    {
      "url": "/api/v1"
    }
  ],
  "paths": {
    "/ping": {
      "get": {
        "operationId": "ping.get",
        "summary": "Checks if the API is operational.",
        "description": "Verifies the API is deployed and functioning properly.",
        "tags": [
          "Utilities"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "description": "The response to a ping should be pong.",
                      "type": "string",
                      "example": "pong"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "key": {
        "type": "apiKey",
        "in": "header",
        "name": "key",
        "description": "test"
      },
      "session": {
        "type": "apiKey",
        "in": "header",
        "name": "session",
        "description": "test"
      }
    },
    "schemas": {
      "test": {
        "type": "object",
        "properties": {
          "test": {
            "description": "This is a test.",
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    }
  }
}`;
const api = new OpenAPIBackend({
  definition,
  apiRoot: "/api/v1"
});

I get errors like:

{
  "instancePath": "/components/schemas/test/properties/test/type",
  "schemaPath": "#/properties/type/type",
  "keyword": "type",
  "params": {
    "type": "string"
  },
  "message": "must be string"
}

If I set the type to a string, the error goes away. But it should support an array? Any help appreciated. Thanks!

@revnode
Copy link
Author

revnode commented Feb 21, 2023

It looks like the culprit might be https://www.npmjs.com/package/openapi-schema-validator which is used internally? It doesn't look like openapi-schema-validator supports 3.1

@revnode
Copy link
Author

revnode commented Feb 21, 2023

Seems there is a ticket for it: kogosoftwarellc/open-api#837

For those running into the same issue, a quick hack is to set quick to true as an option to OpenAPIBackend to suppress the errors.

@danbars
Copy link

danbars commented Feb 22, 2024

The docs say that 3.1 is supported... So it's not really the case?

@kennethaasan
Copy link

#212 #158 says otherwise. Not sure why this issue is not closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants