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

Comparison crashes if "components" property is omitted from the schema #141

Open
flakey-bit opened this issue Sep 25, 2024 · 0 comments
Open

Comments

@flakey-bit
Copy link

Given the following schema file schema-v1.json

{
  "openapi": "3.0.0",
  "info": {
    "title": "Animal API",
    "version": "1.0.0",
    "description": "API for managing animal types"
  },
  "paths": {
    "/basic-request": {
      "post": {
        "summary": "Create an animal request",
        "requestBody": {
          "description": "Empty request body",
          "content": {
            "application/json": {
              "schema": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "animalType": {
                      "type": "string",
                      "enum": ["Cat", "Dog", "Mouse"]
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

When I run

docker run --rm -v C:\temp\:/data:rw typeable/comparest --client /data/schema-v1.json --server /data/schema-v1.json --output /data/report.md

It crashes with the following

compaREST: user error (Exiting)
Could not parse as json or yaml
"Error in $: key \"components\" not found"
AesonException "Error in $: key \"components\" not found"

According to the docs, it's sufficent for the schema to only have paths:

A self-contained or composite resource which defines or describes an API or elements of an API. The OpenAPI document MUST contain at least one paths field, a components field or a webhooks field. An OpenAPI document uses and conforms to the OpenAPI Specification

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

1 participant