11package app
22
3- import cats .Applicative
43import cats .data .Kleisli
54import cats .effect .kernel .Async
6- import cats .implicits . _
5+ import cats .syntax . all . *
76import dev .usommerl .BuildInfo
87import eu .timepit .refined .api .Refined
9- import eu .timepit .refined .auto ._
10- import eu .timepit .refined .collection ._
11- import io .circe .generic .auto ._
8+ import eu .timepit .refined .collection .*
9+ import io .circe .generic .auto .*
1210import org .http4s .{HttpRoutes , Request , Response }
1311import org .http4s .dsl .Http4sDsl
1412import org .http4s .headers .Location
15- import org .http4s .implicits ._
13+ import org .http4s .implicits .*
1614import org .http4s .server .middleware .CORS
1715import sttp .model .StatusCode
1816import sttp .apispec .openapi .OpenAPI
1917import sttp .apispec .Tag
2018import sttp .apispec .openapi .Info as OpenApiInfo
2119import sttp .apispec .openapi .Server
22- import sttp .apispec .openapi .circe .yaml ._
23- import sttp .tapir ._
24- import sttp .tapir .codec .refined ._
25- import sttp .tapir .docs .openapi ._
26- import sttp .tapir .generic .auto ._
20+ import sttp .apispec .openapi .circe .yaml .*
21+ import sttp .tapir .*
22+ import sttp .tapir .codec .refined .*
23+ import sttp .tapir .docs .openapi .*
24+ import sttp .tapir .generic .auto .*
2725import sttp .tapir .json .circe .jsonBody
2826import sttp .tapir .server .ServerEndpoint
2927import sttp .tapir .server .http4s .Http4sServerInterpreter
@@ -39,7 +37,7 @@ object Api {
3937
4038 val docs : OpenAPI = OpenAPIDocsInterpreter ()
4139 .toOpenAPI(apis.flatMap(_.endpoints), OpenApiInfo (BuildInfo .name, BuildInfo .version, description = config.description))
42- .servers(List (Server (config.serverUrl )))
40+ .servers(List (Server (config.server.toString )))
4341 .tags(apis.map(_.tag))
4442
4543 val swaggerUi : HttpRoutes [F ] = Http4sServerInterpreter ().toRoutes(SwaggerUI [F ](docs.toYaml))
@@ -51,7 +49,7 @@ object Api {
5149}
5250
5351object Examples {
54- def apply [F [_]: Async ]()( implicit F : Applicative [ F ]) = new TapirApi [F ] {
52+ def apply [F [_]: Async ]() = new TapirApi [F ] {
5553 override val tag : Tag = Tag (" Getting started" , None )
5654 override lazy val serverEndpoints : List [ServerEndpoint [Any , F ]] = List (info, hello)
5755 type NonEmptyString = String Refined NonEmpty
@@ -64,17 +62,15 @@ object Examples {
6462 .out(jsonBody[Info ])
6563 .errorOut(statusCode)
6664 .serverLogic(_ =>
67- F .pure(
68- Info (
69- BuildInfo .name,
70- BuildInfo .version,
71- System .getProperty(" java.vm.version" ),
72- BuildInfo .scalaVersion,
73- BuildInfo .sbtVersion,
74- BuildInfo .builtAtString,
75- BuildInfo .test_libraryDependencies.sorted
76- ).asRight
77- )
65+ Info (
66+ BuildInfo .name,
67+ BuildInfo .version,
68+ System .getProperty(" java.vm.version" ),
69+ BuildInfo .scalaVersion,
70+ BuildInfo .sbtVersion,
71+ BuildInfo .builtAtString,
72+ BuildInfo .test_libraryDependencies.sorted
73+ ).asRight.pure
7874 )
7975
8076 private val hello : ServerEndpoint .Full [Unit , Unit , Option [NonEmptyString ], StatusCode , String , Any , F ] =
@@ -85,7 +81,7 @@ object Examples {
8581 .in(query[Option [NonEmptyString ]](" name" ).description(" Optional name to greet" ))
8682 .out(stringBody)
8783 .errorOut(statusCode)
88- .serverLogic(name => F .pure( s " Hello ${name.getOrElse(" World" )}! " .asRight) )
84+ .serverLogic(name => s " Hello ${name.getOrElse(" World" )}! " .asRight.pure )
8985
9086 case class Info (
9187 name : String ,
@@ -102,6 +98,6 @@ object Examples {
10298abstract class TapirApi [F [_]: Async ] {
10399 def tag : Tag
104100 def serverEndpoints : List [ServerEndpoint [Any , F ]]
105- def endpoints : List [Endpoint [_, _, _, _, _ ]] = serverEndpoints.map(_.endpoint)
101+ def endpoints : List [Endpoint [? , ? , ? , ? , ? ]] = serverEndpoints.map(_.endpoint)
106102 def routes : HttpRoutes [F ] = Http4sServerInterpreter ().toRoutes(serverEndpoints)
107103}
0 commit comments