291 lines
4.3 KiB
Markdown
291 lines
4.3 KiB
Markdown
# Flight Service
|
||
|
||
## HTTP API
|
||
|
||
### Регистрация нового пользователя
|
||
|
||
---
|
||
|
||
```http title="Request"
|
||
PUT /api/users HTTP/1.1
|
||
Accept: application/json
|
||
```
|
||
|
||
<details green>
|
||
<summary>Request Example</summary>
|
||
|
||
```json title="Body"
|
||
{
|
||
"first_name": "Ivan",
|
||
"last_name": "Ivanov",
|
||
"age": 25
|
||
}
|
||
```
|
||
</details>
|
||
|
||
<details>
|
||
<summary>Response Example</summary>
|
||
|
||
```json title="Body"
|
||
{
|
||
"id": 1,
|
||
"first_name": "Ivan",
|
||
"last_name": "Ivanov",
|
||
"age": 25
|
||
}
|
||
```
|
||
</details>
|
||
|
||
### Получение пользователя
|
||
|
||
---
|
||
|
||
```http title="Request"
|
||
GET /api/users/{id} HTTP/1.1
|
||
Accept: application/json
|
||
```
|
||
|
||
<details>
|
||
<summary>Response Example</summary>
|
||
|
||
```json title="Body"
|
||
{
|
||
"id": 1,
|
||
"first_name": "Ivan",
|
||
"last_name": "Ivanov",
|
||
"age": 25
|
||
}
|
||
```
|
||
</details>
|
||
|
||
### Получение информации о самолете
|
||
|
||
---
|
||
|
||
```http title="Request"
|
||
POST /api/airplane/{id} HTTP/1.1
|
||
Accept: application/json
|
||
```
|
||
|
||
|
||
<details>
|
||
<summary>Response Example</summary>
|
||
|
||
```json title="Body"
|
||
{
|
||
"id": 1,
|
||
"name": "Airplane #1",
|
||
"max_passengers": 115,
|
||
"max_cargo_weight": 7350
|
||
}
|
||
```
|
||
</details>
|
||
|
||
### Список всех самолетов
|
||
|
||
---
|
||
|
||
```http title="Request"
|
||
GET /api/airplane HTTP/1.1
|
||
Accept: application/json
|
||
```
|
||
|
||
<details>
|
||
<summary>Query Parameters</summary>
|
||
|
||
| Name | Default value | Description |
|
||
|------|---------------|-------------|
|
||
| page | 0 | Страница |
|
||
|
||
</details>
|
||
|
||
<details>
|
||
<summary>Response Example</summary>
|
||
|
||
```json title="Body"
|
||
[
|
||
{
|
||
"id": 1,
|
||
"name": "Airplane #1",
|
||
"max_passengers": 115,
|
||
"max_cargo_weight": 7350
|
||
},
|
||
...
|
||
]
|
||
```
|
||
</details>
|
||
|
||
### Получение информации об аэропорте
|
||
|
||
---
|
||
|
||
```http
|
||
GET /api/airport/{id} HTTP/1.1
|
||
Accept: application/json
|
||
```
|
||
|
||
<details>
|
||
<summary>Response Example</summary>
|
||
|
||
```json title="Body"
|
||
{
|
||
"id": 32,
|
||
"Name": "Airport #32",
|
||
"longitude": 47.488425,
|
||
"latitude": 39.929261
|
||
}
|
||
```
|
||
</details>
|
||
|
||
### Список всех аэропортов
|
||
|
||
---
|
||
|
||
```http title="Request"
|
||
GET /api/airport HTTP/1.1
|
||
Accept: application/json
|
||
```
|
||
|
||
<details>
|
||
<summary>Query Parameters</summary>
|
||
|
||
| Name | Default value | Description |
|
||
|------|---------------|-------------|
|
||
| page | 0 | Страница |
|
||
|
||
</details>
|
||
|
||
<details>
|
||
<summary>Response Example</summary>
|
||
|
||
```json title="Body"
|
||
[
|
||
{
|
||
"id": 32,
|
||
"Name": "Airport #32",
|
||
"longitude": 47.488425,
|
||
"latitude": 39.929261
|
||
},
|
||
...
|
||
]
|
||
```
|
||
</details>
|
||
|
||
|
||
### Создание нового рейса
|
||
|
||
---
|
||
|
||
```http title="Request"
|
||
POST /api/flight HTTP/1.1
|
||
Accept: application/json
|
||
```
|
||
|
||
<details>
|
||
<summary>Request Example</summary>
|
||
|
||
```json title="Body"
|
||
{
|
||
"departure_airport": 12,
|
||
"arrival_airport": 15,
|
||
"airplane": 3,
|
||
"departure_timestamp": 1771834281934
|
||
}
|
||
```
|
||
</details>
|
||
|
||
<details>
|
||
<summary>Response Example</summary>
|
||
|
||
```json title="Body"
|
||
{
|
||
"id": 1,
|
||
"departure_airport": {
|
||
"id": 12,
|
||
"Name": "Airport #12",
|
||
"longitude": 47.488425,
|
||
"latitude": 39.929261
|
||
},
|
||
"arrival_airport": {
|
||
"id": 15,
|
||
"Name": "Airport #15",
|
||
"longitude": 47.488425,
|
||
"latitude": 39.929261
|
||
},
|
||
"airplane": {
|
||
"id": 3,
|
||
"name": "Airplane #3",
|
||
"max_passengers": 115,
|
||
"max_cargo_weight": 7350
|
||
},
|
||
"departure_timestamp": 1771834281934,
|
||
"passengers": []
|
||
}
|
||
```
|
||
</details>
|
||
|
||
### Получение информации о рейсе
|
||
|
||
---
|
||
|
||
```http title="Request"
|
||
GET /api/flight/{id} HTTP/1.1
|
||
Accept: application/json
|
||
```
|
||
|
||
<details>
|
||
<summary>Response Example</summary>
|
||
|
||
```json title="Body"
|
||
{
|
||
"id": 1,
|
||
"departure_airport": {
|
||
"id": 12,
|
||
"Name": "Airport #12",
|
||
"longitude": 47.488425,
|
||
"latitude": 39.929261
|
||
},
|
||
"arrival_airport": {
|
||
"id": 15,
|
||
"Name": "Airport #15",
|
||
"longitude": 47.488425,
|
||
"latitude": 39.929261
|
||
},
|
||
"airplane": {
|
||
"id": 3,
|
||
"name": "Airplane #3",
|
||
"max_passengers": 115,
|
||
"max_cargo_weight": 7350
|
||
},
|
||
"departure_timestamp": 1771834281934,
|
||
"passengers": [
|
||
{
|
||
"id": 1,
|
||
"first_name": "Ivan",
|
||
"last_name": "Ivanov",
|
||
"age": 25
|
||
},
|
||
...
|
||
]
|
||
}
|
||
```
|
||
</details>
|
||
|
||
### Регистрация пассажира на рейс
|
||
|
||
---
|
||
|
||
```http title="Request"
|
||
POST /api/flight/register HTTP/1.1
|
||
```
|
||
|
||
<details>
|
||
<summary>Request Example</summary>
|
||
|
||
```json title="Body"
|
||
{
|
||
"flight_id": 1,
|
||
"user_id": 3
|
||
}
|
||
```
|
||
</details> |