Skip to content

[Schema Inaccuracy] Invalid examples reported by Spectral #31

Closed
@philsturgeon

Description

@philsturgeon

Schema Inaccuracy

I know you lot use Spectral for some internal stuff, and I wanted to let you know we've been working on a new feature that lets you know when examples are invalid against their defined schema (stoplightio/spectral#1284). It looks like there's quite a few invalid examples in this repo, so I figured I should give you a heads up to resolve them before you upgrade and have to fix things in a rush.

Expected

I'd expect none of these errors to be here. (Some are showing up twice and we're investigating why, and some of the errors are a little hard to read and we're working on that too).

Screen Shot 2020-08-21 at 5 10 31 PM

It's because the enum is only showing uploaded, and then the example is open.

        state:
          description: State of the release asset.
          type: string
          enum:
          - uploaded
          example: open

I'd ditch that example and put it in the enum. Most tooling will take an enum value and use it as an example if a property doesn't have one (especially ReDoc, which you mentioned in the README.md).

        state:
          description: State of the release asset.
          type: string
          enum:
          - uploaded
          - open

Simple enough fix right?

Reproduction Steps

Clone spectral.

$ gco fix/support-examples-validation
$ yarn
$ yarn build
$ yarn cli lint {path-to-this-repo}/descriptions/api.github.com/api.github.com.yaml

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions