HackerTrans
TopNewTrendsCommentsPastAskShowJobs

Petermarcu

no profile record

comments

Petermarcu
·hace 2 años·discuss
Wondering if you can generate your service stubs and your clients to use for testing from TypeSpec, could it be faster even in the prototyping/early stages to define your spec first? A la gRpc?
Petermarcu
·hace 2 años·discuss
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
Petermarcu
·hace 2 años·discuss
Agreed. If the schema can also generate the service routes, models, serialization, etc, and you just have to maintain the business logic in the service, you get the spec matches the service benefits that way as well. Best of both worlds? People using gRpc seem to be 100% fine with schema first and generating the service stubs.

One of the key things with having the spec is that you can actually describe a lot more than you can with the various attributes and comments in the code. Especially things that are not as much service concerns but potentially client concerns or documentation concerns. You can also encapsulate reusable API patterns so you know different operations are following the same pattern.

The author didn't go into all the details but there are lots of ways in TypeSpec to separate the concerns of different consumers of the spec. There is a lot of opportunity and creative thinking that can be done here.
Petermarcu
·hace 2 años·discuss
The author has an example repo demonstrating some of the early support for codegen. https://github.com/bterlson/typespec-todo

Server side codegen is also one the horizon and is a key way to keep the spec and service in sync. So many possibilities here!
Petermarcu
·hace 2 años·discuss
http://typespec.io