zalando / intellij-swagger

A plugin to help you easily edit Swagger and OpenAPI specification files inside IntelliJ IDEA
https://plugins.jetbrains.com/plugin/8347
MIT License
1.18k stars 74 forks source link

Good code is red: "Missing required property '$ref' #297

Open jgindin opened 4 years ago

jgindin commented 4 years ago

I just installed the OpenAPI editor to give it a try. I've been using Apicurio to generate my YAML. The first time opening one of my YAML files in IntelliJ, I see a bunch of red.

This is the first big red block. I'm really not sure why it thinks I'm missing a '$ref' property: image

There's another block that has the same problem.

It seems that the actual problem is the use of a "description" when the property is defined by a $ref.

I verified this by deleting the "description" associated with each of the properties that is defined by a $ref.

Interestingly, if a data type has 1 or 2 properties with this "extraneous" "description", then only the $ref and description are colored red. Although, in this case, the error message is wrong:

Property '$ref' is not allowed image

It seems that these "description"s ought to be no more than a possible warning. At least according to https://swagger.io/docs/specification/using-ref/ (see the "$ref and Sibling Elements" section):

Any sibling elements of a $ref are ignored.