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

fix: clarify support for Boolean JSON Schemas #550

Conversation

magicmatatjahu
Copy link
Member

@magicmatatjahu magicmatatjahu commented Jun 2, 2021


title: "Mention about true/false JSON Schemas in Schema Object"

As Schema Object in spec is defined as superset of the JSON Schema Specification Draft 07, it would be nice to specify that the Schema Object itself can be boolean value. I know it results from the definition of draft 07, so I'd like to hear your opinion about the changes.

Description for true/false schemas I took from https://github.com/OAI/OpenAPI-Specification/pull/2609/files Thanks to @MikeRalphson


Related issue(s):
asyncapi/parser-js#232
Fixes #554

Related PR(s):
asyncapi/spec-json-schemas#63 - fix bug with true/false schemas in JSON Schema of spec
asyncapi/parser-js#311 - handle true/false JSON Schema in parser
asyncapi/asyncapi-react#367 - handle Boolean JSON Schema in the react-component


Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.

Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@jonaslagoni
Copy link
Member

@magicmatatjahu is this really necessary? When we refer to the Schema object, to me that implicitly say that boolean is allowed? 🤔

@magicmatatjahu
Copy link
Member Author

@jonaslagoni Do you mean union type Schema Object | boolean? I honestly wonder. We can describe that Schema Object can be boolean (as I did) and won't add a union type.

@magicmatatjahu magicmatatjahu added the ✏️ Editorial PR is non-normative or does not influence implementation label Jun 2, 2021
@magicmatatjahu magicmatatjahu marked this pull request as ready for review June 2, 2021 20:55
spec/asyncapi.md Outdated
Comment on lines 1513 to 1514
This object is a superset of the [JSON Schema Specification Draft 07](http://json-schema.org/). This means that Schema Object can be a boolean value. `True` means that the type can be anything, while `false` means that the given schema cannot be defined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat incorrect depending on how you look at it. If we are talking purely JSON Schema, then true means everything will be accepted, false means everything will be rejected. Not sure how to best describe that in this sentence though 🤔

Copy link
Member Author

@magicmatatjahu magicmatatjahu Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then true means everything will be accepted - True means that the type can be anything.
false means everything will be rejected - false means that the given schema cannot be defined.

I think that both phrases seem to have the same meaning.

The biggest problem to describe is for some parts of spec, because when we will allow making schema as boolean value (as described in spec after merging this PR), some parts, like headersin message, MUST be ofobject` type, not boolean. People may not understand exactly when they will be able to use scheme as boolean. The schema for the Channel Parameters is another example where the boolean schema doesn't make much sense, but if it's a Schema Object then they have possibility to do that...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then true means everything will be accepted - True means that the type can be anything.
false means everything will be rejected - false means that the given schema cannot be defined.

Hehe, I see your point, but it is two different perspectives, the one I proposed is from a validation point of view, the other is from a definition point of view. - and as JSON Schema is validation, that is why I proposed to change the wording 🙂

The bigger problem to describe is for some parts of spec, ...

From my perspective, it is not a problem, as soon as you say it can be a Schema Object that entails that it can be a boolean. Why would you want to restrict this? 🤔 IMO, whether it is used or not, that's up to the user, not us 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am starting to wonder if it is intentional that the schema object is not allowed to be a boolean or if that was just how it came to be? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In spec we use usually definition point of view, in some places also validation POV, but only by purpose, we define that some parts must be in given shape or must be unique. Now I understand why you want describe true/false in this way, but as I read Schema Object section in spec I see description from definition POV, not validation 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In spec we use usually definition point of view, in some places also validation POV, but only by purpose, we define that some parts must be in given shape or must be unique. Now I understand why you want describe true/false in this way, but as I read Schema Object section in spec I see description from definition POV, not validation 😅

Yeea, and I agree we should be consistent.

IMO it needs to be re-written to use the correct perspective, but it might become unclear for other people then... 🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it needs to be re-written to use the correct perspective, but it might become unclear for other people then...

Ok, let's wait for other comments :)

Copy link
Member

@smoya smoya Jun 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it needs to be re-written to use the correct perspective, but it might become unclear for other people then

I agree we should advocate for consistency since having two perspectives are adding confusion when reading.

In spec we use usually definition point of view, in some places also validation POV, but only by purpose, we define that some parts must be in given shape or must be unique. Now I understand why you want describe true/false in this way, but as I read Schema Object section in spec I see description from definition POV, not validation 😅

IMHO, definition/describing POV looks more easy to understand for the first reader. Specs are made for describing, tooling around does other things such as validation.

The point is, shall we rewrite the doc entirely? This is something we can discuss in another issue.
What shall we do with this current PR? I see a couple of options:

  1. To keep using the same POV schemaObject section had, which seems to ve a validation POV.
  2. To rewrite the schemaObject section entirely replacing wording to be adapted to a describe/definition POV.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specs are made for describing, tooling around does other things such as validation.

Then what if you describe what your data (payload) should validate against? 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the description from https://github.com/OAI/OpenAPI-Specification/pull/2609/files PR:

The empty schema (which allows any instance to validate) MAY be represented by the boolean value true and a schema which allows no instance to validate MAY be represented by the boolean value false.

It's from validation pov, but for me it's a better than previous one.

@MikeRalphson
Copy link
Contributor

From our co-incidentally raised PR over at OAS https://github.com/OAI/OpenAPI-Specification/pull/2609/files

@magicmatatjahu
Copy link
Member Author

magicmatatjahu commented Jun 9, 2021

As I can see AsyncAPI not only copied the architecture (of spec), but also full sentences from the specification 😅

@jonaslagoni Do you agree that

The empty schema (which allows any instance to validate) MAY be represented by the boolean value true and a schema which allows no instance to validate MAY be represented by the boolean value false.

is much better that current description in PR? Will you accept it? As you see, there we have desc from validation point of view.

@MikeRalphson will you have any problem so that we can reuse it in the AsyncAPI specification, or do you want us to pay you? 😄

@MikeRalphson
Copy link
Contributor

MikeRalphson commented Jun 9, 2021

I think we share a common license, as well as having common interests! So feedback on our PR can be two-way.

smoya
smoya previously approved these changes Jun 14, 2021
Copy link
Member

@smoya smoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 🌔

fmvilas
fmvilas previously approved these changes Jun 15, 2021
Copy link
Member

@fmvilas fmvilas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@fmvilas fmvilas changed the base branch from master to 2021-06-release June 15, 2021 09:19
@fmvilas fmvilas changed the base branch from 2021-06-release to master June 15, 2021 09:20
@fmvilas fmvilas dismissed stale reviews from smoya and themself June 15, 2021 09:20

The base branch was changed.

@magicmatatjahu
Copy link
Member Author

@fmvilas I see that you changed two times the target branch and we end to master. I thought that we will merge it to master and then rebase the 2021-06-release. Am I right?

@fmvilas
Copy link
Member

fmvilas commented Jun 15, 2021

Yes, I got confused at first. If it's just an editorial change and it doesn't change the behavior, it should point to master and should trigger a patch release when merged.

@derberg
Copy link
Member

derberg commented Jun 15, 2021

@magicmatatjahu @fmvilas
We did not trigger official 2.1 yet using automation.

If it's just an editorial change and it doesn't change the behavior, it should point to master

yes, but in the future after 2.1, otherwise merge of this fix will trigger 2.1

now it should go to release candidate branch with fix: and it will produce v2.1.0-2021-06-release.3

@derberg
Copy link
Member

derberg commented Jun 15, 2021

yes, but in the future after 2.1, otherwise merge of this fix will trigger 2.1

why? because it already happened twice 😓
semantic-release analyze all commits between tags, so after merging this to master it will analyze all commits since 2.0 tag, and therefore trigger release that we do not want

@magicmatatjahu
Copy link
Member Author

magicmatatjahu commented Jun 15, 2021

Another solution can be go with docs:, rebase in pre-release and make patch manually, but merging it to the pre-release branch is fine for me.

@magicmatatjahu magicmatatjahu changed the title fix: support true/false JSON Schemas in Schema Object fix: clarify support for Boolean JSON Schemas Jun 15, 2021
@derberg
Copy link
Member

derberg commented Jun 15, 2021

@magicmatatjahu

Another solution can be go with docs:

no, unless you provide in commit details [skip: ci]

rebase in pre-release and make patch manually

good luck 😄

@magicmatatjahu
Copy link
Member Author

@fmvilas I'm changing the target to prerelease due to problems described by Łukasz :) I need only info from you that you accept our decision, or if you have problems, please write them.

@magicmatatjahu magicmatatjahu changed the base branch from master to 2021-06-release June 15, 2021 10:26
@fmvilas
Copy link
Member

fmvilas commented Jun 15, 2021

That's fine. I don't think we too many options right now 😄

@magicmatatjahu magicmatatjahu force-pushed the true-false-json-schemas branch from 18a02bc to 9e00dfa Compare June 15, 2021 11:53
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@magicmatatjahu
Copy link
Member Author

Merged in #561 Thanks guys for review!

@magicmatatjahu magicmatatjahu deleted the true-false-json-schemas branch June 15, 2021 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✏️ Editorial PR is non-normative or does not influence implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarify support for Boolean JSON Schemas
7 participants