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

Question: add a lint rule to avoid boolean keys in parameters #283

Closed
dlouzan opened this issue Feb 6, 2019 · 2 comments
Closed

Question: add a lint rule to avoid boolean keys in parameters #283

dlouzan opened this issue Feb 6, 2019 · 2 comments

Comments

@dlouzan
Copy link
Contributor

dlouzan commented Feb 6, 2019

The YAML 1.1 spec allows to use booleans as keys of maps and performs auto-conversion, which most of the time is not what you want. The YAML 1.2 spec actually changes this and reduces the number of strings that can be interpreted as booleans.

I have just encountered this with one of our specs, using a construct like this:

    Coord:
      description: A 3D coordinate
      type: object
      required:
        - x
        - y
      properties:
        system:
          description: The coordinate system
          type: string
        x:
          description: The X coordinate
          type: number
        y:
          description: The Y coordinate
          type: number
        z:
          description: The Z coordinate
          type: number
        accuracy:
          description: The accuracy of the coordinate
          type: number

It happened because we are performing some processing using go-yaml and they implement YAML spec 1.1:
go-yaml/yaml#214

The y parameter in the previous sample is actually interpreted by go-yaml as a true value, instead of the string "y".

Although speccy itself properly handles this case, I think it would make sense to warn users that they are using an error-prone construct.

@MikeRalphson
Copy link
Contributor

Just a note that OpenAPI mandates YAML 1.2

@philsturgeon
Copy link
Contributor

Yeah I think this one can be closed, seeing as OpenAPI is telling users to use YAML 1.2 it's not up to Speccy to worry about it. @djtarazona could you close this one?

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

4 participants