guardrail-dev / guardrail

Principled code generation from OpenAPI specifications
https://guardrail.dev
MIT License
526 stars 133 forks source link

Http4s Client Generation Don't use UnsafeFromString #86

Open calvinbrown085 opened 6 years ago

calvinbrown085 commented 6 years ago

It's pretty well known in the http4s community to stay way from Uri.unsafeFromString

httpClient.expect[GetConfigurationResponse](Request[F](method = Method.POST, uri = Uri.unsafeFromString(host + basePath + "/get-configuration")

We should be able to do this in a safe way.

blast-hardcheese commented 6 years ago

String-concatting URL construction is definitely not ideal, I agree. http4s was added as an experimental alternate client generation, unfortunately without the server component, preventing writing round-trip tests.

calvinbrown085 commented 6 years ago

@blast-hardcheese I talked to a couple people with differing opinions on this, some say unsafe from string might be okay in compiled code.

blast-hardcheese commented 6 years ago

Still, if there's a safe way to build a URI, there's no reason to not use it. There isn't one in akka-land, and I didn't want the middleware to become huge.

calvinbrown085 commented 6 years ago

Yep, that totally makes sense