From 0c79487a483a5cdb4eee33846dad7dfd4b57c48e Mon Sep 17 00:00:00 2001 From: yshyn-iohk Date: Wed, 30 Nov 2022 22:08:52 +0800 Subject: [PATCH] feat(pollux): alight the OAS for schema registry --- .../service/api/http/pollux/schemas.yaml | 183 ++++++++---------- .../api/http/prism-agent-openapi-spec.yaml | 172 ++++++++++------ prism-agent/service/build.sbt | 1 + .../atala/agent/server/MainInMemory.scala | 17 ++ .../server/http/marshaller/JsonSupport.scala | 8 - .../schema/SchemaRegistryEndpoints.scala | 15 +- .../schema/VerificationPolicyEndpoints.scala | 6 +- .../model/VerifiableCredentialSchema.scala | 70 ++++--- .../service/SchemaRegistryService.scala | 18 +- .../SchemaRegistryServiceInMemory.scala | 12 +- .../schema/SchemaRegistryEndpointsSpec.scala | 4 +- 11 files changed, 280 insertions(+), 226 deletions(-) create mode 100644 prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/MainInMemory.scala diff --git a/prism-agent/service/api/http/pollux/schemas.yaml b/prism-agent/service/api/http/pollux/schemas.yaml index d48f05427f..53bde9c7c9 100644 --- a/prism-agent/service/api/http/pollux/schemas.yaml +++ b/prism-agent/service/api/http/pollux/schemas.yaml @@ -1,148 +1,129 @@ components: schemas: - W3CProof: - description: "Proof object implemented according https://w3c.github.io/vc-data-integrity/ specification" - externalDocs: - url: "https://w3c.github.io/vc-data-integrity/" +# Common + InternalServerError: required: - ["type", "created", "verificationMethod", "proofPurpose", "proofValue"] + - msg + type: object + properties: + msg: + type: string + + NotFoundResponse: + required: + - msg + type: object + properties: + msg: + type: string + +# Schema Registry + + Proof: + required: + - type + - created + - verificationMethod + - proofPurpose + - proofValue + type: object properties: type: type: string - description: "The specific proof type used. For example, an Ed25519Signature2020 type indicates that the proof includes a digital signature produced by an ed25519 cryptographic key." - example: "JcsSignature2020" created: type: string - description: "The string value of an [ISO8601] combined date and time string generated by the Proof Algorithm" - example: "2020-11-05T19:23:24Z" + format: date-time verificationMethod: type: string - description: "A set of parameters required to independently verify the proof, such as an identifier for a public/private key pair that would be used in the proof." - example: "https://di.example/issuer#z6MkjLrk3gKS2nnkeWcmcxiZPGskmesDpuwRBorgHxUXfxnG" proofPurpose: type: string - description: "The specific intent for the proof, the reason why an entity created it. Acts as a safeguard to prevent the proof from being misused for a purpose other than the one it was intended for. For example, a proof can be used for purposes of authentication, for asserting control of a Verifiable Credential (assertionMethod), and several others." - example: "assertionMethod" proofValue: type: string - description: "One of any number of valid representations of proof value generated by the Proof Algorithm." - example: "zQeVbY4oey5q2M3XKaxup3tmzN4DRFTLVqpLMweBrSxMY2xHX5XTYV8nQApmEcqaqA3Q1gVHMrXFkXJeV6doDwLWx" domain: type: string - description: "A string value specifying the restricted domain of the proof." - W3CSchemaInput: - description: SchemaInput object with the metadata and claims - required: ["name", "version", "claims"] + VerifiableCredentialSchema: + required: + - id + - name + - version + - author + - authored + type: object properties: + id: + type: string + format: uuid name: type: string - description: Human friendly name of the schema - example: UniversityDegree version: type: string - description: SemVer of the schema - example: "1.0" + tags: + type: array + items: + type: string description: type: string - description: Schema description attributes: - type: "array" - description: List of attributes + type: array items: - type: "string" - example: - - first_name - - last_name - - date_of_birth + type: string + author: + type: string + authored: + type: string + format: date-time + proof: + $ref: '#/components/schemas/Proof' - W3CSchemaMeta: - description: Schema metadata + VerifiableCredentialSchemaPage: + required: + - self + - kind + - pageOf + type: object properties: - type: - type: string #should be URI - description: The URI of the schema - example: "https://w3c-ccg.github.io/vc-json-schemas/schema/2.0/schema.json" - version: + self: type: string - description: Semantic version of the schema - example: "1.0" - id: + kind: type: string - description: Globally unique identifier of the schema (composed of issuer did, schema id and version) - example: "did:example:MDP8AsFhHzhwUvGNuYkX7T;id=06e126d1-fa44-4882-a243-1e326fbe21db;version=1.0" - name: + pageOf: type: string - description: Human readable schema name - example: "UniversityDegree" - author: + next: type: string - description: Issuer DID - example: "did:example:MDP8AsFhHzhwUvGNuYkX7T" - authored: + previous: type: string - description: Datetime of the schema issuance in ISO format - example: "2021-01-01T00:00:00+00:00" + contents: + type: array + items: + $ref: '#/components/schemas/VerifiableCredentialSchema' - W3CSchemaClaims: - description: Verifiable Credentials Schema Claims + VerificationCredentialSchemaInput: + required: + - name + - version + type: object properties: - $schema: + id: type: string - description: "Schema reference that can be used for validation" - example: "https://json-schema.org/draft/2019-09/schema" - $id: + format: uuid + name: type: string - description: UID of this Schema - example: "06e126d1-fa44-4882-a243-1e326fbe21db" - description: + version: type: string - description: "Schema description" - type: + description: type: string - description: "OpenAPI specification field that describes the object declaration" - example: "object" - properties: - type: object - description: "Set of clames" - additionalProperties: false - properties: - claim1: - type: string - description: "Some example claim" - required: + attributes: type: array items: type: string - description: "Defines the set of required claims" - additionalProperties: - type: boolean - description: "Restrict the claims set to have additional attributes" - - W3CSchema: - description: "W3C Json format of the verifiable credentials schema according to VC Data Model" - allOf: - - $ref: "#/components/schemas/W3CSchemaMeta" - - type: object - properties: - schema: - $ref: "#/components/schemas/W3CSchemaClaims" - proof: - $ref: "#/components/schemas/W3CProof" - - W3CSchemaPaginated: - description: "Paginated response that contains an array of the schema objects" - properties: - data: + authored: + type: string + format: date-time + tags: type: array items: - $ref: "#/components/schemas/W3CSchema" - offset: - type: integer - limit: - type: integer - count: - type: integer + type: string # Issue Credential Protocol diff --git a/prism-agent/service/api/http/prism-agent-openapi-spec.yaml b/prism-agent/service/api/http/prism-agent-openapi-spec.yaml index e14c4241de..3f91d435d9 100644 --- a/prism-agent/service/api/http/prism-agent-openapi-spec.yaml +++ b/prism-agent/service/api/http/prism-agent-openapi-spec.yaml @@ -365,93 +365,139 @@ paths: # Pollux # ---------------------------------- /schema-registry/schemas: - post: - tags: [ "Schema Registry" ] - operationId: createSchema - summary: Publish new schema to the schema registry - description: |- - Publish the new schema with claims to the schema registry on behalf of Cloud Agent - Schema will be signed by the keys of Cloud Agent and issued by the DID that corresponds to it - requestBody: - description: SchemaInput object with the metadata and claims - required: true - content: - application/json: - schema: - $ref: "./pollux/schemas.yaml#/components/schemas/W3CSchemaInput" - responses: - "201": - description: The new schema is created - content: - application/json: - schema: - $ref: "./pollux/schemas.yaml#/components/schemas/W3CSchema" - "400": - description: Schema input document cannot be used for the schema creation - "401": - description: Client is unauthorized to call the API get: - tags: [ "Schema Registry" ] - operationId: fetchSchemasByQuery - summary: Fetch schemas by query - description: |- - Lookup the schemas in the registry to query by the author, version, name + tags: + - Schema Registry + summary: Lookup schemas by indexed fields + description: 'Lookup schemas by `author`, `name`, `tags` parameters and control + the pagination by `offset` and `limit` parameters ' + operationId: lookupSchemasByQuery parameters: - - in: query - name: author - description: Fetch schemas by the author (issuer) DID - example: "did:prism:abcdefg" + - name: author + in: query + required: false schema: type: string - - in: query - name: name - description: Fetch schemas by the name - example: UniversityDegree + - name: name + in: query + required: false schema: type: string - - in: query - name: offset - description: Pagination offset - example: 15 + - name: tags + in: query + required: false + schema: + type: string + - name: offset + in: query + required: false schema: type: integer - - in: query - name: limit - description: Pagination limit - example: 100 + format: int32 + - name: limit + in: query + required: false schema: type: integer + format: int32 + - name: order + in: query + required: false + schema: + type: string responses: - "200": - description: Schemas are fetched by the query + '200': + description: '' content: application/json: schema: - $ref: "./pollux/schemas.yaml#/components/schemas/W3CSchemaPaginated" + $ref: ./pollux/schemas.yaml#/components/schemas/VerifiableCredentialSchemaPage + '400': + description: 'Invalid value for: query parameter author, Invalid value for: + query parameter name, Invalid value for: query parameter tags, Invalid + value for: query parameter offset, Invalid value for: query parameter + limit, Invalid value for: query parameter order' + content: + text/plain: + schema: + type: string + '500': + description: '' + content: + application/json: + schema: + $ref: ./pollux/schemas.yaml#/components/schemas/InternalServerError + post: + tags: + - Schema Registry + summary: Publish new schema to the schema registry + description: Publish the new schema with attributes to the schema registry on + behalf of Cloud Agent. Schema will be signed by the keys of Cloud Agent and + issued by the DID that corresponds to it + operationId: createSchema + requestBody: + description: Create schema input object with the metadata and attributes + content: + application/json: + schema: + $ref: ./pollux/schemas.yaml#/components/schemas/VerificationCredentialSchemaInput + required: true + responses: + '201': + description: '' + content: + application/json: + schema: + $ref: ./pollux/schemas.yaml#/components/schemas/VerifiableCredentialSchema + '400': + description: 'Invalid value for: body' + content: + text/plain: + schema: + type: string + '500': + description: '' + content: + application/json: + schema: + $ref: ./pollux/schemas.yaml#/components/schemas/InternalServerError /schema-registry/schemas/{id}: get: - tags: [ "Schema Registry" ] - operationId: getSchemaById + tags: + - Schema Registry summary: Fetch the schema from the registry by id - description: |- - Fetch the schema by the unique identifier. Verifiable Credential Schema in json format is returned + description: Fetch the schema by the unique identifier. Verifiable Credential + Schema in json format is returned. + operationId: getSchemaById parameters: - - in: path - name: id + - name: id + in: path + description: Get the schema by id + required: true schema: type: string - required: true - description: Unique identifier of the schema published in the registry - example: "did:example:MDP8AsFhHzhwUvGNuYkX7T;id=06e126d1-fa44-4882-a243-1e326fbe21db;version=1.0" + format: uuid responses: - "200": - description: Successful response, W3C compliant schema is returned + '200': + description: '' content: application/json: schema: - $ref: "./pollux/schemas.yaml#/components/schemas/W3CSchema" - "404": - description: Schema is not found by id + $ref: ./pollux/schemas.yaml#/components/schemas/VerifiableCredentialSchema + '400': + description: 'Invalid value for: path parameter id' + content: + text/plain: + schema: + type: string + '404': + description: '' + content: + application/json: + schema: + $ref: ./pollux/schemas.yaml#/components/schemas/NotFoundResponse + + ## Issue Credential Protocol /issue-credentials/credential-offers: diff --git a/prism-agent/service/build.sbt b/prism-agent/service/build.sbt index 9d5847cca7..47cb457245 100644 --- a/prism-agent/service/build.sbt +++ b/prism-agent/service/build.sbt @@ -49,6 +49,7 @@ lazy val server = project name := "prism-agent", fork := true, libraryDependencies ++= serverDependencies, + Compile / mainClass := Some("io.iohk.atala.agent.server.Main"), // OpenAPI settings Compile / unmanagedResourceDirectories += apiBaseDirectory.value, Compile / sourceGenerators += openApiGenerateClasses, diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/MainInMemory.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/MainInMemory.scala new file mode 100644 index 0000000000..034aee2dd8 --- /dev/null +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/MainInMemory.scala @@ -0,0 +1,17 @@ +package io.iohk.atala.agent.server + +import io.iohk.atala.agent.server.Modules +import io.iohk.atala.mercury.* +import io.iohk.atala.resolvers.UniversalDidResolver +import org.didcommx.didcomm.DIDComm +import zio.* + +object MainInMemory extends ZIOAppDefault { + + override def run: ZIO[Any, Throwable, Unit] = + for { + _ <- Modules.zioApp.fork + _ <- ZIO.never + } yield () + +} diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/http/marshaller/JsonSupport.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/http/marshaller/JsonSupport.scala index e900abaa78..d8f2b5bfdc 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/http/marshaller/JsonSupport.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/http/marshaller/JsonSupport.scala @@ -84,14 +84,6 @@ trait JsonSupport extends SprayJsonSupport with DefaultJsonProtocol { given RootJsonFormat[W3CPresentation] = jsonFormat1(W3CPresentation.apply) given RootJsonFormat[W3CPresentationInput] = jsonFormat1(W3CPresentationInput.apply) given RootJsonFormat[W3CPresentationPaginated] = jsonFormat4(W3CPresentationPaginated.apply) - given RootJsonFormat[W3CProof] = jsonFormat6(W3CProof.apply) - given RootJsonFormat[W3CSchema] = jsonFormat8(W3CSchema.apply) - given RootJsonFormat[W3CSchemaAllOf] = jsonFormat2(W3CSchemaAllOf.apply) - given RootJsonFormat[W3CSchemaClaims] = jsonFormat7(W3CSchemaClaims.apply) - given RootJsonFormat[W3CSchemaClaimsProperties] = jsonFormat1(W3CSchemaClaimsProperties.apply) - given RootJsonFormat[W3CSchemaInput] = jsonFormat4(W3CSchemaInput.apply) - given RootJsonFormat[W3CSchemaMeta] = jsonFormat6(W3CSchemaMeta.apply) - given RootJsonFormat[W3CSchemaPaginated] = jsonFormat4(W3CSchemaPaginated.apply) // Connections Management given RootJsonFormat[CreateConnectionRequest] = jsonFormat1(CreateConnectionRequest.apply) diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/SchemaRegistryEndpoints.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/SchemaRegistryEndpoints.scala index 0e1ae8c2c3..2b2e09877d 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/SchemaRegistryEndpoints.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/SchemaRegistryEndpoints.scala @@ -2,8 +2,11 @@ package io.iohk.atala.pollux.schema import io.iohk.atala.api.http.model.{Order, Pagination} import io.iohk.atala.api.http.{BadRequest, FailureResponse, InternalServerError, NotFoundResponse} -import io.iohk.atala.pollux.schema.model.VerifiableCredentialSchema -import io.iohk.atala.pollux.schema.model.VerifiableCredentialSchema.{Input, Page} +import io.iohk.atala.pollux.schema.model.{ + VerifiableCredentialSchema, + VerificationCredentialSchemaInput, + VerifiableCredentialSchemaPage +} import io.iohk.atala.api.http.codec.OrderCodec._ import sttp.tapir.EndpointIO.Info import sttp.tapir.json.zio.jsonBody @@ -28,7 +31,7 @@ import java.util.UUID object SchemaRegistryEndpoints { val createSchemaEndpoint: PublicEndpoint[ - VerifiableCredentialSchema.Input, + VerificationCredentialSchemaInput, FailureResponse, VerifiableCredentialSchema, Any @@ -36,7 +39,7 @@ object SchemaRegistryEndpoints { endpoint.post .in("schema-registry" / "schemas") .in( - jsonBody[VerifiableCredentialSchema.Input] + jsonBody[VerificationCredentialSchemaInput] .copy(info = Info.empty.description( "Create schema input object with the metadata and attributes" @@ -87,7 +90,7 @@ object SchemaRegistryEndpoints { val lookupSchemasByQueryEndpoint: PublicEndpoint[ (VerifiableCredentialSchema.Filter, Pagination, Option[Order]), FailureResponse, - VerifiableCredentialSchema.Page, + VerifiableCredentialSchemaPage, Any ] = endpoint.get @@ -108,7 +111,7 @@ object SchemaRegistryEndpoints { .mapTo[Pagination] ) .in(query[Option[Order]]("order")) - .out(jsonBody[VerifiableCredentialSchema.Page]) + .out(jsonBody[VerifiableCredentialSchemaPage]) .errorOut( oneOf[FailureResponse]( oneOfVariant( diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/VerificationPolicyEndpoints.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/VerificationPolicyEndpoints.scala index e822018899..a9e5e63529 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/VerificationPolicyEndpoints.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/VerificationPolicyEndpoints.scala @@ -3,7 +3,11 @@ package io.iohk.atala.pollux.schema import io.iohk.atala.api.http.codec.OrderCodec.* import io.iohk.atala.api.http.model.{Order, Pagination} import io.iohk.atala.api.http.{BadRequest, FailureResponse, InternalServerError, NotFoundResponse} -import io.iohk.atala.pollux.schema.model.VerifiableCredentialSchema.{Input, Page} +import io.iohk.atala.pollux.schema.model.{ + VerifiableCredentialSchema, + VerificationCredentialSchemaInput, + VerifiableCredentialSchemaPage +} import io.iohk.atala.pollux.schema.model.{ VerifiableCredentialSchema, VerificationPolicy, diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/model/VerifiableCredentialSchema.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/model/VerifiableCredentialSchema.scala index 551bef16b7..2e15728f40 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/model/VerifiableCredentialSchema.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/schema/model/VerifiableCredentialSchema.scala @@ -20,7 +20,7 @@ case class VerifiableCredentialSchema( ) object VerifiableCredentialSchema { - def apply(in: VerifiableCredentialSchema.Input): VerifiableCredentialSchema = + def apply(in: VerificationCredentialSchemaInput): VerifiableCredentialSchema = VerifiableCredentialSchema( id = in.id.getOrElse(UUID.randomUUID()), name = in.name, @@ -35,32 +35,10 @@ object VerifiableCredentialSchema { given encoder: zio.json.JsonEncoder[VerifiableCredentialSchema] = DeriveJsonEncoder.gen[VerifiableCredentialSchema] - given decoder: zio.json.JsonDecoder[VerifiableCredentialSchema] = DeriveJsonDecoder.gen[VerifiableCredentialSchema] - given schema: Schema[VerifiableCredentialSchema] = Schema.derived - case class Input( - id: Option[UUID], - name: String, - version: String, - description: Option[String], - attributes: List[String], - authored: Option[ZonedDateTime], - tags: List[String] - ) - - object Input { - given encoder: zio.json.JsonEncoder[Input] = - DeriveJsonEncoder.gen[Input] - - given decoder: zio.json.JsonDecoder[Input] = - DeriveJsonDecoder.gen[Input] - - given schema: Schema[Input] = Schema.derived - } - case class Filter( author: Option[String], name: Option[String], @@ -71,19 +49,39 @@ object VerifiableCredentialSchema { author.forall(_ == vcs.author) && tags.map(_.split(',')).forall(vcs.tags.intersect(_).nonEmpty) } +} + +case class VerificationCredentialSchemaInput( + id: Option[UUID], + name: String, + version: String, + description: Option[String], + attributes: List[String], + authored: Option[ZonedDateTime], + tags: List[String] +) - case class Page( - self: String, - kind: String, - pageOf: String, - next: Option[String], - previous: Option[String], - contents: List[VerifiableCredentialSchema] - ) +object VerificationCredentialSchemaInput { + given encoder: zio.json.JsonEncoder[VerificationCredentialSchemaInput] = + DeriveJsonEncoder.gen[VerificationCredentialSchemaInput] + given decoder: zio.json.JsonDecoder[VerificationCredentialSchemaInput] = + DeriveJsonDecoder.gen[VerificationCredentialSchemaInput] + given schema: Schema[VerificationCredentialSchemaInput] = Schema.derived +} - object Page { - given encoder: zio.json.JsonEncoder[Page] = DeriveJsonEncoder.gen[Page] - given decoder: zio.json.JsonDecoder[Page] = DeriveJsonDecoder.gen[Page] - given schema: sttp.tapir.Schema[Page] = Schema.derived - } +case class VerifiableCredentialSchemaPage( + self: String, + kind: String, + pageOf: String, + next: Option[String], + previous: Option[String], + contents: List[VerifiableCredentialSchema] +) + +object VerifiableCredentialSchemaPage { + given encoder: zio.json.JsonEncoder[VerifiableCredentialSchemaPage] = + DeriveJsonEncoder.gen[VerifiableCredentialSchemaPage] + given decoder: zio.json.JsonDecoder[VerifiableCredentialSchemaPage] = + DeriveJsonDecoder.gen[VerifiableCredentialSchemaPage] + given schema: sttp.tapir.Schema[VerifiableCredentialSchemaPage] = Schema.derived } diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/service/SchemaRegistryService.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/service/SchemaRegistryService.scala index 72b7d11656..71ea098082 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/service/SchemaRegistryService.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/service/SchemaRegistryService.scala @@ -2,13 +2,17 @@ package io.iohk.atala.pollux.service import io.iohk.atala.api.http.model.{Order, Pagination} import zio.{Task, ZIO, ZLayer} -import io.iohk.atala.pollux.schema.model.VerifiableCredentialSchema +import io.iohk.atala.pollux.schema.model.{ + VerifiableCredentialSchema, + VerifiableCredentialSchemaPage, + VerificationCredentialSchemaInput +} import java.util.UUID trait SchemaRegistryService { def createSchema( - in: VerifiableCredentialSchema.Input + in: VerificationCredentialSchemaInput ): Task[VerifiableCredentialSchema] def getSchemaById(id: UUID): Task[Option[VerifiableCredentialSchema]] @@ -16,12 +20,12 @@ trait SchemaRegistryService { filter: VerifiableCredentialSchema.Filter, pagination: Pagination, order: Option[Order] - ): Task[VerifiableCredentialSchema.Page] + ): Task[VerifiableCredentialSchemaPage] } object SchemaRegistryService { def createSchema( - in: VerifiableCredentialSchema.Input + in: VerificationCredentialSchemaInput ): ZIO[SchemaRegistryService, Throwable, VerifiableCredentialSchema] = ZIO.serviceWithZIO[SchemaRegistryService](_.createSchema(in)) @@ -34,7 +38,11 @@ object SchemaRegistryService { filter: VerifiableCredentialSchema.Filter, pagination: Pagination, order: Option[Order] - ): ZIO[SchemaRegistryService, Throwable, VerifiableCredentialSchema.Page] = + ): ZIO[ + SchemaRegistryService, + Throwable, + VerifiableCredentialSchemaPage + ] = ZIO.serviceWithZIO[SchemaRegistryService]( _.lookupSchemas(filter, pagination, order) ) diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/service/SchemaRegistryServiceInMemory.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/service/SchemaRegistryServiceInMemory.scala index 1a3fb92540..fdb2b8af15 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/service/SchemaRegistryServiceInMemory.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/pollux/service/SchemaRegistryServiceInMemory.scala @@ -1,7 +1,11 @@ package io.iohk.atala.pollux.service import io.iohk.atala.api.http.model.{Order, Pagination} -import io.iohk.atala.pollux.schema.model.VerifiableCredentialSchema +import io.iohk.atala.pollux.schema.model.{ + VerifiableCredentialSchema, + VerificationCredentialSchemaInput, + VerifiableCredentialSchemaPage +} import zio.{Ref, Task, UIO, ZIO, ZLayer} import java.util.UUID @@ -14,7 +18,7 @@ class SchemaRegistryServiceInMemory( // TODO: Figure out what is the logic for trying to overwrite the schema with the same id (409 Conflict) // TODO: Other validations (same [schema_name, version], list of the attributes is not empty, etc) override def createSchema( - in: VerifiableCredentialSchema.Input + in: VerificationCredentialSchemaInput ): Task[VerifiableCredentialSchema] = { val schema = VerifiableCredentialSchema(in) for { @@ -36,7 +40,7 @@ class SchemaRegistryServiceInMemory( filter: VerifiableCredentialSchema.Filter, pagination: Pagination, order: Option[Order] - ): Task[VerifiableCredentialSchema.Page] = { + ): Task[VerifiableCredentialSchemaPage] = { for { storage: Map[UUID, VerifiableCredentialSchema] <- ref.get filtered = storage.values.filter(filter.predicate) @@ -45,7 +49,7 @@ class SchemaRegistryServiceInMemory( pagination.offset.getOrElse(0), pagination.offset.getOrElse(0) + pagination.limit.getOrElse(10) ) - } yield VerifiableCredentialSchema.Page( + } yield VerifiableCredentialSchemaPage( self = "sss", kind = "VerifiableCredentialSchema", pageOf = "ppp", diff --git a/prism-agent/service/server/src/test/scala/io/iohk/atala/pollux/schema/SchemaRegistryEndpointsSpec.scala b/prism-agent/service/server/src/test/scala/io/iohk/atala/pollux/schema/SchemaRegistryEndpointsSpec.scala index 3099a6d834..5c4687dc9e 100644 --- a/prism-agent/service/server/src/test/scala/io/iohk/atala/pollux/schema/SchemaRegistryEndpointsSpec.scala +++ b/prism-agent/service/server/src/test/scala/io/iohk/atala/pollux/schema/SchemaRegistryEndpointsSpec.scala @@ -12,7 +12,7 @@ import zio.ZIO import zio.test.Assertion.* import zio.test.{Assertion, ZIOSpecDefault, assertZIO} import io.iohk.atala.pollux.schema.* -import io.iohk.atala.pollux.schema.model.VerifiableCredentialSchema +import io.iohk.atala.pollux.schema.model.{VerifiableCredentialSchema, VerificationCredentialSchemaInput} import io.iohk.atala.pollux.service.SchemaRegistryServiceInMemory import sttp.model.StatusCode import zio.ZLayer @@ -25,7 +25,7 @@ object SchemaRegistryEndpointsSpec extends ZIOSpecDefault: private val schemaId = UUID.randomUUID() - private val schemaInput = VerifiableCredentialSchema.Input( + private val schemaInput = VerificationCredentialSchemaInput( Option(schemaId), name = "test schema", version = "1.0",