From 7d4c59ac5aea64a6db83e79d6bb7aee1ed66250e Mon Sep 17 00:00:00 2001 From: the harder the luckier Date: Mon, 28 Aug 2023 21:52:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20OpenAPI=20cannot=20correctly=20identify?= =?UTF-8?q?=20the=20file=20type=20under=20the=20canoni=E2=80=A6=20(#2898)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- net/goai/goai.go | 3 +++ net/goai/goai_shema_ref.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/net/goai/goai.go b/net/goai/goai.go index f7d1ce35e..d248374af 100644 --- a/net/goai/goai.go +++ b/net/goai/goai.go @@ -43,6 +43,7 @@ const ( TypeBoolean = `boolean` TypeArray = `array` TypeString = `string` + TypeFile = `file` TypeObject = `object` FormatInt32 = `int32` FormatInt64 = `int64` @@ -145,6 +146,8 @@ func (oai *OpenApiV3) golangTypeToOAIType(t reflect.Type) string { switch t.String() { case `time.Time`, `gtime.Time`: return TypeString + case `ghttp.UploadFile`: + return TypeFile } return TypeObject diff --git a/net/goai/goai_shema_ref.go b/net/goai/goai_shema_ref.go index 5f6137d50..2c378b937 100644 --- a/net/goai/goai_shema_ref.go +++ b/net/goai/goai_shema_ref.go @@ -76,7 +76,7 @@ func (oai *OpenApiV3) newSchemaRefWithGolangType(golangType reflect.Type, tagMap } schemaRef.Value = schema switch oaiType { - case TypeString: + case TypeString, TypeFile: // Nothing to do. case TypeInteger: if schemaRef.Value.Default != nil {