Skip to content

Commit f7a1dca

Browse files
committed
Update swagger docs
1 parent 32b6aef commit f7a1dca

File tree

5 files changed

+312
-16
lines changed

5 files changed

+312
-16
lines changed

modules/structs/repo_actions.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type ActionTaskResponse struct {
3333
TotalCount int64 `json:"total_count"`
3434
}
3535

36-
// ActionTask represents a ActionTask
36+
// ActionArtifact represents a ActionArtifact
3737
type ActionArtifact struct {
3838
ID int64 `json:"id"`
3939
Name string `json:"name"`
@@ -51,13 +51,14 @@ type ActionArtifact struct {
5151
ExpiresAt time.Time `json:"expires_at"`
5252
}
5353

54+
// ActionWorkflowRun represents a WorkflowRun
5455
type ActionWorkflowRun struct {
5556
ID int64 `json:"id"`
5657
RepositoryID int64 `json:"repository_id"`
5758
HeadSha string `json:"head_sha"`
5859
}
5960

60-
// ActionArtifactsResponse returns a ActionTask
61+
// ActionArtifactsResponse returns ActionArtifacts
6162
type ActionArtifactsResponse struct {
6263
Entries []*ActionArtifact `json:"artifacts"`
6364
TotalCount int64 `json:"total_count"`

routers/api/v1/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,7 @@ func Routes() *web.Router {
12371237
m.Get("/tasks", repo.ListActionTasks)
12381238
m.Get("/runs/{run}/artifacts", repo.GetArtifactsOfRun)
12391239
m.Get("/artifacts", repo.GetArtifacts)
1240+
m.Get("/artifacts/{artifact_id}", repo.GetArtifact)
12401241
m.Get("/artifacts/{artifact_id}/zip", repo.DownloadArtifact)
12411242
m.Get("/artifacts/{artifact_id}/zip/raw", repo.DownloadArtifactRaw)
12421243
}, reqRepoReader(unit.TypeActions), context.ReferencesGitRepo(true))

routers/api/v1/repo/action.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ func ListActionTasks(ctx *context.APIContext) {
590590

591591
// GetArtifacts Lists all artifacts for a repository
592592
func GetArtifactsOfRun(ctx *context.APIContext) {
593-
// swagger:operation GET /repos/{owner}/{repo}/actions/artifacts repository getArtifacts
593+
// swagger:operation GET /repos/{owner}/{repo}/actions/artifacts repository getArtifactsOfRun
594594
// ---
595595
// summary: Lists all artifacts for a repository run
596596
// produces:
@@ -608,7 +608,7 @@ func GetArtifactsOfRun(ctx *context.APIContext) {
608608
// required: true
609609
// responses:
610610
// "200":
611-
// description: response when getting the artifacts
611+
// "$ref": "#/responses/ArtifactsList"
612612
// "400":
613613
// "$ref": "#/responses/error"
614614
// "404":
@@ -670,7 +670,7 @@ func GetArtifacts(ctx *context.APIContext) {
670670
// required: true
671671
// responses:
672672
// "200":
673-
// description: response when getting the artifacts
673+
// "$ref": "#/responses/ArtifactsList"
674674
// "400":
675675
// "$ref": "#/responses/error"
676676
// "404":
@@ -709,9 +709,9 @@ func GetArtifacts(ctx *context.APIContext) {
709709
ctx.JSON(http.StatusOK, &res)
710710
}
711711

712-
// DownloadArtifact Gets a specific artifact for a workflow run.
712+
// GetArtifact Gets a specific artifact for a workflow run.
713713
func GetArtifact(ctx *context.APIContext) {
714-
// swagger:operation GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/zip repository downloadArtifact
714+
// swagger:operation GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id} repository getArtifact
715715
// ---
716716
// summary: Gets a specific artifact for a workflow run.
717717
// produces:
@@ -734,7 +734,7 @@ func GetArtifact(ctx *context.APIContext) {
734734
// required: true
735735
// responses:
736736
// "200":
737-
// description: response when getting the artifacts
737+
// "$ref": "#/responses/Artifact"
738738
// "400":
739739
// "$ref": "#/responses/error"
740740
// "404":
@@ -774,11 +774,11 @@ func GetArtifact(ctx *context.APIContext) {
774774
ctx.Error(http.StatusNotFound, "artifact not found", fmt.Errorf("artifact not found"))
775775
}
776776

777-
// DownloadArtifact Gets a specific artifact for a workflow run.
777+
// DownloadArtifact Downloads a specific artifact for a workflow run redirects to blob url.
778778
func DownloadArtifact(ctx *context.APIContext) {
779779
// swagger:operation GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/zip repository downloadArtifact
780780
// ---
781-
// summary: Gets a specific artifact for a workflow run redirects to blob url.
781+
// summary: Downloads a specific artifact for a workflow run redirects to blob url.
782782
// produces:
783783
// - application/json
784784
// parameters:
@@ -798,8 +798,8 @@ func DownloadArtifact(ctx *context.APIContext) {
798798
// type: string
799799
// required: true
800800
// responses:
801-
// "200":
802-
// description: response when getting the artifacts
801+
// "302":
802+
// description: redirect to the blob download
803803
// "400":
804804
// "$ref": "#/responses/error"
805805
// "404":
@@ -845,11 +845,11 @@ func DownloadArtifact(ctx *context.APIContext) {
845845
ctx.Error(http.StatusNotFound, "artifact not found", fmt.Errorf("artifact not found"))
846846
}
847847

848-
// DownloadArtifactRaw Gets a specific artifact for a workflow run.
848+
// DownloadArtifactRaw Downloads a specific artifact for a workflow run directly.
849849
func DownloadArtifactRaw(ctx *context.APIContext) {
850850
// swagger:operation GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/zip/raw repository downloadArtifactRaw
851851
// ---
852-
// summary: Gets a specific artifact for a workflow run direct download.
852+
// summary: Downloads a specific artifact for a workflow run directly.
853853
// produces:
854854
// - application/json
855855
// parameters:
@@ -870,7 +870,7 @@ func DownloadArtifactRaw(ctx *context.APIContext) {
870870
// required: true
871871
// responses:
872872
// "200":
873-
// description: response when getting the artifacts
873+
// description: the artifact content
874874
// "400":
875875
// "$ref": "#/responses/error"
876876
// "404":

routers/api/v1/swagger/repo.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,20 @@ type swaggerRepoTasksList struct {
443443
Body api.ActionTaskResponse `json:"body"`
444444
}
445445

446+
// ArtifactsList
447+
// swagger:response ArtifactsList
448+
type swaggerRepoArtifactsList struct {
449+
// in:body
450+
Body api.ActionArtifactsResponse `json:"body"`
451+
}
452+
453+
// Artifact
454+
// swagger:response Artifact
455+
type swaggerRepoArtifact struct {
456+
// in:body
457+
Body api.ActionArtifact `json:"body"`
458+
}
459+
446460
// swagger:response Compare
447461
type swaggerCompare struct {
448462
// in:body

0 commit comments

Comments
 (0)