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 swagger documentation for multiple files API endpoint #25110

Merged
merged 3 commits into from
Jun 7, 2023
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
10 changes: 6 additions & 4 deletions modules/structs/repo_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ type ChangeFileOperation struct {
// enum: create,update,delete
Operation string `json:"operation" binding:"Required"`
// path to the existing or new file
Path string `json:"path" binding:"MaxSize(500)"`
// content must be base64 encoded
// required: true
Path string `json:"path" binding:"Required;MaxSize(500)"`
// new or updated file content, must be base64 encoded
Content string `json:"content"`
// sha is the SHA for the file that already exists, required for update, delete
// sha is the SHA for the file that already exists, required for update or delete
SHA string `json:"sha"`
// old path of the file to move
FromPath string `json:"from_path"`
Expand All @@ -85,7 +85,9 @@ type ChangeFileOperation struct {
// 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)
type ChangeFilesOptions struct {
FileOptions
Files []*ChangeFileOperation `json:"files"`
// list of file operations
// required: true
Files []*ChangeFileOperation `json:"files" binding:"Required"`
}

// Branch returns branch name
Expand Down
4 changes: 2 additions & 2 deletions routers/api/v1/repo/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,11 @@ func canReadFiles(r *context.Repository) bool {
return r.Permission.CanRead(unit.TypeCode)
}

// ChangeFiles handles API call for creating or updating multiple files
// ChangeFiles handles API call for modifying multiple files
func ChangeFiles(ctx *context.APIContext) {
// swagger:operation POST /repos/{owner}/{repo}/contents repository repoChangeFiles
// ---
// summary: Create or update multiple files in a repository
// summary: Modify multiple files in a repository
// consumes:
// - application/json
// produces:
Expand Down
12 changes: 8 additions & 4 deletions templates/swagger/v1_json.tmpl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.