41 lines
1.2 KiB
Markdown
41 lines
1.2 KiB
Markdown
# SwaggerUI
|
||
|
||
**Özet:** Fiber v3 native Swagger UI entegrasyonu (`main.go:79`). OpenAPI spec `docs/swagger.json` dosyasından statik olarak servis edilir, UI CDN'den (unpkg) yüklenir.
|
||
|
||
**Kütüphaneler:** swaggo/swag, Swagger UI 5.x (CDN)
|
||
|
||
**Bağlantılar:** [[Main]], [[Index]]
|
||
|
||
## Route'lar
|
||
|
||
| Path | Açıklama |
|
||
|---|---|
|
||
| `GET /swagger` | `/swagger/`'a redirect |
|
||
| `GET /swagger/` | Swagger UI HTML (CDN) |
|
||
| `GET /swagger/swagger.json` | Statik OpenAPI spec dosyası |
|
||
|
||
## Kullanım
|
||
|
||
```bash
|
||
# Swagger spec'i yenile
|
||
swag init
|
||
|
||
# Swagger UI'a tarayıcıdan eriş
|
||
open http://localhost:8000/swagger/
|
||
```
|
||
|
||
## Swagger Annotation'ları
|
||
|
||
- `main.go:1-19` — Genel API bilgisi (title, version, host, security)
|
||
- `handlers/health.go:21-27` — `/health` endpoint
|
||
- `handlers/openai.go:20-28` — `/v1/{path}` endpoint
|
||
- `handlers/anthropic.go:65-73` — `/anthropic/{path}` endpoint
|
||
|
||
## Önemli Detaylar
|
||
|
||
- Swagger UI **unpkg CDN'inden** yüklenir (offline çalışmaz)
|
||
- Spec statik dosyadır: `docs/swagger.json`
|
||
- `docs/swagger.yaml` da mevcuttur (aynı spec)
|
||
- `swag init` her endpoint/değişiklik sonrası çalıştırılmalıdır
|
||
- API key: `Authorization: Bearer` (Swagger UI'da "Authorize" butonu)
|