]> source.dussan.org Git - gitea.git/commitdiff
Swagger AccessToken fixes (#16574)
authorzeripath <art27@cantab.net>
Sun, 1 Aug 2021 20:44:15 +0000 (21:44 +0100)
committerGitHub <noreply@github.com>
Sun, 1 Aug 2021 20:44:15 +0000 (16:44 -0400)
There is a subtle problem with the Swagger definition for AccessTokens which causes
autogeneration of APIs for these endpoints to fail.

This PR corrects these errors.

Ref: https://github.com/zeripath/java-gitea-api/issues/4
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
routers/api/v1/swagger/app.go
routers/api/v1/swagger/options.go
routers/api/v1/user/app.go
templates/swagger/v1_json.tmpl

index 8be2c855749a3ec3d5414478b893fb77870c4294..9783abe1a082fdbca4dc1088820db4864d515a0a 100644 (file)
@@ -14,3 +14,10 @@ type swaggerResponseOAuth2Application struct {
        // in:body
        Body api.OAuth2Application `json:"body"`
 }
+
+// AccessToken represents an API access token.
+// swagger:response AccessToken
+type swaggerResponseAccessToken struct {
+       // in:body
+       Body api.AccessToken `json:"body"`
+}
index 0ae96a9203543893e2a269ba5d98b70b1f3fdcfa..3f0c6e2d524c4a823ba4fe46dbf843190a9386da 100644 (file)
@@ -164,6 +164,9 @@ type swaggerParameterBodies struct {
        // in:body
        CreateTagOption api.CreateTagOption
 
+       // in:body
+       CreateAccessTokenOption api.CreateAccessTokenOption
+
        // in:body
        UserSettingsOptions api.UserSettingsOptions
 }
index 9f355a82895069f2cf79c619106f4bcab8fdb275..afd209f2f079165af90e71f0ea2c5516754409c5 100644 (file)
@@ -76,15 +76,10 @@ func CreateAccessToken(ctx *context.APIContext) {
        //   description: username of user
        //   type: string
        //   required: true
-       // - name: accessToken
+       // - name: userCreateToken
        //   in: body
        //   schema:
-       //     type: object
-       //     required:
-       //       - name
-       //     properties:
-       //       name:
-       //         type: string
+       //     "$ref": "#/definitions/CreateAccessTokenOption"
        // responses:
        //   "201":
        //     "$ref": "#/responses/AccessToken"
index d97ec5ff2d7be458c21616b7363318b976373f70..a1d92abec7a86e0813994def915aafdb1271664d 100644 (file)
             "required": true
           },
           {
-            "name": "accessToken",
+            "name": "userCreateToken",
             "in": "body",
             "schema": {
-              "type": "object",
-              "required": [
-                "name"
-              ],
-              "properties": {
-                "name": {
-                  "type": "string"
-                }
-              }
+              "$ref": "#/definitions/CreateAccessTokenOption"
             }
           }
         ],
       },
       "x-go-package": "code.gitea.io/gitea/modules/structs"
     },
+    "CreateAccessTokenOption": {
+      "description": "CreateAccessTokenOption options when create access token",
+      "type": "object",
+      "properties": {
+        "name": {
+          "type": "string",
+          "x-go-name": "Name"
+        }
+      },
+      "x-go-package": "code.gitea.io/gitea/modules/structs"
+    },
     "CreateBranchProtectionOption": {
       "description": "CreateBranchProtectionOption options for creating a branch protection",
       "type": "object",
   "responses": {
     "AccessToken": {
       "description": "AccessToken represents an API access token.",
-      "headers": {
-        "id": {
-          "type": "integer",
-          "format": "int64"
-        },
-        "name": {
-          "type": "string"
-        },
-        "sha1": {
-          "type": "string"
-        },
-        "token_last_eight": {
-          "type": "string"
-        }
+      "schema": {
+        "$ref": "#/definitions/AccessToken"
       }
     },
     "AccessTokenList": {