APIDevTools / swagger-cli

Swagger 2.0 and OpenAPI 3.0 command-line tool
https://apitools.dev/swagger-cli
MIT License
515 stars 69 forks source link

Validation errors are not useful for larger APIs #53

Open mtaylorfsmb opened 3 years ago

mtaylorfsmb commented 3 years ago

I might be missing some option but when I run the validate command on a larger API (2K lines) I only get a single error at a time even though there are multiple errors in the YAML. Additionally it just gives me the error message with line information so I have to find it myself. Example

paths:
   /blah
      post:
         requestBody:
            content:
               application/json:
                  schema:
                     $ref: '#/components/schemas/myData'

components:
   schemas:
      MyData:
         type: string               

Here the error is that the $ref is using camel case name for schema while the schema itself is using Pascal cased. Imagine that this schema name is being used in multiple places and there are several different schema types that have this same problem.

When I run the validate command all I get is this:

Token "myData" does not exist.

To fix this I have to search for all the places it is wrong and fix them. Then I have to run validate again to find that I have done this with other schemas as well.

It would be nice if the validation tool shows me the location in the YAML where the error was detected and it tries to find all errors and doesn't just stop on the first one.