From dc1a82bf4cfe17cb7847270f59e185879a3d4c9c Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Wed, 8 Nov 2023 08:56:22 +0100 Subject: [PATCH] use star as swagger model --- modules/forgefed/star.go | 3 +++ routers/api/v1/activitypub/repository.go | 5 ++++- routers/api/v1/swagger/options.go | 6 +++++- templates/swagger/v1_json.tmpl | 7 +++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/forgefed/star.go b/modules/forgefed/star.go index 17bcd57aea..e34c67e7d9 100644 --- a/modules/forgefed/star.go +++ b/modules/forgefed/star.go @@ -25,7 +25,10 @@ var KnownSourceTypes = SourceTypes{ ForgejoSourceType, } +// Star activity for adding a star to an repository +// swagger:model type Star struct { + // swagger: ignore ap.Activity // Source identifies the system generated this Activity. Exact one value has to be specified. Source SourceType `jsonld:"source,omitempty"` diff --git a/routers/api/v1/activitypub/repository.go b/routers/api/v1/activitypub/repository.go index b0732acc0c..1279c2f3be 100644 --- a/routers/api/v1/activitypub/repository.go +++ b/routers/api/v1/activitypub/repository.go @@ -34,7 +34,6 @@ func Repository(ctx *context.APIContext) { // "200": // "$ref": "#/responses/ActivityPub" - // TODO: Mabe we should use F3 Repo instead? link := fmt.Sprintf("%s/api/v1/activitypub/repoistory-id/%d", strings.TrimSuffix(setting.AppURL, "/"), ctx.Repo.Repository.ID) repo := forgefed.RepositoryNew(ap.IRI(link)) @@ -61,6 +60,10 @@ func RepositoryInbox(ctx *context.APIContext) { // description: repository ID of the repo // type: integer // required: true + // - name: body + // in: body + // schema: + // "$ref": "#/definitions/Star" // responses: // "204": // "$ref": "#/responses/empty" diff --git a/routers/api/v1/swagger/options.go b/routers/api/v1/swagger/options.go index 2886b865e8..0d56aa09bf 100644 --- a/routers/api/v1/swagger/options.go +++ b/routers/api/v1/swagger/options.go @@ -1,9 +1,10 @@ -// Copyright 2017 The Gitea Authors. All rights reserved. +// Copyright 2023 The Gitea & forgejo Authors. All rights reserved. // SPDX-License-Identifier: MIT package swagger import ( + ffed "code.gitea.io/gitea/modules/forgefed" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/services/forms" ) @@ -14,6 +15,9 @@ import ( // parameterBodies // swagger:response parameterBodies type swaggerParameterBodies struct { + // in:body + Star ffed.Star + // in:body AddCollaboratorOption api.AddCollaboratorOption diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 595798cc55..0342515c1c 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -66,6 +66,13 @@ "name": "repository-id", "in": "path", "required": true + }, + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/Star" + } } ], "responses": {