From aaa3c9a8d89f0da1eaa44a4d2025703f8a9b70aa Mon Sep 17 00:00:00 2001 From: yusing Date: Sat, 10 Jan 2026 15:57:56 +0800 Subject: [PATCH] fix(swagger): correct type names in swagger docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename icon-related types in swagger docs: - homepage.FetchResult → iconfetch.Result - homepage.IconMetaSearch → iconlist.IconMetaSearch - homepage.IconSource → icons.Source - Shorten enum varnames (IconSourceAbsolute → SourceAbsolute, etc.) - Add x-nullable: true to rules arrays --- internal/api/v1/docs/swagger.json | 26 ++++++++++++-------------- internal/api/v1/docs/swagger.yaml | 22 ++++++++++++---------- internal/api/v1/favicon.go | 2 +- internal/api/v1/icons.go | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/internal/api/v1/docs/swagger.json b/internal/api/v1/docs/swagger.json index d37822a4..7683bffa 100644 --- a/internal/api/v1/docs/swagger.json +++ b/internal/api/v1/docs/swagger.json @@ -811,7 +811,7 @@ "schema": { "type": "array", "items": { - "$ref": "#/definitions/homepage.FetchResult" + "$ref": "#/definitions/iconfetch.Result" } } }, @@ -1698,7 +1698,7 @@ "schema": { "type": "array", "items": { - "$ref": "#/definitions/homepage.IconMetaSearch" + "$ref": "#/definitions/iconlist.IconMetaSearch" } } }, @@ -4335,8 +4335,7 @@ "items": { "$ref": "#/definitions/rules.Rule" }, - "x-nullable": false, - "x-omitempty": false + "x-nullable": true }, "scheme": { "type": "string", @@ -5202,7 +5201,7 @@ "x-nullable": false, "x-omitempty": false }, - "homepage.FetchResult": { + "iconfetch.Result": { "type": "object", "properties": { "icon": { @@ -5223,7 +5222,7 @@ "x-nullable": false, "x-omitempty": false }, - "homepage.IconMetaSearch": { + "iconlist.IconMetaSearch": { "type": "object", "properties": { "Dark": { @@ -5252,7 +5251,7 @@ "x-omitempty": false }, "Source": { - "$ref": "#/definitions/homepage.IconSource", + "$ref": "#/definitions/icons.Source", "x-nullable": false, "x-omitempty": false }, @@ -5265,7 +5264,7 @@ "x-nullable": false, "x-omitempty": false }, - "homepage.IconSource": { + "icons.Source": { "type": "string", "enum": [ "https://", @@ -5274,10 +5273,10 @@ "@selfhst" ], "x-enum-varnames": [ - "IconSourceAbsolute", - "IconSourceRelative", - "IconSourceWalkXCode", - "IconSourceSelfhSt" + "SourceAbsolute", + "SourceRelative", + "SourceWalkXCode", + "SourceSelfhSt" ], "x-nullable": false, "x-omitempty": false @@ -5515,8 +5514,7 @@ "items": { "$ref": "#/definitions/rules.Rule" }, - "x-nullable": false, - "x-omitempty": false + "x-nullable": true }, "scheme": { "type": "string", diff --git a/internal/api/v1/docs/swagger.yaml b/internal/api/v1/docs/swagger.yaml index a7f2c0ae..f6f692a0 100644 --- a/internal/api/v1/docs/swagger.yaml +++ b/internal/api/v1/docs/swagger.yaml @@ -959,6 +959,7 @@ definitions: items: $ref: '#/definitions/rules.Rule' type: array + x-nullable: true scheme: enum: - http @@ -1428,7 +1429,7 @@ definitions: required: - id type: object - homepage.FetchResult: + iconfetch.Result: properties: icon: items: @@ -1438,7 +1439,7 @@ definitions: statusCode: type: integer type: object - homepage.IconMetaSearch: + iconlist.IconMetaSearch: properties: Dark: type: boolean @@ -1451,11 +1452,11 @@ definitions: SVG: type: boolean Source: - $ref: '#/definitions/homepage.IconSource' + $ref: '#/definitions/icons.Source' WebP: type: boolean type: object - homepage.IconSource: + icons.Source: enum: - https:// - '@target' @@ -1463,10 +1464,10 @@ definitions: - '@selfhst' type: string x-enum-varnames: - - IconSourceAbsolute - - IconSourceRelative - - IconSourceWalkXCode - - IconSourceSelfhSt + - SourceAbsolute + - SourceRelative + - SourceWalkXCode + - SourceSelfhSt mem.VirtualMemoryStat: properties: available: @@ -1594,6 +1595,7 @@ definitions: items: $ref: '#/definitions/rules.Rule' type: array + x-nullable: true scheme: enum: - http @@ -2229,7 +2231,7 @@ paths: description: OK schema: items: - $ref: '#/definitions/homepage.FetchResult' + $ref: '#/definitions/iconfetch.Result' type: array "400": description: 'Bad Request: alias is empty or route is not HTTPRoute' @@ -2811,7 +2813,7 @@ paths: description: OK schema: items: - $ref: '#/definitions/homepage.IconMetaSearch' + $ref: '#/definitions/iconlist.IconMetaSearch' type: array "400": description: Bad Request diff --git a/internal/api/v1/favicon.go b/internal/api/v1/favicon.go index 44dfb4d8..ea5b9dff 100644 --- a/internal/api/v1/favicon.go +++ b/internal/api/v1/favicon.go @@ -28,7 +28,7 @@ type GetFavIconRequest struct { // @Produce image/svg+xml,image/x-icon,image/png,image/webp // @Param url query string false "URL of the route" // @Param alias query string false "Alias of the route" -// @Success 200 {array} homepage.FetchResult +// @Success 200 {array} iconfetch.Result // @Failure 400 {object} apitypes.ErrorResponse "Bad Request: alias is empty or route is not HTTPRoute" // @Failure 403 {object} apitypes.ErrorResponse "Forbidden: unauthorized" // @Failure 404 {object} apitypes.ErrorResponse "Not Found: route or icon not found" diff --git a/internal/api/v1/icons.go b/internal/api/v1/icons.go index 52e0c4a7..4258d171 100644 --- a/internal/api/v1/icons.go +++ b/internal/api/v1/icons.go @@ -22,7 +22,7 @@ type ListIconsRequest struct { // @Produce json // @Param limit query int false "Limit" // @Param keyword query string false "Keyword" -// @Success 200 {array} homepage.IconMetaSearch +// @Success 200 {array} iconlist.IconMetaSearch // @Failure 400 {object} apitypes.ErrorResponse // @Failure 403 {object} apitypes.ErrorResponse // @Router /icons [get]