Files
my-blog-posts/flight-service/index.md
2026-02-23 12:10:06 +03:00

253 lines
4.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Flight Service
## HTTP API
### Регистрация нового пользователя
---
```http title="Request"
PUT /api/users HTTP/1.1
Accept: application/json
```
<details>
<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
```
```json title="Response Body Example"
{
"id": 1,
"first_name": "Ivan",
"last_name": "Ivanov",
"age": 25
}
```
### Получение информации о самолете
---
```http title="Request"
POST /api/airplane/{id} HTTP/1.1
Accept: application/json
```
```json title="Response Body Example"
{
"id": 1,
"name": "Airplane #1",
"max_passengers": 115,
"max_cargo_weight": 7350
}
```
### Список всех самолетов
---
```http title="Request"
GET /api/airplane HTTP/1.1
Accept: application/json
```
<details>
<summary>Query Parameters</summary>
| Name | Default value | Description |
|------|---------------|-------------|
| page | 0 | Страница |
</details>
```json title="Response Body Example"
[
{
"id": 1,
"name": "Airplane #1",
"max_passengers": 115,
"max_cargo_weight": 7350
},
...
]
```
### Получение информации об аэропорте
---
```http
GET /api/airport/{id} HTTP/1.1
Accept: application/json
```
```json title="Response Body Example"
{
"id": 32,
"Name": "Airport #32",
"longitude": 47.488425,
"latitude": 39.929261
}
```
### Список всех аэропортов
---
```http title="Request"
GET /api/airport HTTP/1.1
Accept: application/json
```
<details>
<summary>Query Parameters</summary>
| Name | Default value | Description |
|------|---------------|-------------|
| page | 0 | Страница |
</details>
```json title="Response Body Example"
[
{
"id": 32,
"Name": "Airport #32",
"longitude": 47.488425,
"latitude": 39.929261
},
...
]
```
### Создание нового рейса
---
```http title="Request"
POST /api/flight HTTP/1.1
Accept: application/json
```
```json title="Request Body Example"
{
"departure_airport": 12,
"arrival_airport": 15,
"airplane": 3,
"departure_timestamp": 1771834281934
}
```
```json title="Response Body Example"
{
"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": []
}
```
### Получение информации о рейсе
---
```http title="Request"
GET /api/flight/{id} HTTP/1.1
Accept: application/json
```
```json title="Response Body Example"
{
"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
},
...
]
}
```
### Регистрация пассажира на рейс
---
```http title="Request"
POST /api/flight/register HTTP/1.1
```
```json title="Request Body Example"
{
"flight_id": 1,
"user_id": 3
}
```