-
Notifications
You must be signed in to change notification settings - Fork 4
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(Playground) #76
feat(Playground) #76
Conversation
Hmm.. This sparked some questions about our toast message approach:
Feel free to share your detailed thoughts! We need this tool to be both accurate and user friendly. This particular error occurs when the schema is not a valid JSON. I think this could very well be inlined. |
Yeah, maybe for simplicity, it makes sense to ditch the toast notifications.
Good question... maybe we should just require that all schemas provide examples :)
Sounds like it's worth having one of these :) Good thoughts! |
Ahoy! I have made the following updates:
But... complex schemas still have verbose errors (apart from the useful ones). Could you take a look ? Not sure if this has to do with the schema itself or the AJV options. |
const ajv = new Ajv({ | ||
schemas: Object.values(schemas), | ||
allErrors: true, | ||
strict: false, |
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.
Documentation for AJV options: https://ajv.js.org/options.html
I have made minimal changes to the schema to get this to work. We could:
classDiagram
Wrapper <|-- Type
Wrapper <|-- Reference
Type <|-- KnownType
Type <|-- UnkownType
KnownType <|-- Elementary
KnownType <|-- Complex
UnkownType <|-- Base
But I reckon these changes are mostly cosmetic. |
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.
Hey @raxhvl sorry for the delay on reviewing these changes.
Starting here with just a review of the schema changes... looks great. Excellent find on that type wrapper change; I would not have thought of that at all.
I'd like to merge the schema changes separately from the playground stuff - assuming you won't mind, I'm going to cherry-pick and rebase myself to save you the trouble. Happy to show you how I do that sort if thing sometime, if you're curious for the future.
Couple notes, though:
- You will need to
git pull -f
on this branch after I do the rebase. [Sorry about this... I like a neat git history and I believe it's worth being mildly annoying.] - I noticed your editor is doing automatic formatting for YAML files... this will get annoying, I think, with larger schema change PRs. We should figure out a way to set up prettier or something to run on this repo as a git hook, rather than leaving it to be the editor/IDE's job.
schemas/type/wrapper.schema.yaml
Outdated
# Discriminate between reference and type based on presence of `id` | ||
if: | ||
required: | ||
- id | ||
then: | ||
$ref: "schema:ethdebug/format/type/reference" | ||
else: | ||
$ref: "schema:ethdebug/format/type" |
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.
Oooh this one is a good catch. Nice find.
schemas/type.schema.yaml
Outdated
description: Then the object must adhere to exactly one known kind of type | ||
allOf: | ||
- if: | ||
properties: | ||
kind: | ||
$ref: "schema:ethdebug/format/type/elementary#/$defs/Kind" | ||
then: | ||
$ref: "schema:ethdebug/format/type/elementary" | ||
- if: | ||
properties: | ||
kind: | ||
$ref: "schema:ethdebug/format/type/complex#/$defs/Kind" | ||
then: | ||
$ref: "schema:ethdebug/format/type/complex" |
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.
Nice :)
(This almost makes me think we should define separate schemas for ethdebug/format/type/kind/elementary
etc., rather than reaching into the external schema's $defs
. Maybe that's overkill.)
@gnidan I have removed |
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.
Bam!
🪄 Summary
Closes #64 - This feature introduces an interactive playground for quick tinkering with the EthDebug schema.
🎯 Updates
packages/web/src/components/Playground.tsx
packages/web/src/components/SchemaViewer.tsx
example
from each schema if present.📦 New Dependencies