Skip to content

Commit eac1bdd

Browse files
authored
fix swagger documentation for multiple files API endpoint (#25110)
Fixes some issues with the swagger documentation for the new multiple files API endpoint (#24887) which were overlooked when submitting the original PR: 1. add some missing parameter descriptions 2. set correct `required` option for required parameters 3. change endpoint description to match it full functionality (every kind of file modification is supported, not just creating and updating)
1 parent 027014d commit eac1bdd

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

modules/structs/repo_file.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ type ChangeFileOperation struct {
7171
// enum: create,update,delete
7272
Operation string `json:"operation" binding:"Required"`
7373
// path to the existing or new file
74-
Path string `json:"path" binding:"MaxSize(500)"`
75-
// content must be base64 encoded
7674
// required: true
75+
Path string `json:"path" binding:"Required;MaxSize(500)"`
76+
// new or updated file content, must be base64 encoded
7777
Content string `json:"content"`
78-
// sha is the SHA for the file that already exists, required for update, delete
78+
// sha is the SHA for the file that already exists, required for update or delete
7979
SHA string `json:"sha"`
8080
// old path of the file to move
8181
FromPath string `json:"from_path"`
@@ -85,7 +85,9 @@ type ChangeFileOperation struct {
8585
// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)
8686
type ChangeFilesOptions struct {
8787
FileOptions
88-
Files []*ChangeFileOperation `json:"files"`
88+
// list of file operations
89+
// required: true
90+
Files []*ChangeFileOperation `json:"files" binding:"Required"`
8991
}
9092

9193
// Branch returns branch name

routers/api/v1/repo/file.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,11 @@ func canReadFiles(r *context.Repository) bool {
408408
return r.Permission.CanRead(unit.TypeCode)
409409
}
410410

411-
// ChangeFiles handles API call for creating or updating multiple files
411+
// ChangeFiles handles API call for modifying multiple files
412412
func ChangeFiles(ctx *context.APIContext) {
413413
// swagger:operation POST /repos/{owner}/{repo}/contents repository repoChangeFiles
414414
// ---
415-
// summary: Create or update multiple files in a repository
415+
// summary: Modify multiple files in a repository
416416
// consumes:
417417
// - application/json
418418
// produces:

templates/swagger/v1_json.tmpl

+8-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)