mirror of https://github.com/go-gitea/gitea.git
parent
bab1204db4
commit
dba5d82f86
|
@ -46,4 +46,16 @@ func TestAPIExposedSettings(t *testing.T) {
|
||||||
MirrorsDisabled: setting.Repository.DisableMirrors,
|
MirrorsDisabled: setting.Repository.DisableMirrors,
|
||||||
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
|
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
|
||||||
}, repo)
|
}, repo)
|
||||||
|
|
||||||
|
attachment := new(api.GeneralAttachmentSettings)
|
||||||
|
req = NewRequest(t, "GET", "/api/v1/settings/attachment")
|
||||||
|
resp = MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
|
DecodeJSON(t, resp, &attachment)
|
||||||
|
assert.EqualValues(t, &api.GeneralAttachmentSettings{
|
||||||
|
Enabled: setting.Attachment.Enabled,
|
||||||
|
AllowedTypes: setting.Attachment.AllowedTypes,
|
||||||
|
MaxFiles: setting.Attachment.MaxFiles,
|
||||||
|
MaxSize: setting.Attachment.MaxSize,
|
||||||
|
}, attachment)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,3 +22,11 @@ type GeneralAPISettings struct {
|
||||||
DefaultGitTreesPerPage int `json:"default_git_trees_per_page"`
|
DefaultGitTreesPerPage int `json:"default_git_trees_per_page"`
|
||||||
DefaultMaxBlobSize int64 `json:"default_max_blob_size"`
|
DefaultMaxBlobSize int64 `json:"default_max_blob_size"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GeneralAttachmentSettings contains global Attachment settings exposed by API
|
||||||
|
type GeneralAttachmentSettings struct {
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
|
AllowedTypes string `json:"allowed_types"`
|
||||||
|
MaxSize int64 `json:"max_size"`
|
||||||
|
MaxFiles int `json:"max_files"`
|
||||||
|
}
|
||||||
|
|
|
@ -522,6 +522,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
m.Group("/settings", func() {
|
m.Group("/settings", func() {
|
||||||
m.Get("/ui", settings.GetGeneralUISettings)
|
m.Get("/ui", settings.GetGeneralUISettings)
|
||||||
m.Get("/api", settings.GetGeneralAPISettings)
|
m.Get("/api", settings.GetGeneralAPISettings)
|
||||||
|
m.Get("/attachment", settings.GetGeneralAttachmentSettings)
|
||||||
m.Get("/repository", settings.GetGeneralRepoSettings)
|
m.Get("/repository", settings.GetGeneralRepoSettings)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -60,3 +60,21 @@ func GetGeneralRepoSettings(ctx *context.APIContext) {
|
||||||
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
|
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetGeneralAttachmentSettings returns instance's global settings for Attachment
|
||||||
|
func GetGeneralAttachmentSettings(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /settings/Attachment settings getGeneralAttachmentSettings
|
||||||
|
// ---
|
||||||
|
// summary: Get instance's global settings for Attachment
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/GeneralAttachmentSettings"
|
||||||
|
ctx.JSON(http.StatusOK, api.GeneralAttachmentSettings{
|
||||||
|
Enabled: setting.Attachment.Enabled,
|
||||||
|
AllowedTypes: setting.Attachment.AllowedTypes,
|
||||||
|
MaxFiles: setting.Attachment.MaxFiles,
|
||||||
|
MaxSize: setting.Attachment.MaxSize,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -26,3 +26,10 @@ type swaggerResponseGeneralAPISettings struct {
|
||||||
// in:body
|
// in:body
|
||||||
Body api.GeneralAPISettings `json:"body"`
|
Body api.GeneralAPISettings `json:"body"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GeneralAttachmentSettings
|
||||||
|
// swagger:response GeneralAttachmentSettings
|
||||||
|
type swaggerResponseGeneralAttachmentSettings struct {
|
||||||
|
// in:body
|
||||||
|
Body api.GeneralAttachmentSettings `json:"body"`
|
||||||
|
}
|
||||||
|
|
|
@ -8672,6 +8672,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/settings/Attachment": {
|
||||||
|
"get": {
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"settings"
|
||||||
|
],
|
||||||
|
"summary": "Get instance's global settings for Attachment",
|
||||||
|
"operationId": "getGeneralAttachmentSettings",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"$ref": "#/responses/GeneralAttachmentSettings"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/settings/api": {
|
"/settings/api": {
|
||||||
"get": {
|
"get": {
|
||||||
"produces": [
|
"produces": [
|
||||||
|
@ -13021,6 +13038,31 @@
|
||||||
},
|
},
|
||||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
},
|
},
|
||||||
|
"GeneralAttachmentSettings": {
|
||||||
|
"description": "GeneralAttachmentSettings contains global Attachment settings exposed by API",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"allowed_types": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "AllowedTypes"
|
||||||
|
},
|
||||||
|
"enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"x-go-name": "Enabled"
|
||||||
|
},
|
||||||
|
"max_files": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"x-go-name": "MaxFiles"
|
||||||
|
},
|
||||||
|
"max_size": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"x-go-name": "MaxSize"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
|
},
|
||||||
"GeneralRepoSettings": {
|
"GeneralRepoSettings": {
|
||||||
"description": "GeneralRepoSettings contains global repository settings exposed by API",
|
"description": "GeneralRepoSettings contains global repository settings exposed by API",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -15247,6 +15289,12 @@
|
||||||
"$ref": "#/definitions/GeneralAPISettings"
|
"$ref": "#/definitions/GeneralAPISettings"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"GeneralAttachmentSettings": {
|
||||||
|
"description": "GeneralAttachmentSettings",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/GeneralAttachmentSettings"
|
||||||
|
}
|
||||||
|
},
|
||||||
"GeneralRepoSettings": {
|
"GeneralRepoSettings": {
|
||||||
"description": "GeneralRepoSettings",
|
"description": "GeneralRepoSettings",
|
||||||
"schema": {
|
"schema": {
|
||||||
|
|
Loading…
Reference in New Issue