diff --git a/Makefile b/Makefile index d8b06565fc..b26d454b04 100644 --- a/Makefile +++ b/Makefile @@ -127,6 +127,13 @@ SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl}}/api/v SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl}}/api/v1"|"basePath": "/api/v1"|g SWAGGER_EXCLUDE := code.gitea.io/sdk SWAGGER_NEWLINE_COMMAND := -e '$$a\' +# DCS Customizations +SWAGGER_CATALOG_SPEC := templates/swagger/catalog/catalog_json.tmpl +SWAGGER_CATALOG_SPEC_S_TMPL := s|"basePath": *"/api/catalog"|"basePath": "{{AppSubUrl}}/api/catalog"|g +SWAGGER_CATALOG_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl}}/api/catalog"|"basePath": "/api/catalog"|g +SWAGGER_CATALOG_EXCLUDE := code.gitea.io/sdk" -x "code.gitea.io/gitea/routers/api/v1 +SWAGGER_EXCLUDE := code.gitea.io/sdk" -x "code.gitea.io/gitea/routers/api/catalog +# END DCS Customizations TEST_MYSQL_HOST ?= mysql:3306 TEST_MYSQL_DBNAME ?= testgitea @@ -230,7 +237,7 @@ vet: # Default vet $(GO) vet $(GO_PACKAGES) # Custom vet - $(GO) build -mod=vendor gitea.com/unfoldingword/gitea-vet + $(GO) build -mod=vendor gitea.com/unfoldingword/gitea-vet $(GO) vet -vettool=gitea-vet $(GO_PACKAGES) .PHONY: $(TAGS_EVIDENCE) @@ -247,6 +254,11 @@ generate-swagger: $(SWAGGER) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)' $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)' $(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)' +# DCS Customizations + $(SWAGGER) generate spec -x "$(SWAGGER_CATALOG_EXCLUDE)" -o './$(SWAGGER_CATALOG_SPEC)' + $(SED_INPLACE) '$(SWAGGER_CATALOG_SPEC_S_TMPL)' './$(SWAGGER_CATALOG_SPEC)' + $(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_CATALOG_SPEC)' +# END DCS Customizaitons .PHONY: swagger-check swagger-check: generate-swagger diff --git a/models/door43metadata.go b/models/door43metadata.go index 6be5cdcae4..75d467c1ea 100644 --- a/models/door43metadata.go +++ b/models/door43metadata.go @@ -7,6 +7,7 @@ package models import ( "fmt" "sort" + "time" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" @@ -33,41 +34,43 @@ type Door43Metadata struct { UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` } +// GetRepo gets the repo associated with the door43 metadata entry func (dm *Door43Metadata) GetRepo() error { return dm.getRepo(x) } func (dm *Door43Metadata) getRepo(e Engine) error { if dm.Repo == nil { - if repo, err := GetRepositoryByID(dm.RepoID); err != nil { + repo, err := GetRepositoryByID(dm.RepoID) + if err != nil { + return err + } + dm.Repo = repo + if err := dm.Repo.getOwner(e); err != nil { return err - } else { - dm.Repo = repo - if err := dm.Repo.getOwner(e); err != nil { - return nil - } } } return nil } +// GetRelease gets the associated release of a door43 metadata entry func (dm *Door43Metadata) GetRelease() error { return dm.getRelease(x) } func (dm *Door43Metadata) getRelease(e Engine) error { if dm.ReleaseID > 0 && dm.Release == nil { - if rel, err := GetReleaseByID(dm.ReleaseID); err != nil { + rel, err := GetReleaseByID(dm.ReleaseID) + if err != nil { return err - } else { - dm.Release = rel - dm.Release.Door43Metadata = dm - if err := dm.getRepo(e); err != nil { - return err - } - dm.Release.Repo = dm.Repo - return dm.Release.loadAttributes(e) } + dm.Release = rel + dm.Release.Door43Metadata = dm + if err := dm.getRepo(e); err != nil { + return err + } + dm.Release.Repo = dm.Repo + return dm.Release.loadAttributes(e) } return nil } @@ -77,7 +80,7 @@ func (dm *Door43Metadata) loadAttributes(e Engine) error { return err } if dm.Release == nil && dm.ReleaseID > 0 { - if err := dm.getRelease(e); err !=nil { + if err := dm.getRelease(e); err != nil { return nil } } @@ -145,7 +148,12 @@ func (dm *Door43Metadata) GetZipballURL() string { // GetReleaseURL get the URL the release API func (dm *Door43Metadata) GetReleaseURL() string { if dm.ReleaseID > 0 { - return dm.Release.APIURL() + if dm.Release != nil { + return dm.Release.APIURL() + } + if err := dm.GetRepo(); err == nil { + return fmt.Sprintf("%sapi/v1/repos/%s/releases/%d", setting.AppURL, dm.Repo.FullName(), dm.ReleaseID) + } } return "" } @@ -342,6 +350,11 @@ func (dm *Door43Metadata) GetReleaseCount() (int64, error) { Count(&Door43Metadata{}) } +// GetReleaseDateTime returns the ReleaseDateUnix time stamp as a RFC3339 date, e.g. 2006-01-02T15:04:05Z07:00 +func (dm *Door43Metadata) GetReleaseDateTime() string { + return dm.ReleaseDateUnix.Format(time.RFC3339) +} + // GetDoor43MetadataByRepoIDAndReleaseID returns the metadata of a given release ID (0 = default branch). func GetDoor43MetadataByRepoIDAndReleaseID(repoID, releaseID int64) (*Door43Metadata, error) { return getDoor43MetadataByRepoIDAndReleaseID(x, repoID, releaseID) @@ -359,6 +372,26 @@ func getDoor43MetadataByRepoIDAndReleaseID(e Engine, repoID, releaseID int64) (* return dm, err } +// GetDoor43MetadataByRepoIDAndStage returns the metadata of a given repo ID and stage. +func GetDoor43MetadataByRepoIDAndStage(repoID int64, stage Stage) (*Door43Metadata, error) { + return getDoor43MetadataByRepoIDAndStage(x, repoID, stage) +} + +func getDoor43MetadataByRepoIDAndStage(e Engine, repoID int64, stage Stage) (*Door43Metadata, error) { + var cond = builder.NewCond(). + And(builder.Eq{"repo_id": repoID}). + And(builder.Eq{"stage": stage}) + e = e.Where(cond) + e.Desc("created_unix") + + dm := &Door43Metadata{} + found, err := e.Get(dm) + if err != nil || !found { + return nil, err + } + return dm, err +} + type door43MetadataSorter struct { dms []*Door43Metadata } diff --git a/models/repo.go b/models/repo.go index 9668d286f0..ba1d65fd31 100644 --- a/models/repo.go +++ b/models/repo.go @@ -410,6 +410,75 @@ func (repo *Repository) innerAPIFormat(e Engine, mode AccessMode, isParent bool) numReleases, _ := GetReleaseCountByRepoID(repo.ID, FindReleasesOptions{IncludeDrafts: false, IncludeTags: true}) /* DCS Customizations */ + catalog := &api.CatalogStages{} + prod, err := GetDoor43MetadataByRepoIDAndStage(repo.ID, StageProd) + if err != nil { + log.Error("GetDoor43MetadataByRepoIDAndStage: %v", err) + } + preprod, err := GetDoor43MetadataByRepoIDAndStage(repo.ID, StagePreProd) + if err != nil { + log.Error("GetDoor43MetadataByRepoIDAndStage: %v", err) + } + draft, err := GetDoor43MetadataByRepoIDAndStage(repo.ID, StageDraft) + if err != nil { + log.Error("GetDoor43MetadataByRepoIDAndStage: %v", err) + } + latest, err := GetDoor43MetadataByRepoIDAndStage(repo.ID, StageLatest) + if err != nil { + log.Error("GetDoor43MetadataByRepoIDAndStage: %v", err) + } + + if draft != nil && ((prod != nil && prod.ReleaseDateUnix >= draft.ReleaseDateUnix) || + (preprod != nil && preprod.ReleaseDateUnix >= draft.ReleaseDateUnix)) { + draft = nil + } + if prod != nil && preprod != nil && prod.ReleaseDateUnix >= preprod.ReleaseDateUnix { + preprod = nil + } + if prod != nil { + prod.Repo = repo + url := prod.GetReleaseURL() + catalog.Production = &api.CatalogStage{ + Tag: prod.BranchOrTag, + ReleaseURL: &url, + Released: prod.GetReleaseDateTime(), + ZipballURL: prod.GetZipballURL(), + TarballURL: prod.GetTarballURL(), + } + } + if preprod != nil { + preprod.Repo = repo + url := preprod.GetReleaseURL() + catalog.PreProduction = &api.CatalogStage{ + Tag: preprod.BranchOrTag, + ReleaseURL: &url, + Released: preprod.GetReleaseDateTime(), + ZipballURL: preprod.GetZipballURL(), + TarballURL: preprod.GetTarballURL(), + } + } + if draft != nil { + draft.Repo = repo + url := draft.GetReleaseURL() + catalog.Draft = &api.CatalogStage{ + Tag: draft.BranchOrTag, + ReleaseURL: &url, + Released: draft.GetReleaseDateTime(), + ZipballURL: draft.GetZipballURL(), + TarballURL: draft.GetTarballURL(), + } + } + if latest != nil { + latest.Repo = repo + catalog.Latest = &api.CatalogStage{ + Tag: latest.BranchOrTag, + ReleaseURL: nil, + Released: latest.GetReleaseDateTime(), + ZipballURL: latest.GetZipballURL(), + TarballURL: latest.GetTarballURL(), + } + } + metadata, err := getDoor43MetadataByRepoIDAndReleaseID(e, repo.ID, 0) if err != nil && !IsErrDoor43MetadataNotExist(err) { log.Error("getDoor43MetadataByRepoIDAndReleaseID: %v", err) @@ -480,6 +549,7 @@ func (repo *Repository) innerAPIFormat(e Engine, mode AccessMode, isParent bool) Subject: subject, Books: books, CheckingLevel: checkingLevel, + Catalog: catalog, } } diff --git a/modules/convert/door43metadata.go b/modules/convert/door43metadata.go index 7741923dfe..806d56bc34 100644 --- a/modules/convert/door43metadata.go +++ b/modules/convert/door43metadata.go @@ -44,7 +44,7 @@ func ToDoor43MetadataV4(dm *models.Door43Metadata, mode models.AccessMode) *api. // ToDoor43MetadataV5 converts a Door43Metadata to api.Door43Metadata for Catalog V5 func ToDoor43MetadataV5(dm *models.Door43Metadata, mode models.AccessMode) *api.Door43MetadataV5 { if err := dm.LoadAttributes(); err != nil { - return nil + return nil } if err := dm.Repo.GetOwner(); err != nil { @@ -59,11 +59,11 @@ func ToDoor43MetadataV5(dm *models.Door43Metadata, mode models.AccessMode) *api. return &api.Door43MetadataV5{ ID: dm.ID, Self: dm.APIURLV5(), - Name: dm.Repo.Name, - Owner: dm.Repo.OwnerName, - FullName: dm.Repo.FullName(), + Name: dm.Repo.Name, + Owner: dm.Repo.OwnerName, + FullName: dm.Repo.FullName(), Repo: dm.Repo.APIFormat(mode), - Release: release, + Release: release, TarballURL: dm.GetTarballURL(), ZipballURL: dm.GetZipballURL(), Language: (*dm.Metadata)["dublin_core"].(map[string]interface{})["language"].(map[string]interface{})["identifier"].(string), @@ -72,7 +72,7 @@ func ToDoor43MetadataV5(dm *models.Door43Metadata, mode models.AccessMode) *api. Books: dm.GetBooks(), BranchOrTag: dm.BranchOrTag, Stage: dm.Stage.String(), - Released: dm.ReleaseDateUnix.FormatDate(), + Released: dm.GetReleaseDateTime(), MetadataVersion: dm.MetadataVersion, MetadataURL: dm.GetMetadataURL(), MetadataJSONURL: dm.GetMetadataJSONURL(), diff --git a/modules/structs/door43metadata.go b/modules/structs/door43metadata.go index 1ed0409321..20f59f84c7 100644 --- a/modules/structs/door43metadata.go +++ b/modules/structs/door43metadata.go @@ -32,11 +32,11 @@ type Door43MetadataV4 struct { type Door43MetadataV5 struct { ID int64 `json:"id"` Self string `json:"url"` - Name string `json:"name"` - Owner string `json:"owner"` - FullName string `json:"full_name"` + Name string `json:"name"` + Owner string `json:"owner"` + FullName string `json:"full_name"` Repo *Repository `json:"repo"` - Release *Release `json:"release"` + Release *Release `json:"release"` TarballURL string `json:"tarbar_url"` ZipballURL string `json:"zipball_url"` Language string `json:"language"` @@ -64,3 +64,32 @@ type CatalogSearchResultsV5 struct { OK bool `json:"ok"` Data []*Door43MetadataV5 `json:"data"` } + +// CatalogVersionEndpoints Info on the versions of the catalog +type CatalogVersionEndpoints struct { + Latest string `json:"latest"` + Versions map[string]string `json:"versions"` +} + +// CatalogVersionEndpointsResponse response with the endpoints for all versions of the catalog +type CatalogVersionEndpointsResponse struct { + OK bool `json:"ok"` + Data []*CatalogVersionEndpoints `json:"data"` +} + +// CatalogStages a repo's catalog stages +type CatalogStages struct { + Production *CatalogStage `json:"prod"` + PreProduction *CatalogStage `json:"preprod"` + Draft *CatalogStage `json:"draft"` + Latest *CatalogStage `json:"latest"` +} + +// CatalogStage a repo's catalog stage metadata +type CatalogStage struct { + Tag string `json:"branch_or_tag_name"` + ReleaseURL *string `json:"release_url"` + Released string `json:"released"` + ZipballURL string `json:"zipball_url"` + TarballURL string `json:"tarball_url"` +} diff --git a/modules/structs/repo.go b/modules/structs/repo.go index c64d3262f9..997f11192a 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -96,6 +96,7 @@ type Repository struct { Books []string `json:"books"` Title string `json:"title"` CheckingLevel string `json:"checking_level"` + Catalog *CatalogStages `json:"catalog"` } // CreateRepoOption options when creating repository diff --git a/options/schema/rc.schema.json b/options/schema/rc.schema.json index 6676edae61..1b8c53df75 100644 --- a/options/schema/rc.schema.json +++ b/options/schema/rc.schema.json @@ -255,7 +255,12 @@ "TSV Study Questions", "TSV Translation Notes", "TSV Translation Questions", - "TSV Translation Words Links" + "TSV Translation Words Links", + "TSV OBS Study Notes", + "TSV OBS Study Questions", + "TSV OBS Translation Notes", + "TSV OBS Translation Questions", + "TSV OBS Translation Words Links" ] }, "title": { diff --git a/routers/api/catalog/api.go b/routers/api/catalog/api.go index b89f52c207..39ba3155e1 100644 --- a/routers/api/catalog/api.go +++ b/routers/api/catalog/api.go @@ -2,13 +2,13 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -// Package v4 Catalog API. +// Package catalog Catalog Next API. // -// This documentation describes the DCS Catalog API. +// This documentation describes the Catalog Next API for all versions and other miscellaneous endpoints. // // Schemes: http, https -// BasePath: /api/catalog/v4 -// Version: 4 +// BasePath: /api/catalog +// Version: 5.0.0 // License: MIT http://opensource.org/licenses/MIT // // Consumes: @@ -58,25 +58,25 @@ package catalog import ( + "fmt" + "net/http" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + _ "code.gitea.io/gitea/routers/api/catalog/swagger" // for swagger generation v4 "code.gitea.io/gitea/routers/api/catalog/v4" v5 "code.gitea.io/gitea/routers/api/catalog/v5" - "code.gitea.io/gitea/routers/api/v1/misc" - _ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation - "fmt" - "net/http" "gitea.com/macaron/macaron" ) -var Versions = []string{ +var versions = []string{ "v4", "v5", } -var LatestVersion = Versions[len(Versions)-1] +var latestVersion = versions[len(versions)-1] func sudo() macaron.Handler { return func(ctx *context.APIContext) { @@ -112,18 +112,20 @@ func sudo() macaron.Handler { // FIXME: custom form error response func RegisterRoutes(m *macaron.Macaron) { if setting.API.EnableSwagger { - m.Get("/swagger", misc.Swagger) // Render catalog by default + m.Get("/swagger", Swagger) // Render catalog by default } m.Group("", func() { - m.Get("", ListCatalogVersionEndpoints) + m.Group("/misc", func() { + m.Get("/versions", ListCatalogVersionEndpoints) + }) m.Group("/latest", func() { m.Get("", func(ctx *context.APIContext) { - ctx.Redirect(fmt.Sprintf("/api/catalog/%s", LatestVersion)) + ctx.Redirect(fmt.Sprintf("/api/catalog/%s", latestVersion)) }) m.Get("/*", func(ctx *context.APIContext) { - ctx.Redirect(fmt.Sprintf("/api/catalog/%s/%s", LatestVersion, ctx.Params("*"))) + ctx.Redirect(fmt.Sprintf("/api/catalog/%s/%s", latestVersion, ctx.Params("*"))) }) }) diff --git a/routers/api/catalog/catalog.go b/routers/api/catalog/catalog.go index 6ab5ceef8d..7d6aa66945 100644 --- a/routers/api/catalog/catalog.go +++ b/routers/api/catalog/catalog.go @@ -1,3 +1,7 @@ +// Copyright 2021 unfoldingWord. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + package catalog import ( @@ -6,39 +10,34 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/structs" ) -// ListCatalogEndpoints Lists all the Catalog Endpoints for all versions +// ListCatalogVersionEndpoints Lists all the Catalog Endpoints for all versions func ListCatalogVersionEndpoints(ctx *context.APIContext) { - // swagger:operation GET /catalog catalog catalogListCatalogVersionEndpoints + // swagger:operation GET /misc/versions misc miscListCatalogVersionEndpoints // --- - // summary: Catalog version endpoint list, including "latest" pointing to the latest version + // summary: Catalog Next version endpoint list, including what version "latest" points to // produces: // - application/json - // parameters: - // - name: version - // in: path - // description: version to list, all if empty - // type: string - // required: false // responses: // "200": - // "$ref": "#/responses/CatalogVersionList" + // "$ref": "#/responses/CatalogVersionEndpointsResponse" // "422": // "$ref": "#/responses/validationError" - versionInfo := map[string]interface{}{ - "latest": LatestVersion, - "versions": map[string]string{}, + versionEndpoints := structs.CatalogVersionEndpoints{ + Latest: latestVersion, + Versions: map[string]string{}, } - for _, version := range Versions { - versionInfo["versions"].(map[string]string)[version] = fmt.Sprintf("%sapi/catalog/%s", setting.AppURL, version) + for _, version := range versions { + versionEndpoints.Versions[version] = fmt.Sprintf("%sapi/catalog/%s", setting.AppURL, version) } resp := map[string]interface{}{ - "ok": true, - "data": versionInfo, + "ok": true, + "data": versionEndpoints, } ctx.JSON(http.StatusOK, resp) } diff --git a/routers/api/catalog/swagger.go b/routers/api/catalog/swagger.go new file mode 100644 index 0000000000..b982174710 --- /dev/null +++ b/routers/api/catalog/swagger.go @@ -0,0 +1,21 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package catalog + +import ( + "net/http" + + "code.gitea.io/gitea/modules/base" + "code.gitea.io/gitea/modules/context" +) + +// tplSwagger swagger page template +const tplSwagger base.TplName = "swagger/catalog/ui" + +// Swagger render swagger-ui page with v1 json +func Swagger(ctx *context.Context) { + ctx.Data["APIJSONVersion"] = "catalog" + ctx.HTML(http.StatusOK, tplSwagger) +} diff --git a/routers/api/catalog/swagger/catalog.go b/routers/api/catalog/swagger/catalog.go new file mode 100644 index 0000000000..d01d21b26a --- /dev/null +++ b/routers/api/catalog/swagger/catalog.go @@ -0,0 +1,51 @@ +// Copyright 2020 unfoldingWord. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package swagger + +import ( + api "code.gitea.io/gitea/modules/structs" +) + +// CatalogSearchResultsV4 +// swagger:response CatalogSearchResultsV4 +type swaggerResponseCatalogSearchResultsV4 struct { + // in:body + Body api.CatalogSearchResultsV4 `json:"body"` +} + +// CatalogEntryV4 +// swagger:response CatalogEntryV4 +type swaggerResponseCatalogEntryV4 struct { + // in:body + Body api.Door43MetadataV4 `json:"body"` +} + +// CatalogSearchResultsV5 +// swagger:response CatalogSearchResultsV5 +type swaggerResponseCatalogSearchResultsV5 struct { + // in:body + Body api.CatalogSearchResultsV5 `json:"body"` +} + +// CatalogEntryV5 +// swagger:response CatalogEntryV5 +type swaggerResponseCatalogEntryV5 struct { + // in:body + Body api.Door43MetadataV5 `json:"body"` +} + +// CatalogMetadata +// swagger:response CatalogMetadata +type swaggerResponseCatalogMetadata struct { + // in:body + Body map[string]interface{} `json:"body"` +} + +// CatalogVersionEndpointsResponse +// swagger:response CatalogVersionEndpointsResponse +type swaggerResponseCatalogVersionEndpointsResponse struct { + // in:body + Body api.CatalogVersionEndpointsResponse `json:"body"` +} diff --git a/routers/api/catalog/v4/api.go b/routers/api/catalog/v4/api.go index 51631eac02..635c2d9490 100644 --- a/routers/api/catalog/v4/api.go +++ b/routers/api/catalog/v4/api.go @@ -2,9 +2,9 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -// Package v4 Catalog API. +// Package v4 Catalog v4 API. // -// This documentation describes the DCS Catalog API. +// This documentation describes the DCS Catalog Next v4 API. // // Schemes: http, https // BasePath: /api/catalog/v4 @@ -58,15 +58,15 @@ package v4 import ( + "fmt" "net/http" "strings" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/setting" + _ "code.gitea.io/gitea/routers/api/catalog/swagger" // for swagger generation "code.gitea.io/gitea/routers/api/v1/misc" - _ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation "gitea.com/macaron/macaron" ) @@ -166,9 +166,9 @@ func repoAssignment() macaron.Handler { func RegisterRoutes(m *macaron.Macaron) { m.Group("/v4", func() { // Miscellaneous - if setting.API.EnableSwagger { - m.Get("/swagger", misc.Swagger) - } + m.Get("/swagger", func(ctx *context.APIContext) { + ctx.Redirect(fmt.Sprintf("../swagger")) + }) m.Get("/version", misc.Version) m.Get("/signing-key.gpg", misc.SigningKey) diff --git a/routers/api/catalog/v4/catalog.go b/routers/api/catalog/v4/catalog.go index 172db4cc01..62ff114b86 100644 --- a/routers/api/catalog/v4/catalog.go +++ b/routers/api/catalog/v4/catalog.go @@ -41,7 +41,7 @@ var searchOrderByMap = map[string]map[string]models.CatalogOrderBy{ // Search search the catalog via options func Search(ctx *context.APIContext) { - // swagger:operation GET /catalog catalog catalogSearch + // swagger:operation GET /v4/search v4 catalogSearch // --- // summary: Catalog search // produces: @@ -129,7 +129,7 @@ func Search(ctx *context.APIContext) { // SearchOwner search the catalog via owner and via options func SearchOwner(ctx *context.APIContext) { - // swagger:operation GET /catalog/search/{owner} catalog catalogSearchOwner + // swagger:operation GET /v4/search/{owner} v4 v4SearchOwner // --- // summary: Catalog search by owner // produces: @@ -218,7 +218,7 @@ func SearchOwner(ctx *context.APIContext) { // SearchRepo search the catalog via repo and options func SearchRepo(ctx *context.APIContext) { - // swagger:operation GET /catalog/search/{owner}/{repo} catalog catalogSearchRepo + // swagger:operation GET /v4/search/{owner}/{repo} v4 v4SearchRepo // --- // summary: Catalog search by repo // produces: @@ -308,7 +308,7 @@ func SearchRepo(ctx *context.APIContext) { // GetCatalogEntry Get the catalog entry from the given ownername, reponame and ref func GetCatalogEntry(ctx *context.APIContext) { - // swagger:operation GET /catalog/entry/{owner}/{repo}/{tag} catalog catalogGetCatalogEntry + // swagger:operation GET /v4/entry/{owner}/{repo}/{tag} v4 v4GetCatalogEntry // --- // summary: Catalog entry // produces: @@ -363,9 +363,9 @@ func GetCatalogEntry(ctx *context.APIContext) { // GetCatalogMetadata Get the metadata (RC 0.2.0 manifest) in JSON format for the given ownername, reponame and ref func GetCatalogMetadata(ctx *context.APIContext) { - // swagger:operation GET /catalog/entry/{owner}/{repo}/{tag}/metadata catalog catalogGetMetadata + // swagger:operation GET /v4/entry/{owner}/{repo}/{tag}/metadata v4 v4GetMetadata // --- - // summary: Catalog entry metadata + // summary: Catalog entry metadata (manifest.yaml in JSON format) // produces: // - application/json // parameters: diff --git a/routers/api/catalog/v5/api.go b/routers/api/catalog/v5/api.go index 969fb7df42..7956636d30 100644 --- a/routers/api/catalog/v5/api.go +++ b/routers/api/catalog/v5/api.go @@ -2,9 +2,9 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -// Package v4 Catalog API. +// Package v5 Catalog Next v5 API. // -// This documentation describes the DCS Catalog API. +// This documentation describes the DCS Catalog Next v5 API. // // Schemes: http, https // BasePath: /api/catalog/v4 @@ -58,15 +58,15 @@ package v5 import ( + "fmt" "net/http" "strings" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/setting" + _ "code.gitea.io/gitea/routers/api/catalog/swagger" // for swagger generation "code.gitea.io/gitea/routers/api/v1/misc" - _ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation "gitea.com/macaron/macaron" ) @@ -166,9 +166,9 @@ func repoAssignment() macaron.Handler { func RegisterRoutes(m *macaron.Macaron) { m.Group("/v5", func() { // Miscellaneous - if setting.API.EnableSwagger { - m.Get("/swagger", misc.Swagger) - } + m.Get("/swagger", func(ctx *context.APIContext) { + ctx.Redirect(fmt.Sprintf("../swagger")) + }) m.Get("/version", misc.Version) m.Get("/signing-key.gpg", misc.SigningKey) diff --git a/routers/api/catalog/v5/catalog.go b/routers/api/catalog/v5/catalog.go index c830828ae6..2f4941a895 100644 --- a/routers/api/catalog/v5/catalog.go +++ b/routers/api/catalog/v5/catalog.go @@ -41,7 +41,7 @@ var searchOrderByMap = map[string]map[string]models.CatalogOrderBy{ // Search search the catalog via options func Search(ctx *context.APIContext) { - // swagger:operation GET /catalog catalog catalogSearch + // swagger:operation GET /v5/search v5 v5Search // --- // summary: Catalog search // produces: @@ -129,7 +129,7 @@ func Search(ctx *context.APIContext) { // SearchOwner search the catalog via owner and via options func SearchOwner(ctx *context.APIContext) { - // swagger:operation GET /catalog/search/{owner} catalog catalogSearchOwner + // swagger:operation GET /v5/search/{owner} v5 v5SearchOwner // --- // summary: Catalog search by owner // produces: @@ -218,7 +218,7 @@ func SearchOwner(ctx *context.APIContext) { // SearchRepo search the catalog via repo and options func SearchRepo(ctx *context.APIContext) { - // swagger:operation GET /catalog/search/{owner}/{repo} catalog catalogSearchRepo + // swagger:operation GET /v5/search/{owner}/{repo} v5 v5SearchRepo // --- // summary: Catalog search by repo // produces: @@ -308,7 +308,7 @@ func SearchRepo(ctx *context.APIContext) { // GetCatalogEntry Get the catalog entry from the given ownername, reponame and ref func GetCatalogEntry(ctx *context.APIContext) { - // swagger:operation GET /catalog/entry/{owner}/{repo}/{tag} catalog catalogGetCatalogEntry + // swagger:operation GET /v5/entry/{owner}/{repo}/{tag} v5 v5GetCatalogEntry // --- // summary: Catalog entry // produces: @@ -363,9 +363,9 @@ func GetCatalogEntry(ctx *context.APIContext) { // GetCatalogMetadata Get the metadata (RC 0.2.0 manifest) in JSON format for the given ownername, reponame and ref func GetCatalogMetadata(ctx *context.APIContext) { - // swagger:operation GET /catalog/entry/{owner}/{repo}/{tag}/metadata catalog catalogGetMetadata + // swagger:operation GET /v5/entry/{owner}/{repo}/{tag}/metadata v5 v5GetMetadata // --- - // summary: Catalog entry metadata + // summary: Catalog entry metadata (manifest.yaml in JSON format) // produces: // - application/json // parameters: diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 869d462c9c..cf2f0f9005 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -3,7 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -// Package v1 Gitea API. +// Package v1 DCS (Gitea) API. // // This documentation describes the DCS (Gitea) API. // @@ -74,7 +74,6 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" - catalog "code.gitea.io/gitea/routers/api/catalog/v4" "code.gitea.io/gitea/routers/api/v1/admin" "code.gitea.io/gitea/routers/api/v1/misc" "code.gitea.io/gitea/routers/api/v1/notify" @@ -973,23 +972,6 @@ func RegisterRoutes(m *macaron.Macaron) { /*** DCS Customizations ***/ m.Post("/yaml", bind(misc.YamlOption{}), misc.Yaml) - // Catalog - m.Group("/catalog", func() { - m.Get("", catalog.Search) - m.Group("/search", func() { - m.Get("", catalog.Search) - m.Group("/:username", func() { - m.Get("", catalog.SearchOwner) - m.Group("/:reponame", func() { - m.Get("", catalog.SearchRepo) - }, repoAssignment()) - }) - }) - m.Group("/entry/:username/:reponame/:tag", func() { - m.Get("", catalog.GetCatalogEntry) - m.Get("/metadata", catalog.GetCatalogMetadata) - }, repoAssignment()) - }) /*** END DCS Customizations ***/ }, securityHeaders(), context.APIContexter(), sudo()) } diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 133f68635a..c68841f20a 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -1120,6 +1120,9 @@ func RegisterRoutes(m *macaron.Macaron) { if setting.API.EnableSwagger { m.Get("/swagger.v1.json", templates.JSONRenderer(), routers.SwaggerV1Json) + /*** DCS Customizations ***/ + m.Get("/swagger.catalog.json", templates.JSONRenderer(), routers.SwaggerCatalogJSON) + /*** END DCS Customizations ***/ } var handlers []macaron.Handler diff --git a/routers/swagger_json.go b/routers/swagger_json.go index 58c4ec50d9..5e3dbd46f6 100644 --- a/routers/swagger_json.go +++ b/routers/swagger_json.go @@ -16,3 +16,13 @@ const tplSwaggerV1Json base.TplName = "swagger/v1_json" func SwaggerV1Json(ctx *context.Context) { ctx.HTML(200, tplSwaggerV1Json) } + +/*** DCS Customizations ***/ +const tplSwaggerCatalogJSON base.TplName = "swagger/catalog/catalog_json" + +// SwaggerCatalogJSON render swagger catalog v5 json +func SwaggerCatalogJSON(ctx *context.Context) { + ctx.HTML(200, tplSwaggerCatalogJSON) +} + +/*** EMD DCS Customizations ***/ diff --git a/templates/swagger/catalog/catalog_json.tmpl b/templates/swagger/catalog/catalog_json.tmpl new file mode 100644 index 0000000000..fb08b1e1bf --- /dev/null +++ b/templates/swagger/catalog/catalog_json.tmpl @@ -0,0 +1,1981 @@ +{ + "consumes": [ + "application/json", + "text/plain" + ], + "produces": [ + "application/json", + "text/html" + ], + "schemes": [ + "http", + "https" + ], + "swagger": "2.0", + "info": { + "description": "This documentation describes the Catalog Next API for all versions and other miscellaneous endpoints.", + "title": "Catalog Next API.", + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "5.0.0" + }, + "basePath": "{{AppSubUrl}}/api/catalog", + "paths": { + "/misc/versions": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "misc" + ], + "summary": "Catalog Next version endpoint list, including what version \"latest\" points to", + "operationId": "miscListCatalogVersionEndpoints", + "responses": { + "200": { + "$ref": "#/responses/CatalogVersionEndpointsResponse" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/v4/entry/{owner}/{repo}/{tag}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "v4" + ], + "summary": "Catalog entry", + "operationId": "v4GetCatalogEntry", + "parameters": [ + { + "type": "string", + "description": "name of the owner", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "release tag or default branch", + "name": "tag", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/CatalogEntryV4" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/v4/entry/{owner}/{repo}/{tag}/metadata": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "v4" + ], + "summary": "Catalog entry metadata (manifest.yaml in JSON format)", + "operationId": "v4GetMetadata", + "parameters": [ + { + "type": "string", + "description": "name of the owner", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "release tag or default branch", + "name": "tag", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/CatalogMetadata" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/v4/search": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "v4" + ], + "summary": "Catalog search", + "operationId": "catalogSearch", + "parameters": [ + { + "type": "string", + "description": "keyword(s). Can use multiple `q=\u003ckeyword\u003e`s or commas for more than one keyword", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given owner name(s).", + "name": "owner", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given repo name(s).", + "name": "repo", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given release tag(s)", + "name": "tag", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given language(s)", + "name": "lang", + "in": "query" + }, + { + "type": "string", + "description": "specifies which release stage to be return of these stages: \"prod\" - return only the production releases (default); \"preprod\" - return the pre-production release if it exists instead of the production release; \"draft\" - return the draft release if it exists instead of pre-production or production release; \"latest\" -return the default branch (e.g. master) if it is a valid RC instead of the above", + "name": "stage", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given subject(s). Must match the entire string (case insensitive)", + "name": "subject", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given checking level(s). Can be 1, 2 or 3", + "name": "checkingLevel", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given book(s) (project ids)", + "name": "book", + "in": "query" + }, + { + "type": "boolean", + "description": "if true, all releases, not just the latest, are included. Default is false", + "name": "includeHistory", + "in": "query" + }, + { + "type": "boolean", + "description": "if false, only subject and title are searched with query terms, if true all metadata values are searched. Default is true", + "name": "includeMetadata", + "in": "query" + }, + { + "type": "boolean", + "description": "if true, a list of the projects in the resource and their file paths will be listed for each entry. Default is false", + "name": "showIngredients", + "in": "query" + }, + { + "type": "string", + "description": "sort repos alphanumerically by attribute. Supported values are \"subject\", \"title\", \"tag\", \"released\", \"lang\", \"releases\", \"stars\", \"forks\". Default is by \"language\", \"subject\" and then \"tag\"", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "sort order, either \"asc\" (ascending) or \"desc\" (descending). Default is \"asc\", ignored if \"sort\" is not specified.", + "name": "order", + "in": "query" + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results, maximum page size is 50", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/CatalogSearchResultsV4" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/v4/search/{owner}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "v4" + ], + "summary": "Catalog search by owner", + "operationId": "v4SearchOwner", + "parameters": [ + { + "type": "string", + "description": "owner of entries", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "keyword(s). Can use multiple `q=\u003ckeyword\u003e`s or commas for more than one keyword", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given repo name(s).", + "name": "repo", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given release tag(s)", + "name": "tag", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given language(s)", + "name": "lang", + "in": "query" + }, + { + "type": "string", + "description": "specifies which release stage to be return of these stages: \"prod\" - return only the production releases (default); \"preprod\" - return the pre-production release if it exists instead of the production release; \"draft\" - return the draft release if it exists instead of pre-production or production release; \"latest\" -return the default branch (e.g. master) if it is a valid RC instead of the above", + "name": "stage", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given subject(s). Must match the entire string (case insensitive)", + "name": "subject", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given checking level(s). Can be 1, 2 or 3", + "name": "checkingLevel", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given book(s) (project ids)", + "name": "book", + "in": "query" + }, + { + "type": "boolean", + "description": "if true, all releases, not just the latest, are included. Default is false", + "name": "includeHistory", + "in": "query" + }, + { + "type": "boolean", + "description": "if false, only subject and title are searched with query terms, if true all metadata values are searched. Default is true", + "name": "includeMetadata", + "in": "query" + }, + { + "type": "boolean", + "description": "if true, a list of the projects in the resource and their file paths will be listed for each entry. Default is false", + "name": "showIngredients", + "in": "query" + }, + { + "type": "string", + "description": "sort repos alphanumerically by attribute. Supported values are \"subject\", \"title\", \"tag\", \"released\", \"lang\", \"releases\", \"stars\", \"forks\". Default is by \"language\", \"subject\" and then \"tag\"", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "sort order, either \"asc\" (ascending) or \"desc\" (descending). Default is \"asc\", ignored if \"sort\" is not specified.", + "name": "order", + "in": "query" + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results, maximum page size is 50", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/CatalogSearchResultsV4" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/v4/search/{owner}/{repo}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "v4" + ], + "summary": "Catalog search by repo", + "operationId": "v4SearchRepo", + "parameters": [ + { + "type": "string", + "description": "name of the owner", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "keyword(s). Can use multiple `q=\u003ckeyword\u003e`s or commas for more than one keyword", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given release tag(s)", + "name": "tag", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given language(s)", + "name": "lang", + "in": "query" + }, + { + "type": "string", + "description": "specifies which release stage to be return of these stages: \"prod\" - return only the production releases (default); \"preprod\" - return the pre-production release if it exists instead of the production release; \"draft\" - return the draft release if it exists instead of pre-production or production release; \"latest\" -return the default branch (e.g. master) if it is a valid RC instead of the above", + "name": "stage", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given subject(s). Must match the entire string (case insensitive)", + "name": "subject", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given checking level(s). Can be 1, 2 or 3", + "name": "checkingLevel", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given book(s) (project ids)", + "name": "book", + "in": "query" + }, + { + "type": "boolean", + "description": "if true, all releases, not just the latest, are included. Default is false", + "name": "includeHistory", + "in": "query" + }, + { + "type": "boolean", + "description": "if false, only subject and title are searched with query terms, if true all metadata values are searched. Default is true", + "name": "includeMetadata", + "in": "query" + }, + { + "type": "boolean", + "description": "if true, a list of the projects in the resource and their file paths will be listed for each entry. Default is false", + "name": "showIngredients", + "in": "query" + }, + { + "type": "string", + "description": "sort repos alphanumerically by attribute. Supported values are \"subject\", \"title\", \"tag\", \"released\", \"lang\", \"releases\", \"stars\", \"forks\". Default is language,subject,tag", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "sort order, either \"asc\" (ascending) or \"desc\" (descending). Default is \"asc\", ignored if \"sort\" is not specified.", + "name": "order", + "in": "query" + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results, maximum page size is 50", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/CatalogSearchResultsV4" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/v5/entry/{owner}/{repo}/{tag}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "v5" + ], + "summary": "Catalog entry", + "operationId": "v5GetCatalogEntry", + "parameters": [ + { + "type": "string", + "description": "name of the owner", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "release tag or default branch", + "name": "tag", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/CatalogEntryV5" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/v5/entry/{owner}/{repo}/{tag}/metadata": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "v5" + ], + "summary": "Catalog entry metadata (manifest.yaml in JSON format)", + "operationId": "v5GetMetadata", + "parameters": [ + { + "type": "string", + "description": "name of the owner", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "release tag or default branch", + "name": "tag", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/CatalogMetadata" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/v5/search": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "v5" + ], + "summary": "Catalog search", + "operationId": "v5Search", + "parameters": [ + { + "type": "string", + "description": "keyword(s). Can use multiple `q=\u003ckeyword\u003e`s or commas for more than one keyword", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given owner name(s).", + "name": "owner", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given repo name(s).", + "name": "repo", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given release tag(s)", + "name": "tag", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given language(s)", + "name": "lang", + "in": "query" + }, + { + "type": "string", + "description": "specifies which release stage to be return of these stages: \"prod\" - return only the production releases (default); \"preprod\" - return the pre-production release if it exists instead of the production release; \"draft\" - return the draft release if it exists instead of pre-production or production release; \"latest\" -return the default branch (e.g. master) if it is a valid RC instead of the above", + "name": "stage", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given subject(s). Must match the entire string (case insensitive)", + "name": "subject", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given checking level(s). Can be 1, 2 or 3", + "name": "checkingLevel", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given book(s) (project ids)", + "name": "book", + "in": "query" + }, + { + "type": "boolean", + "description": "if true, all releases, not just the latest, are included. Default is false", + "name": "includeHistory", + "in": "query" + }, + { + "type": "boolean", + "description": "if false, only subject and title are searched with query terms, if true all metadata values are searched. Default is true", + "name": "includeMetadata", + "in": "query" + }, + { + "type": "boolean", + "description": "if true, a list of the projects in the resource and their file paths will be listed for each entry. Default is false", + "name": "showIngredients", + "in": "query" + }, + { + "type": "string", + "description": "sort repos alphanumerically by attribute. Supported values are \"subject\", \"title\", \"tag\", \"released\", \"lang\", \"releases\", \"stars\", \"forks\". Default is by \"language\", \"subject\" and then \"tag\"", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "sort order, either \"asc\" (ascending) or \"desc\" (descending). Default is \"asc\", ignored if \"sort\" is not specified.", + "name": "order", + "in": "query" + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results, maximum page size is 50", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/CatalogSearchResultsV5" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/v5/search/{owner}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "v5" + ], + "summary": "Catalog search by owner", + "operationId": "v5SearchOwner", + "parameters": [ + { + "type": "string", + "description": "owner of entries", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "keyword(s). Can use multiple `q=\u003ckeyword\u003e`s or commas for more than one keyword", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given repo name(s).", + "name": "repo", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given release tag(s)", + "name": "tag", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given language(s)", + "name": "lang", + "in": "query" + }, + { + "type": "string", + "description": "specifies which release stage to be return of these stages: \"prod\" - return only the production releases (default); \"preprod\" - return the pre-production release if it exists instead of the production release; \"draft\" - return the draft release if it exists instead of pre-production or production release; \"latest\" -return the default branch (e.g. master) if it is a valid RC instead of the above", + "name": "stage", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given subject(s). Must match the entire string (case insensitive)", + "name": "subject", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given checking level(s). Can be 1, 2 or 3", + "name": "checkingLevel", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given book(s) (project ids)", + "name": "book", + "in": "query" + }, + { + "type": "boolean", + "description": "if true, all releases, not just the latest, are included. Default is false", + "name": "includeHistory", + "in": "query" + }, + { + "type": "boolean", + "description": "if false, only subject and title are searched with query terms, if true all metadata values are searched. Default is true", + "name": "includeMetadata", + "in": "query" + }, + { + "type": "boolean", + "description": "if true, a list of the projects in the resource and their file paths will be listed for each entry. Default is false", + "name": "showIngredients", + "in": "query" + }, + { + "type": "string", + "description": "sort repos alphanumerically by attribute. Supported values are \"subject\", \"title\", \"tag\", \"released\", \"lang\", \"releases\", \"stars\", \"forks\". Default is by \"language\", \"subject\" and then \"tag\"", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "sort order, either \"asc\" (ascending) or \"desc\" (descending). Default is \"asc\", ignored if \"sort\" is not specified.", + "name": "order", + "in": "query" + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results, maximum page size is 50", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/CatalogSearchResultsV5" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + }, + "/v5/search/{owner}/{repo}": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "v5" + ], + "summary": "Catalog search by repo", + "operationId": "v5SearchRepo", + "parameters": [ + { + "type": "string", + "description": "name of the owner", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "keyword(s). Can use multiple `q=\u003ckeyword\u003e`s or commas for more than one keyword", + "name": "q", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given release tag(s)", + "name": "tag", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given language(s)", + "name": "lang", + "in": "query" + }, + { + "type": "string", + "description": "specifies which release stage to be return of these stages: \"prod\" - return only the production releases (default); \"preprod\" - return the pre-production release if it exists instead of the production release; \"draft\" - return the draft release if it exists instead of pre-production or production release; \"latest\" -return the default branch (e.g. master) if it is a valid RC instead of the above", + "name": "stage", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given subject(s). Must match the entire string (case insensitive)", + "name": "subject", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given checking level(s). Can be 1, 2 or 3", + "name": "checkingLevel", + "in": "query" + }, + { + "type": "string", + "description": "search only for entries with the given book(s) (project ids)", + "name": "book", + "in": "query" + }, + { + "type": "boolean", + "description": "if true, all releases, not just the latest, are included. Default is false", + "name": "includeHistory", + "in": "query" + }, + { + "type": "boolean", + "description": "if false, only subject and title are searched with query terms, if true all metadata values are searched. Default is true", + "name": "includeMetadata", + "in": "query" + }, + { + "type": "boolean", + "description": "if true, a list of the projects in the resource and their file paths will be listed for each entry. Default is false", + "name": "showIngredients", + "in": "query" + }, + { + "type": "string", + "description": "sort repos alphanumerically by attribute. Supported values are \"subject\", \"title\", \"tag\", \"released\", \"lang\", \"releases\", \"stars\", \"forks\". Default is language,subject,tag", + "name": "sort", + "in": "query" + }, + { + "type": "string", + "description": "sort order, either \"asc\" (ascending) or \"desc\" (descending). Default is \"asc\", ignored if \"sort\" is not specified.", + "name": "order", + "in": "query" + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results, maximum page size is 50", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/CatalogSearchResultsV5" + }, + "422": { + "$ref": "#/responses/validationError" + } + } + } + } + }, + "definitions": { + "AccessToken": { + "type": "object", + "title": "AccessToken represents an API access token.", + "properties": { + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "sha1": { + "type": "string", + "x-go-name": "Token" + }, + "token_last_eight": { + "type": "string", + "x-go-name": "TokenLastEight" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Attachment": { + "description": "Attachment a generic attachment", + "type": "object", + "properties": { + "browser_download_url": { + "type": "string", + "x-go-name": "DownloadURL" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "download_count": { + "type": "integer", + "format": "int64", + "x-go-name": "DownloadCount" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "size": { + "type": "integer", + "format": "int64", + "x-go-name": "Size" + }, + "uuid": { + "type": "string", + "x-go-name": "UUID" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CatalogSearchResultsV4": { + "description": "CatalogSearchResultsV4 results of a successful search for V4", + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/Door43MetadataV4" + }, + "x-go-name": "Data" + }, + "ok": { + "type": "boolean", + "x-go-name": "OK" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CatalogSearchResultsV5": { + "description": "CatalogSearchResultsV5 results of a successful search for V5", + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/Door43MetadataV5" + }, + "x-go-name": "Data" + }, + "ok": { + "type": "boolean", + "x-go-name": "OK" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CatalogStage": { + "description": "CatalogStage a repo's catalog stage metadata", + "type": "object", + "properties": { + "branch_or_tag_name": { + "type": "string", + "x-go-name": "Tag" + }, + "release_url": { + "type": "string", + "x-go-name": "ReleaseURL" + }, + "released": { + "type": "string", + "x-go-name": "Released" + }, + "tarball_url": { + "type": "string", + "x-go-name": "TarballURL" + }, + "zipball_url": { + "type": "string", + "x-go-name": "ZipballURL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CatalogStages": { + "description": "CatalogStages a repo's catalog stages", + "type": "object", + "properties": { + "draft": { + "$ref": "#/definitions/CatalogStage" + }, + "latest": { + "$ref": "#/definitions/CatalogStage" + }, + "preprod": { + "$ref": "#/definitions/CatalogStage" + }, + "prod": { + "$ref": "#/definitions/CatalogStage" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CatalogVersionEndpoints": { + "description": "CatalogVersionEndpoints Info on the versions of the catalog", + "type": "object", + "properties": { + "latest": { + "type": "string", + "x-go-name": "Latest" + }, + "versions": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Versions" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CatalogVersionEndpointsResponse": { + "description": "CatalogVersionEndpointsResponse response with the endpoints for all versions of the catalog", + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/CatalogVersionEndpoints" + }, + "x-go-name": "Data" + }, + "ok": { + "type": "boolean", + "x-go-name": "OK" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Door43MetadataV4": { + "description": "Door43MetadataV4 represents a repository's metadata of a tag or default branch", + "type": "object", + "properties": { + "books": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Books" + }, + "branch_or_tag_name": { + "type": "string", + "x-go-name": "BranchOrTag" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "ingredients": { + "type": "array", + "items": { + "type": "object" + }, + "x-go-name": "Ingredients" + }, + "lang_code": { + "type": "string", + "x-go-name": "Language" + }, + "metadata_api_contents_url": { + "type": "string", + "x-go-name": "MetadataAPIContentsURL" + }, + "metadata_json_url": { + "type": "string", + "x-go-name": "MetadataJSONURL" + }, + "metadata_url": { + "type": "string", + "x-go-name": "MetadataURL" + }, + "metadata_version": { + "type": "string", + "x-go-name": "MetadataVersion" + }, + "owner": { + "type": "string", + "x-go-name": "Owner" + }, + "release_url": { + "type": "string", + "x-go-name": "ReleaseURL" + }, + "released": { + "type": "string", + "x-go-name": "Released" + }, + "repo": { + "type": "string", + "x-go-name": "Repo" + }, + "repo_url": { + "type": "string", + "x-go-name": "RepoURL" + }, + "stage": { + "type": "string", + "x-go-name": "Stage" + }, + "subject": { + "type": "string", + "x-go-name": "Subject" + }, + "tarbar_url": { + "type": "string", + "x-go-name": "TarballURL" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "url": { + "type": "string", + "x-go-name": "Self" + }, + "zipball_url": { + "type": "string", + "x-go-name": "ZipballURL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Door43MetadataV5": { + "description": "Door43MetadataV5 represents a repository's metadata of a tag or default branch for V5", + "type": "object", + "properties": { + "books": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Books" + }, + "branch_or_tag_name": { + "type": "string", + "x-go-name": "BranchOrTag" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "ingredients": { + "type": "array", + "items": { + "type": "object" + }, + "x-go-name": "Ingredients" + }, + "language": { + "type": "string", + "x-go-name": "Language" + }, + "metadata_api_contents_url": { + "type": "string", + "x-go-name": "MetadataAPIContentsURL" + }, + "metadata_json_url": { + "type": "string", + "x-go-name": "MetadataJSONURL" + }, + "metadata_url": { + "type": "string", + "x-go-name": "MetadataURL" + }, + "metadata_version": { + "type": "string", + "x-go-name": "MetadataVersion" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "owner": { + "type": "string", + "x-go-name": "Owner" + }, + "release": { + "$ref": "#/definitions/Release" + }, + "released": { + "type": "string", + "x-go-name": "Released" + }, + "repo": { + "$ref": "#/definitions/Repository" + }, + "stage": { + "type": "string", + "x-go-name": "Stage" + }, + "subject": { + "type": "string", + "x-go-name": "Subject" + }, + "tarbar_url": { + "type": "string", + "x-go-name": "TarballURL" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "url": { + "type": "string", + "x-go-name": "Self" + }, + "zipball_url": { + "type": "string", + "x-go-name": "ZipballURL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ExternalTracker": { + "description": "ExternalTracker represents settings for external tracker", + "type": "object", + "properties": { + "external_tracker_format": { + "description": "External Issue Tracker URL Format. Use the placeholders {user}, {repo} and {index} for the username, repository name and issue index.", + "type": "string", + "x-go-name": "ExternalTrackerFormat" + }, + "external_tracker_style": { + "description": "External Issue Tracker Number Format, either `numeric` or `alphanumeric`", + "type": "string", + "x-go-name": "ExternalTrackerStyle" + }, + "external_tracker_url": { + "description": "URL of external issue tracker.", + "type": "string", + "x-go-name": "ExternalTrackerURL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "ExternalWiki": { + "description": "ExternalWiki represents setting for external wiki", + "type": "object", + "properties": { + "external_wiki_url": { + "description": "URL of external wiki.", + "type": "string", + "x-go-name": "ExternalWikiURL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "InternalTracker": { + "description": "InternalTracker represents settings for internal tracker", + "type": "object", + "properties": { + "allow_only_contributors_to_track_time": { + "description": "Let only contributors track time (Built-in issue tracker)", + "type": "boolean", + "x-go-name": "AllowOnlyContributorsToTrackTime" + }, + "enable_issue_dependencies": { + "description": "Enable dependencies for issues and pull requests (Built-in issue tracker)", + "type": "boolean", + "x-go-name": "EnableIssueDependencies" + }, + "enable_time_tracker": { + "description": "Enable time tracking (Built-in issue tracker)", + "type": "boolean", + "x-go-name": "EnableTimeTracker" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "OAuth2Application": { + "type": "object", + "title": "OAuth2Application represents an OAuth2 application.", + "properties": { + "client_id": { + "type": "string", + "x-go-name": "ClientID" + }, + "client_secret": { + "type": "string", + "x-go-name": "ClientSecret" + }, + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "redirect_uris": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "RedirectURIs" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Permission": { + "description": "Permission represents a set of permissions", + "type": "object", + "properties": { + "admin": { + "type": "boolean", + "x-go-name": "Admin" + }, + "pull": { + "type": "boolean", + "x-go-name": "Pull" + }, + "push": { + "type": "boolean", + "x-go-name": "Push" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Release": { + "description": "Release represents a repository release", + "type": "object", + "properties": { + "assets": { + "type": "array", + "items": { + "$ref": "#/definitions/Attachment" + }, + "x-go-name": "Attachments" + }, + "author": { + "$ref": "#/definitions/User" + }, + "body": { + "type": "string", + "x-go-name": "Note" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "CreatedAt" + }, + "draft": { + "type": "boolean", + "x-go-name": "IsDraft" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Title" + }, + "prerelease": { + "type": "boolean", + "x-go-name": "IsPrerelease" + }, + "published_at": { + "type": "string", + "format": "date-time", + "x-go-name": "PublishedAt" + }, + "tag_name": { + "type": "string", + "x-go-name": "TagName" + }, + "tarball_url": { + "type": "string", + "x-go-name": "TarURL" + }, + "target_commitish": { + "type": "string", + "x-go-name": "Target" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "zipball_url": { + "type": "string", + "x-go-name": "ZipURL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "Repository": { + "description": "Repository represents a repository", + "type": "object", + "properties": { + "allow_merge_commits": { + "type": "boolean", + "x-go-name": "AllowMerge" + }, + "allow_rebase": { + "type": "boolean", + "x-go-name": "AllowRebase" + }, + "allow_rebase_explicit": { + "type": "boolean", + "x-go-name": "AllowRebaseMerge" + }, + "allow_squash_merge": { + "type": "boolean", + "x-go-name": "AllowSquash" + }, + "archived": { + "type": "boolean", + "x-go-name": "Archived" + }, + "avatar_url": { + "type": "string", + "x-go-name": "AvatarURL" + }, + "books": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Books" + }, + "catalog": { + "$ref": "#/definitions/CatalogStages" + }, + "checking_level": { + "type": "string", + "x-go-name": "CheckingLevel" + }, + "clone_url": { + "type": "string", + "x-go-name": "CloneURL" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "default_branch": { + "type": "string", + "x-go-name": "DefaultBranch" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "empty": { + "type": "boolean", + "x-go-name": "Empty" + }, + "external_tracker": { + "$ref": "#/definitions/ExternalTracker" + }, + "external_wiki": { + "$ref": "#/definitions/ExternalWiki" + }, + "fork": { + "type": "boolean", + "x-go-name": "Fork" + }, + "forks_count": { + "type": "integer", + "format": "int64", + "x-go-name": "Forks" + }, + "full_name": { + "type": "string", + "x-go-name": "FullName" + }, + "has_issues": { + "type": "boolean", + "x-go-name": "HasIssues" + }, + "has_projects": { + "type": "boolean", + "x-go-name": "HasProjects" + }, + "has_pull_requests": { + "type": "boolean", + "x-go-name": "HasPullRequests" + }, + "has_wiki": { + "type": "boolean", + "x-go-name": "HasWiki" + }, + "html_url": { + "type": "string", + "x-go-name": "HTMLURL" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "ignore_whitespace_conflicts": { + "type": "boolean", + "x-go-name": "IgnoreWhitespaceConflicts" + }, + "internal": { + "type": "boolean", + "x-go-name": "Internal" + }, + "internal_tracker": { + "$ref": "#/definitions/InternalTracker" + }, + "language": { + "type": "string", + "x-go-name": "Language" + }, + "mirror": { + "type": "boolean", + "x-go-name": "Mirror" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "open_issues_count": { + "type": "integer", + "format": "int64", + "x-go-name": "OpenIssues" + }, + "open_pr_counter": { + "type": "integer", + "format": "int64", + "x-go-name": "OpenPulls" + }, + "original_url": { + "type": "string", + "x-go-name": "OriginalURL" + }, + "owner": { + "$ref": "#/definitions/User" + }, + "parent": { + "$ref": "#/definitions/Repository" + }, + "permissions": { + "$ref": "#/definitions/Permission" + }, + "private": { + "type": "boolean", + "x-go-name": "Private" + }, + "release_counter": { + "type": "integer", + "format": "int64", + "x-go-name": "Releases" + }, + "size": { + "type": "integer", + "format": "int64", + "x-go-name": "Size" + }, + "ssh_url": { + "type": "string", + "x-go-name": "SSHURL" + }, + "stars_count": { + "type": "integer", + "format": "int64", + "x-go-name": "Stars" + }, + "subject": { + "type": "string", + "x-go-name": "Subject" + }, + "template": { + "type": "boolean", + "x-go-name": "Template" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "watchers_count": { + "type": "integer", + "format": "int64", + "x-go-name": "Watchers" + }, + "website": { + "type": "string", + "x-go-name": "Website" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "User": { + "description": "User represents a user", + "type": "object", + "properties": { + "avatar_url": { + "description": "URL to the user's avatar", + "type": "string", + "x-go-name": "AvatarURL" + }, + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "email": { + "type": "string", + "format": "email", + "x-go-name": "Email" + }, + "full_name": { + "description": "the user's full name", + "type": "string", + "x-go-name": "FullName" + }, + "id": { + "description": "the user's id", + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "is_admin": { + "description": "Is the user an administrator", + "type": "boolean", + "x-go-name": "IsAdmin" + }, + "language": { + "description": "User locale", + "type": "string", + "x-go-name": "Language" + }, + "last_login": { + "type": "string", + "format": "date-time", + "x-go-name": "LastLogin" + }, + "login": { + "description": "the user's username", + "type": "string", + "x-go-name": "UserName" + }, + "repo_languages": { + "description": "Repo languages", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "RepoLanguages" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + } + }, + "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" + } + } + }, + "AccessTokenList": { + "description": "AccessTokenList represents a list of API access token.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/AccessToken" + } + } + }, + "CatalogEntryV4": { + "description": "CatalogEntryV4", + "schema": { + "$ref": "#/definitions/Door43MetadataV4" + } + }, + "CatalogEntryV5": { + "description": "CatalogEntryV5", + "schema": { + "$ref": "#/definitions/Door43MetadataV5" + } + }, + "CatalogMetadata": { + "description": "CatalogMetadata", + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + }, + "CatalogSearchResultsV4": { + "description": "CatalogSearchResultsV4", + "schema": { + "$ref": "#/definitions/CatalogSearchResultsV4" + } + }, + "CatalogSearchResultsV5": { + "description": "CatalogSearchResultsV5", + "schema": { + "$ref": "#/definitions/CatalogSearchResultsV5" + } + }, + "CatalogVersionEndpointsResponse": { + "description": "CatalogVersionEndpointsResponse", + "schema": { + "$ref": "#/definitions/CatalogVersionEndpointsResponse" + } + }, + "MarkdownRender": { + "description": "MarkdownRender is a rendered markdown document", + "schema": { + "type": "string" + } + }, + "OAuth2Application": { + "description": "OAuth2Application represents an OAuth2 application.", + "headers": { + "client_id": { + "type": "string" + }, + "client_secret": { + "type": "string" + }, + "created": { + "type": "string", + "format": "date-time" + }, + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "redirect_uris": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "OAuth2ApplicationList": { + "description": "OAuth2ApplicationList represents a list of OAuth2 applications.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/OAuth2Application" + } + } + }, + "empty": { + "description": "APIEmpty is an empty response" + }, + "error": { + "description": "APIError is error format response", + "headers": { + "message": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, + "forbidden": { + "description": "APIForbiddenError is a forbidden error response", + "headers": { + "message": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, + "invalidTopicsError": { + "description": "APIInvalidTopicsError is error format response to invalid topics", + "headers": { + "invalidTopics": { + "type": "array", + "items": { + "type": "string" + } + }, + "message": { + "type": "string" + } + } + }, + "notFound": { + "description": "APINotFound is a not found empty response" + }, + "redirect": { + "description": "APIRedirect is a redirect response" + }, + "string": { + "description": "APIString is a string response", + "schema": { + "type": "string" + } + }, + "validationError": { + "description": "APIValidationError is error format response related to input validation", + "headers": { + "message": { + "type": "string" + }, + "url": { + "type": "string" + } + } + } + }, + "securityDefinitions": { + "AccessToken": { + "type": "apiKey", + "name": "access_token", + "in": "query" + }, + "AuthorizationHeaderToken": { + "description": "API tokens must be prepended with \"token\" followed by a space.", + "type": "apiKey", + "name": "Authorization", + "in": "header" + }, + "BasicAuth": { + "type": "basic" + }, + "SudoHeader": { + "description": "Sudo API request as the user provided as the key. Admin privileges are required.", + "type": "apiKey", + "name": "Sudo", + "in": "header" + }, + "SudoParam": { + "description": "Sudo API request as the user provided as the key. Admin privileges are required.", + "type": "apiKey", + "name": "sudo", + "in": "query" + }, + "Token": { + "type": "apiKey", + "name": "token", + "in": "query" + } + }, + "security": [ + { + "BasicAuth": [] + }, + { + "Token": [] + }, + { + "AccessToken": [] + }, + { + "AuthorizationHeaderToken": [] + }, + { + "SudoParam": [] + }, + { + "SudoHeader": [] + } + ] +} diff --git a/templates/swagger/catalog/ui.tmpl b/templates/swagger/catalog/ui.tmpl new file mode 100644 index 0000000000..8c110da111 --- /dev/null +++ b/templates/swagger/catalog/ui.tmpl @@ -0,0 +1,14 @@ + + + + + Catalog Next API + + + +{{svg "octicon-reply"}}Return to DCS API +{{svg "octicon-reply"}}Return to DCS +
+ + + diff --git a/templates/swagger/ui.tmpl b/templates/swagger/ui.tmpl index 55f45693e4..dcb2ad7b1f 100644 --- a/templates/swagger/ui.tmpl +++ b/templates/swagger/ui.tmpl @@ -6,7 +6,10 @@ - {{svg "octicon-reply"}}{{.i18n.Tr "return_to_gitea"}} + + {{svg "octicon-reply"}}Return to DCS + {{svg "octicon-tag"}}Goto Catalog Next API +
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 98b4b7a8ed..9134f83c7a 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -14,7 +14,7 @@ "swagger": "2.0", "info": { "description": "This documentation describes the DCS (Gitea) API.", - "title": "Gitea API.", + "title": "DCS (Gitea) API.", "license": { "name": "MIT", "url": "http://opensource.org/licenses/MIT" @@ -561,359 +561,6 @@ } } }, - "/catalog": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "catalog" - ], - "summary": "Catalog version endpoint list, including \"latest\" pointing to the latest version", - "operationId": "catalogListCatalogVersionEndpoints", - "parameters": [ - { - "type": "string", - "description": "version to list, all if empty", - "name": "version", - "in": "path" - } - ], - "responses": { - "200": { - "$ref": "#/responses/CatalogVersionList" - }, - "422": { - "$ref": "#/responses/validationError" - } - } - } - }, - "/catalog/entry/{owner}/{repo}/{tag}": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "catalog" - ], - "summary": "Catalog entry", - "operationId": "catalogGetCatalogEntry", - "parameters": [ - { - "type": "string", - "description": "name of the owner", - "name": "owner", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name of the repo", - "name": "repo", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "release tag or default branch", - "name": "tag", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "$ref": "#/responses/CatalogEntryV5" - }, - "422": { - "$ref": "#/responses/validationError" - } - } - } - }, - "/catalog/entry/{owner}/{repo}/{tag}/metadata": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "catalog" - ], - "summary": "Catalog entry metadata", - "operationId": "catalogGetMetadata", - "parameters": [ - { - "type": "string", - "description": "name of the owner", - "name": "owner", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name of the repo", - "name": "repo", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "release tag or default branch", - "name": "tag", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "$ref": "#/responses/CatalogMetadata" - }, - "422": { - "$ref": "#/responses/validationError" - } - } - } - }, - "/catalog/search/{owner}": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "catalog" - ], - "summary": "Catalog search by owner", - "operationId": "catalogSearchOwner", - "parameters": [ - { - "type": "string", - "description": "owner of entries", - "name": "owner", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "keyword(s). Can use multiple `q=\u003ckeyword\u003e`s or commas for more than one keyword", - "name": "q", - "in": "query" - }, - { - "type": "string", - "description": "search only for entries with the given repo name(s).", - "name": "repo", - "in": "query" - }, - { - "type": "string", - "description": "search only for entries with the given release tag(s)", - "name": "tag", - "in": "query" - }, - { - "type": "string", - "description": "search only for entries with the given language(s)", - "name": "lang", - "in": "query" - }, - { - "type": "string", - "description": "specifies which release stage to be return of these stages: \"prod\" - return only the production releases (default); \"preprod\" - return the pre-production release if it exists instead of the production release; \"draft\" - return the draft release if it exists instead of pre-production or production release; \"latest\" -return the default branch (e.g. master) if it is a valid RC instead of the above", - "name": "stage", - "in": "query" - }, - { - "type": "string", - "description": "search only for entries with the given subject(s). Must match the entire string (case insensitive)", - "name": "subject", - "in": "query" - }, - { - "type": "string", - "description": "search only for entries with the given checking level(s). Can be 1, 2 or 3", - "name": "checkingLevel", - "in": "query" - }, - { - "type": "string", - "description": "search only for entries with the given book(s) (project ids)", - "name": "book", - "in": "query" - }, - { - "type": "boolean", - "description": "if true, all releases, not just the latest, are included. Default is false", - "name": "includeHistory", - "in": "query" - }, - { - "type": "boolean", - "description": "if false, only subject and title are searched with query terms, if true all metadata values are searched. Default is true", - "name": "includeMetadata", - "in": "query" - }, - { - "type": "boolean", - "description": "if true, a list of the projects in the resource and their file paths will be listed for each entry. Default is false", - "name": "showIngredients", - "in": "query" - }, - { - "type": "string", - "description": "sort repos alphanumerically by attribute. Supported values are \"subject\", \"title\", \"tag\", \"released\", \"lang\", \"releases\", \"stars\", \"forks\". Default is by \"language\", \"subject\" and then \"tag\"", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "description": "sort order, either \"asc\" (ascending) or \"desc\" (descending). Default is \"asc\", ignored if \"sort\" is not specified.", - "name": "order", - "in": "query" - }, - { - "type": "integer", - "description": "page number of results to return (1-based)", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "page size of results, maximum page size is 50", - "name": "limit", - "in": "query" - } - ], - "responses": { - "200": { - "$ref": "#/responses/CatalogSearchResultsV5" - }, - "422": { - "$ref": "#/responses/validationError" - } - } - } - }, - "/catalog/search/{owner}/{repo}": { - "get": { - "produces": [ - "application/json" - ], - "tags": [ - "catalog" - ], - "summary": "Catalog search by repo", - "operationId": "catalogSearchRepo", - "parameters": [ - { - "type": "string", - "description": "name of the owner", - "name": "owner", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "name of the repo", - "name": "repo", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "keyword(s). Can use multiple `q=\u003ckeyword\u003e`s or commas for more than one keyword", - "name": "q", - "in": "query" - }, - { - "type": "string", - "description": "search only for entries with the given release tag(s)", - "name": "tag", - "in": "query" - }, - { - "type": "string", - "description": "search only for entries with the given language(s)", - "name": "lang", - "in": "query" - }, - { - "type": "string", - "description": "specifies which release stage to be return of these stages: \"prod\" - return only the production releases (default); \"preprod\" - return the pre-production release if it exists instead of the production release; \"draft\" - return the draft release if it exists instead of pre-production or production release; \"latest\" -return the default branch (e.g. master) if it is a valid RC instead of the above", - "name": "stage", - "in": "query" - }, - { - "type": "string", - "description": "search only for entries with the given subject(s). Must match the entire string (case insensitive)", - "name": "subject", - "in": "query" - }, - { - "type": "string", - "description": "search only for entries with the given checking level(s). Can be 1, 2 or 3", - "name": "checkingLevel", - "in": "query" - }, - { - "type": "string", - "description": "search only for entries with the given book(s) (project ids)", - "name": "book", - "in": "query" - }, - { - "type": "boolean", - "description": "if true, all releases, not just the latest, are included. Default is false", - "name": "includeHistory", - "in": "query" - }, - { - "type": "boolean", - "description": "if false, only subject and title are searched with query terms, if true all metadata values are searched. Default is true", - "name": "includeMetadata", - "in": "query" - }, - { - "type": "boolean", - "description": "if true, a list of the projects in the resource and their file paths will be listed for each entry. Default is false", - "name": "showIngredients", - "in": "query" - }, - { - "type": "string", - "description": "sort repos alphanumerically by attribute. Supported values are \"subject\", \"title\", \"tag\", \"released\", \"lang\", \"releases\", \"stars\", \"forks\". Default is language,subject,tag", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "description": "sort order, either \"asc\" (ascending) or \"desc\" (descending). Default is \"asc\", ignored if \"sort\" is not specified.", - "name": "order", - "in": "query" - }, - { - "type": "integer", - "description": "page number of results to return (1-based)", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "page size of results, maximum page size is 50", - "name": "limit", - "in": "query" - } - ], - "responses": { - "200": { - "$ref": "#/responses/CatalogSearchResultsV5" - }, - "422": { - "$ref": "#/responses/validationError" - } - } - } - }, "/markdown": { "post": { "consumes": [ @@ -11770,6 +11417,52 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "CatalogStage": { + "description": "CatalogStage a repo's catalog stage metadata", + "type": "object", + "properties": { + "branch_or_tag_name": { + "type": "string", + "x-go-name": "Tag" + }, + "release_url": { + "type": "string", + "x-go-name": "ReleaseURL" + }, + "released": { + "type": "string", + "x-go-name": "Released" + }, + "tarball_url": { + "type": "string", + "x-go-name": "TarballURL" + }, + "zipball_url": { + "type": "string", + "x-go-name": "ZipballURL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CatalogStages": { + "description": "CatalogStages a repo's catalog stages", + "type": "object", + "properties": { + "draft": { + "$ref": "#/definitions/CatalogStage" + }, + "latest": { + "$ref": "#/definitions/CatalogStage" + }, + "preprod": { + "$ref": "#/definitions/CatalogStage" + }, + "prod": { + "$ref": "#/definitions/CatalogStage" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "CombinedStatus": { "description": "CombinedStatus holds the combined state of several statuses for a single commit", "type": "object", @@ -15567,6 +15260,9 @@ }, "x-go-name": "Books" }, + "catalog": { + "$ref": "#/definitions/CatalogStages" + }, "checking_level": { "type": "string", "x-go-name": "CheckingLevel" @@ -17091,4 +16787,4 @@ "TOTPHeader": [] } ] -} \ No newline at end of file +} diff --git a/web_src/less/standalone/swagger.less b/web_src/less/standalone/swagger.less index c34469bede..3dc4010ec2 100644 --- a/web_src/less/standalone/swagger.less +++ b/web_src/less/standalone/swagger.less @@ -17,10 +17,15 @@ body { .swagger-back-link { color: #1f69c0; text-decoration: none; - position: absolute; - top: 1rem; - right: 1.5rem; - display: flex; + /*** DCS Customizations ***/ + // position: absolute; + // top: 1rem; + // right: 1.5rem; + // display: flex; + float: right; + padding-right: 10px; + clear: both; + /*** END DCS Customizations ***/ align-items: center; }