Re:Show HN: Instant API – Build type-safe web APIs with Java...
by purplerabbit on Thursday October 26, 2023 @02:36PM
(#38029880)
I like the sentiment, but you’ve gotta admit that being able to skip the “generation” step has its benefits
Re:Show HN: Instant API – Build type-safe web APIs with Java...
by madeofpalk on Friday October 27, 2023 @06:25AM
(#38036768)
The only way to can skip that generation is if the zod type is your primary schema, which is only possible if your API is in javascript.
Re:Show HN: Instant API – Build type-safe web APIs with Java...
by yencabulator on Thursday October 26, 2023 @04:46PM
(#38031485)
Everybody seems to want that, except for the people who work on Typescript, who argue it'd be the wrong tool.
Typescript's types simply aren't able to provide input validation, both because they don't exist at runtime and for lack of power ("number must be 0..10").
At least with Zod, you also get Typescript types, from the same schema.
Re:Show HN: Instant API – Build type-safe web APIs with Java...
by madeofpalk on Friday October 27, 2023 @06:14AM
(#38036691)
My problem is how you declare the schema. I think the Typescript's teams stance is valid (though, I would love for them to sponsor/release an additional project for more runtime validation using typescript).
I don't want to declare my schema with zod's DSL. I'll either use an openapi spec from elsewhere and generate artefacts from that, or declare them with Typescript and... generate validation from them.
I want to write definitions in the "first party syntax" - which both JSDoc and Typescript types are - and have everything else generated out from that.