From 94e9cbcd719bbc3a225d0e3000005ee18716a644 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Thu, 25 Jul 2024 14:06:19 +0200 Subject: [PATCH] Add return type to GetRawFileOrLFS and GetRawFile (#31680) Document return type for the endpoints that fetch specific files from a repository. This allows the swagger generated code to read the returned data. Co-authored-by: Giteabot (cherry picked from commit bae87dfb0958e6a2920c905e51c2a026b7b71ca6) --- routers/api/v1/repo/file.go | 8 +++++++- templates/swagger/v1_json.tmpl | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 34ccc929a5..aae82894c7 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -45,7 +45,7 @@ func GetRawFile(ctx *context.APIContext) { // --- // summary: Get a file from a repository // produces: - // - application/json + // - application/octet-stream // parameters: // - name: owner // in: path @@ -70,6 +70,8 @@ func GetRawFile(ctx *context.APIContext) { // responses: // 200: // description: Returns raw file content. + // schema: + // type: file // "404": // "$ref": "#/responses/notFound" @@ -96,6 +98,8 @@ func GetRawFileOrLFS(ctx *context.APIContext) { // swagger:operation GET /repos/{owner}/{repo}/media/{filepath} repository repoGetRawFileOrLFS // --- // summary: Get a file or it's LFS object from a repository + // produces: + // - application/octet-stream // parameters: // - name: owner // in: path @@ -120,6 +124,8 @@ func GetRawFileOrLFS(ctx *context.APIContext) { // responses: // 200: // description: Returns raw file content. + // schema: + // type: file // "404": // "$ref": "#/responses/notFound" diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index dacec3ed1a..b8b896a00c 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -10867,6 +10867,9 @@ }, "/repos/{owner}/{repo}/media/{filepath}": { "get": { + "produces": [ + "application/octet-stream" + ], "tags": [ "repository" ], @@ -10903,7 +10906,10 @@ ], "responses": { "200": { - "description": "Returns raw file content." + "description": "Returns raw file content.", + "schema": { + "type": "file" + } }, "404": { "$ref": "#/responses/notFound" @@ -13122,7 +13128,7 @@ "/repos/{owner}/{repo}/raw/{filepath}": { "get": { "produces": [ - "application/json" + "application/octet-stream" ], "tags": [ "repository" @@ -13160,7 +13166,10 @@ ], "responses": { "200": { - "description": "Returns raw file content." + "description": "Returns raw file content.", + "schema": { + "type": "file" + } }, "404": { "$ref": "#/responses/notFound"