Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 25 21:36
    blast-hardcheese commented #1595
  • Sep 25 20:19
    blast-hardcheese commented #1592
  • Sep 25 20:19
    blast-hardcheese commented #1592
  • Sep 25 20:18
    blast-hardcheese labeled #1595
  • Sep 25 20:18
    blast-hardcheese opened #1595
  • Sep 25 20:11

    blast-hardcheese on master

    Adding Tracker history for fall… Merge pull request #1593 from b… (compare)

  • Sep 25 20:11
    blast-hardcheese closed #1592
  • Sep 25 20:11
    blast-hardcheese closed #1593
  • Sep 25 19:59
    blast-hardcheese labeled #1594
  • Sep 25 19:59
    blast-hardcheese opened #1594
  • Sep 25 19:42
    codecov[bot] commented #1593
  • Sep 25 19:42
    codecov[bot] commented #1593
  • Sep 25 19:42
    codecov[bot] commented #1593
  • Sep 25 19:40
    codecov[bot] commented #1593
  • Sep 25 19:40
    codecov[bot] commented #1593
  • Sep 25 19:39
    codecov[bot] commented #1593
  • Sep 25 19:25
    blast-hardcheese commented #1592
  • Sep 25 19:24
    blast-hardcheese opened #1593
  • Sep 25 19:24
    blast-hardcheese labeled #1593
  • Sep 24 14:33
    KineticCookie commented #195
jonasberg
@jonasberg:matrix.org
[m]
If you generate a client based on a api spec that has auth for all or certain endpoints, is there a way to add credentials to the generated client today?
or is that not possible at all
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
that's certainly possible.
jonasberg
@jonasberg:matrix.org
[m]
ok, so it's just more convenience thing that this is missing. That should be ok for my use case πŸ‘οΈ
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
Yes. Low level protocol work can be done by way of supplying a pre-authenticated HttpClient[F], by way of FooClient.httpClient[F[_]](httpClient: Http4sClient[F], host: String = "http://localhost:1234")(implicit F: Async[F]): FooClient[F]
this is also used in the case of servers that misrepresent content types or include other odd network features that must be coerced
jonasberg
@jonasberg:matrix.org
[m]
had a look at my generated client and was wondering exactly that πŸ˜ƒ
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
πŸ‘οΈ
jonasberg
@jonasberg:matrix.org
[m]
Thank you!
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
Of course! I'm going to keep driving now, but please enjoy your evening
jonasberg
@jonasberg:matrix.org
[m]
Thanks, have a nice day
Lorenzo Gabriele
@lolgab
Hi :)
Thank you for guardrail! It is amazing!
I wanted to ask a question about optional fields on objects, is it possible to disable the = None default values for optional values?
blast_hardcheese
@blast_hardcheese:matrix.org
[m]

@lolgab Pardon for the delay in response! I must have missed the notification.

This isn't currently configurable, though I'm curious about your use case. Would you want to disable this in all cases, in order to make it obvious where the code needs to change if a spec changes?
The location where those None values are interpolated is here

blast_hardcheese
@blast_hardcheese:matrix.org
[m]
I don't have a great answer for you right now, since I'm still working on guardrail-dev/guardrail#1414, but once that is merged and released, you should be able to define a subclass of any of these generators directly in sbt, for instance like project/src/main/scala/dev/guardrail/CirceOverrides.scala. I'm trying to get that wrapped up soon, life has been getting in the way a bit πŸ˜…
Lorenzo Gabriele
@lolgab

Would you want to disable this in all cases, in order to make it obvious where the code needs to change if a spec changes?

Yes, I try to avoid default parameters since I always forget to propagate some of them and end up creating bugs.
I check if I can define that override myself, thank you very much :)

blast_hardcheese
@blast_hardcheese:matrix.org
[m]
I'll really try to wrap up the spi branch in the next few weeks, if you don't mind waiting; I can provide a working example of what you're trying to do once it's done
This kind of extensibility is a desired feature, to support companies that need to add internal frameworks
Lorenzo Gabriele
@lolgab

This kind of extensibility is a desired feature, to support companies that need to add internal frameworks

Definitely! Great, thank you!

martijn.hoekstra.zivver
@martijn.hoekstra.zivver:matrix.org
[m]
Hey all, I'm wondering what the status is of the projects CI -- github runners are failing, and have been for a long time. Can I help getting that passing?
blast_hardcheese
@blast_hardcheese:matrix.org
[m]

martijn.hoekstra.zivver: It's an unfortunate state of the MiMa checker -- I'm changing how the module system works, building towards a new minor release, but the build fails unless there's the GitHub major or minor tag present in the build event...

I was thinking of trying to use the GitHub API to collect the semver tags of merged PRs, though maybe as a stopgap just disabling MiMa checking on master would be acceptable

blast_hardcheese
@blast_hardcheese:matrix.org
[m]
The tests all pass on individual PRs though πŸ˜…
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
@martijnhoekstra: Thanks for bringing this up -- it was easy to lose sight of the visibility of the master CI tests and what that means to people checking out the repo for the first time. I've fixed it now, hopefully that improves confidence more broadly.
or martijn.hoekstra.zivver... sorry, mistyped
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
Stale PRs now reduced to 14 -- getting closer to addressing them all πŸ“ˆ
Lorenzo Gabriele
@lolgab
πŸ‘πŸ‘πŸ‘
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
@lolgab: OK. It's a little messy, but it is now possible to override built-in functionality in the source generators.
https://gist.github.com/blast-hardcheese/4e0037332eb606330b90c3b19650e874 is a gist to explain how to do it, with a link to a branch in the sample-sbt-http4s repo where it is used.
The reason I think this is useful is it permits new feature development, alternately better fitment to custom internal idioms.
iterating in this way ends up being way faster than modifying the main guardrail repository, as well as working in your existing repository, so you can see what kind of impact it would have on your real-world code
Each of the *Generator classes has a .copy method that takes all parameters, so you can just open a file, copy the entire function you want to modify, then modify and re-inject it via https://github.com/guardrail-dev/guardrail-sample-sbt-http4s/blob/a3c270dc2ef340ed7f980b6e866c9c1d2cafb3b4/custom-circe/src/main/scala/CustomCirce.scala#L120-L122
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
please let me know how the experience is, and if there are any obvious improvements that could be made.
(I actually anticipated it would be possible to do by defining the extension directly inside projects/, but I got bit by sbt/sbt#3498 )
Lorenzo Gabriele
@lolgab
Thank you very much @blast_hardcheese:matrix.org ! This is wonderful! Every great software has a plug-in system, and now also Guardrail has it (which was already great software :) )!
I'm going to try it and let you know :)
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
sbt-guardrail 0.72.0 released, with some significant improvements. Pretty excited.
blast_hardcheese
@blast_hardcheese:matrix.org
[m]

Latest version of guardrail published to coursier contrib apps,

cs install --contrib guardrail

to get the CLI runner

Devon Stewart
@blast-hardcheese

Thanks to @stanislav-chetvertkov for adding support for refined to the circe generator! guardrail-dev/guardrail#1508 is merged, to be released shortly.

For those interested in trying it out, you can use modules=Seq("http4s", "circe-refined") or modules=Seq("akka-http", "circe-refined") in your sbt-guardrail configuration

1 reply
Lorenzo Gabriele
@lolgab

Hello!
I have a question about default values..
If I have a query parameter with:

required: false
default = 100

Guardrail generates limit: Option[Int] = Option(100) where I wanted it to generate limit: Int = 100.
Is that possible?
I tried with:

required: true
default = 100

and it seems to generate what I want, but it is not what the spec says to do, in fact it is in the "Common Mistakes"

blast_hardcheese
@blast_hardcheese:matrix.org
[m]
We don't currently do any consideration to think of optional values with defaults as non-optional types, this is definitely a bug as you've identified
@lolgab: Would you mind opening an issue?
Lorenzo Gabriele
@lolgab
@blast_hardcheese:matrix.org Sure! I can
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
Thanks!
Lorenzo Gabriele
@lolgab

I wanted also to ask if in the meantime I could rely on using

required: false
default: 100

or I am signing for other problems?

blast_hardcheese
@blast_hardcheese:matrix.org
[m]
lolgab (Lorenzo Gabriele): It permits the caller to send None, which violates the MUST in the specification, but there are no other implications
Lorenzo Gabriele
@lolgab
Opened the issue here: guardrail-dev/guardrail#1532
Sorry @blast_hardcheese:matrix.org, I sent the wrong snippet of code. When you use required: false it generates an Option while if you do use required: true it seems to do what I want
But let's see if this can be solved properly
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
I would use required: true, and eventually the required: false construction will also generate the same signature.
Lorenzo Gabriele
@lolgab
Perfect thank you very much πŸ™
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
@lolgab: Pretty sure this is correct. Bummer that both core and $lang-support need changes, probably an opportunity to unify. guardrail-dev/guardrail#1534
blast_hardcheese
@blast_hardcheese:matrix.org
[m]
@stanislav-chetvertkov: I think guardrail-dev/guardrail#1510 is ready for merge