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:
@@ -17,7 +17,7 @@ import (
|
||||
// @Produce json
|
||||
// @Security AdminAuth
|
||||
// @Param key body dto.APIKeyDTO true "API key payload"
|
||||
// @Success 201 {object} ResponseEnvelope{data=model.APIKey}
|
||||
// @Success 201 {object} ResponseEnvelope{data=dto.APIKeyResponse}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=MapData}
|
||||
// @Router /admin/api-keys [post]
|
||||
@@ -100,7 +100,7 @@ func (h *Handler) CreateAPIKey(c *gin.Context) {
|
||||
// @Param limit query int false "limit (default 50, max 200)"
|
||||
// @Param group_id query int false "filter by group_id"
|
||||
// @Param status query string false "filter by status (active, suspended, auto_disabled, manual_disabled)"
|
||||
// @Success 200 {object} ResponseEnvelope{data=[]model.APIKey}
|
||||
// @Success 200 {object} ResponseEnvelope{data=[]dto.APIKeyResponse}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=MapData}
|
||||
// @Router /admin/api-keys [get]
|
||||
func (h *Handler) ListAPIKeys(c *gin.Context) {
|
||||
@@ -128,7 +128,7 @@ func (h *Handler) ListAPIKeys(c *gin.Context) {
|
||||
// @Produce json
|
||||
// @Security AdminAuth
|
||||
// @Param id path int true "APIKey ID"
|
||||
// @Success 200 {object} ResponseEnvelope{data=model.APIKey}
|
||||
// @Success 200 {object} ResponseEnvelope{data=dto.APIKeyResponse}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 404 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=MapData}
|
||||
@@ -155,7 +155,7 @@ func (h *Handler) GetAPIKey(c *gin.Context) {
|
||||
// @Security AdminAuth
|
||||
// @Param id path int true "APIKey ID"
|
||||
// @Param key body dto.APIKeyDTO true "API key payload"
|
||||
// @Success 200 {object} ResponseEnvelope{data=model.APIKey}
|
||||
// @Success 200 {object} ResponseEnvelope{data=dto.APIKeyResponse}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 404 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=MapData}
|
||||
|
||||
Reference in New Issue
Block a user