From 8617d56cd7d888c1ea74f4257a038cef7ce19571 Mon Sep 17 00:00:00 2001 From: Guilherme Oliveira Date: Tue, 2 Jul 2024 15:23:22 +0200 Subject: [PATCH] Updated dropzone and pickup apis --- api-dropzone-openapi.yaml | 73 +++++++++++++------------- api-pickup-openapi.yaml | 104 +++++++++++++++++++++++++++++++------- 2 files changed, 125 insertions(+), 52 deletions(-) diff --git a/api-dropzone-openapi.yaml b/api-dropzone-openapi.yaml index 8415b60..733ae47 100644 --- a/api-dropzone-openapi.yaml +++ b/api-dropzone-openapi.yaml @@ -8,8 +8,7 @@ info: email: dev@parsly.com url: http://parsly.com servers: - - url: https://parsly.com/api/dropzone/v1 - - url: /api/dropzone/v1 + - url: https://apix.parsly.com/dropzone/v1 paths: /healthcheck: description: | @@ -24,16 +23,23 @@ paths: content: application/json: schema: - type: boolean - /attachments: + $ref: "#/components/schemas/Status" + /files: description: | - Invoice files. + Invoice invoice . post: description: | - Upload invoice attachments. - operationId: postAttachments + Upload invoice files. + operationId: postFiles + parameters: + - name: uploadId + in: query + description: Optional upload ID (automatically assigned if omitted) + required: false + schema: + $ref: "#/components/schemas/ResourceId" requestBody: - description: Array of invoice attachments. + description: Array of invoice files. required: true content: multipart/form-data: @@ -45,56 +51,53 @@ paths: items: type: string format: binary + encoding: + file: + contentType: multipart/form-data + headers: + X-File-Id: + description: Optional file ID (automatically assigned if omitted) + schema: + $ref: "#/components/schemas/ResourceId" responses: '201': - description: List of uploaded invoice attachments. + description: List of uploaded invoice files. content: application/json: schema: - $ref: '#/components/schemas/AttachmentList' - default: - description: unexpected error - content: - application/json: - schema: - $ref: '#/components/schemas/Error' + $ref: '#/components/schemas/FileList' components: schemas: - AttachmentList: + Status: + type: boolean + ResourceId: + type: string + minLength: 8 + maxLength: 256 + pattern: '^[a-zA-Z0-9]+[a-zA-Z0-9\-]*[a-zA-Z0-9]+$' + FileList: type: object required: - id - - attachments + - files properties: id: - type: string - format: uuid - x-go-type: uuid.UUID - x-go-type-import: - path: github.com/google/uuid - attachments: + $ref: "#/components/schemas/ResourceId" + files: type: array items: - $ref: "#/components/schemas/Attachment" - Attachment: + $ref: "#/components/schemas/File" + File: type: object required: - id - - external_id - file_name - content_type - checksum - size properties: id: - type: string - format: uuid - x-go-type: uuid.UUID - x-go-type-import: - path: github.com/google/uuid - external_id: - type: string - maxLength: 200 + $ref: "#/components/schemas/ResourceId" file_name: type: string maxLength: 1024 diff --git a/api-pickup-openapi.yaml b/api-pickup-openapi.yaml index 9d6f9bb..a498e53 100644 --- a/api-pickup-openapi.yaml +++ b/api-pickup-openapi.yaml @@ -25,41 +25,60 @@ paths: application/json: schema: type: boolean - /results/{list_id}/{attachment_id}: + /results/{uploadId}: + description: | + Available result status of uploaded file group. + get: + description: | + Download available result status of uploaded file group. + operationId: getFileGroupResult + parameters: + - name: uploadId + in: path + description: Id of uploaded file group + required: true + schema: + $ref: "#/components/schemas/ResourceId" + responses: + '200': + description: file group result status + content: + application/json: + schema: + $ref: "#/components/schemas/ResultList" + default: + description: unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /results/{uploadId}/{fileId}: description: | Invoice parser results. get: description: | Download invoice parser result. - operationId: getResult + operationId: getFileResult parameters: - - name: list_id + - name: uploadId in: path - description: Id of uploaded attachment list + description: Id of uploaded file group required: true schema: - type: string - format: uuid - x-go-type: uuid.UUID - x-go-type-import: - path: github.com/google/uuid - - name: attachment_id + $ref: "#/components/schemas/ResourceId" + - name: fileId in: path - description: Id of uploaded attachment + description: Id of uploaded file required: true schema: - type: string - format: uuid - x-go-type: uuid.UUID - x-go-type-import: - path: github.com/google/uuid + $ref: "#/components/schemas/ResourceId" responses: '200': description: invoice parser result content: application/json: schema: - type: object + $ref: "#/components/schemas/Result" default: description: unexpected error content: @@ -68,6 +87,57 @@ paths: $ref: '#/components/schemas/Error' components: schemas: + ResourceId: + type: string + minLength: 8 + maxLength: 256 + pattern: '^[a-zA-Z0-9]+[a-zA-Z0-9\-]*[a-zA-Z0-9]+$' + FileList: + type: object + required: + - id + - files + properties: + id: + $ref: "#/components/schemas/ResourceId" + files: + type: array + items: + $ref: "#/components/schemas/Result" + ResultList: + type: object + required: + - id + - results + properties: + id: + $ref: "#/components/schemas/ResourceId" + results: + type: array + items: + $ref: "#/components/schemas/ResultHead" + Result: + allOf: + - $ref: '#/components/schemas/ResultHead' + - type: object + required: + - content + properties: + content: + type: object + ResultHead: + type: object + required: + - id + - status + properties: + id: + $ref: "#/components/schemas/ResourceId" + status: + $ref: "#/components/schemas/ResultStatus" + ResultStatus: + type: string + enum: [unknown, processed, failed] Error: type: object required: