Add strict types and type hints across API
Apply strict_types and extensive type declarations throughout the API and models, improving type safety and error handling. Key changes: add declare(strict_types=1) to many files; convert properties, method parameters and return values to typed signatures (PDO, arrays, ints, strings, bools, nullables); switch exception handling to Throwable in index and Router; improve Router, controllers and model method signatures and nullability handling; refine file/image serving security checks and headers in ImageController; strengthen Database typing and initialization methods; return explicit types from BaseModel CRUD helpers and counting; update Media/Cast/Adult/Game/Console/Settings controllers and models to use typed methods, better validation, and clearer update/create return types. Also add AGENTS.md (agent skills index), update README with Swagger/OpenAPI usage instructions, and add /.windsurf to .gitignore. These changes aim to harden runtime correctness, make intended contracts explicit, and prepare the codebase for easier maintenance and static analysis.
This commit is contained in:
31
README.md
31
README.md
@@ -326,6 +326,37 @@ Tables are auto-created on first API call. Check logs:
|
||||
docker-compose logs php
|
||||
```
|
||||
|
||||
## Swagger/OpenAPI Documentation
|
||||
|
||||
A Swagger/OpenAPI specification file is included at `swagger.json` in the project root. This file can be used with Swagger UI to interactively test the API.
|
||||
|
||||
### Using Swagger UI
|
||||
|
||||
#### Option 1: Online Swagger Editor
|
||||
1. Go to [https://editor.swagger.io](https://editor.swagger.io)
|
||||
2. Import the `swagger.json` file
|
||||
3. Click "Try it out" to test endpoints
|
||||
|
||||
#### Option 2: Docker with Swagger UI
|
||||
```bash
|
||||
docker run -p 8080:8080 -e SWAGGER_JSON=/swagger/swagger.json -v $(pwd):/swagger swaggerapi/swagger-ui
|
||||
```
|
||||
Then access at: http://localhost:8080
|
||||
|
||||
#### Option 3: Local Swagger UI
|
||||
1. Download Swagger UI from [https://github.com/swagger-api/swagger-ui](https://github.com/swagger-api/swagger-ui)
|
||||
2. Extract and open `dist/index.html`
|
||||
3. Modify the URL to point to your `swagger.json` file
|
||||
|
||||
### API Endpoints Covered
|
||||
- Root endpoints (API info, auto-docs)
|
||||
- Media CRUD operations
|
||||
- Series episodes CRUD operations
|
||||
- Music tracks CRUD operations
|
||||
- Cast CRUD operations
|
||||
- Adult cast CRUD operations
|
||||
- Settings operations
|
||||
|
||||
## License
|
||||
|
||||
[Add your license here]
|
||||
|
||||
Reference in New Issue
Block a user