mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
fix type integer from type number for package goai
This commit is contained in:
@ -49,6 +49,7 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
TypeInteger = `integer`
|
||||
TypeNumber = `number`
|
||||
TypeBoolean = `boolean`
|
||||
TypeArray = `array`
|
||||
@ -179,7 +180,10 @@ func (oai *OpenApiV3) golangTypeToOAIType(t reflect.Type) string {
|
||||
|
||||
case
|
||||
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
|
||||
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
|
||||
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
return TypeInteger
|
||||
|
||||
case
|
||||
reflect.Float32, reflect.Float64,
|
||||
reflect.Complex64, reflect.Complex128:
|
||||
return TypeNumber
|
||||
|
||||
@ -37,6 +37,7 @@ func (oai *OpenApiV3) newSchemaRefWithGolangType(golangType reflect.Type, tagMap
|
||||
schemaRef.Value = schema
|
||||
switch oaiType {
|
||||
case
|
||||
TypeInteger,
|
||||
TypeNumber,
|
||||
TypeString,
|
||||
TypeBoolean:
|
||||
|
||||
@ -51,7 +51,7 @@ func Test_Basic(t *testing.T) {
|
||||
t.Assert(len(oai.Components.Schemas.Map()), 2)
|
||||
t.Assert(oai.Components.Schemas.Get(`github.com.gogf.gf.v2.protocol.goai_test.CreateResourceReq`).Value.Type, goai.TypeObject)
|
||||
t.Assert(len(oai.Components.Schemas.Get(`github.com.gogf.gf.v2.protocol.goai_test.CreateResourceReq`).Value.Properties.Map()), 7)
|
||||
t.Assert(oai.Components.Schemas.Get(`github.com.gogf.gf.v2.protocol.goai_test.CreateResourceReq`).Value.Properties.Get(`appId`).Value.Type, goai.TypeNumber)
|
||||
t.Assert(oai.Components.Schemas.Get(`github.com.gogf.gf.v2.protocol.goai_test.CreateResourceReq`).Value.Properties.Get(`appId`).Value.Type, goai.TypeInteger)
|
||||
t.Assert(oai.Components.Schemas.Get(`github.com.gogf.gf.v2.protocol.goai_test.CreateResourceReq`).Value.Properties.Get(`resourceId`).Value.Type, goai.TypeString)
|
||||
|
||||
t.Assert(len(oai.Components.Schemas.Get(`github.com.gogf.gf.v2.protocol.goai_test.SetSpecInfo`).Value.Properties.Map()), 3)
|
||||
@ -111,7 +111,7 @@ func TestOpenApiV3_Add(t *testing.T) {
|
||||
t.Assert(len(oai.Components.Schemas.Map()), 3)
|
||||
t.Assert(oai.Components.Schemas.Get(`github.com.gogf.gf.v2.protocol.goai_test.CreateResourceReq`).Value.Type, goai.TypeObject)
|
||||
t.Assert(len(oai.Components.Schemas.Get(`github.com.gogf.gf.v2.protocol.goai_test.CreateResourceReq`).Value.Properties.Map()), 7)
|
||||
t.Assert(oai.Components.Schemas.Get(`github.com.gogf.gf.v2.protocol.goai_test.CreateResourceReq`).Value.Properties.Get(`appId`).Value.Type, goai.TypeNumber)
|
||||
t.Assert(oai.Components.Schemas.Get(`github.com.gogf.gf.v2.protocol.goai_test.CreateResourceReq`).Value.Properties.Get(`appId`).Value.Type, goai.TypeInteger)
|
||||
t.Assert(oai.Components.Schemas.Get(`github.com.gogf.gf.v2.protocol.goai_test.CreateResourceReq`).Value.Properties.Get(`resourceId`).Value.Type, goai.TypeString)
|
||||
|
||||
t.Assert(len(oai.Components.Schemas.Get(`github.com.gogf.gf.v2.protocol.goai_test.SetSpecInfo`).Value.Properties.Map()), 3)
|
||||
|
||||
Reference in New Issue
Block a user