Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 26 15:28
    scala-steward opened #663
  • Oct 25 15:06
    julienrf commented #637
  • Oct 25 02:35
    harpocrates commented #637
  • Oct 23 14:26

    julienrf on master

    Update sbt-version-policy Merge pull request #662 from en… (compare)

  • Oct 23 14:26
    julienrf closed #662
  • Oct 23 14:09
    codecov[bot] commented #662
  • Oct 23 14:08
    codecov[bot] commented #662
  • Oct 23 14:00
    julienrf opened #662
  • Oct 23 13:59

    julienrf on sbt-version-policy

    Update sbt-version-policy (compare)

  • Oct 22 15:41

    julienrf on master

    Exclude coverageEnabled from li… (compare)

  • Oct 22 15:31

    julienrf on master

    Update http4s-async-http-client… Merge branch 'master' into upda… Bump major version of http4s cl… and 1 more (compare)

  • Oct 22 15:31
    julienrf closed #654
  • Oct 22 15:27
    codecov[bot] commented #654
  • Oct 22 15:22

    julienrf on master

    Update akka-actor, akka-actor-t… Merge branch 'master' into upda… Merge pull request #649 from sc… (compare)

  • Oct 22 15:22
    julienrf closed #649
  • Oct 22 15:22

    julienrf on master

    Update scalafmt-core to 2.7.5 Adopt new code style Merge branch 'master' into upda… and 1 more (compare)

  • Oct 22 15:22
    julienrf closed #655
  • Oct 22 15:18
    codecov[bot] commented #655
  • Oct 22 15:18
    codecov[bot] commented #654
  • Oct 22 15:18
    julienrf synchronize #654
Dominic Egger
@GrafBlutwurst
I just noticed that I have a slight issue with cats laws for Monad[RequestEntity] this is a Functiontype and cats laws would like to have an Eq instance on it. How is this done on e.g. Reader I can't find the code for that
that should be able to get you going :)
Dominic Egger
@GrafBlutwurst
@LukaJCB thanks!
Dominic Egger
@GrafBlutwurst
wait isn't this essentially usage ofRepresentable? ugh I should have had that idea myelf
Dominic Egger
@GrafBlutwurst
@julienrf thanks for the publish. worked like a charm :ok_hand:
Dominic Egger
@GrafBlutwurst
I'm affraid I don't know when I get to finish the MonadError instace. I'm very sorry for the delay on that
Julien Richard-Foy
@julienrf
Do you need any help?
Luka Jacobowitz
@LukaJCB
I can help out as well
Dominic Egger
@GrafBlutwurst
it' really just finishing upthe tests, which tbh is the hard bit on this PR. if someone wants to pick it up sure. I'm just currently swamped at the job ( https://github.com/rivero-ag/endpoints4s/tree/feature-tc-instances)
Dominic Egger
@GrafBlutwurst
I'm right in the middle on figuring out how cats-laws and discipline works so don't take this code as something I would open a PR with :see_no_evil:
Dominic Egger
@GrafBlutwurst
@julienrf I was also wondering how to get traverse on Validated I just did my own instance of Applicative but the module where Validated lives has no cats dependency which makes sense. Should we consider a cats-extras module or perhaps a bespoke traverse implementation on Validated directly?
Julien Richard-Foy
@julienrf
What would be the signature of traverse on Validated?
I think we could create a cats-extras module, put the Applicative[Validated] instance into it, and make the http4s-server and http4s-client module depend on it.
Dominic Egger
@GrafBlutwurst
ah right we couldn't do traverse except we hardcode the other effect. so there'd be traverse overloaded over Option List etc. but that seems annoying
couldn't cats-extras also be it's own dependency a user may put into their buildfile?
Julien Richard-Foy
@julienrf
couldn't cats-extras also be it's own dependency a user may put into their buildfile?
sure
user753
@user753
Hi. How can I add description to each member of case class Foo(foo: String, bar: String) jsonResponse[Foo]?
Is it possible to add custom properties to OpenApi documentation like x-faker?
Julien Richard-Foy
@julienrf

@user753 We don’t support custom properties. You can add a documentation with the docs parameter of the field constructor:

field[String]("foo", docs = Some("A string…"))

In case you use generic derivation, you can use the @docs annotation:

case class Foo(@docs("A string…") foo: String, bar: String)
5 replies
Ryan Peters
@sloshy
Hello, I recently updated to the latest versions of endpoints & the circe/http4s support, and it seems that none of my endpoints are outputting JSON. Their error codes are correct, as are headers, but my browser and REST clients both are not returning any bodies. In fact Postman is giving me a parse error:
Error: Parse Error: Expected HTTP/
I'm using WSL2 on Windows but I can see that is not likely the problem as I was able to start an http4s quickstart g8 project and it seems to be working as expected
I feel like I must have misconfigured something since it does not seem anyone else has ran into this yet
Ryan Peters
@sloshy
Ahh I've reduced the problem to me using Ember as the server backend (vs the usual Blaze). I'll look into this w/ the http4s folks and see if maybe there's a known breakage
Luka Jacobowitz
@LukaJCB
I wonder if there should be a implicit def optionJsonSchema[A](jsonSchema: JsonSchema[A]): JsonSchema[Option[A]] in endpoints4s.algebra.JsonSchemas?
Julien Richard-Foy
@julienrf
Why not, how would you model None values in JSON?
Julien Richard-Foy
@julienrf
We need to make sure it wouldn’t clash with the existing optField constructor
Luka Jacobowitz
@LukaJCB
I would expect it to be mapped to null?
Julien Richard-Foy
@julienrf
This is not a good idea because this would not be parametric
Problems start to appear when you consider Option[Option[A]]
If you serialize Some(None) to null, you may deserialize it to None
Also, we currently treat null in object properties as a possible value for an optional field (it is decoded as None)
So, we need to be careful about how else we would use null
Luka Jacobowitz
@LukaJCB
Hmm
I guess that makes sense
Luka Jacobowitz
@LukaJCB
I suppose if we made it not implicit it would still be easier than what we’d have right now?
i.e. some function def option[A: JsonSchema]: JsonSchema[Option[A]]?
Julien Richard-Foy
@julienrf
I think it’s fine to have such a function, even implicit, but I believe we should make it correct. One way to do it would be to use an empty JSON array to model None, and an array with exactly one element to model Some.

well, maybe it’d be better to have it non implicit at first :)
The risk, if it’s implicit, is that users write this:

case class User(name: String, email: Option[String])

val userSchema = (
  field[String]("name") zip
  field[Option[String]]("email")
).as[User]

Which would compile and work, but most probably we want to write the following instead?

case class User(name: String, email: Option[String])

val userSchema = (
  field[String]("name") zip
  optField[String]("email")
).as[User]

(ie, we would use optField[String] instead of field[Option[String]])

Luka Jacobowitz
@LukaJCB
right
Georgi Krastev
@joroKr21
Hmm, how does circe deal with this problem?
I think it has implicit Decoder for Option
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"] }