This commit is contained in:
John Guo
2021-10-08 14:44:10 +08:00
parent 5e32e8868e
commit 73e4a69383
3 changed files with 15 additions and 5 deletions

View File

@ -110,6 +110,10 @@ func (oai *OpenApiV3) addPath(in addPathInput) error {
)
}
if v, ok := oai.Paths[in.Path]; ok {
path = v
}
// Method check.
if in.Method == "" {
in.Method = gmeta.Get(inputObject.Interface(), TagNameMethod).String()

View File

@ -131,6 +131,12 @@ func (oai *OpenApiV3) golangTypeToOAIType(t reflect.Type) string {
return TypeString
case reflect.Struct:
switch t.String() {
case
`time.Time`,
`gtime.Time`:
return TypeString
}
return TypeObject
case reflect.Slice, reflect.Array:

View File

@ -99,7 +99,7 @@ func TestOpenApiV3_Add(t *testing.T) {
t.AssertNil(err)
err = oai.Add(goai.AddInput{
Path: "/test2/{appId}",
Path: "/test1/{appId}",
Method: goai.HttpMethodPost,
Object: f,
})
@ -116,13 +116,13 @@ func TestOpenApiV3_Add(t *testing.T) {
t.Assert(oai.Components.Schemas[`goai_test.SetSpecInfo`].Value.Properties[`Params`].Value.Type, goai.TypeArray)
// Paths.
t.Assert(len(oai.Paths), 2)
t.Assert(len(oai.Paths), 1)
t.AssertNE(oai.Paths[`/test1/{appId}`].Put, nil)
t.Assert(len(oai.Paths[`/test1/{appId}`].Put.Tags), 1)
t.Assert(len(oai.Paths[`/test1/{appId}`].Put.Parameters), 2)
t.AssertNE(oai.Paths[`/test2/{appId}`].Post, nil)
t.Assert(len(oai.Paths[`/test2/{appId}`].Post.Tags), 1)
t.Assert(len(oai.Paths[`/test2/{appId}`].Post.Parameters), 2)
t.AssertNE(oai.Paths[`/test1/{appId}`].Post, nil)
t.Assert(len(oai.Paths[`/test1/{appId}`].Post.Tags), 1)
t.Assert(len(oai.Paths[`/test1/{appId}`].Post.Parameters), 2)
})
}