by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 13:08
    pewniak747 synchronize #696
  • 13:08

    pewniak747 on convert-docs-to-mdoc

    [Docs] Review the use of mdoc:i… (compare)

  • 12:43
    pewniak747 synchronize #696
  • 12:43

    pewniak747 on convert-docs-to-mdoc

    Apply suggested changes for bui… [Docs] Apply suggested changes … (compare)

  • 12:36

    mergify[bot] on master

    Update client:akka-http-backend… Merge pull request #699 from sc… (compare)

  • 12:36
    mergify[bot] closed #699
  • 12:27
    scala-steward opened #699
  • 12:18
    adamw commented #696
  • 06:42
    scala-steward opened #698
  • Aug 06 17:48
    scala-steward opened #697
  • Aug 06 14:04
    pewniak747 review_requested #696
  • Aug 06 14:04
    pewniak747 review_requested #696
  • Aug 06 14:03
    pewniak747 opened #696
  • Aug 06 13:31

    pewniak747 on convert-docs-to-mdoc

    Revert back to sbt 1.2.8 (compare)

  • Aug 06 12:55

    pewniak747 on convert-docs-to-mdoc

    Bump sbt version This allows s… (compare)

  • Aug 06 12:27

    pewniak747 on convert-docs-to-mdoc

    Update the example in README (compare)

  • Aug 06 11:55

    pewniak747 on convert-docs-to-mdoc

    [Docs] Convert .html links to .… [Docs] Fix syntax highlighting … Add documentation to the releas… (compare)

  • Aug 06 09:18
    gzhk assigned #695
  • Aug 06 09:16
    ghostbuster91 edited #695
  • Aug 06 09:14
    ghostbuster91 opened #695
Alexander Van Hecke
@alexandervanhecke
this doesnt start :
Exception in thread "main" java.lang.NoSuchMethodError: org.http4s.HttpRoutes$.apply(Lscala/Function1;Lcats/effect/Sync;)Lcats/data/Kleisli;
    at tapir.server.http4s.EndpointToHttp4sServer.toRoutes(EndpointToHttp4sServer.scala:22)
    at tapir.server.http4s.TapirHttp4sServer$RichHttp4sHttpEndpoint.toRoutes(TapirHttp4sServer.scala:18)
    at ....mocksupport.po.Test$.<clinit>(FakePno.scala:207)
    at ....mocksupport.po.Test.main(FakePno.scala)
I'm using tapir v 0.11.11, scala 2.13, and explicitly managed versions of of cats (2.1.1) and circe (0.13.0)
  val tapirExclusions = List(
    ExclusionRule().withOrganization("org.typelevel"),
    ExclusionRule().withOrganization("io.circe")
  )
  val tapirCore      = "com.softwaremill.tapir" %% "tapir-core"               % tapirVersion excludeAll (tapirExclusions: _*)
  val tapirHttp4s    = "com.softwaremill.tapir" %% "tapir-http4s-server"      % tapirVersion excludeAll (tapirExclusions: _*)
  val tapirSwaggerUI = "com.softwaremill.tapir" %% "tapir-swagger-ui-http4s"  % tapirVersion excludeAll (tapirExclusions: _*)
  val tapirOpenApi   = "com.softwaremill.tapir" %% "tapir-openapi-docs"       % tapirVersion excludeAll (tapirExclusions: _*)
  val tapirCirceYaml = "com.softwaremill.tapir" %% "tapir-openapi-circe-yaml" % tapirVersion excludeAll (tapirExclusions: _*)
  val tapirCirce     = "com.softwaremill.tapir" %% "tapir-json-circe"         % tapirVersion excludeAll (tapirExclusions: _*)
I feel like I'm missing something very obvious here ... any thoughts?
Per Øyvind Kanestrøm
@perok
Hi! Is there a reason for PartialServerEndpoint to not extend EndpointErrorOutputsOps?
5 replies
vonchav
@voonchav_gitlab
Hi @adamw, the latest Tapir release 0.15.4 is still using sttp-client 2.1.5 and yet they were both updated and released today. I suppose another Tapir release is already in the works :) It'd be nice that I upgrade both to the latest and greatest :)
9 replies
BTW, I assume Tapir 0.15.4 is a minor release. And sttp-client 2.2.0 is a bigger release to deserve the version bump. So what's new in sttp-client?
1 reply
Nick Childers
@Voltir
@adamw I spent more time continuing my foray into multipartBodies and one problem im running in to is supporting streaming body types as part of a multipart body. It looks like there are only a finite number of allowed types per how RawBodyType is implemented, and they all materialize the body into memory - I was looking for something like a Part[Source[ByteString, Any]], which seems like it should be easy to implement from the perspective of the akka-tapir integration (its just the entity.dataBytes after all), but threading that type through the rest of the sttp machinery seems.. complicated.
10 replies
maybe RawBodyType could take a second parameter (the backend's stream type), but that might open pandora's box
Denis Novac
@DenisNovac
Hi everyone. I just wanted to push branch to tapir, but got "ERROR: Permission to softwaremill/tapir.git denied to DenisNovac.". Is tapir closed for PRs?
Denis Novac
@DenisNovac
Oh, it is done through fork, now i get it
dharm82465
@dharm82465
Hello, I am curious if it is possible to create Tapir endpoint that matches either path /userId or /accountId. Something similar to pipe operator (|) used in Akka-Http
1 reply
Антон Войцишевский
@FunFunFine

Hi!
How can I access URI of called method in the handler?
Http4s allows me to call uri on request like that:

case req @ GET -> Root =>  Ok(req.uri.toString)

Is it possible to do the same with tapir?

3 replies
Uwe Sommerlatt
@usommerl

Hi. I'm getting the following exception when I run a service that is using tapir, and that was packaged as a fat jar:

java.lang.NullPointerException
    at sttp.tapir.swagger.http4s.SwaggerHttp4s.<init>(SwaggerHttp4s.scala:36)

I use sbt assembly for packaging. The service is working fine if I don't use a fat jar. Has anyone here encountered this issue? I would be glad for any pointers!

edit: I'm using tapir v0.15.4 and sbt-assembly v0.14.0

7 replies
Mateusz Ligęza
@mrForest13
Hello, is there any reason why SwaggerHttp4s has "redirectQuery" and SwaggerAkka not? version 0.16.1
1 reply
Mateusz Wójcik
@matwojcik
@adamw Are there any plans to start keeping brief release notes for both tapir and sttp (at least for major/minor version updates)? I believe it would make more people aware of new features and places that could break after release :)
4 replies
Gergő Törcsvári
@tg44
hy! can sb help me with a snippet?
https://gist.github.com/tg44/8649649b01dfefde2c55428f40d29bf3
(pbpaste > script.sc && amm script.sc)
It compiles, but runtime I get Error during processing of request: 'Outputs and output values don't match in output I think this is bcs of the val emptyResponse, but I think I use that right.
3 replies
Антон Войцишевский
@FunFunFine

Hi!
How to correctly define custom schemas for cases of Enumeratum's enum?

I have this enum and a schema for it defined as in documentation here:

sealed trait RuleInspectType extends EnumEntry

object RuleInspectType extends Enum[RuleInspectType] with CirceEnum[RuleInspectType] with Uppercase {
  case object Probe extends RuleInspectType
  case object Manual extends RuleInspectType
  case object Wait extends RuleInspectType
  implicit val sEntity: Schema[RuleInspectType] =
    Schema.oneOf[RuleInspectType, String](_.entryName, identity)(
      "PROBE" -> Schema(SchemaType.SString).description(
        "probe decr"
      ),
      "MANUAL" -> Schema(SchemaType.SString).description(
        "manual descr."
      ),
      "WAIT" -> Schema(SchemaType.SString).description(
        "wait descr."
      )
    )

  override def values: IndexedSeq[RuleInspectType] = findValues
}

I am also using tapir-enumeratum integration, but at the start of application I get weird runtime error:

java.lang.ClassCastException: sttp.tapir.SchemaType$SString$ cannot be cast to sttp.tapir.SchemaType$SObject
1 reply
Jules Ivanic
@guizmaii

Hi everyone,

I’m trying to use Scala-newtype with Tapir.

If replace some types (String) by some newtypes in my request datatype, then I have this error:

Cannot find a codec for type: Request, formatted as: sttp.tapir.CodecFormat.Json.
Did you define a codec for: Request?
Did you import the codecs for: sttp.tapir.CodecFormat.Json?
Is there an implicit schema for: Request, and all of its components?
(codecs are looked up as implicit values of type Codec[Request, sttp.tapir.CodecFormat.Json, _];
schemas are looked up as implicit values of type Schema[Request])

I’m still using Tapir 0.12.

Does anyone know how to fix that?

14 replies
vonchav
@voonchav_gitlab
@adamw I suppose a release with ZIO RC21 is already in the works? :)
4 replies
vonchav
@voonchav_gitlab
Hello all, has anyone ever tried, with Tapir, setting the outgoing header to some cache-control? I suppose it'd be something like .out(header[String]("cache-control: ???") This seems to mess up Tapir's serverLogic signature. @adamw, any example of setting headers when returning?
1 reply
PawelJ-PL
@PawelJ-PL
Hi. I'm trying to migrate to serverLogicForCurrent from andThenFirstE (because it's deprecated now). But I have no idea, how to turn PartialServerEndpoint[_, _, _, _] back to Endpoint[_, _, _, _]. I need Endpoint, because it's required by toOpenApi extension method.
2 replies
Jakub Kozłowski
@kubukoz
Hi, is there any automatic derivation for TextPlain codecs for, let's say, value classes?
1 reply
fjbenitog
@fjbenitog
Hi, I have an issue after updating to version 0.13.2,
[error] scala.reflect.macros.TypecheckException: could not find implicit value for parameter e: sttp.tapir.Schema[MyClass]
The error is happening when the case class has more than 7 fields
17 replies
profic
@profic
Hi, is there an option to add an example to Schemas? I have following open API peace and seems like sttp.tapir.Schema does not have a field "example", but there is sttp.tapir.openapi.Schema#example
client_id:
    type: string
    description: Unique ID of the client
    example: my_unique_id
2 replies
Michał Pawlik
@majk-p

Hi,
I have an endpoint, something like:

baseEndpoint
    .in("api")
    .in(path[String]("item"))
    .in("delete")
    .out(jsonBody[Unit])
    .description("deletes the item")

This endpoint doesn't require any json body, but I'd like it to require Content-Type: application/json header.
Is there any simple way to do this in tapir?

3 replies
Henry
@hygt
Hello, I use a custom failure handler with badRequestOnPathErrorIfPathShapeMatches = true as suggested by the documentation, it's working as expected for endpoints like /foo/{path-param} but not with something like /foo/{path-param}?{queryParam} where I get 404 for anything that doesn't get validated by the path param codec
3 replies
Yatheesha Lokesha
@yatheesha-agoda
could anyone help how I can use existing authentication feature available in akka
def authenticateOAuth2Async[T](realm: String, authenticator: AsyncAuthenticator[T]): AuthenticationDirective[T]
1 reply
ionutioio
@ionutioio

Hello, in one of my exposed objects I have Set[Enum] as an attribute.
The swagger isn't generated correctly:

myAttribute:
          type: array
          items:
            type: string
            enum:
            - ENUM1
            - ENUM2
            - ENUM3
            - ENUM4
          enum:
          - ENUM1
          - ENUM2
          - ENUM3
          - ENUM4

What can I do about it? The enum uses TapirCodecEnumeratum

4 replies
Loránd Szakács
@lorandszakacs

folks, does anyone have a nice pattern of working with tapir and http4s' AuthMiddleware? I'm trying to incrementally rewrite endpoint definitions in tapir, and honestly, keeping the logic in AuthMiddleware is a tad bit essential. Honestly, I don't even mind if tapir doesn't know about the auth token and it doesn't show up in documentation. I care more about authentication working exactly as it did before.

I'll figure it out eventually, but if I don't have to reinvent the wheel, then even better

2 replies
dadanoq
@lp33pp66

Hello, I have an Enum as an attribute.
When I give an implicit value for naming policy,
The swagger isn’t generated correctly:

object MyEnum extends Enumeration with EnumHelper {
    type Type = Value
    val aaa = Value("AAA")
    val bbb = Value("BBB")
  }

  case class MyClass(myAttribute: MyEnum.Type)

  implicit val customConfiguration: Configuration =
    Configuration.default.withSnakeCaseMemberNames

  val baseEndpoint = endpoint.post.in(jsonBody[MyClass])

toYaml:

```yaml =
schemas:
MyClass:
required:

  - my_attribute
  type: object
  properties:
    my_attribute:
      type: string

```
What can I do about it?

4 replies
Srepfler Srdan
@schrepfler
hi folks, is there any extension to Tapir to support Lagom services? Or if not, how can one go about to implement one?
2 replies
Stefanqn
@Stefanqn
Hi, is it possible to create tapir Endpoints from an openAPI-spec? (start from an openAPI definition)
4 replies
sken
@sken77
is there a migration guide for play codebases?
Paulius Imbrasas
@CremboC

I'm having issues with https://tapir.softwaremill.com/en/latest/testing.html - this code doesn't seem to work at all for me? Getting

type mismatch;
 found   : sttp.client.testing.SttpBackendStub[cats.effect.IO,Nothing,Nothing]
 required: sttp.client.testing.SttpBackendStub[[+A]cats.effect.IO[A],S,WS_HANDLER]
Note: Nothing <: S, but class SttpBackendStub is invariant in type S.
You may wish to define S as +S instead. (SLS 4.5)
Note: Nothing <: WS_HANDLER, but class SttpBackendStub is invariant in type WS_HANDLER.
You may wish to define WS_HANDLER as +WS_HANDLER instead. (SLS 4.5)
        new RichSttpBackendStub(SttpBackendStub.apply[IO, Nothing, Nothing](implicitly[MonadError[IO]]))

yes I did a new RichSttpBackendStub to get the error properly

Paulius Imbrasas
@CremboC
If I give the type hints to new RichSttpBackendStub[IO, Nothing, Nothing] then it works fine :(
Kasper Kondzielski
@ghostbuster91
yes, scala has some problems with inferencing Nothing type. Hopefully we will migrate documentation to mdoc in the nearest future so such errors won't occur anymore
Paulius Imbrasas
@CremboC
is there a solution that still allows me to use nice syntax or do I have to give the the Nothing explicitly like I mentioned?
nigredo-tori
@nigredo-tori

Hello. Is there a nice way to use Tapir endpoints with existing Http4s AuthMiddlewares (or ContextMiddlewares)? The point of such middleware is that it provides an additional input (packaged into ContextRequest - I'll call this input "context" or Context from here on out), effectfully extracted from the Request.

First, extracting the context can't be a part of the ServerEndpoint's logic - it needs to have access to the original Request, rather than to its ServerRequest projection.

An obvious solution would be to build ServerEndpoints from this context (Context => List[ServerEndpoint[_, _, _, EntityBody[F], F]]). This works, but it has the unfortunate consequence: we have to build all the ServerEndpoint objects for each authenticated request. This strikes me as inefficient.

Finally, we might want to pass the context through the monad (List[ServerEndpoint[_, _, _, EntityBody[F], ReaderT[F, Context, *]]]). This seems like the best solution to me, but from what I can see, Tapir is not geared to handle this. Tapir works with types like ServerEndpoint[_, _, _, EntityBody[F], F] and HttpRoutes[F], which assume that the monad we use for streaming (EntityBody parameter) is the same we use for routing. We can probably work around this by using ReaderTfor streaming (List[ServerEndpoint[_, _, _, EntityBody[ReaderT[F, Context, *]], ReaderT[F, Context, *]]]), but that also seems inefficient. Otherwise we can try and add some mapK-like combinator for ServerEndpoint - but that is also annoying because of the MonadError requirement in ServerEndpoint.

Has anyone found a satisfactory way to handle this?

nigredo-tori
@nigredo-tori
Ah, it seems like someone already asked this two weeks ago. In my case, I can't use the the partial endpoint functionality because the particular middleware I need uses Request.attributes - and these are not available in ServerRequest.
dhaub
@dhaub
In the example from the docs for dynamic status codes, is there a way to get the statusCode associated with the emptyOutput to appear in the OpenApi documentation? Is there a way to attach a description?
val baseEndpoint = endpoint.errorOut(
  oneOf[ErrorInfo](
    statusMapping(StatusCode.NotFound, jsonBody[NotFound].description("not found")),
    statusMapping(StatusCode.Unauthorized, jsonBody[Unauthorized].description("unauthorized")),
    statusMapping(StatusCode.NoContent, emptyOutput.map(_ => NoContent)(_ => ())),  <-- disappears from OpenApi docs
    statusDefaultMapping(jsonBody[Unknown].description("unknown"))
  )
)
1 reply
Daniel Joanes
@djoanes
Any example of parsing query[MyClass] using Circe?
1 reply
feoktant
@feoktant

Hi, I need to implement API which has special boolean field in response to identify success. For example, field status:

//on success
{
    "status": true,
    "data": "some data
}

//on error
{
    "status": false
    "msg": "error happenend"
}

In my logic I have function which returns Either:

def businessLogic(e: Entity): Future[Either[Error, ChangedEntity]] = ...

I do not want to have field status: Boolean in case classes Error or responses. So I've created Circe codecs:

val status = "status"

implicit val errorCodec: Codec[Error] = Codec.from(
    deriveDecoder[Error],
    deriveEncoder[Error].mapJsonObject(_.+:(status, false.asJson)),
)
val errorResp: EndpointIO.Body[String, Error] =
  jsonBody[Error]
    .description("Error response")
    .example(Error(145, "We have a problem"))

implicit val entityCodec: Codec[Entity] = Codec.from(
    deriveDecoder[BalanceDto],
    deriveEncoder[BalanceDto].mapJsonObject(_.+:(status, true.asJson)),
)

Such solution works, but in Swagger Schema I have no this field. However, it is in Error's example. Entity has no this field neither in schema nor in example.

What should I do to solve this? Does better solution exist for such API?

3 replies
Sebastián Rojas
@sebastiansen
Hi everyone, I need to add validations to a case class that also also contains an enum using enumeratum. I'm using import sttp.tapir.codec.enumeratum._ to implicitly encode enums, but if I add another validation to a class containing one of those enums inside, the enum encoding disappears or gets overridden apparently.
14 replies
dadanoq
@lp33pp66
Hello,
I need to add a default value for the query parameter in the generated docs.
What should I do?
2 replies
Loránd Szakács
@lorandszakacs
hello folks, is there an easy way to turn an Endpoint into an org.http4s.Request[IO] that I can then run against an org.http4s.HttpApp[IO]? I need this for testing, but don't want to bind ports, I just want to create requests to just test that my error handling is all nice and proper :)
1 reply
Mateusz Stankiewicz
@mas15

Hi everyone
Is it possible to set output headers dynamically?
I have got an endpoint that returns different content types: zip or pdf.
I don't know the content type of returned data in advance. Is it possible to define that my endpoint returns either pdf or zip and set a concrete header later on while streaming data?

     .get
      .in("something" / path[Something.Id]("id"))
      .out(streamBody[Source[ByteString, Any]](Schema(SBinary), Either[CodecFormat.Zip(), CodecFormatPdf()])) // Set it later on
      .out(header(contentDispositionHeader())) // Set it later on as well

Thanks!

6 replies
Sebastian Voss
@sebastianvoss
Hi guys - I'm trying to use .in(multipartBody) in version 0.16.10. I have trouble to access the bodies of the parts using part.body as the type is not Array[Byte] as stated in the docs. Can somebody give me a hint how I can get hold of the body?
Sebastian Voss
@sebastianvoss
Maybe I need to use multipartBody[Seq[Part[Array[Byte]]]] and somehow bring MultipartCodec[Seq[Part[Array[Byte]]]] into scope? Or is there a simpler way?
4 replies