Skip to content

Enhance error messages when input is not a valid openapi #25

Description

@gooplancton

I'm trying to use openapi-tui with an openapi document generated by the elysia/swagger plugin [link].
Graphical interfaces like scalar [link] don't seem to have a problem with it.
This is a stripped down version of the document that still raises the error:

{
  "openapi": "3.0.3",
  "info": {
    "title": "Elysia Documentation",
    "description": "Development documentation",
    "version": "0.0.0"
  },
  "paths": {
    "/users/": {
      "get": {
        "responses": {
          "200": {
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "createdAt": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "email": {
                  "type": "string"
                },
                "birthDate": {
                  "type": "string"
                },
                "phoneNumberPrefix": {
                  "type": "string"
                },
                "phoneNumber": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "createdAt",
                "name",
                "email",
                "birthDate",
                "phoneNumberPrefix",
                "phoneNumber"
              ]
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "createdAt": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string"
                      },
                      "birthDate": {
                        "type": "string"
                      },
                      "phoneNumberPrefix": {
                        "type": "string"
                      },
                      "phoneNumber": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "createdAt",
                      "name",
                      "email",
                      "birthDate",
                      "phoneNumberPrefix",
                      "phoneNumber"
                    ]
                  }
                }
              },
              "multipart/form-data": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "createdAt": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string"
                      },
                      "birthDate": {
                        "type": "string"
                      },
                      "phoneNumberPrefix": {
                        "type": "string"
                      },
                      "phoneNumber": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "createdAt",
                      "name",
                      "email",
                      "birthDate",
                      "phoneNumberPrefix",
                      "phoneNumber"
                    ]
                  }
                }
              },
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "createdAt": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string"
                      },
                      "birthDate": {
                        "type": "string"
                      },
                      "phoneNumberPrefix": {
                        "type": "string"
                      },
                      "phoneNumber": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "createdAt",
                      "name",
                      "email",
                      "birthDate",
                      "phoneNumberPrefix",
                      "phoneNumber"
                    ]
                  }
                }
              }
            }
          }
        },
        "operationId": "getUsers",
        "tags": [
          "User"
        ]
      }
    }
  },
  "components": {
    "schemas": {}
  }
}

openapi-tui -i ./api.json

openapi-tui error: Something went wrong
Error:
   0: paths: data did not match any variant of untagged enum ObjectOrRef at line 8 column 12

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions