Skip to content

API: Expose its limitation settings #12714

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions modules/structs/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ type GeneralRepoSettings struct {
type GeneralUISettings struct {
AllowedReactions []string `json:"allowed_reactions"`
}

// GeneralAPISettings contains global api settings exposed by it
type GeneralAPISettings struct {
MaxResponseItems int `json:"max_response_items"`
DefaultPagingNum int `json:"default_paging_num"`
DefaultGitTreesPerPage int `json:"default_git_trees_per_page"`
DefaultMaxBlobSize int64 `json:"default_max_blob_size"`
}
1 change: 1 addition & 0 deletions routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/markdown/raw", misc.MarkdownRaw)
m.Group("/settings", func() {
m.Get("/ui", settings.GetGeneralUISettings)
m.Get("/api", settings.GetGeneralAPISettings)
m.Get("/repository", settings.GetGeneralRepoSettings)
})

Expand Down
18 changes: 18 additions & 0 deletions routers/api/v1/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ func GetGeneralUISettings(ctx *context.APIContext) {
})
}

// GetGeneralAPISettings returns instance's global settings for api
func GetGeneralAPISettings(ctx *context.APIContext) {
// swagger:operation GET /settings/api settings getGeneralAPISettings
// ---
// summary: Get instance's global settings for api
// produces:
// - application/json
// responses:
// "200":
// "$ref": "#/responses/GeneralAPISettings"
ctx.JSON(http.StatusOK, api.GeneralAPISettings{
MaxResponseItems: setting.API.MaxResponseItems,
DefaultPagingNum: setting.API.DefaultPagingNum,
DefaultGitTreesPerPage: setting.API.DefaultGitTreesPerPage,
DefaultMaxBlobSize: setting.API.DefaultMaxBlobSize,
})
}

// GetGeneralRepoSettings returns instance's global settings for repositories
func GetGeneralRepoSettings(ctx *context.APIContext) {
// swagger:operation GET /settings/repository settings getGeneralRepositorySettings
Expand Down
7 changes: 7 additions & 0 deletions routers/api/v1/swagger/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ type swaggerResponseGeneralUISettings struct {
// in:body
Body api.GeneralUISettings `json:"body"`
}

// GeneralAPISettings
// swagger:response GeneralAPISettings
type swaggerResponseGeneralAPISettings struct {
// in:body
Body api.GeneralAPISettings `json:"body"`
}
50 changes: 50 additions & 0 deletions templates/swagger/v1_json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8672,6 +8672,23 @@
}
}
},
"/settings/api": {
"get": {
"produces": [
"application/json"
],
"tags": [
"settings"
],
"summary": "Get instance's global settings for api",
"operationId": "getGeneralAPISettings",
"responses": {
"200": {
"$ref": "#/responses/GeneralAPISettings"
}
}
}
},
"/settings/repository": {
"get": {
"produces": [
Expand Down Expand Up @@ -12977,6 +12994,33 @@
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
"GeneralAPISettings": {
"description": "GeneralAPISettings contains global api settings exposed by it",
"type": "object",
"properties": {
"default_git_trees_per_page": {
"type": "integer",
"format": "int64",
"x-go-name": "DefaultGitTreesPerPage"
},
"default_max_blob_size": {
"type": "integer",
"format": "int64",
"x-go-name": "DefaultMaxBlobSize"
},
"default_paging_num": {
"type": "integer",
"format": "int64",
"x-go-name": "DefaultPagingNum"
},
"max_response_items": {
"type": "integer",
"format": "int64",
"x-go-name": "MaxResponseItems"
}
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
"GeneralRepoSettings": {
"description": "GeneralRepoSettings contains global repository settings exposed by API",
"type": "object",
Expand Down Expand Up @@ -15197,6 +15241,12 @@
}
}
},
"GeneralAPISettings": {
"description": "GeneralAPISettings",
"schema": {
"$ref": "#/definitions/GeneralAPISettings"
}
},
"GeneralRepoSettings": {
"description": "GeneralRepoSettings",
"schema": {
Expand Down