github.com/gogf/gf/v2@v2.7.4/net/goai/goai_config.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 package goai 8 9 // Config provides extra configuration feature for OpenApiV3 implements. 10 type Config struct { 11 ReadContentTypes []string // ReadContentTypes specifies the default MIME types for consuming if MIME types are not configured. 12 WriteContentTypes []string // WriteContentTypes specifies the default MIME types for producing if MIME types are not configured. 13 CommonRequest interface{} // Common request structure for all paths. 14 CommonRequestDataField string // Common request field name to be replaced with certain business request structure. Eg: `Data`, `Request.`. 15 CommonResponse interface{} // Common response structure for all paths. 16 CommonResponseDataField string // Common response field name to be replaced with certain business response structure. Eg: `Data`, `Response.`. 17 IgnorePkgPath bool // Ignores package name for schema name. 18 } 19 20 // fillWithDefaultValue fills configuration object of `oai` with default values if these are not configured. 21 func (oai *OpenApiV3) fillWithDefaultValue() { 22 if oai.OpenAPI == "" { 23 oai.OpenAPI = `3.0.0` 24 } 25 if len(oai.Config.ReadContentTypes) == 0 { 26 oai.Config.ReadContentTypes = defaultReadContentTypes 27 } 28 if len(oai.Config.WriteContentTypes) == 0 { 29 oai.Config.WriteContentTypes = defaultWriteContentTypes 30 } 31 }