Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Move schema endpoits to core API #694

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 158 additions & 2 deletions api/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ paths:
'500':
$ref: '#/components/responses/500'

#claims:
/v1/{identifier}/claims:
post:
summary: Create Claim (Deprecated)
Expand Down Expand Up @@ -562,7 +561,6 @@ paths:
'500':
$ref: '#/components/responses/500'


/v1/{identifier}/claims/revoke/{nonce}:
post:
summary: Revoke Claim (Deprecated)
Expand Down Expand Up @@ -748,6 +746,84 @@ paths:
'500':
$ref: '#/components/responses/500'

#schemas:
/v1/schemas:
post:
summary: Import JSON schema
operationId: ImportSchema
security:
- basicAuth: [ ]
tags:
- Schemas
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ImportSchemaRequest'
responses:
'201':
description: Schema imported
content:
application/json:
schema:
$ref: '#/components/schemas/UUIDResponse'
'400':
$ref: '#/components/responses/400'
'500':
$ref: '#/components/responses/500'
get:
summary: Get Schemas
operationId: GetSchemas
security:
- basicAuth: [ ]
tags:
- Schemas
parameters:
- in: query
name: query
schema:
type: string
description: Query string to do full text search in schema types and attributes.
responses:
'200':
description: Schema collection
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Schema'
'400':
$ref: '#/components/responses/400'
'500':
$ref: '#/components/responses/500'

/v1/schemas/{id}:
get:
summary: Get Schema
operationId: GetSchema
security:
- basicAuth: [ ]
tags:
- Schemas
parameters:
- $ref: '#/components/parameters/id'
responses:
'200':
description: Schema information
content:
application/json:
schema:
$ref: '#/components/schemas/Schema'
'400':
$ref: '#/components/responses/400'
'404':
$ref: '#/components/responses/404'
'500':
$ref: '#/components/responses/500'


components:
securitySchemes:
basicAuth:
Expand Down Expand Up @@ -781,6 +857,16 @@ components:
x-omitempty: false
example: b7144f1c-d54e-4f67-a4f1-f2e7ff1beb07

UUIDResponse:
type: object
required:
- id
properties:
id:
type: string
x-omitempty: false
example: c79c9c04-8c98-40f2-a7a0-5eeabf08d836

GenericErrorMessage:
type: object
required:
Expand Down Expand Up @@ -921,6 +1007,76 @@ components:
enum:
- "Iden3RefreshService2023"

ImportSchemaRequest:
type: object
required:
- url
- schemaType
- version
properties:
url:
type: string
example: "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/KYCAgeCredential-v3.json"
schemaType:
type: string
example: "vaccinationCertificate"
title:
type: string
example: "KYC Age Credential"
description:
type: string
example: "KYC Age Credential description"
version:
type: string
example: "1.0.0"

Schema:
type: object
required:
- id
- hash
- bigInt
- url
- type
- createdAt
- version
properties:
id:
type: string
x-omitempty: false
example: c79c9c04-8c98-40f2-a7a0-5eeabf08d836
hash:
type: string
x-omitempty: false
example: 18f30714a35a5db88ca24728c0c53dfd
bigInt:
type: string
x-omitempty: false
example: "336615423900919464193075592850483704600"
url:
type: string
x-omitempty: false
example: https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/KYCAgeCredential-v3.json
type:
type: string
x-omitempty: false
example: KYCCountryOfResidenceCredential
createdAt:
$ref: '#/components/schemas/TimeUTC'
x-omitempty: false
title:
type: string
x-omitempty: false
example: "KYC Age Credential"
description:
type: string
x-omitempty: false
example: "KYC Age Credential description"
version:
type: string
x-omitempty: false
example: "1.0.0"

# display method
DisplayMethod:
type: object
Expand Down
1 change: 0 additions & 1 deletion api_ui/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,6 @@ components:
items:
$ref: '#/components/schemas/KeyValue'


ImportSchemaRequest:
type: object
required:
Expand Down
11 changes: 8 additions & 3 deletions cmd/platform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func main() {
mtRepository := repositories.NewIdentityMerkleTreeRepository()
identityStateRepository := repositories.NewIdentityState()
revocationRepository := repositories.NewRevocation()
schemaRepository := repositories.NewSchema(*storage)

// services initialization
mtService := services.NewIdentityMerkleTrees(mtRepository)
Expand All @@ -154,6 +155,7 @@ func main() {
identityService := services.NewIdentity(keyStore, identityRepository, mtRepository, identityStateRepository, mtService, qrService, claimsRepository, revocationRepository, nil, storage, nil, nil, ps, *networkResolver, rhsFactory, revocationStatusResolver)
claimsService := services.NewClaim(claimsRepository, identityService, qrService, mtService, identityStateRepository, schemaLoader, storage, cfg.ServerUrl, ps, cfg.IPFS.GatewayURL, revocationStatusResolver, mediaTypeManager)
proofService := gateways.NewProver(ctx, cfg, circuitsLoaderService)
schemaService := services.NewSchema(schemaRepository, schemaLoader)

transactionService, err := gateways.NewTransaction(*networkResolver)
if err != nil {
Expand Down Expand Up @@ -191,15 +193,18 @@ func main() {
cors.Handler(cors.Options{AllowedOrigins: []string{"*"}}),
chiMiddleware.NoCache,
)
api.HandlerFromMux(
api.HandlerWithOptions(
api.NewStrictHandlerWithOptions(
api.NewServer(cfg, identityService, accountService, connectionsService, claimsService, qrService, publisher, packageManager, *networkResolver, serverHealth),
api.NewServer(cfg, identityService, accountService, connectionsService, claimsService, qrService, publisher, packageManager, *networkResolver, serverHealth, schemaService),
middlewares(ctx, cfg.HTTPBasicAuth),
api.StrictHTTPServerOptions{
RequestErrorHandlerFunc: errors.RequestErrorHandlerFunc,
ResponseErrorHandlerFunc: errors.ResponseErrorHandlerFunc,
}),
mux)
api.ChiServerOptions{
BaseRouter: mux,
ErrorHandlerFunc: api.ErrorHandlerFunc,
})
api.RegisterStatic(mux)

server := &http.Server{
Expand Down
Loading
Loading