mirror of
https://github.com/harness/drone.git
synced 2025-05-06 04:50:38 +08:00
import API openapi definition
This commit is contained in:
parent
f03566954d
commit
935b70a9ad
@ -384,6 +384,18 @@ func repoOperations(reflector *openapi3.Reflector) {
|
|||||||
_ = reflector.SetJSONResponse(&createRepository, new(usererror.Error), http.StatusForbidden)
|
_ = reflector.SetJSONResponse(&createRepository, new(usererror.Error), http.StatusForbidden)
|
||||||
_ = reflector.Spec.AddOperation(http.MethodPost, "/repos", createRepository)
|
_ = reflector.Spec.AddOperation(http.MethodPost, "/repos", createRepository)
|
||||||
|
|
||||||
|
importRepository := openapi3.Operation{}
|
||||||
|
importRepository.WithTags("repository")
|
||||||
|
importRepository.WithMapOfAnything(map[string]interface{}{"operationId": "importRepository"})
|
||||||
|
importRepository.WithParameters(queryParameterSpacePath)
|
||||||
|
_ = reflector.SetRequest(&importRepository, &struct{ repo.ImportInput }{}, http.MethodPost)
|
||||||
|
_ = reflector.SetJSONResponse(&importRepository, new(types.Repository), http.StatusCreated)
|
||||||
|
_ = reflector.SetJSONResponse(&importRepository, new(usererror.Error), http.StatusBadRequest)
|
||||||
|
_ = reflector.SetJSONResponse(&importRepository, new(usererror.Error), http.StatusInternalServerError)
|
||||||
|
_ = reflector.SetJSONResponse(&importRepository, new(usererror.Error), http.StatusUnauthorized)
|
||||||
|
_ = reflector.SetJSONResponse(&importRepository, new(usererror.Error), http.StatusForbidden)
|
||||||
|
_ = reflector.Spec.AddOperation(http.MethodPost, "/repos/import", importRepository)
|
||||||
|
|
||||||
opFind := openapi3.Operation{}
|
opFind := openapi3.Operation{}
|
||||||
opFind.WithTags("repository")
|
opFind.WithTags("repository")
|
||||||
opFind.WithMapOfAnything(map[string]interface{}{"operationId": "findRepository"})
|
opFind.WithMapOfAnything(map[string]interface{}{"operationId": "findRepository"})
|
||||||
|
@ -158,6 +158,17 @@ func spaceOperations(reflector *openapi3.Reflector) {
|
|||||||
_ = reflector.SetJSONResponse(&opCreate, new(usererror.Error), http.StatusForbidden)
|
_ = reflector.SetJSONResponse(&opCreate, new(usererror.Error), http.StatusForbidden)
|
||||||
_ = reflector.Spec.AddOperation(http.MethodPost, "/spaces", opCreate)
|
_ = reflector.Spec.AddOperation(http.MethodPost, "/spaces", opCreate)
|
||||||
|
|
||||||
|
opImport := openapi3.Operation{}
|
||||||
|
opImport.WithTags("space")
|
||||||
|
opImport.WithMapOfAnything(map[string]interface{}{"operationId": "importSpace"})
|
||||||
|
_ = reflector.SetRequest(&opImport, &struct{ space.ImportInput }{}, http.MethodPost)
|
||||||
|
_ = reflector.SetJSONResponse(&opImport, new(types.Space), http.StatusCreated)
|
||||||
|
_ = reflector.SetJSONResponse(&opImport, new(usererror.Error), http.StatusBadRequest)
|
||||||
|
_ = reflector.SetJSONResponse(&opImport, new(usererror.Error), http.StatusInternalServerError)
|
||||||
|
_ = reflector.SetJSONResponse(&opImport, new(usererror.Error), http.StatusUnauthorized)
|
||||||
|
_ = reflector.SetJSONResponse(&opImport, new(usererror.Error), http.StatusForbidden)
|
||||||
|
_ = reflector.Spec.AddOperation(http.MethodPost, "/spaces/import", opImport)
|
||||||
|
|
||||||
opGet := openapi3.Operation{}
|
opGet := openapi3.Operation{}
|
||||||
opGet.WithTags("space")
|
opGet.WithTags("space")
|
||||||
opGet.WithMapOfAnything(map[string]interface{}{"operationId": "getSpace"})
|
opGet.WithMapOfAnything(map[string]interface{}{"operationId": "getSpace"})
|
||||||
|
@ -29,14 +29,7 @@ const (
|
|||||||
ProviderTypeGitLabEnterprise ProviderType = "gitlab-enterprise"
|
ProviderTypeGitLabEnterprise ProviderType = "gitlab-enterprise"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Provider struct {
|
func (p ProviderType) Enum() []any {
|
||||||
Type ProviderType `json:"type"`
|
|
||||||
Host string `json:"host"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
Password string `json:"password"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Provider) Enum() []any {
|
|
||||||
return []any{
|
return []any{
|
||||||
ProviderTypeGitHub,
|
ProviderTypeGitHub,
|
||||||
ProviderTypeGitHubEnterprise,
|
ProviderTypeGitHubEnterprise,
|
||||||
@ -45,6 +38,13 @@ func (p Provider) Enum() []any {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Provider struct {
|
||||||
|
Type ProviderType `json:"type"`
|
||||||
|
Host string `json:"host"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
}
|
||||||
|
|
||||||
type RepositoryInfo struct {
|
type RepositoryInfo struct {
|
||||||
Space string
|
Space string
|
||||||
UID string
|
UID string
|
||||||
|
Loading…
Reference in New Issue
Block a user