Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: kusion server handler swagger apis #1365

Merged
merged 5 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 96 additions & 90 deletions api/openapispec/docs.go

Large diffs are not rendered by default.

186 changes: 96 additions & 90 deletions api/openapispec/swagger.json

Large diffs are not rendered by default.

160 changes: 82 additions & 78 deletions api/openapispec/swagger.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ require (
github.com/jinzhu/now v1.1.5 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/json-iterator/go v1.1.12
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
Expand Down
50 changes: 25 additions & 25 deletions pkg/server/handler/backend/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ func (h *Handler) CreateBackend() http.HandlerFunc {
// @Description Delete specified backend by ID
// @Tags backend
// @Produce json
// @Param id path int true "Backend ID"
// @Success 200 {object} handler.Response{data=string} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/backends/{id} [delete]
// @Param backendID path int true "Backend ID"
// @Success 200 {object} handler.Response{data=string} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/backends/{backendID} [delete]
func (h *Handler) DeleteBackend() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context
Expand All @@ -82,15 +82,15 @@ func (h *Handler) DeleteBackend() http.HandlerFunc {
// @Tags backend
// @Accept json
// @Produce json
// @Param id path int true "Backend ID"
// @Param backend body request.UpdateBackendRequest true "Updated backend"
// @Success 200 {object} handler.Response{data=entity.Backend} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/backends/{id} [put]
// @Param backendID path int true "Backend ID"
// @Param backend body request.UpdateBackendRequest true "Updated backend"
// @Success 200 {object} handler.Response{data=entity.Backend} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/backends/{backendID} [put]
func (h *Handler) UpdateBackend() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context
Expand Down Expand Up @@ -118,14 +118,14 @@ func (h *Handler) UpdateBackend() http.HandlerFunc {
// @Description Get backend information by backend ID
// @Tags backend
// @Produce json
// @Param id path int true "Backend ID"
// @Success 200 {object} handler.Response{data=entity.Backend} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/backends/{id} [get]
// @Param backendID path int true "Backend ID"
// @Success 200 {object} handler.Response{data=entity.Backend} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/backends/{backendID} [get]
func (h *Handler) GetBackend() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context
Expand Down
50 changes: 25 additions & 25 deletions pkg/server/handler/module/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ func (h *Handler) CreateModule() http.HandlerFunc {
// @Description Delete the specified module by name
// @Tags module
// @Produce json
// @Param name path string true "Module Name"
// @Success 200 {object} handler.Response{data=string} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules/{name} [delete]
// @Param moduleName path string true "Module Name"
// @Success 200 {object} handler.Response{data=string} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules/{moduleName} [delete]
func (h *Handler) DeleteModule() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context.
Expand All @@ -83,15 +83,15 @@ func (h *Handler) DeleteModule() http.HandlerFunc {
// @Tags module
// @Accept json
// @Produce json
// @Param name path string true "Module Name"
// @Param module body request.UpdateModuleRequest true "Updated module"
// @Success 200 {object} handler.Response{data=entity.Module} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules/{name} [put]
// @Param moduleName path string true "Module Name"
// @Param module body request.UpdateModuleRequest true "Updated module"
// @Success 200 {object} handler.Response{data=entity.Module} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules/{moduleName} [put]
func (h *Handler) UpdateModule() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context.
Expand Down Expand Up @@ -120,14 +120,14 @@ func (h *Handler) UpdateModule() http.HandlerFunc {
// @Description Get module information by module name
// @Tags module
// @Produce json
// @Param name path string true "Module Name"
// @Success 200 {object} handler.Response{data=entity.Module} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules/{name} [get]
// @Param moduleName path string true "Module Name"
// @Success 200 {object} handler.Response{data=entity.Module} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/modules/{moduleName} [get]
func (h *Handler) GetModule() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context.
Expand Down
36 changes: 18 additions & 18 deletions pkg/server/handler/organization/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ func (h *Handler) CreateOrganization() http.HandlerFunc {
// @Description Delete specified organization by ID
// @Tags organization
// @Produce json
// @Param id path int true "Organization ID"
// @Success 200 {object} handler.Response{data=string} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/orgs/{id} [delete]
// @Param orgID path int true "Organization ID"
// @Success 200 {object} handler.Response{data=string} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/orgs/{orgID} [delete]
func (h *Handler) DeleteOrganization() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context
Expand All @@ -89,15 +89,15 @@ func (h *Handler) DeleteOrganization() http.HandlerFunc {
// @Tags organization
// @Accept json
// @Produce json
// @Param id path int true "Organization ID"
// @Param orgID path int true "Organization ID"
// @Param organization body request.UpdateOrganizationRequest true "Updated organization"
// @Success 200 {object} handler.Response{data=entity.Organization} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/orgs/{id} [put]
// @Router /api/v1/orgs/{orgID} [put]
func (h *Handler) UpdateOrganization() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context
Expand Down Expand Up @@ -132,14 +132,14 @@ func (h *Handler) UpdateOrganization() http.HandlerFunc {
// @Description Get organization information by organization ID
// @Tags organization
// @Produce json
// @Param id path int true "Organization ID"
// @Success 200 {object} handler.Response{data=entity.Organization} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/orgs/{id} [get]
// @Param orgID path int true "Organization ID"
// @Success 200 {object} handler.Response{data=entity.Organization} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/orgs/{orgID} [get]
func (h *Handler) GetOrganization() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context
Expand Down
12 changes: 6 additions & 6 deletions pkg/server/handler/project/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ func (h *Handler) CreateProject() http.HandlerFunc {
// @Description Delete specified project by ID
// @Tags project
// @Produce json
// @Param project_id path int true "Project ID"
// @Param projectID path int true "Project ID"
// @Success 200 {object} handler.Response{data=string} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/projects/{project_id} [delete]
// @Router /api/v1/projects/{projectID} [delete]
func (h *Handler) DeleteProject() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context
Expand All @@ -99,15 +99,15 @@ func (h *Handler) DeleteProject() http.HandlerFunc {
// @Tags project
// @Accept json
// @Produce json
// @Param project_id path uint true "Project ID"
// @Param projectID path uint true "Project ID"
// @Param project body request.UpdateProjectRequest true "Updated project"
// @Success 200 {object} handler.Response{data=entity.Project} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/projects/{project_id} [put]
// @Router /api/v1/projects/{projectID} [put]
func (h *Handler) UpdateProject() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context
Expand Down Expand Up @@ -141,14 +141,14 @@ func (h *Handler) UpdateProject() http.HandlerFunc {
// @Description Get project information by project ID
// @Tags project
// @Produce json
// @Param project_id path uint true "Project ID"
// @Param projectID path uint true "Project ID"
// @Success 200 {object} handler.Response{data=entity.Project} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/projects/{project_id} [get]
// @Router /api/v1/projects/{projectID} [get]
func (h *Handler) GetProject() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context
Expand Down
49 changes: 27 additions & 22 deletions pkg/server/handler/resource/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ import (
// @Description List resource information
// @Tags resource
// @Produce json
// @Param page query uint false "The current page to fetch. Default to 1"
// @Param pageSize query uint false "The size of the page. Default to 10"
// @Success 200 {object} handler.Response{data=[]response.PaginatedResourceResponse} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Param orgID query uint false "The organization ID"
// @Param projectID query uint false "The project ID"
// @Param stackID query uint false "The stack ID"
// @Param resourceType query string false "The resource type"
// @Param resourcePlane query string false "The resource plane"
// @Param page query uint false "The current page to fetch. Default to 1"
// @Param pageSize query uint false "The size of the page. Default to 10"
// @Success 200 {object} handler.Response{data=[]response.PaginatedResourceResponse} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/resources [get]
func (h *Handler) ListResources() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -65,14 +70,14 @@ func (h *Handler) ListResources() http.HandlerFunc {
// @Description Get resource information by resource ID
// @Tags resource
// @Produce json
// @Param id path int true "Resource ID"
// @Success 200 {object} handler.Response{data=entity.Resource} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/resources/{id} [get]
// @Param resourceID path int true "Resource ID"
// @Success 200 {object} handler.Response{data=entity.Resource} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/resources/{resourceID} [get]
func (h *Handler) GetResource() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Getting stuff from context
Expand All @@ -94,12 +99,12 @@ func (h *Handler) GetResource() http.HandlerFunc {
// @Tags resource
// @Produce json
// @Param stackID query uint true "Stack ID"
// @Success 200 {object} handler.Response{data=entity.ResourceGraph} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Success 200 {object} handler.Response{data=entity.ResourceGraph} "Success"
// @Failure 400 {object} error "Bad Request"
// @Failure 401 {object} error "Unauthorized"
// @Failure 429 {object} error "Too Many Requests"
// @Failure 404 {object} error "Not Found"
// @Failure 500 {object} error "Internal Server Error"
// @Router /api/v1/resources/graph [get]
func (h *Handler) GetResourceGraph() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
Expand Down
Loading
Loading