• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / atala-prism-building-blocks / 7295755663

22 Dec 2023 03:08AM UTC coverage: 30.564% (-0.5%) from 31.05%
7295755663

Pull #829

web-flow
Merge branch 'epic/ATL-4095-revocation-for-jwt-creds' into ATL-6136-get-credential-status-list-cred-endpoint
Pull Request #829: feat(pollux): Implement endpoint that returns status list credential

1 of 92 new or added lines in 10 files covered. (1.09%)

376 existing lines in 112 files now uncovered.

4061 of 13287 relevant lines covered (30.56%)

0.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.0
/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/schema/validator/SchemaSerDes.scala
1
package io.iohk.atala.pollux.core.model.schema.validator
2

3
import com.networknt.schema.JsonSchema
4
import io.iohk.atala.pollux.core.model.schema.validator.JsonSchemaError.*
5
import zio.IO
6
import zio.ZIO
7
import zio.json.*
8
import zio.json.JsonDecoder
9
import zio.json.ast.Json
10
import zio.json.ast.Json.*
11

12
class SchemaSerDes[S](jsonSchemaSchemaStr: String) {
13

1✔
14
  def initialiseJsonSchema: IO[JsonSchemaError, JsonSchema] =
1✔
15
    JsonSchemaUtils.jsonSchema(jsonSchemaSchemaStr)
16

1✔
17
  def deserialize(
18
      schema: zio.json.ast.Json
19
  )(using decoder: JsonDecoder[S]): IO[JsonSchemaError, S] = {
1✔
20
    deserialize(schema.toString())
21
  }
22

1✔
23
  def deserialize(
24
      jsonString: String
25
  )(using decoder: JsonDecoder[S]): IO[JsonSchemaError, S] = {
1✔
26
    for {
1✔
27
      _ <- validate(jsonString)
1✔
28
      anoncredSchema <-
×
29
        ZIO
×
30
          .fromEither(decoder.decodeJson(jsonString))
31
          .mapError(JsonSchemaError.JsonSchemaParsingError.apply)
32
    } yield anoncredSchema
33
  }
34

1✔
35
  def deserializeAsJson(jsonString: String): IO[JsonSchemaError, Json] = {
1✔
36
    for {
×
37
      _ <- validate(jsonString)
1✔
38
      json <-
×
39
        ZIO
×
40
          .fromEither(jsonString.fromJson[Json])
41
          .mapError(JsonSchemaError.JsonSchemaParsingError.apply)
42
    } yield json
43
  }
44

1✔
45
  def validate(jsonString: String): IO[JsonSchemaError, Boolean] = {
1✔
46
    for {
×
47
      jsonSchemaSchema <- JsonSchemaUtils.jsonSchema(jsonSchemaSchemaStr)
UNCOV
48
      schemaValidator = JsonSchemaValidatorImpl(jsonSchemaSchema)
×
49
      _ <- schemaValidator.validate(jsonString)
50
    } yield true
51
  }
52

53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc