IlluzionzDev / typespec

MIT License
0 stars 0 forks source link

Create java-spring component to handle TypeSpec Operation #7

Closed IlluzionzDev closed 1 month ago

IlluzionzDev commented 2 months ago

For now create a component along the lines of SpringServiceEndpoint which will take a TypeSpec Operation.

An operation represents a service endpoint. The basis of this component should be building a RouteHandler from a TypeSpec Operation. It should be able to query all http decorators from the operations, and pass them to the RouteHandler with the respective annotations.

Study https://typespec.io/docs/language-basics/operations and https://typespec.io/docs/libraries/http/reference/decorators for the type of decorators that will be applied.

Operations seem to take their arguments in the form of a Model, and each argument to the function is a ModelProperty. Each of these ModelProperty has a decorator applied.

Look at the @typespec/http library which should have some useful methods to query these decorators off operations etc. Look at the TypeKits availabile too as those might be of help.

Should aim to implement all HTTP verbs:

Should aim to implement passing data to the route through

That is all the decorators that should need to be focused on for now. Most will correspond to passing an annotation in some way, either on the Java method or on paramters to the method. Consult the spring-boot docs for how to implement each of these things in Spring, then you can map each decorator to the spring equivalent.

Don't hesitate to reach out to the Microsoft team for help if needed (Or Jamin)