Skip to content

Commit

Permalink
Pending changes exported from your codespace
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolachoquet06250 committed Mar 14, 2024
1 parent 0dc42c5 commit 28c0061
Show file tree
Hide file tree
Showing 2 changed files with 197 additions and 0 deletions.
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 | / |

107 changes: 107 additions & 0 deletions file-system-service.swagger.yml
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit 28c0061

Please sign in to comment.