import API openapi definition

This commit is contained in:
Marko Gaćeša 2023-09-09 14:29:13 +02:00
parent f03566954d
commit 935b70a9ad
3 changed files with 31 additions and 8 deletions

View File

@ -384,6 +384,18 @@ func repoOperations(reflector *openapi3.Reflector) {
_ = reflector.SetJSONResponse(&createRepository, new(usererror.Error), http.StatusForbidden)
_ = 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.WithTags("repository")
opFind.WithMapOfAnything(map[string]interface{}{"operationId": "findRepository"})

View File

@ -158,6 +158,17 @@ func spaceOperations(reflector *openapi3.Reflector) {
_ = reflector.SetJSONResponse(&opCreate, new(usererror.Error), http.StatusForbidden)
_ = 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.WithTags("space")
opGet.WithMapOfAnything(map[string]interface{}{"operationId": "getSpace"})

View File

@ -29,14 +29,7 @@ const (
ProviderTypeGitLabEnterprise ProviderType = "gitlab-enterprise"
)
type Provider struct {
Type ProviderType `json:"type"`
Host string `json:"host"`
Username string `json:"username"`
Password string `json:"password"`
}
func (p Provider) Enum() []any {
func (p ProviderType) Enum() []any {
return []any{
ProviderTypeGitHub,
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 {
Space string
UID string