gf/net/goai/goai_config.go

32 lines
1.6 KiB
Go
Raw Normal View History

2021-10-02 18:54:06 +08:00
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package goai
// Config provides extra configuration feature for OpenApiV3 implements.
type Config struct {
2021-10-14 15:03:39 +08:00
ReadContentTypes []string // ReadContentTypes specifies the default MIME types for consuming if MIME types are not configured.
WriteContentTypes []string // WriteContentTypes specifies the default MIME types for producing if MIME types are not configured.
CommonRequest interface{} // Common request structure for all paths.
CommonRequestDataField string // Common request field name to be replaced with certain business request structure. Eg: `Data`, `Request.`.
2021-10-08 21:16:47 +08:00
CommonResponse interface{} // Common response structure for all paths.
CommonResponseDataField string // Common response field name to be replaced with certain business response structure. Eg: `Data`, `Response.`.
2021-10-14 15:03:39 +08:00
IgnorePkgPath bool // Ignores package name for schema name.
2021-10-02 18:54:06 +08:00
}
// fillWithDefaultValue fills configuration object of `oai` with default values if these are not configured.
func (oai *OpenApiV3) fillWithDefaultValue() {
if oai.OpenAPI == "" {
oai.OpenAPI = `3.0.0`
}
if len(oai.Config.ReadContentTypes) == 0 {
oai.Config.ReadContentTypes = defaultReadContentTypes
}
if len(oai.Config.WriteContentTypes) == 0 {
oai.Config.WriteContentTypes = defaultWriteContentTypes
}
}