Преглед изворни кода

add openapi spec and client-library for pdf-converter

Futa Arai пре 1 година
родитељ
комит
d0ab9ae07b

+ 0 - 2
apps/pdf-converter/.gitignore

@@ -1,3 +1 @@
 /dist
-/specs
-/src/client-library

+ 149 - 0
apps/pdf-converter/specs/v3/docs/swagger.json

@@ -0,0 +1,149 @@
+{
+  "openapi": "3.0.1",
+  "info": {
+    "title": "Api documentation",
+    "version": "1.0.0"
+  },
+  "paths": {
+    "/pdf/sync-job": {
+      "post": {
+        "responses": {
+          "202": {
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "object",
+                  "properties": {
+                    "status": {
+                      "type": "string",
+                      "enum": [
+                        "HTML_EXPORT_IN_PROGRESS",
+                        "HTML_EXPORT_DONE",
+                        "FAILED",
+                        "PDF_EXPORT_DONE"
+                      ]
+                    }
+                  },
+                  "required": [
+                    "status"
+                  ]
+                }
+              }
+            },
+            "description": "Accepted"
+          },
+          "500": {
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/InternalServerError"
+                }
+              }
+            },
+            "description": "Internal Server Error"
+          }
+        },
+        "description": "\n    Sync job pdf convert status with GROWI.\n    Register or update job inside pdf-converter with given jobId, expirationDate, and status.\n    Return resulting status of job to GROWI.\n  ",
+        "parameters": [],
+        "requestBody": {
+          "required": false,
+          "content": {
+            "application/json": {
+              "schema": {
+                "properties": {
+                  "jobId": {
+                    "type": "string"
+                  },
+                  "expirationDate": {
+                    "type": "string"
+                  },
+                  "status": {
+                    "type": "string",
+                    "enum": [
+                      "HTML_EXPORT_IN_PROGRESS",
+                      "HTML_EXPORT_DONE",
+                      "FAILED"
+                    ]
+                  }
+                },
+                "type": "object"
+              }
+            }
+          }
+        },
+        "tags": [
+          "PdfCtrl"
+        ],
+        "operationId": "pdfCtrlSyncJobStatus"
+      }
+    }
+  },
+  "tags": [
+    {
+      "name": "PdfCtrl"
+    }
+  ],
+  "components": {
+    "schemas": {
+      "InternalServerError": {
+        "type": "object",
+        "properties": {
+          "name": {
+            "type": "string",
+            "minLength": 1,
+            "description": "The error name",
+            "example": "INTERNAL_SERVER_ERROR",
+            "default": "INTERNAL_SERVER_ERROR"
+          },
+          "message": {
+            "type": "string",
+            "minLength": 1,
+            "description": "An error message"
+          },
+          "status": {
+            "type": "number",
+            "description": "The status code of the exception",
+            "example": 500,
+            "default": 500
+          },
+          "errors": {
+            "type": "array",
+            "items": {
+              "$ref": "#/components/schemas/GenericError"
+            },
+            "description": "A list of related errors"
+          },
+          "stack": {
+            "type": "string",
+            "description": "The stack trace (only in development mode)"
+          }
+        },
+        "required": [
+          "name",
+          "message",
+          "status"
+        ]
+      },
+      "GenericError": {
+        "type": "object",
+        "properties": {
+          "name": {
+            "type": "string",
+            "minLength": 1,
+            "description": "The error name"
+          },
+          "message": {
+            "type": "string",
+            "minLength": 1,
+            "description": "An error message"
+          }
+        },
+        "additionalProperties": true,
+        "required": [
+          "name",
+          "message"
+        ]
+      }
+    }
+  }
+}

+ 106 - 0
apps/pdf-converter/specs/v3/docs/swagger.yaml

@@ -0,0 +1,106 @@
+openapi: 3.0.1
+info:
+  title: Api documentation
+  version: 1.0.0
+paths:
+  /pdf/sync-job:
+    post:
+      responses:
+        '202':
+          content:
+            application/json:
+              schema:
+                type: object
+                properties:
+                  status:
+                    type: string
+                    enum:
+                      - HTML_EXPORT_IN_PROGRESS
+                      - HTML_EXPORT_DONE
+                      - FAILED
+                      - PDF_EXPORT_DONE
+                required:
+                  - status
+          description: Accepted
+        '500':
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/InternalServerError'
+          description: Internal Server Error
+      description: |2-
+
+            Sync job pdf convert status with GROWI.
+            Register or update job inside pdf-converter with given jobId, expirationDate, and status.
+            Return resulting status of job to GROWI.
+          
+      parameters: []
+      requestBody:
+        required: false
+        content:
+          application/json:
+            schema:
+              properties:
+                jobId:
+                  type: string
+                expirationDate:
+                  type: string
+                status:
+                  type: string
+                  enum:
+                    - HTML_EXPORT_IN_PROGRESS
+                    - HTML_EXPORT_DONE
+                    - FAILED
+              type: object
+      tags:
+        - PdfCtrl
+      operationId: pdfCtrlSyncJobStatus
+tags:
+  - name: PdfCtrl
+components:
+  schemas:
+    InternalServerError:
+      type: object
+      properties:
+        name:
+          type: string
+          minLength: 1
+          description: The error name
+          example: INTERNAL_SERVER_ERROR
+          default: INTERNAL_SERVER_ERROR
+        message:
+          type: string
+          minLength: 1
+          description: An error message
+        status:
+          type: number
+          description: The status code of the exception
+          example: 500
+          default: 500
+        errors:
+          type: array
+          items:
+            $ref: '#/components/schemas/GenericError'
+          description: A list of related errors
+        stack:
+          type: string
+          description: The stack trace (only in development mode)
+      required:
+        - name
+        - message
+        - status
+    GenericError:
+      type: object
+      properties:
+        name:
+          type: string
+          minLength: 1
+          description: The error name
+        message:
+          type: string
+          minLength: 1
+          description: An error message
+      additionalProperties: true
+      required:
+        - name
+        - message

+ 96 - 0
apps/pdf-converter/src/client-library/index.ts

@@ -0,0 +1,96 @@
+/**
+ * Generated by orval v7.1.1 🍺
+ * Do not edit manually.
+ * Api documentation
+ * OpenAPI spec version: 1.0.0
+ */
+import axios from 'axios'
+import type {
+  AxiosRequestConfig,
+  AxiosResponse
+} from 'axios'
+export type PdfCtrlSyncJobStatus202Status = typeof PdfCtrlSyncJobStatus202Status[keyof typeof PdfCtrlSyncJobStatus202Status];
+
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const PdfCtrlSyncJobStatus202Status = {
+  HTML_EXPORT_IN_PROGRESS: 'HTML_EXPORT_IN_PROGRESS',
+  HTML_EXPORT_DONE: 'HTML_EXPORT_DONE',
+  FAILED: 'FAILED',
+  PDF_EXPORT_DONE: 'PDF_EXPORT_DONE',
+} as const;
+
+export type PdfCtrlSyncJobStatus202 = {
+  status: PdfCtrlSyncJobStatus202Status;
+};
+
+export type PdfCtrlSyncJobStatusBodyStatus = typeof PdfCtrlSyncJobStatusBodyStatus[keyof typeof PdfCtrlSyncJobStatusBodyStatus];
+
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const PdfCtrlSyncJobStatusBodyStatus = {
+  HTML_EXPORT_IN_PROGRESS: 'HTML_EXPORT_IN_PROGRESS',
+  HTML_EXPORT_DONE: 'HTML_EXPORT_DONE',
+  FAILED: 'FAILED',
+} as const;
+
+export type PdfCtrlSyncJobStatusBody = {
+  expirationDate?: string;
+  jobId?: string;
+  status?: PdfCtrlSyncJobStatusBodyStatus;
+};
+
+export interface GenericError {
+  /**
+   * An error message
+   * @minLength 1
+   */
+  message: string;
+  /**
+   * The error name
+   * @minLength 1
+   */
+  name: string;
+  [key: string]: unknown;
+ }
+
+export interface InternalServerError {
+  /** A list of related errors */
+  errors?: GenericError[];
+  /**
+   * An error message
+   * @minLength 1
+   */
+  message: string;
+  /**
+   * The error name
+   * @minLength 1
+   */
+  name: string;
+  /** The stack trace (only in development mode) */
+  stack?: string;
+  /** The status code of the exception */
+  status: number;
+}
+
+
+
+
+
+  /**
+ * 
+    Sync job pdf convert status with GROWI.
+    Register or update job inside pdf-converter with given jobId, expirationDate, and status.
+    Return resulting status of job to GROWI.
+  
+ */
+export const pdfCtrlSyncJobStatus = <TData = AxiosResponse<PdfCtrlSyncJobStatus202>>(
+    pdfCtrlSyncJobStatusBody?: PdfCtrlSyncJobStatusBody, options?: AxiosRequestConfig
+ ): Promise<TData> => {
+    return axios.post(
+      `/pdf/sync-job`,
+      pdfCtrlSyncJobStatusBody,options
+    );
+  }
+
+export type PdfCtrlSyncJobStatusResult = AxiosResponse<PdfCtrlSyncJobStatus202>