Skip to content

Commit 4dd36eb

Browse files
nanotaboadaCopilot
andcommitted
chore(api): replace Postman collection with REST Client file (#493)
- Add rest/players.rest covering all CRUD operations for VS Code REST Client - Add humao.rest-client to .vscode/extensions.json recommendations - Add HTTP Requests section to README.md - Update .vscode/settings.json, pyproject.toml, codecov.yml to reference rest/ instead of postman_collections/ - Remove postman_collections/ directory Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4242cbb commit 4dd36eb

File tree

8 files changed

+120
-166
lines changed

8 files changed

+120
-166
lines changed

.vscode/extensions.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"coderabbit.coderabbit-vscode", // CodeRabbit - AI-powered code review
99

1010
// Code Quality
11-
"sonarsource.sonarlint-vscode", // SonarLint - Code quality and security analysis
11+
// "sonarsource.sonarlint-vscode", // SonarLint - Code quality and security analysis
1212

1313
// Formatting & Linting
1414
"ms-python.black-formatter", // Python code formatting
@@ -30,6 +30,9 @@
3030
"ms-azuretools.vscode-containers", // Container Tools - Docker and container management
3131
"yy0931.vscode-sqlite3-editor", // SQLite3 Editor - View and edit SQLite databases
3232

33+
// API Development
34+
"humao.rest-client", // REST Client - Send HTTP requests from .http files
35+
3336
// UI Enhancements
3437
"github.github-vscode-theme", // GitHub Theme - GitHub color themes
3538
"pkief.material-icon-theme", // Material Icon Theme - Material Design file icons

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"**/.vscode/**",
3535
"**/assets/**",
3636
"**/htmlcov/**",
37-
"**/postman_collections/**",
37+
"**/rest/**",
3838
"**/scripts/**",
3939
"**/tools/**",
4040
"**/storage/**",

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ This project uses famous football coaches as release codenames, following an A-Z
4444

4545
### Added
4646

47+
- `rest/players.rest` file covering all CRUD operations, compatible with the VS Code REST Client extension
48+
- `humao.rest-client` added to `.vscode/extensions.json` recommendations
4749
- UUID v4 primary key for the `players` table, replacing the previous integer PK (#66)
4850
- `PlayerRequestModel` Pydantic model for POST/PUT request bodies (no `id` field) (#66)
4951
- `PlayerResponseModel` Pydantic model for GET/POST response bodies (includes `id: UUID`) (#66)
@@ -69,6 +71,8 @@ This project uses famous football coaches as release codenames, following an A-Z
6971

7072
### Removed
7173

74+
- `postman_collections/` directory replaced by `rest/players.rest`
75+
7276
### Fixed
7377

7478
- POST/PUT/DELETE routes now raise `HTTP 500` on DB failure instead of silently returning success (#66)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ http://localhost:9000/docs
5858

5959
![API Documentation](assets/images/swagger.png)
6060

61+
## HTTP Requests
62+
63+
The [`rest/players.rest`](rest/players.rest) file covers all CRUD operations and can be run directly in VS Code with the [REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) extension.
64+
6165
## Container
6266

6367
### Docker Compose

codecov.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://docs.codecov.com/docs/codecov-yaml
33

44
coverage:
5-
# https://docs.codecov.com/docs/commit-status
5+
# https://docs.codecov.com/docs/commit-status
66
status:
77
project:
88
default:
@@ -42,7 +42,7 @@ ignore:
4242
- "^assets/.*"
4343
- "^databases/.*"
4444
- "^models/.*"
45-
- "^postman_collections/.*"
45+
- "^rest/.*"
4646
- "^schemas/.*"
4747
- "^tools/.*"
4848
- "^tests/.*"

postman_collections/python-samples-fastapi-restful.postman_collection.json

Lines changed: 0 additions & 161 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ exclude = '''
1111
| \.vscode
1212
| assets
1313
| htmlcov
14-
| postman_collections
14+
| rest
1515
| scripts
1616
| tools
1717
| storage

rest/players.rest

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
### RESTful API with Python 3 and FastAPI
2+
### https://github.com/nanotaboada/python-samples-fastapi-restful
3+
###
4+
### Requires the REST Client extension for VS Code:
5+
### https://marketplace.visualstudio.com/items?itemName=humao.rest-client
6+
###
7+
### Key design note:
8+
### squad_number = natural key (domain-meaningful, preferred for lookups)
9+
### id (UUID) = surrogate key (internal, opaque, used for CRUD operations)
10+
11+
@baseUrl = http://localhost:9000
12+
13+
# ------------------------------------------------------------------------------
14+
# Health
15+
# ------------------------------------------------------------------------------
16+
17+
### GET /health/ — liveness check
18+
GET {{baseUrl}}/health/
19+
Accept: application/json
20+
21+
# ------------------------------------------------------------------------------
22+
# POST /players/ — Create
23+
# Thiago Almada (squad 16): not seeded in the database, used as the creation
24+
# fixture. No id in the body; the server generates a UUID v4 on creation.
25+
# ------------------------------------------------------------------------------
26+
27+
### POST /players/ — Create a new Player
28+
POST {{baseUrl}}/players/
29+
Content-Type: application/json
30+
31+
{
32+
"firstName": "Thiago",
33+
"middleName": "Ezequiel",
34+
"lastName": "Almada",
35+
"dateOfBirth": "2001-04-26T00:00:00.000Z",
36+
"squadNumber": 16,
37+
"position": "Attacking Midfield",
38+
"abbrPosition": "AM",
39+
"team": "Atlanta United FC",
40+
"league": "Major League Soccer",
41+
"starting11": false
42+
}
43+
44+
# ------------------------------------------------------------------------------
45+
# GET /players/ — Retrieve all
46+
# ------------------------------------------------------------------------------
47+
48+
### GET /players/ — Retrieve all Players
49+
GET {{baseUrl}}/players/
50+
Accept: application/json
51+
52+
# ------------------------------------------------------------------------------
53+
# GET /players/{player_id} — Retrieve by UUID (surrogate key, internal)
54+
# Emiliano Martínez (squad 23): UUID v5, seeded by seed_001.
55+
# ------------------------------------------------------------------------------
56+
57+
### GET /players/{player_id} — Retrieve a Player by UUID
58+
GET {{baseUrl}}/players/b04965e6-a9bb-591f-8f8a-1adcb2c8dc39
59+
Accept: application/json
60+
61+
# ------------------------------------------------------------------------------
62+
# GET /players/squadnumber/{squad_number} — Retrieve by Squad Number (natural key, domain)
63+
# Preferred lookup for external consumers.
64+
# ------------------------------------------------------------------------------
65+
66+
### GET /players/squadnumber/{squad_number} — Retrieve a Player by Squad Number
67+
GET {{baseUrl}}/players/squadnumber/10
68+
Accept: application/json
69+
70+
# ------------------------------------------------------------------------------
71+
# PUT /players/{player_id} — Update
72+
# Emiliano Martínez (squad 23): UUID v5, seeded by seed_001.
73+
# ------------------------------------------------------------------------------
74+
75+
### PUT /players/{player_id} — Update an existing Player
76+
PUT {{baseUrl}}/players/b04965e6-a9bb-591f-8f8a-1adcb2c8dc39
77+
Content-Type: application/json
78+
79+
{
80+
"firstName": "Emiliano",
81+
"middleName": "",
82+
"lastName": "Martínez",
83+
"dateOfBirth": "1992-09-02T00:00:00.000Z",
84+
"squadNumber": 23,
85+
"position": "Goalkeeper",
86+
"abbrPosition": "GK",
87+
"team": "Aston Villa FC",
88+
"league": "Premier League",
89+
"starting11": true
90+
}
91+
92+
# ------------------------------------------------------------------------------
93+
# DELETE /players/{player_id} — Delete
94+
# Thiago Almada (squad 16): created by POST above. Since the UUID is generated
95+
# at runtime, retrieve it first via squad number, then substitute it below.
96+
# ------------------------------------------------------------------------------
97+
98+
### Step 1 — Look up Almada's UUID by squad number
99+
GET {{baseUrl}}/players/squadnumber/16
100+
Accept: application/json
101+
102+
### Step 2 — Delete Almada using the UUID returned above
103+
# Replace {player_id} with the id field from the response above.
104+
DELETE {{baseUrl}}/players/{player_id}

0 commit comments

Comments
 (0)