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

Resolve evaluates node 'y' to true. Is this always required ? #740

Closed
arjunbhandage opened this issue May 18, 2021 · 4 comments
Closed

Resolve evaluates node 'y' to true. Is this always required ? #740

arjunbhandage opened this issue May 18, 2021 · 4 comments

Comments

@arjunbhandage
Copy link

arjunbhandage commented May 18, 2021

There is map created to resolve values which resolves y as below to true:
{true, yaml_BOOL_TAG, []string{"y", "Y", "yes", "Yes", "YES"}},

If the value of node is 'y' should it be resolved to 'true' always ?
I faced issue while generating go code from openAPI yaml --> oapi-codegen/oapi-codegen#362

Not sure if it is bug or I should never use the tags from the resolveMapList ?

{true, yaml_BOOL_TAG, []string{"y", "Y", "yes", "Yes", "YES"}},

@perlpunk
Copy link

In YAML 1.1, scalars like y and Y are resolved as booleans. I guess go-yaml implements YAML 1.1.

OpenAPI however documents this:
https://swagger.io/specification/#format

If go-yaml wants to implement the YAML 1.2 schemas, here is official test data:
https://github.com/perlpunk/yaml-test-schema

Note that the YAML JSON schema definition is a bit ambiguous in the YAML spec. Strictly speaking, all strings not being booleans or numbers would have to be quoted. The OpenAPI documentation is quite unclear regarding that.

@arjunbhandage
Copy link
Author

Thank you very much for the clarification @perlpunk. Quoting around the strings solved the issue for me.

@arjunbhandage
Copy link
Author

I see in the compatibility section that go-yaml supports YAML 1.2 and 1.1
And according to YAML spec 1.2 schema, y is not interpreted as bool, where as in 1.1 y is interpreted as bool.
https://yaml.org/spec/1.2/spec.html#id2804923
I think this is a bug in go-yaml.

@arjunbhandage arjunbhandage reopened this May 18, 2021
@niemeyer
Copy link
Contributor

We support a useful mix of the two: v2 handles them as booleans, while v3 tries to move us forward by only considering them as bool if you explicitly attempt to unmarshal the value onto a boolean.

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

3 participants