Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Update to a more actively maintained JSONSchema library #100

Open
chrusty opened this issue Nov 6, 2021 · 10 comments
Open

Update to a more actively maintained JSONSchema library #100

chrusty opened this issue Nov 6, 2021 · 10 comments

Comments

@chrusty
Copy link
Owner

chrusty commented Nov 6, 2021

Currently we're using https://github.com/alecthomas/jsonschema to build JSONSchemas, but this project seems to have stopped at draft-04. It might be time to consider an alternative such as https://github.com/santhosh-tekuri/jsonschema,

@atreya2011
Copy link

Thanks for link! I was searching for a library which supports JSON Schema Draft 07

@atreya2011
Copy link

Upon further inspection it looks like this library https://github.com/santhosh-tekuri/jsonschema doesn't support conversion but rather just validation?

@chrusty
Copy link
Owner Author

chrusty commented Nov 16, 2021

Hi @atreya2011. I've not done any testing against this library, but at first glance it did seem to support the new JSONSchema features that I'd like to use here.

protoc-gen-jsonschema wouldn't make use of any conversion capabilities anyway - these behaviours are so tighltly bound to the options we offer and the desired layouts. I'd really just be looking to use the structure and marshalling capabilities instead.

In any case, I've opened a PR with our existing dependency lib to introduce some of the stuff I want to use, so it might take the pressure off for a bit.

@atreya2011
Copy link

Thanks for your kind reply 🙏🏼
In then end I have decided to go down this path

  • Maintain the JSON Schema as a YAML file
  • Convert it to JSON, Go and TypeScript definitions using codegen libraries

A example of how I went about it is here if you are interested
https://github.com/atreya2011/go-kratos-test/blob/32328056c8f2764b5f0fadeaf8e1d7a817b630d8/Makefile#L4

@parsnips
Copy link

Hey @chrusty - pnwcode@86b60af gets a compiling version of this. As the commit says, the tests are of course broken...but i needed schema 07 and this got me close enough.

@chrusty
Copy link
Owner Author

chrusty commented Apr 17, 2022

Hey @parsnips, the invopop fork looks like the right choice - almost a drop-in replacement!

I can pick this up at some point, get it fully integrated and make sure the tests pass. Should we be concerned about any other schema-07 features that need to be brought along?

@parsnips
Copy link

Should we be concerned about any other schema-07 features that need to be brought along?

I'm not sure, the thing I needed was the newer enumeration format and just by flipping versions it produced the correct json schema.

@franchb
Copy link

franchb commented Apr 22, 2022

jsonschema by @alecthomas was discontinued. Maintenance has moved to invopop/jsonschema.

@timofurrer
Copy link

Are there still plans to update to a newer draft?

@mfridman
Copy link

mfridman commented Mar 13, 2024

Following the publication of https://buf.build/community/chrusty-jsonschema, we received several questions and support requests for updated JSON Schema drafts.

We've started an initiative to publish a collection of Protobuf plugins, including jsonschema (Draft 2020-12), that generate various schemas from protobuf files.

Anyone interested can find the open-source repository here: bufbuild/protoschema-plugins and a protoc-gen-jsonschema is also available as a Remote Plugin here.

We'll continue to publish @chrusty's plugin as new tags become available. ✌️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants