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

Add "examples" to allowed Meta #64

Closed
wants to merge 1 commit into from

Conversation

bensaufley
Copy link

Based on the ajv docs it looks like examples, which already exists on BaseSchema, should be allowable as a meta property. I don't see any other references to examples anywhere in the package – please lmk if I've missed something and I should just use some other means of setting examples

Based on the [ajv docs](https://ajv.js.org/json-schema.html#metadata-keywords) it looks like `examples`, which already exists on `BaseSchema`, should be allowable as a `meta` property. I don't see any other references to `examples` anywhere in the package – please lmk if I've missed something and I should just use some other means of setting `examples`
@vitalics vitalics added the good first issue Good for newcomers label Sep 9, 2024
@vitalics
Copy link
Owner

vitalics commented Sep 9, 2024

@bensaufley thanks for MR. Could you also add tests for output schema? or will it be okay to handle it on my end?

@bensaufley
Copy link
Author

@vitalics I'm happy to take a look tonight - I don't see any other meta tests so I'm not sure what pattern to follow here, but I can obviously put something together. But you're welcome to handle it on your end as well. FWIW I did two "tests" locally to confirm expected behavior:

  1.  npx node -e "console.log(require('ajv-ts').s.object().meta({ examples: ['foo'] }).schema)"
     #=> { type: 'object', properties: {}, examples: [ 'foo' ] }
  2. Went into my node_modules in the project that uses this library (https://github.com/bensaufley/audiobook-catalog) and manually added this change; checked that typechecking in my project now passed

@vitalics
Copy link
Owner

vitalics commented Sep 9, 2024

will closed in #66

@vitalics vitalics closed this Sep 9, 2024
vitalics added a commit that referenced this pull request Sep 9, 2024
@github-actions github-actions bot mentioned this pull request Sep 9, 2024
@bensaufley
Copy link
Author

Thanks!

@bensaufley bensaufley deleted the patch-1 branch September 9, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants