Skip to content

Commit

Permalink
api: Add operation IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed Sep 9, 2024
1 parent 25b5ce5 commit 9ebcd82
Show file tree
Hide file tree
Showing 7 changed files with 363 additions and 263 deletions.
17 changes: 9 additions & 8 deletions pkg/api/rest/controller/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ var OkMessage = model.SimpleMsg{}
var IsReady = false

// CheckReady func is for checking Cicada server health.
// @Summary Check Ready
// @Description Check Cicada is ready
// @Tags [Admin] System management
// @Accept json
// @Produce json
// @Success 200 {object} model.SimpleMsg "Successfully get ready state."
// @Failure 500 {object} common.ErrorResponse "Failed to check ready state."
//
// @Router /readyz [get]
// @ID health-check-readyz
// @Summary Check Ready
// @Description Check Cicada is ready
// @Tags [Admin] System management
// @Accept json
// @Produce json
// @Success 200 {object} model.SimpleMsg "Successfully get ready state."
// @Failure 500 {object} common.ErrorResponse "Failed to check ready state."
// @Router /readyz [get]
func CheckReady(c echo.Context) error {
status := http.StatusOK

Expand Down
130 changes: 68 additions & 62 deletions pkg/api/rest/controller/taskComponent.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ import (

// CreateTaskComponent godoc
//
// @Summary Create TaskComponent
// @Description Register the task component.
// @Tags [Task Component]
// @Accept json
// @Produce json
// @Param TaskComponent body model.CreateTaskComponentReq true "task component of the node."
// @Success 200 {object} model.TaskComponent "Successfully register the task component"
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
// @Failure 500 {object} common.ErrorResponse "Failed to register the task component"
// @Router /task_component [post]
// @ID create-task-component
// @Summary Create TaskComponent
// @Description Register the task component.
// @Tags [Task Component]
// @Accept json
// @Produce json
// @Param TaskComponent body model.CreateTaskComponentReq true "task component of the node."
// @Success 200 {object} model.TaskComponent "Successfully register the task component"
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
// @Failure 500 {object} common.ErrorResponse "Failed to register the task component"
// @Router /task_component [post]
func CreateTaskComponent(c echo.Context) error {
createTaskComponentReq := new(model.CreateTaskComponentReq)
err := c.Bind(createTaskComponentReq)
Expand All @@ -48,16 +49,17 @@ func CreateTaskComponent(c echo.Context) error {

// GetTaskComponent godoc
//
// @Summary Get TaskComponent
// @Description Get the task component.
// @Tags [Task Component]
// @Accept json
// @Produce json
// @Param tcId path string true "ID of the TaskComponent"
// @Success 200 {object} model.TaskComponent "Successfully get the task component"
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
// @Failure 500 {object} common.ErrorResponse "Failed to get the task component"
// @Router /task_component/{tcId} [get]
// @ID get-task-component
// @Summary Get TaskComponent
// @Description Get the task component.
// @Tags [Task Component]
// @Accept json
// @Produce json
// @Param tcId path string true "ID of the TaskComponent"
// @Success 200 {object} model.TaskComponent "Successfully get the task component"
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
// @Failure 500 {object} common.ErrorResponse "Failed to get the task component"
// @Router /task_component/{tcId} [get]
func GetTaskComponent(c echo.Context) error {
tcId := c.Param("tcId")
if tcId == "" {
Expand All @@ -72,16 +74,17 @@ func GetTaskComponent(c echo.Context) error {

// GetTaskComponentByName godoc
//
// @Summary Get TaskComponent by Name
// @Description Get the task component by name.
// @Tags [Task Component]
// @Accept json
// @Produce json
// @Param tcName path string true "Name of the TaskComponent"
// @Success 200 {object} model.TaskComponent "Successfully get the task component"
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
// @Failure 500 {object} common.ErrorResponse "Failed to get the task component"
// @Router /task_component/name/{tcName} [get]
// @ID get-task-component-by-name
// @Summary Get TaskComponent by Name
// @Description Get the task component by name.
// @Tags [Task Component]
// @Accept json
// @Produce json
// @Param tcName path string true "Name of the TaskComponent"
// @Success 200 {object} model.TaskComponent "Successfully get the task component"
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
// @Failure 500 {object} common.ErrorResponse "Failed to get the task component"
// @Router /task_component/name/{tcName} [get]
func GetTaskComponentByName(c echo.Context) error {
tcName := c.Param("tcName")
if tcName == "" {
Expand All @@ -96,17 +99,18 @@ func GetTaskComponentByName(c echo.Context) error {

// ListTaskComponent godoc
//
// @Summary List TaskComponent
// @Description Get a list of task component.
// @Tags [Task Component]
// @Accept json
// @Produce json
// @Param page query string false "Page of the task component list."
// @Param row query string false "Row of the task component list."
// @Success 200 {object} []model.TaskComponent "Successfully get a list of task component."
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
// @Failure 500 {object} common.ErrorResponse "Failed to get a list of task component."
// @Router /task_component [get]
// @ID list-task-component
// @Summary List TaskComponent
// @Description Get a list of task component.
// @Tags [Task Component]
// @Accept json
// @Produce json
// @Param page query string false "Page of the task component list."
// @Param row query string false "Row of the task component list."
// @Success 200 {object} []model.TaskComponent "Successfully get a list of task component."
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
// @Failure 500 {object} common.ErrorResponse "Failed to get a list of task component."
// @Router /task_component [get]
func ListTaskComponent(c echo.Context) error {
page, row, err := common.CheckPageRow(c)
if err != nil {
Expand All @@ -122,17 +126,18 @@ func ListTaskComponent(c echo.Context) error {

// UpdateTaskComponent godoc
//
// @Summary Update TaskComponent
// @Description Update the task component.
// @Tags [Task Component]
// @Accept json
// @Produce json
// @Param tcId path string true "ID of the TaskComponent"
// @Param TaskComponent body model.CreateTaskComponentReq true "task component to modify."
// @Success 200 {object} model.TaskComponent "Successfully update the task component"
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
// @Failure 500 {object} common.ErrorResponse "Failed to update the task component"
// @Router /task_component/{tcId} [put]
// @ID update-task-component
// @Summary Update TaskComponent
// @Description Update the task component.
// @Tags [Task Component]
// @Accept json
// @Produce json
// @Param tcId path string true "ID of the TaskComponent"
// @Param TaskComponent body model.CreateTaskComponentReq true "task component to modify."
// @Success 200 {object} model.TaskComponent "Successfully update the task component"
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
// @Failure 500 {object} common.ErrorResponse "Failed to update the task component"
// @Router /task_component/{tcId} [put]
func UpdateTaskComponent(c echo.Context) error {
taskComponent := new(model.CreateTaskComponentReq)
err := c.Bind(taskComponent)
Expand Down Expand Up @@ -165,16 +170,17 @@ func UpdateTaskComponent(c echo.Context) error {

// DeleteTaskComponent godoc
//
// @Summary Delete TaskComponent
// @Description Delete the task component.
// @Tags [Task Component]
// @Accept json
// @Produce json
// @Param tcId path string true "ID of the task component."
// @Success 200 {object} model.SimpleMsg "Successfully delete the task component"
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
// @Failure 500 {object} common.ErrorResponse "Failed to delete the task component"
// @Router /task_component/{tcId} [delete]
// @ID delete-task-component
// @Summary Delete TaskComponent
// @Description Delete the task component.
// @Tags [Task Component]
// @Accept json
// @Produce json
// @Param tcId path string true "ID of the task component."
// @Success 200 {object} model.SimpleMsg "Successfully delete the task component"
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
// @Failure 500 {object} common.ErrorResponse "Failed to delete the task component"
// @Router /task_component/{tcId} [delete]
func DeleteTaskComponent(c echo.Context) error {
tcId := c.Param("tcId")
if tcId == "" {
Expand Down
Loading

0 comments on commit 9ebcd82

Please sign in to comment.