-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: presentation-exchange model and json schema refactoring (#1304)
Signed-off-by: Pat Losoponkul <[email protected]> Signed-off-by: Hyperledger Bot <[email protected]> Co-authored-by: Hyperledger Bot <[email protected]>
- Loading branch information
1 parent
2668baa
commit 75b2736
Showing
48 changed files
with
917 additions
and
306 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
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
29 changes: 4 additions & 25 deletions
29
...rvice/server/src/main/scala/org/hyperledger/identus/api/http/codec/CirceJsonInterop.scala
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,36 +1,15 @@ | ||
package org.hyperledger.identus.api.http.codec | ||
|
||
import io.circe.Json as CirceJson | ||
import org.hyperledger.identus.shared.json.JsonInterop | ||
import sttp.tapir.json.zio.* | ||
import sttp.tapir.Schema | ||
import zio.json.* | ||
import zio.json.ast.Json as ZioJson | ||
|
||
object CirceJsonInterop { | ||
|
||
private def toZioJsonAst(circeJson: CirceJson): ZioJson = { | ||
val encoded = circeJson.noSpaces | ||
encoded.fromJson[ZioJson] match { | ||
case Left(failure) => | ||
throw Exception(s"Circe and Zio Json interop fail. Unable to convert from Circe to Zio AST. $failure") | ||
case Right(value) => value | ||
} | ||
} | ||
|
||
private def toCirceJsonAst(zioJson: ZioJson): CirceJson = { | ||
val encoded = zioJson.toJson | ||
io.circe.parser.parse(encoded).left.map(_.toString) match { | ||
case Left(failure) => | ||
throw Exception(s"Circe and Zio Json interop fail. Unable to convert from Zio to Circe AST. $failure") | ||
case Right(value) => value | ||
} | ||
} | ||
|
||
given encodeJson: JsonEncoder[CirceJson] = JsonEncoder[ZioJson].contramap(toZioJsonAst) | ||
|
||
given decodeJson: JsonDecoder[CirceJson] = JsonDecoder[ZioJson].map(toCirceJsonAst) | ||
|
||
given encodeJson: JsonEncoder[CirceJson] = JsonEncoder[ZioJson].contramap(JsonInterop.toZioJsonAst) | ||
given decodeJson: JsonDecoder[CirceJson] = JsonDecoder[ZioJson].map(JsonInterop.toCirceJsonAst) | ||
given schemaJson: Schema[CirceJson] = | ||
Schema.derived[ZioJson].map[CirceJson](js => Some(toCirceJsonAst(js)))(toZioJsonAst) | ||
|
||
Schema.derived[ZioJson].map[CirceJson](js => Some(JsonInterop.toCirceJsonAst(js)))(JsonInterop.toZioJsonAst) | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...rc/main/scala/org/hyperledger/identus/pollux/core/model/error/CredentialSchemaError.scala
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
...re/src/main/scala/org/hyperledger/identus/pollux/core/model/error/PresentationError.scala
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
2 changes: 1 addition & 1 deletion
2
.../org/hyperledger/identus/pollux/core/model/schema/type/CredentialJsonSchemaSerDesV1.scala
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
...cala/org/hyperledger/identus/pollux/core/model/schema/type/CredentialJsonSchemaType.scala
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
...in/scala/org/hyperledger/identus/pollux/core/model/schema/type/CredentialSchemaType.scala
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
...g/hyperledger/identus/pollux/core/model/schema/type/anoncred/AnoncredSchemaSerDesV1.scala
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
17 changes: 0 additions & 17 deletions
17
...in/scala/org/hyperledger/identus/pollux/core/model/schema/validator/JsonSchemaError.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.