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

Clarifying "const" usage. #708

Merged
merged 1 commit into from
Mar 4, 2019
Merged

Clarifying "const" usage. #708

merged 1 commit into from
Mar 4, 2019

Conversation

djpadz
Copy link

@djpadz djpadz commented Feb 7, 2019

It would seem to me that const is the same as a single-valued enum. If that's correct, then that should be noted. If it's not, then the difference should also be noted.

@Relequestual
Copy link
Member

Thanks for your contribution! You are correct. There are lots of equivolencies in JSON Schema. This info likely belongs on the Understandibg JSON Schema website, probably not in the spec document.

Is there anywhere else in the spec where we detail similar comparisons?

@awwright
Copy link
Member

We document equivalencies where theres no-effect behavior, e.g. how minLength: 0 is the same as no keyword. It might be worth it to mention that enum and const have similar behavior if we can keep it under a few words.

@djpadz
Copy link
Author

djpadz commented Feb 19, 2019

FWIW, I think that it's important to point out equivalencies wherever they may exist, not so much for those who are writing specs, but for those who are writing code generators. It'd save a fair amount of confusion, not to mention unintentional interpretation. Basically, something like this would tell an implementer that const can be coded as:

def const(what):
    return enum([what])

@handrews
Copy link
Contributor

@djpadz there are too many ways for things to be equivalent for us to address within the spec, which is more than long enough already. However, adding notes for implementors (of anything- code generation included) to the json-schema.org site would be much appreciated!

That said, I don't feel strongly either way about this particular note. If @Relequestual and @awwright are in favor of it, I'm fine with merging it.

@handrews handrews merged commit eb25539 into json-schema-org:master Mar 4, 2019
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

Successfully merging this pull request may close these issues.

4 participants