Skip to content

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

@flakey-bit

Description

@flakey-bit

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions