Skip to content

Commit

Permalink
added some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsmkl committed Aug 24, 2022
1 parent fd5ec9f commit b800223
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/openapi.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"openapi":"3.0.0","paths":{"/":{"get":{"operationId":"InfoController_getInfo","summary":"Public","description":"Get API info","parameters":[],"responses":{"200":{"description":"Return API Info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetInfoDto"}}}}},"tags":["Info"]}},"/api/v1/gateway/services/encrypt":{"post":{"operationId":"EncryptController_doEncrypt","summary":"Public","description":"Encrypt","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EncryptDto"}}}},"responses":{"200":{"description":"Return encrypted stuff","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EncryptResult"}}}}},"tags":["Encrypt"]}},"/api/v1/gateway/services/access/{agreement_id}/{index}":{"get":{"operationId":"AccessController_doAccess","summary":"Public","description":"Access asset","parameters":[{"name":"index","required":true,"in":"path","schema":{"type":"number"}}],"responses":{"200":{"description":"Return the url of asset","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessResult"}}}}},"tags":["Access"],"security":[{"Authorization":[]}]}},"/api/v1/gateway/services/access-proof/{agreement_id}/{index}":{"get":{"operationId":"AccessController_doAccessProof","summary":"Public","description":"Access asset w/ DTP proof","parameters":[{"name":"index","required":true,"in":"path","schema":{"type":"number"}}],"responses":{"200":{"description":"Return the url of asset","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessResult"}}}}},"tags":["Access"],"security":[{"Authorization":[]}]}},"/api/v1/gateway/services/nft-access/{agreement_id}/{index}":{"get":{"operationId":"AccessController_doNftAccess","summary":"Public","description":"Access asset","parameters":[{"name":"index","required":true,"in":"path","schema":{"type":"number"}}],"responses":{"200":{"description":"Return the url of asset","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessResult"}}}}},"tags":["Access"],"security":[{"Authorization":[]}]}},"/api/v1/gateway/services/nft-transfer":{"post":{"operationId":"AccessController_doNftTransfer","summary":"Public","description":"Access asset","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TransferDto"}}}},"responses":{"200":{"description":"Return the url of asset"}},"tags":["Access"]}},"/api/v1/gateway/services/download/{index}":{"get":{"operationId":"AccessController_doDownload","summary":"Public","description":"Download asset","parameters":[{"name":"index","required":true,"in":"path","schema":{"type":"number"}}],"responses":{"200":{"description":"Return the url of asset","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessResult"}}}}},"tags":["Access"],"security":[{"Authorization":[]}]}},"/api/v1/gateway/services/upload/{backend}":{"post":{"operationId":"AccessController_doUpload","summary":"Public","description":"Access asset","parameters":[{"name":"backend","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UploadDto"}}}},"responses":{"200":{"description":"Return the url of asset"}},"tags":["Access"]}},"/api/v1/gateway/services/oauth/token":{"post":{"operationId":"AuthController_token","summary":"Public","description":"Login using a JWT claim for client authentication","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientAssertionDto"}}}},"responses":{"201":{"description":"The access_token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginDto"}}}},"401":{"description":"Unauthorized access"}},"tags":["Auth"]}}},"info":{"title":"Nevermined Gateway","description":"","version":"0.1.5","contact":{}},"tags":[],"servers":[],"components":{"securitySchemes":{"Authorization":{"scheme":"bearer","bearerFormat":"JWT","type":"http"}},"schemas":{"GetInfoDto":{"type":"object","properties":{"APIversion":{"type":"string","example":"1.0.4","description":"Marketplace API Version"},"docs":{"type":"string","example":"http://localhost:3100/api/v1/docs","description":"API docs url"}},"required":["APIversion","docs"]},"EncryptDto":{"type":"object","properties":{"method":{"type":"string","example":"PSK-ECDSA","description":"Encryption method"},"message":{"type":"string","example":"Hello!","description":"Encrypted message"}},"required":["method","message"]},"EncryptResult":{"type":"object","properties":{}},"AccessResult":{"type":"object","properties":{}},"TransferDto":{"type":"object","properties":{"agreementId":{"type":"string","description":"The agreement for NFT transfer","example":"0x..."},"nftHolder":{"type":"string","description":"NFT holder address","example":"0x..."},"nftReceiver":{"type":"string","description":"NFT receiver address","example":"0x..."},"nftAmount":{"type":"number","description":"Number of NFTs to transfer","example":"1"},"nftType":{"type":"number","description":"Type of NFT","example":"721"}},"required":["agreementId","nftHolder","nftReceiver","nftAmount","nftType"]},"UploadDto":{"type":"object","properties":{}},"ClientAssertionDto":{"type":"object","properties":{"grant_type":{"type":"string","description":"Type type of JWT client assertion. Must be urn:ietf:params:oauth:grant-type:jwt-bearer","example":"urn:ietf:params:oauth:grant-type:jwt-bearer"},"assertion":{"type":"string","description":"A single JWT","example":"eyJhbGciOiJSUzI1NiIsImtpZCI6IjIyIn0.eyJpc3Mi[...omitted for brevity...]"}},"required":["grant_type","assertion"]},"LoginDto":{"type":"object","properties":{"access_token":{"type":"string","description":"The Authorization Bearer token","example":"eyJhbGciOiJSUzI1NiIsImtpZCI6IjIyIn0.eyJpc3Mi[...omitted for brevity...]"}},"required":["access_token"]}}}}
{"openapi":"3.0.0","paths":{"/":{"get":{"operationId":"InfoController_getInfo","summary":"Public","description":"Get API info","parameters":[],"responses":{"200":{"description":"Return API Info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetInfoDto"}}}}},"tags":["Info"]}},"/api/v1/gateway/services/encrypt":{"post":{"operationId":"EncryptController_doEncrypt","summary":"Public","description":"Encrypt","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EncryptDto"}}}},"responses":{"200":{"description":"Return encrypted stuff","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EncryptResult"}}}}},"tags":["Encrypt"]}},"/api/v1/gateway/services/access/{agreement_id}/{index}":{"get":{"operationId":"AccessController_doAccess","summary":"Public","description":"Access asset","parameters":[{"name":"index","required":true,"in":"path","schema":{"type":"number"}}],"responses":{"200":{"description":"Return the url of asset","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StreamableFile"}}}}},"tags":["Access"],"security":[{"Authorization":[]}]}},"/api/v1/gateway/services/access-proof/{agreement_id}/{index}":{"get":{"operationId":"AccessController_doAccessProof","summary":"Public","description":"Access asset w/ DTP proof","parameters":[{"name":"index","required":true,"in":"path","schema":{"type":"number"}}],"responses":{"200":{"description":"Return the url of asset","content":{"application/json":{"schema":{"type":"string"}}}}},"tags":["Access"],"security":[{"Authorization":[]}]}},"/api/v1/gateway/services/nft-access/{agreement_id}/{index}":{"get":{"operationId":"AccessController_doNftAccess","summary":"Public","description":"Access asset","parameters":[{"name":"index","required":true,"in":"path","schema":{"type":"number"}}],"responses":{"200":{"description":"Return the url of asset","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StreamableFile"}}}}},"tags":["Access"],"security":[{"Authorization":[]}]}},"/api/v1/gateway/services/nft-transfer":{"post":{"operationId":"AccessController_doNftTransfer","summary":"Public","description":"Access asset","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TransferDto"}}}},"responses":{"200":{"description":"Return \"success\" if transfer worked"}},"tags":["Access"]}},"/api/v1/gateway/services/download/{index}":{"get":{"operationId":"AccessController_doDownload","summary":"Public","description":"Download asset","parameters":[{"name":"index","required":true,"in":"path","schema":{"type":"number"}}],"responses":{"200":{"description":"Return the asset","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StreamableFile"}}}}},"tags":["Access"],"security":[{"Authorization":[]}]}},"/api/v1/gateway/services/upload/{backend}":{"post":{"operationId":"AccessController_doUpload","summary":"Public","description":"Access asset","parameters":[{"name":"backend","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UploadDto"}}}},"responses":{"200":{"description":"Return the url of asset"}},"tags":["Access"]}},"/api/v1/gateway/services/oauth/token":{"post":{"operationId":"AuthController_token","summary":"Public","description":"Login using a JWT claim for client authentication","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientAssertionDto"}}}},"responses":{"201":{"description":"The access_token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginDto"}}}},"401":{"description":"Unauthorized access"}},"tags":["Auth"]}}},"info":{"title":"Nevermined Gateway","description":"","version":"0.1.5","contact":{}},"tags":[],"servers":[],"components":{"securitySchemes":{"Authorization":{"scheme":"bearer","bearerFormat":"JWT","type":"http"}},"schemas":{"GetInfoDto":{"type":"object","properties":{"APIversion":{"type":"string","example":"1.0.4","description":"Marketplace API Version"},"docs":{"type":"string","example":"http://localhost:3100/api/v1/docs","description":"API docs url"}},"required":["APIversion","docs"]},"EncryptDto":{"type":"object","properties":{"method":{"type":"string","example":"PSK-ECDSA","description":"Encryption method"},"message":{"type":"string","example":"Hello!","description":"Encrypted message"}},"required":["method","message"]},"EncryptResult":{"type":"object","properties":{}},"StreamableFile":{"type":"object","properties":{}},"TransferDto":{"type":"object","properties":{"agreementId":{"type":"string","description":"The agreement for NFT transfer","example":"0x..."},"nftHolder":{"type":"string","description":"NFT holder address","example":"0x..."},"nftReceiver":{"type":"string","description":"NFT receiver address","example":"0x..."},"nftAmount":{"type":"number","description":"Number of NFTs to transfer","example":"1"},"nftType":{"type":"number","description":"Type of NFT","example":"721"}},"required":["agreementId","nftHolder","nftReceiver","nftAmount","nftType"]},"UploadDto":{"type":"object","properties":{"encrypt":{"type":"string","description":"Encrypt uploaded data","example":"false"}}},"ClientAssertionDto":{"type":"object","properties":{"grant_type":{"type":"string","description":"Type type of JWT client assertion. Must be urn:ietf:params:oauth:grant-type:jwt-bearer","example":"urn:ietf:params:oauth:grant-type:jwt-bearer"},"assertion":{"type":"string","description":"A single JWT","example":"eyJhbGciOiJSUzI1NiIsImtpZCI6IjIyIn0.eyJpc3Mi[...omitted for brevity...]"}},"required":["grant_type","assertion"]},"LoginDto":{"type":"object","properties":{"access_token":{"type":"string","description":"The Authorization Bearer token","example":"eyJhbGciOiJSUzI1NiIsImtpZCI6IjIyIn0.eyJpc3Mi[...omitted for brevity...]"}},"required":["access_token"]}}}}
27 changes: 15 additions & 12 deletions src/access/access.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@ import { FileInterceptor } from "@nestjs/platform-express";
import crypto from 'crypto';
import { aes_encryption_256 } from "../common/helpers/utils";

export class AccessResult {
res: string;
}

export class UploadResult {
@ApiProperty({
description: 'Url of the uploaded file',
example: 'cid://bawoeijdoidewj',
required: true,
})
url: string;
@ApiProperty({
description: 'Password for encrypted file',
example: '1234#',
})
password?: string;
}

export class UploadDto {
/*
@ApiProperty({
description: 'Encrypt uploaded data',
example: 'false',
required: false,
})
*/
encrypt: string;
}

Expand Down Expand Up @@ -78,7 +81,7 @@ export class AccessController {
@ApiResponse({
status: 200,
description: 'Return the url of asset',
type: AccessResult,
type: StreamableFile,
})
@ApiBearerAuth('Authorization')
async doAccess(
Expand All @@ -97,7 +100,7 @@ export class AccessController {
@ApiResponse({
status: 200,
description: 'Return the url of asset',
type: AccessResult,
type: String,
})
@ApiBearerAuth('Authorization')
async doAccessProof(
Expand All @@ -116,7 +119,7 @@ export class AccessController {
@ApiResponse({
status: 200,
description: 'Return the url of asset',
type: AccessResult,
type: StreamableFile,
})
@ApiBearerAuth('Authorization')
async doNftAccess(
Expand All @@ -135,7 +138,7 @@ export class AccessController {
@Public()
@ApiResponse({
status: 200,
description: 'Return the url of asset',
description: 'Return "success" if transfer worked',
})
async doNftTransfer(@Body() transferData: TransferDto): Promise<string> {
const nevermined = await Nevermined.getInstance(config);
Expand Down Expand Up @@ -184,8 +187,8 @@ export class AccessController {
})
@ApiResponse({
status: 200,
description: 'Return the url of asset',
type: AccessResult,
description: 'Return the asset',
type: StreamableFile,
})
@ApiBearerAuth('Authorization')
async doDownload(
Expand Down

0 comments on commit b800223

Please sign in to comment.