-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[scala][client]: scala-http4s: minor improvement (enum companion meth…
…od, remove implicit, error handling) (#19901) * [scala][http4s][client]: add enum method; remove implicit * improve error handling * more enum enhancement * remove unused * update samle * avoid breaking change --------- Co-authored-by: Jenny Leahy <[email protected]>
- Loading branch information
1 parent
3a36882
commit 961c2e4
Showing
19 changed files
with
112 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
modules/openapi-generator/src/main/resources/scala-http4s/errorResponsePart.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{{#dataType}}case r if r.status.code == {{code}} => parseJson[F, {{dataType}}]("{{dataType}}", r).flatMap(res => Concurrent[F].raiseError(_FailedRequest(r.status.code, res.asJson.noSpaces))){{/dataType}}{{^dataType}}case r if r.status.code == {{code}} => Concurrent[F].raiseError(_FailedRequest(r.status.code, r.status.reason)){{/dataType}} | ||
{{#dataType}}case r if r.status.code == {{code}} => parseJson[F, {{dataType}}]("{{dataType}}", r).flatMap(res => Concurrent[F].raiseError(_FailedRequest(r.status.code, r.status.reason, Some(res.asJson)))){{/dataType}}{{^dataType}}case r if r.status.code == {{code}} => Concurrent[F].raiseError(_FailedRequest(r.status.code, r.status.reason)){{/dataType}} |
18 changes: 10 additions & 8 deletions
18
modules/openapi-generator/src/main/resources/scala-http4s/failedRequest.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
modules/openapi-generator/src/main/resources/scala-http4s/methodParameters.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{/required}}{{^required}}Option[{{dataType}}]{{/required}}{{^defaultValue}}{{^required}} = None{{/required}}{{/defaultValue}}{{^-last}}, {{/-last}}{{/allParams}}{{#authMethods.0}}{{#isApiKey}})(implicit auth: _Authorization.ApiKey{{/isApiKey}}{{#isBasic}}{{#isBasicBasic}})(implicit auth: _Authorization.Basic{{/isBasicBasic}}{{#isBasicBearer}})(implicit auth: _Authorization.Bearer{{/isBasicBearer}}{{/isBasic}}{{/authMethods.0}} | ||
{{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{/required}}{{^required}}Option[{{dataType}}]{{/required}}{{^defaultValue}}{{^required}} = None{{/required}}{{/defaultValue}}{{^-last}}, {{/-last}}{{/allParams}}{{#authMethods.0}}{{#isApiKey}})(using auth: _Authorization.ApiKey{{/isApiKey}}{{#isBasic}}{{#isBasicBasic}})(using auth: _Authorization.Basic{{/isBasicBasic}}{{#isBasicBearer}})(using auth: _Authorization.Bearer{{/isBasicBearer}}{{/isBasic}}{{/authMethods.0}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 19 additions & 17 deletions
36
modules/openapi-generator/src/main/resources/scala-http4s/modelsPackage.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
{{>licenseInfo}} | ||
package {{packageName}} | ||
|
||
import io.circe.{Decoder, Encoder} | ||
import io.circe.{Decoder, Encoder, Json} | ||
import java.time.{Instant, LocalDate, OffsetDateTime} | ||
import java.util.UUID | ||
|
||
package object models { | ||
given decodeUUID: Decoder[_root_.java.util.UUID] = | ||
Decoder.decodeString.map(str => _root_.java.util.UUID.fromString(str)) | ||
given decodeUUID: Decoder[UUID] = | ||
Decoder.decodeString.map(str => UUID.fromString(str)) | ||
given encodeUUID: Encoder[_root_.java.util.UUID] = | ||
Encoder.encodeString.contramap[_root_.java.util.UUID](uuid => uuid.toString) | ||
given encodeUUID: Encoder[UUID] = | ||
Encoder.encodeString.contramap[UUID](uuid => uuid.toString) | ||
given decodeInstant: Decoder[_root_.java.time.Instant] = | ||
Decoder.decodeString.map(str => _root_.java.time.OffsetDateTime.parse(str).toInstant) | ||
given decodeInstant: Decoder[Instant] = | ||
Decoder.decodeString.map(str => OffsetDateTime.parse(str).toInstant) | ||
given encodeInstant: Encoder[_root_.java.time.Instant] = | ||
Encoder.encodeString.contramap[_root_.java.time.Instant](_.toString) | ||
given encodeInstant: Encoder[Instant] = | ||
Encoder.encodeString.contramap[Instant](_.toString) | ||
given decodeLocalDate: Decoder[_root_.java.time.LocalDate] = | ||
Decoder.decodeString.map(str => _root_.java.time.LocalDate.parse(str)) | ||
given decodeLocalDate: Decoder[LocalDate] = | ||
Decoder.decodeString.map(str => LocalDate.parse(str)) | ||
given encodeLocalDate: Encoder[_root_.java.time.LocalDate] = | ||
Encoder.encodeString.contramap[_root_.java.time.LocalDate](_.toString) | ||
given encodeLocalDate: Encoder[LocalDate] = | ||
Encoder.encodeString.contramap[LocalDate](_.toString) | ||
given decodeJson: Decoder[io.circe.Json] = | ||
Decoder.decodeString.map(str => io.circe.Json.fromString(str)) | ||
given decodeJson: Decoder[Json] = | ||
Decoder.decodeString.map(str => Json.fromString(str)) | ||
given encodeJson: Encoder[io.circe.Json] = | ||
Encoder.encodeString.contramap[io.circe.Json](_.toString) | ||
given encodeJson: Encoder[Json] = | ||
Encoder.encodeString.contramap[Json](_.toString) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.