Skip to content

Commit ad4d0c7

Browse files
committed
doc: add swagger doc for /api/gpg/key
- cleanup swagger validation errors
1 parent a11e004 commit ad4d0c7

2 files changed

Lines changed: 40 additions & 21 deletions

File tree

api/gpg.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,34 @@ import (
1313
)
1414

1515
type gpgAddKeyParams struct {
16-
// Keyserver, when downloading GpgKeyIDs
17-
Keyserver string `json:"Keyserver" example:"hkp://keyserver.ubuntu.com:80"`
18-
// GpgKeyIDs to download from Keyserver, comma separated list
19-
GpgKeyID string `json:"GpgKeyID" example:"EF0F382A1A7B6500,8B48AD6246925553"`
20-
// Armored gpg public ket, instead of downloading from keyserver
21-
GpgKeyArmor string `json:"GpgKeyArmor" example:""`
2216
// Keyring for adding the keys (default: trustedkeys.gpg)
2317
Keyring string `json:"Keyring" example:"trustedkeys.gpg"`
18+
19+
// Add ASCII armored gpg public key, do not download from keyserver
20+
GpgKeyArmor string `json:"GpgKeyArmor" example:""`
21+
22+
// Keyserver to download keys provided in `GpgKeyID`
23+
Keyserver string `json:"Keyserver" example:"hkp://keyserver.ubuntu.com:80"`
24+
// Keys do download from `Keyserver`, separated by space
25+
GpgKeyID string `json:"GpgKeyID" example:"EF0F382A1A7B6500 8B48AD6246925553"`
2426
}
2527

2628
// @Summary Add GPG Keys
2729
// @Description **Adds GPG keys to aptly keyring**
2830
// @Description
2931
// @Description Add GPG public keys for veryfing remote repositories for mirroring.
32+
// @Description
33+
// @Description Keys can be added in two ways:
34+
// @Description * By providing the ASCII armord key in `GpgKeyArmor` (leave Keyserver and GpgKeyID empty)
35+
// @Description * By providing a `Keyserver` and one or more key IDs in `GpgKeyID`, separated by space (leave GpgKeyArmor empty)
36+
// @Description
3037
// @Tags Mirrors
38+
// @Consume json
39+
// @Param request body gpgAddKeyParams true "Parameters"
3140
// @Produce json
3241
// @Success 200 {object} string "OK"
3342
// @Failure 400 {object} Error "Bad Request"
34-
// @Failure 404 {object} Error "Not Found"
35-
// @Router /api/gpg [post]
43+
// @Router /api/gpg/key [post]
3644
func apiGPGAddKey(c *gin.Context) {
3745
b := gpgAddKeyParams{}
3846
if c.Bind(&b) != nil {

api/repos.go

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ type repoCreateParams struct {
107107
// @Description {"Name":"aptly-repo","Comment":"","DefaultDistribution":"","DefaultComponent":""}
108108
// @Description ```
109109
// @Tags Repos
110-
// @Produce json
111110
// @Consume json
112111
// @Param request body repoCreateParams true "Parameters"
112+
// @Produce json
113113
// @Success 201 {object} deb.LocalRepo
114114
// @Failure 404 {object} Error "Source snapshot not found"
115115
// @Failure 409 {object} Error "Local repo already exists"
@@ -178,8 +178,10 @@ type reposEditParams struct {
178178
// @Summary Update Repository
179179
// @Description **Update local repository meta information**
180180
// @Tags Repos
181-
// @Produce json
181+
// @Param name path string true "Repository name"
182+
// @Consume json
182183
// @Param request body reposEditParams true "Parameters"
184+
// @Produce json
183185
// @Success 200 {object} deb.LocalRepo "msg"
184186
// @Failure 404 {object} Error "Not Found"
185187
// @Failure 500 {object} Error "Internal Server Error"
@@ -231,8 +233,8 @@ func apiReposEdit(c *gin.Context) {
231233
// @Summary Get Repository Info
232234
// @Description Returns basic information about local repository.
233235
// @Tags Repos
234-
// @Produce json
235236
// @Param name path string true "Repository name"
237+
// @Produce json
236238
// @Success 200 {object} deb.LocalRepo
237239
// @Failure 404 {object} Error "Repository not found"
238240
// @Router /api/repos/{name} [get]
@@ -254,9 +256,10 @@ func apiReposShow(c *gin.Context) {
254256
// @Description Cannot drop repos that are published.
255257
// @Description Needs force=1 to drop repos used as source by other repos.
256258
// @Tags Repos
257-
// @Produce json
259+
// @Param name path string true "Repository name"
258260
// @Param _async query bool false "Run in background and return task object"
259261
// @Param force query int false "force: 1 to enable"
262+
// @Produce json
260263
// @Success 200 {object} task.ProcessReturnValue "Repo object"
261264
// @Failure 404 {object} Error "Not Found"
262265
// @Failure 404 {object} Error "Repo Conflict"
@@ -306,12 +309,12 @@ func apiReposDrop(c *gin.Context) {
306309
// @Description ["Pi386 aptly 0.8 966561016b44ed80"]
307310
// @Description ```
308311
// @Tags Repos
309-
// @Produce json
310-
// @Param name path string true "Snapshot to search"
312+
// @Param name path string true "Repository name"
311313
// @Param q query string true "Package query (e.g Name%20(~%20matlab))"
312314
// @Param withDeps query string true "Set to 1 to include dependencies when evaluating package query"
313315
// @Param format query string true "Set to 'details' to return extra info about each package"
314316
// @Param maximumVersion query string true "Set to 1 to only return the highest version for each package name"
317+
// @Produce json
315318
// @Success 200 {object} string "msg"
316319
// @Failure 404 {object} Error "Not Found"
317320
// @Failure 404 {object} Error "Internal Server Error"
@@ -406,9 +409,10 @@ func apiReposPackagesAddDelete(c *gin.Context, taskNamePrefix string, cb func(li
406409
// @Description
407410
// @Description API verifies that packages actually exist in aptly database and checks constraint that conflicting packages can’t be part of the same local repository.
408411
// @Tags Repos
409-
// @Produce json
412+
// @Param name path string true "Repository name"
410413
// @Param request body reposPackagesAddDeleteParams true "Parameters"
411414
// @Param _async query bool false "Run in background and return task object"
415+
// @Produce json
412416
// @Success 200 {object} string "msg"
413417
// @Failure 400 {object} Error "Bad Request"
414418
// @Failure 404 {object} Error "Not Found"
@@ -426,9 +430,11 @@ func apiReposPackagesAdd(c *gin.Context) {
426430
// @Description
427431
// @Description Any package(s) can be removed from a local repository. Package references from a local repository can be retrieved with GET /api/repos/:name/packages.
428432
// @Tags Repos
429-
// @Produce json
430-
// @Param request body reposPackagesAddDeleteParams true "Parameters"
433+
// @Param name path string true "Repository name"
431434
// @Param _async query bool false "Run in background and return task object"
435+
// @Consume json
436+
// @Param request body reposPackagesAddDeleteParams true "Parameters"
437+
// @Produce json
432438
// @Success 200 {object} string "msg"
433439
// @Failure 400 {object} Error "Bad Request"
434440
// @Failure 404 {object} Error "Not Found"
@@ -608,8 +614,8 @@ type reposCopyPackageParams struct {
608614
// @Description Copies a package from a source to destination repository
609615
// @Tags Repos
610616
// @Produce json
611-
// @Param name path string true "Source repo"
612-
// @Param src path string true "Destination repo"
617+
// @Param name path string true "Destination repo"
618+
// @Param src path string true "Source repo"
613619
// @Param file path string true "File/packages to copy"
614620
// @Param _async query bool false "Run in background and return task object"
615621
// @Success 200 {object} task.ProcessReturnValue "msg"
@@ -762,12 +768,15 @@ func apiReposCopyPackage(c *gin.Context) {
762768
// @Summary Include File from Directory
763769
// @Description Allows automatic processing of .changes file controlling package upload (uploaded using File Upload API) to the local repository. i.e. Exposes repo include command in api.
764770
// @Tags Repos
765-
// @Produce json
771+
// @Param name path string true "Repository name"
772+
// @Param dir path string true "Directory of packages"
773+
// @Param file path string true "File/packages to include"
766774
// @Param forceReplace query int false "when value is set to 1, when adding package that conflicts with existing package, remove existing package"
767775
// @Param noRemoveFiles query int false "when value is set to 1, don’t remove files that have been imported successfully into repository"
768776
// @Param acceptUnsigned query int false "when value is set to 1, accept unsigned .changes files"
769777
// @Param ignoreSignature query int false "when value is set to 1 disable verification of .changes file signature"
770778
// @Param _async query bool false "Run in background and return task object"
779+
// @Produce json
771780
// @Success 200 {object} string "msg"
772781
// @Failure 404 {object} Error "Not Found"
773782
// @Router /api/repos/{name}/include/{dir}/{file} [post]
@@ -784,12 +793,14 @@ type reposIncludePackageFromDirResponse struct {
784793
// @Summary Include Directory
785794
// @Description Allows automatic processing of .changes file controlling package upload (uploaded using File Upload API) to the local repository. i.e. Exposes repo include command in api.
786795
// @Tags Repos
787-
// @Produce json
796+
// @Param name path string true "Repository name"
797+
// @Param dir path string true "Directory of packages"
788798
// @Param forceReplace query int false "when value is set to 1, when adding package that conflicts with existing package, remove existing package"
789799
// @Param noRemoveFiles query int false "when value is set to 1, don’t remove files that have been imported successfully into repository"
790800
// @Param acceptUnsigned query int false "when value is set to 1, accept unsigned .changes files"
791801
// @Param ignoreSignature query int false "when value is set to 1 disable verification of .changes file signature"
792802
// @Param _async query bool false "Run in background and return task object"
803+
// @Produce json
793804
// @Success 200 {object} reposIncludePackageFromDirResponse "Response"
794805
// @Failure 404 {object} Error "Not Found"
795806
// @Router /api/repos/{name}/include/{dir} [post]

0 commit comments

Comments
 (0)