Live data from Hacker News

Write OpenAPI with TypeSpec

blog.trl.sn

41–50 of 74 posts

Re: Write OpenAPI with TypeSpec

#48
post #17
post #11

As someone who has used JAX-RS (Java) and ASP.NET, APIs are basically created with these kinds of annotations right in the language. @GET public Character getCharacter(@PathParam("id") int id) { return db.getCharacter(id); } That's very similar to TypeSpec's op getCharacter(@path id: safeint): Character; Java and C# classes already have the type information that you'd be getting from a TypeSpec: // TypeSpec model Cha…

This is the code-first vs schema-first debate. Both have their pros and cons. Personally a die hard advocate of schema-first.

Code first for prototyping and early stage.

Then switch as soon as you have customers.

Re: Write OpenAPI with TypeSpec

#49
post #18

What are people's thoughts on this vs AWS's Smithy? We've been looking to buy into Smithy heavily as we no longer have the appetite to deal with OpenAPI and it's horrendous ecosystem.

I would pick Smithy if I had to go spec-first. I currently tolerate OpenAPI because I'm using a robust code-first approach (Tapir in Scala) on the server side, but I otherwise agree, the ecosystem seems brittle.

TypeSpec and Smithy live in a similar space here. You can generate OpenAPI specs from them, or you can generate assets directly from them. OpenAPI is one of the many possible outputs from TypeSpec.

This is an example the author created of TypeSpec being used to generate clients in many languages as well as the OpenAPI spec.

https://github.com/bterlson/typespec-todo

Post reply on HN