From 28c0061462276cd1e879a975f5ea605a492176af Mon Sep 17 00:00:00 2001 From: Choquet Nicolas Date: Thu, 14 Mar 2024 20:51:06 +0000 Subject: [PATCH] Pending changes exported from your codespace --- README.md | 90 +++++++++++++++++++++++++++ file-system-service.swagger.yml | 107 ++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 file-system-service.swagger.yml diff --git a/README.md b/README.md index 978c49d..d815f6d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,92 @@ # file-system-service + Création d'un service en Go pour pouvoir m'y connecter via mon portfolio-apple et interagire avec le système de fichier via l'IHM. + + +## API Reference + +#### Get directory list content items + +```http + GET /file-system/${path...} +``` + +| Parameter | Type | Description | Default value | +| :-------- | :------- | :------------------------- | :------------ | +| `path` | `string` | **Optional**. The path of the directory you would like open | / | + +### Response 200 + +```json +[ + { + "type": "directory", + "path": "/home", + "name": "nchoquet" + }, + { + "type": "file", + "path": "/home", + "name": ".bashrc" + }, + ... +] +``` + +### Response 400 + +```json +{ + "code": 400, + "message": "an error message" +} +``` + +#### Get file content + +```http + GET /file/${path...} +``` + +| Parameter | Type | Description | Default value | +| :-------- | :------- | :-------------------------------- | :------------ | +| `path` | `string` | **Optional**. The path of the directory you would like open | / | + +#### Create file + +```http + POST /file + Content-Type: application/json + Accept: application/json + + { + "type": "file" + "path": "/path/to/create", + "name": "file-to-create", + "extension": "your-extension" + } +``` + +### Response 200 + +```json +{ + "path": "/path/to/create", + "name": "file-to-create", + "extension": "your-extension" +} +``` + +### Response 400 + +```json +{ + "code": 400, + "message": "an error message" +} +``` + +| Parameter | Type | Description | Default value | +| :-------- | :------- | :-------------------------------- | :------------ | +| `path` | `string` | **Optional**. The path of the directory you would like open | / | + diff --git a/file-system-service.swagger.yml b/file-system-service.swagger.yml new file mode 100644 index 0000000..7c43c5e --- /dev/null +++ b/file-system-service.swagger.yml @@ -0,0 +1,107 @@ +openapi: '3.0.2' + +info: + title: File system Service + version: 0.4.0 + +servers: + - url: http://{host}:{port} + variables: + host: + default: 'localhost' + port: + default: '3000' + description: Port where is exposed service. + +components: + schemas: + HttpError: + type: object + properties: + code: + type: integer + format: integer + message: + type: string + + FileSystemItem: + type: object + properties: + type: + type: string + path: + type: string + name: + type: string + +tags: + - name: File System + description: All concerns file system. + - name: Files + description: All concerns files. + - name: Directories + description: All concerns directories. + +paths: + /file-system/{path}: + summary: Get all content of directory (flat) + description: Get all elements in search directory (in {path}) + + parameters: + - name: path + required: true + in: path + description: Path of file to get. + schema: + type: string + explode: true + style: simple + example: "home\/nchoquet" + + get: + tags: + - File System + + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/FileSystemItem' + + '400': + description: Bad Request + # headers: + + content: + application/json: + schema: + $ref: '#/components/schemas/HttpError' + + /file-system: + summary: Get all content of root directory (flat) + description: Get all elements in search directory (in root of your system) + + get: + tags: + - File System + + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/FileSystemItem' + + '400': + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/HttpError'