mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
refactor(api): standardize DTOs and update swagger
Decouple API contract from internal models by introducing dedicated DTOs for requests and responses. - Add Response DTOs for all resources (API Keys, Bindings, Models, Namespaces, etc.) - Update Swagger annotations to use DTOs with field examples instead of internal models - Refactor handlers to bind and return DTO structures - Consolidate request/response definitions in the dto package
This commit is contained in:
@@ -1,14 +1,39 @@
|
||||
package dto
|
||||
|
||||
import "time"
|
||||
|
||||
// ProviderGroupResponse represents a provider group in API responses.
|
||||
// @Description Provider group response
|
||||
type ProviderGroupResponse struct {
|
||||
ID uint `json:"id" example:"1"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Name string `json:"name" example:"openai-prod"`
|
||||
Type string `json:"type" example:"openai"`
|
||||
BaseURL string `json:"base_url" example:"https://api.openai.com"`
|
||||
GoogleProject string `json:"google_project,omitempty"`
|
||||
GoogleLocation string `json:"google_location,omitempty"`
|
||||
StaticHeaders string `json:"static_headers,omitempty"`
|
||||
HeadersProfile string `json:"headers_profile,omitempty"`
|
||||
Models string `json:"models" example:"gpt-4,gpt-3.5-turbo"`
|
||||
Status string `json:"status" example:"active"`
|
||||
TotalRequests int64 `json:"total_requests" example:"1000"`
|
||||
SuccessRequests int64 `json:"success_requests" example:"950"`
|
||||
FailureRequests int64 `json:"failure_requests" example:"50"`
|
||||
SuccessRate float64 `json:"success_rate" example:"0.95"`
|
||||
FailureRate float64 `json:"failure_rate" example:"0.05"`
|
||||
}
|
||||
|
||||
// ProviderGroupDTO defines inbound payload for provider group creation/update.
|
||||
// @Description Provider group create/update request
|
||||
type ProviderGroupDTO struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
BaseURL string `json:"base_url"`
|
||||
Name string `json:"name" example:"openai-prod"`
|
||||
Type string `json:"type" example:"openai"`
|
||||
BaseURL string `json:"base_url" example:"https://api.openai.com"`
|
||||
GoogleProject string `json:"google_project,omitempty"`
|
||||
GoogleLocation string `json:"google_location,omitempty"`
|
||||
StaticHeaders string `json:"static_headers,omitempty"`
|
||||
HeadersProfile string `json:"headers_profile,omitempty"`
|
||||
Models []string `json:"models"`
|
||||
Status string `json:"status"`
|
||||
Models []string `json:"models" example:"gpt-4,gpt-3.5-turbo"`
|
||||
Status string `json:"status" example:"active"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user