disneystreaming / smithy4s

https://disneystreaming.github.io/smithy4s/
Other
349 stars 70 forks source link

Documentation: simpleRestJson add http method / path to scaladoc on service #728

Open daddykotex opened 1 year ago

daddykotex commented 1 year ago

Title says it all but basically: it's not the first time I work in a project where the specification is pulled from somewhere by the build tool. Some code is generated from it and I am implementing the service, and I run it to test it. But sometimes I forget what's the path to reach the specific operation.

Would adding something like the following be interesting:

// this is generated code
package thingy

// imports omitted

trait MyServiceGen[F[_, _, _, _, _]] {
  self =>

  /**
   * Method: GET
   * Path: /health_check
  */
  def getHealth(): F[Unit, MyServiceGen.GetHealthError, HealthResponse, Nothing, Nothing]

  def transform: Transformation.PartiallyApplied[MyServiceGen[F]] = Transformation.of[MyServiceGen[F]](this)
}
// ... rest is omitted

That would make it easier to figure out by using the IDE go-to-definition feature and ending up in the codegen where you find the info. You still don't have all the info, but sometimes that's all you need.

kubukoz commented 1 year ago

I like the idea, but that will require protocol-specific handling in the codegen I think. It's probably not a huge problem though, IIRC the decline module does something similar, and so does smithy-playground.

Baccata commented 1 year ago

I like the idea, but that will require protocol-specific handling in the codegen I think

I think I'm fine with it because it's not adding any protocol specific logic to the generated code