Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
91–100 of 179 posts
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#92Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#93This gives you a pretty good feel for where it’s at: https://json-schema.org/blog/posts/future-of-json-schema I’m invested in it. I’m using it to provide implementation-specific validation of requests to/from a third party API. I wish there was a good macOS editor or IDEA plugin for it with autocomplete etc. The static generators from examples are obscure, ugly, minimal, and can’t account for variations. It isn’t ple…
What are you trying to do in regard to your API? I just developed an extensive API definition using OpenAPI, which (as of version 3.1) is compliant with JSON Schema. I used Stoplight Studio on Mac OS, although it still doesn't fully support OAS 3.1 two years after it became the current OpenAPI standard. The support from tools and generators is terrible; there's still no apparent toolchain that supports version 3.1 fr…
Going into it, I thought we'd be on a well traveled path, but that was far from the case...
Typescript has some decent code generation packages (although fragmented) and request validation can be hacked via AJV... But tooling around C# was halfbaked at best.
In the end, I didn't really feel like OpenApi provided the API "contract" I had originally hoped for.
If I could start over, I would probably use something like gRPC for internal service communication (would maybe still use OpenAPI for any public API)
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#94Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#95Earlier quoted context omitted.
The one out of the box with IntelliJ is pretty decent for checking YAMLs with JSON Schemas, is there something you're missing?
+1 it's great. It just finds the schemas all on its own. Love it. When I've written my own i had to change a setting to point it to my schema but that worked well too.
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#96Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#97Earlier quoted context omitted.
FWIW, I've had good success with Typebox over Zod for exactly this stuff. You don't need to compile out types, you just...have them.
Ditto. It took me a while (coming from C++) to get that types are not the ideal source of truth in TypeScript, due to their disappearance at runtime. Having a runtime parser (which can consequently express things impossible with TypeScript types alone, like "a positive integer" rather than being satisfied with any instance of `number`) from which types are inferred, is a needed mindset shift made easy with Zod. I use…
Typebox just creates JSON Schema objects at runtime and projects them into the type system with `Static`. In so doing, you simultaneously create schema and types and the process of doing so is pleasant--you can just hand a TObject to Fastify as a validator object and you're done. Plus, with a Typebox type provider, it infers down to your handler.
JSON Schema is the lingua franca; to me, working in it, rather than converting to it, is a much easier proposition.
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#98Earlier quoted context omitted.
I think you would have to build in a "integerMultipleOf" filter and slow-deprecate "multipleOf" To be more specific, since I wasn't in GP... It's not clear what you should do when for example you want to see if 0.3f is a "multiple of" 0.1f (due to the whole 0.30000000000004 thing)
That sounds like a limitation of the implementation. Decimal types exist. If the implementation wants to account for some floating point errors I think that's fine too. If they want to codify it though, maybe add an epsilon param so the user can specify how close they want it to be.
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#99Then I can use the same schema in the backend to validate the data, both sent in via the form and directly with the application/json content-type. It's a pretty smooth flow, and reduces a lot of redundancy.
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#100It really needs comments. Unfortunately it'll never be backwards compatible. It's very helpful for debugging
We already use comments in JSON without JSONC in lots of projects. Adding a { "//": "My Comment" } line works and most API's ignore excess fields.