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

Allow ":" in user defined keyword names to support names like 'meta:license' and 'meta:enum' #1421

Closed
teq0 opened this issue Feb 2, 2021 · 3 comments

Comments

@teq0
Copy link
Contributor

teq0 commented Feb 2, 2021

What version of Ajv you are you using?
7.0.4

What problem do you want to solve?
jsonschema2md allows the use of additional keywords such as meta:enum to supply descriptive information to enrich the generated documentation. Adobe use this meta:* pattern in their own schemas, for example XDM.

Turning off strict mode allows these properties, but it would be nicer to be able to add these as user defined keywords while retaining strict validation for everything else. The regex currently used to validate new keyword names doesn't allow : characters.

What do you think is the correct solution to problem?
Change the KEYWORD_NAME regex used to validate keyword names to allow :, but not as the first character. Something like

/^[a-z_$][a-z0-9_$-:]*$/i

Will you be able to implement it?
Yes.

@epoberezkin
Copy link
Member

Thank you - no objections :)

@teq0
Copy link
Contributor Author

teq0 commented Feb 2, 2021

Where should I put the tests?

@epoberezkin
Copy link
Member

Can be just an extension of this test, no need for a separate test probably: https://github.com/ajv-validator/ajv/blob/master/spec/keyword.spec.ts#L1089

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants