Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 24 19:44
    mleclercq commented #847
  • Jul 24 19:39
    codecov[bot] commented #847
  • Jul 24 19:29
    mleclercq synchronize #847
  • Jul 24 19:25
    mleclercq synchronize #847
  • Jul 23 12:28
    codecov[bot] commented #858
  • Jul 23 12:20
    codecov[bot] commented #858
  • Jul 23 12:20
    scala-steward synchronize #858
  • Jul 23 10:34
    codecov[bot] commented #850
  • Jul 23 10:33
    codecov[bot] commented #857
  • Jul 23 10:25
    codecov[bot] commented #850
  • Jul 23 10:25
    codecov[bot] commented #857
  • Jul 23 10:25
    scala-steward synchronize #850
  • Jul 23 10:25
    scala-steward synchronize #857
  • Jul 23 10:04

    julienrf on master

    Update shapeless3-deriving to 3… (compare)

  • Jul 23 10:04
    julienrf closed #859
  • Jul 23 10:03

    julienrf on master

    Update slf4j-simple to 1.7.32 Merge pull request #860 from sc… (compare)

  • Jul 23 10:03
    julienrf closed #860
  • Jul 23 09:15
    codecov[bot] commented #861
  • Jul 23 09:15
    julienrf synchronize #861
  • Jul 23 09:04
    ptrdom commented #510
Alec Theriault
@harpocrates
It falls victim to the problem @julienrf described:
Welcome to the Ammonite Repl 1.7.4
(Scala 2.13.1 Java 11.0.6)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ {
  import $ivy.`io.circe::circe-core:0.12.3`
  import $ivy.`io.circe::circe-parser:0.12.3`

  import io.circe._, io.circe.parser._, io.circe.syntax._

  def roundtrip[A : Encoder : Decoder](a: A): Unit =
    assert(
      Right(a) == decode[A](a.asJson.noSpaces),
      s"Could not round-trip $a"
    )

  roundtrip[Option[Option[Int]]](None)
  roundtrip[Option[Option[Int]]](Some(None))
  }
java.lang.AssertionError: assertion failed: Could not round-trip Some(None)
  scala.Predef$.assert(Predef.scala:282)
  ammonite.$sess.cmd0$.roundtrip(cmd0.sc:9)
  ammonite.$sess.cmd0$.<clinit>(cmd0.sc:13)
While we're on that topic, isn't that already a problem for QueryStringParam which has an instance implicit optionalQueryStringParam[A: QueryStringParam]: QueryStringParam[Option[A]] (which must suffer from the same round-tripping issues for nested options)?
Julien Richard-Foy
@julienrf
Yes, this is true. I have assumed that users would never use nested Option in query string params.
Alec Theriault
@harpocrates
I've wondered in the past if this category of problem makes it worth it to distinguish between an optional schema and a non-optional schema (so that no instance of Schema[Option[Option[A]]] could be implicitly summoned). The downside is that the Option instance would really be special.
Georgi Krastev
@joroKr21

Yes, this is true. I have assumed that users would never use nested Option in query string params.

I guess you could say the same about JsonSchema

Luka Jacobowitz
@LukaJCB
I wouldn’t have a problem at all using an explicit method
but I can’t even figure out how to generate a simple schema like this { "type": ["null", "string"] }
Ryan Peters
@sloshy
Hi, I popped in a little while back to get some help with using endpoints with http4s as my responses were empty and causing errors in some clients. Turns out, it's a combination of issues: the ember server in http4s was not defaulting to chunked encoding when Content-Length is not specified, and endpoints4s was not setting that header. Does this qualify as a bug of some sort, or should I be setting this header myself? The bug is "fixed" on my end by using Blaze as my http4s backend, which defaults to chunked encoding, but I believe endpoints4s should also be setting the content-length header.
Here's a link to the relevant part of the discussion on the http4s gitter from around that time: https://gitter.im/http4s/http4s?at=5f8de432eb82301c1a378008
Ryan Peters
@sloshy
Bonus question: I ran into this issue as well recently, setting the base url from the XHR scalajs client. This hasn't changed recently has it? Or is there another client that more easily allows to do this yet? https://gitter.im/endpoints4s/endpoints4s?at=5ecad4cb27513a72fbada57b
Rustam Sultanov
@RustamSultanov
Now for scalajs only XHR client withiout base url.
sttp have support scala.js backend but now endpoints4s support only jvm back endpoints4s/endpoints4s#571
Julien Richard-Foy
@julienrf
@sloshy We should change the API and add a parameter for the base URL in the xhr Scala.js client
Julien Richard-Foy
@julienrf
@sloshy Thanks for the investigation about Content-Length. My understanding is that we could set this header, but this should not be required for the http4s backend to work correctly.
Ryan Peters
@sloshy
@julienrf Right, it was partially a bug in the http4s Ember backend where a bad default was chosen. I think the bug should be fixed now, or at least on trunk. Now, I'm not exactly super HTTP-fluent so you'll have to excuse this stupid question: would setting the Content-Length header by default where possible be an undesirable change? Is there a reason it is not implemented now VS it just "not being there"? I'm wondering if it's something I could contribute, or if it's a matter of opinion
Julien Richard-Foy
@julienrf
@sloshy Such a contribution would be very welcome :) I see no reason to not set the Content-Length header, if we can. The fact that it is not currently set is an oversight. I think the Play server interpreter does set it, actually. I don’t know for the others.
Mark
@Fristi
@julienrf I've bumped sttp to 2.2.9 (latest stable 2.x release, I think 3.x is around the corner as well, yet I would like this one as I'm using it for projects atm) endpoints4s/endpoints4s#675
Julien Richard-Foy
@julienrf
:pray: thanks!
Mark
@Fristi
When would you able to release the sttp 2.0 module?
Julien Richard-Foy
@julienrf
@Fristi I wanted to make sure the support of optional fields with default values was well designed. I stumbled upon this problem: https://github.com/endpoints4s/endpoints4s/issues/660#issuecomment-722464040
@harpocrates did you make some progress on the support of optional query string parameters with default values?
1 reply
Julien Richard-Foy
@julienrf
@/all I’ve just released endpoints4s-1.2.0 :) See the release notes here: https://github.com/endpoints4s/endpoints4s/releases/tag/v1.2.0
Mark
@Fristi
Thanks! :)
Leif Warner
@LeifW
I've got a route that naturally wants to return a Option[Either[Future]] - it can return 404 or 400 or 200. - Though the implementedByAsync wants the Future to be on the outside.
Is there anything to be done for that? Seems I'll have to do some weird type stuff to swap those around. Thinking about using EitherT[OptionT[Future]] from cats...
Julien Richard-Foy
@julienrf
@LeifW maybe you’ll find an answer here: https://www.youtube.com/watch?v=yEYPf44rS2U
Leif Warner
@LeifW
I guess doing traverse + traverse works.
For some reason sequence on the result wasn't working at all, but traverse does work.
Leif Warner
@LeifW
It seems more common to be to have the Either on the outside - because I do some validation before deciding whether to immediately return 400 or kick off the Future IO action... but traverse works.
Georgi Krastev
@joroKr21
In that case you can do the traverse already in the validation step :thumbsup:
Leif Warner
@LeifW
If I have a lot of different response codes I might want to return, e.g. 200 or 201 or 204 or 400 - does that mean I just nest a bunch of Eithers?
Alec Theriault
@harpocrates
If you've got a lot of possible response codes, you can xmapover the ResponseEntity to turn your nested Either's into some more palatable sealed trait that better fits your domain. That way, the Either stuff shows up only in the body of the endpoint definition and the type of the whole endpoint is in terms of your domain.
Dominic Egger
@GrafBlutwurst
out of curiosity why is QueryString an invariant partial functor? when is there a need to translate from decoded params to query string?
Julien Richard-Foy
@julienrf
@GrafBlutwurst Client interpreters encode params into a query string
Dominic Egger
@GrafBlutwurst
ahhh right makes sense. thanks!
Dominic Egger
@GrafBlutwurst
how does the JsonEntitiesFromEncodersAndDecoders differ from JsonEntitiesFromCodec http4s seems to have the latter but an endpoint serving OpenApi seems to use the former?
Julien Richard-Foy
@julienrf
FromEncodersAndDecoders only requires an Encoder to be available, whereas FromCodec requires both an Encoder and a Decoder. In the case of OpenApi, we only have an Encoder so far, that’s why we still have these JsonEntitiesFromEncodersAndDecoders traits
Dominic Egger
@GrafBlutwurst
ahhh then the AndDecoders bit is slightly confusing i suppose. but that makes a lot of sense. but the algebra is not available for http4s server it seems? or is my code discovering just broken?
hmm I think i need a flavour of jsonResponse that does not require a Codec in that case
Julien Richard-Foy
@julienrf
indeed, we miss the http4s version of the interpreter JsonEntitiesFromEncodersAndDecoders
(it should be easy to add, though)
Leif Warner
@LeifW
Is there a way of turning Paths into nice strings - to refer to from the documentation of other routes?
Julien Richard-Foy
@julienrf
@LeifW I think all the client interpreters should be able to do that. The play-server and xhr-client interpreters have dedicated methods for that. Which interpreter do you use?
caeus
@caeus
Quick question. Does Endpoints4s support xxx-urlencoded-form content type? if so, how?
Julien Richard-Foy
@julienrf
@caeus There is no out-of-the-box support but it would be easy to add even as a third-party extension (without changing the library itself)
Julien Richard-Foy
@julienrf
Hello @/all, I have added an “Adopters” section to the README, I would appreciate if you could give me a few organization names I can add to the list :smile: https://github.com/endpoints4s/endpoints4s/blob/master/README.md#adopters
Dominic Egger
@GrafBlutwurst
1 reply
Leif Warner
@LeifW
@julienrf Using the akka http interpreter.
1 reply
In the routes, I've been using Either and having it Left(Invalid(...)) on the failure case - noticing that Invalid's the failure case of Validated... wondering if I should be having the routes return Validated instead of Either?
2 replies
Julien Richard-Foy
@julienrf
@LeifW Actually, I just realized that you want to be able to do that in the documentation, not necessarily in the server
So, this is something we could add to the openapi interpreter maybe, and all the server interpreters would benefit from it
I’ve just opened #728 to implement it in the Akka HTTP server interpreter, though