-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat(map): Codegen for JsonSchema Target #63
Conversation
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
I noticed that in draft 6 of JSON Schema you can now do:
And even define different regexes for values, by key!
We could use that for keys that have a regex validator (in a follow-on PR?). Which version of JSON Schema are we currently targeting? |
…the type Signed-off-by: Jonathan Casey <[email protected]>
@dselman see PR description, (http://json-schema.org/draft-07/schema) Regarding regex validation, I'm assuming this would apply to validators on Scalar Types used within a Map? If thats the case then I see no reason why that shouldn't be in scope for this PR. |
* feat(map): add graphqlvisitor Signed-off-by: Jonathan Casey <[email protected]> * test(map): update snapshot Signed-off-by: Jonathan Casey <[email protected]> * test(map): adds graphqlvisitor Signed-off-by: Jonathan Casey <[email protected]> * test(map): restores sandbox Signed-off-by: Jonathan Casey <[email protected]> --------- Signed-off-by: Jonathan Casey <[email protected]>
feat(codegen): remove loopback src Signed-off-by: Jonathan Casey <[email protected]>
Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.22.11 to 7.23.2. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse) --- updated-dependencies: - dependency-name: "@babel/traverse" dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Dan Selman <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regex support for strings is a really useful addition but it should be supported for both scalar strings and regular strings.
}; | ||
|
||
if (mapKey.isScalarDeclaration?.() && mapKey.getValidator()?.getRegex()) { | ||
jsonSchema.schema.propertyNames.pattern = String(mapKey.getValidator().getRegex()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we add support for regex validators for scalars we should also support it for string properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That wasn't part of the original spec unfortunately. Supporting regex on Map elements of type string is a fundamental change at the parser level, and on through validation, etc. We should definitely add this as an enhancement at a later stage.
fyi @mttrbrts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be a misunderstanding here?
We support regexs where they are defined in the Scalar type, we don't support them inline in the Map definition (for either Strings or Scalar types).
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
Signed-off-by: Jonathan Casey <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bravo!
Description
Add JsonSchema code generation for Map Type. Validated against Schema Draft v7.
Sample <String, String>
Sample <String, Boolean>
Sample <String, Number>
Sample <String, Person>
Author Checklist
--signoff
option of git commit.