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

Update event-type schemas to be stricter #677

Merged
merged 1 commit into from
Oct 25, 2022

Conversation

svix-gabriel
Copy link
Contributor

@svix-gabriel svix-gabriel commented Oct 25, 2022

This updates the /event-type endpoints "schemas" parsing to match our API more closely.

Motivation

In our API, we specifically parse event-type schemas as a map of version numbers to Json Schemas. While we don't enforce the version numbers, we do enforce that the Json schemas are, well, valid JSON schemas!

The open-source repo was allowing arbitrary JSON objects, which is too lax.

Solution

We use the jsonschemas library to parse Json Schemas. This library has a compatible license (MIT), no known vulnerabilities, is actively maintained, with modest popularity (283 stars in Github, a little over half a million downloads).

We still need to (de)serialize the event_type::Schema, and jsonschema::JSONSchema doesn't implement any of the (de)serialization traits. Consequently, the type definition is still a wrapper over a Hash of strings to Json, and we manually implement deserialize to enforce that that the json schema is always correct.

@svix-gabriel svix-gabriel marked this pull request as ready for review October 25, 2022 16:33
svix-dylan
svix-dylan previously approved these changes Oct 25, 2022
@svix-dylan svix-dylan dismissed their stale review October 25, 2022 16:39

Oh wait, can you provide some information about the new crate?

@svix-dylan
Copy link
Contributor

Almost forgot, we are supposed to provide some information about open source libraries when we add them to deps. Here are some examples.

@svix-gabriel
Copy link
Contributor Author

svix-gabriel commented Oct 25, 2022

Thanks @svix-dylan, I updated the PR message with info on the jsonschema crate.

@svix-gabriel svix-gabriel merged commit 73431db into main Oct 25, 2022
@svix-gabriel svix-gabriel deleted the gabriel/update-event-type-schema branch October 25, 2022 16:57
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.

3 participants