Improved import, by group improt.

This commit is contained in:
houseme
2021-11-13 23:34:16 +08:00
parent d864120353
commit 299e16bed1
11 changed files with 28 additions and 20 deletions

View File

@ -9,6 +9,7 @@ package gctx
import (
"context"
"github.com/gogf/gf/v2/util/guid"
)

View File

@ -8,11 +8,11 @@ package gctx_test
import (
"context"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/text/gstr"
"testing"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/text/gstr"
)
func Test_New(t *testing.T) {

View File

@ -12,12 +12,13 @@ package goai
import (
"context"
"fmt"
"reflect"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/text/gstr"
"reflect"
)
// OpenApiV3 is the structure defined from:

View File

@ -8,6 +8,7 @@ package goai
import (
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/json"

View File

@ -7,13 +7,14 @@
package goai
import (
"reflect"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/structs"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/gmeta"
"reflect"
)
type Path struct {

View File

@ -7,10 +7,11 @@
package goai
import (
"reflect"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/internal/structs"
"github.com/gogf/gf/v2/text/gstr"
"reflect"
)
// RequestBody is specified by OpenAPI/Swagger 3.0 standard.

View File

@ -7,10 +7,11 @@
package goai
import (
"reflect"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/internal/structs"
"github.com/gogf/gf/v2/text/gstr"
"reflect"
)
// Response is specified by OpenAPI/Swagger 3.0 standard.

View File

@ -7,13 +7,14 @@
package goai
import (
"reflect"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/structs"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/gmeta"
"reflect"
)
type Schemas map[string]SchemaRef

View File

@ -7,11 +7,12 @@
package goai
import (
"reflect"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/util/gconv"
"reflect"
)
type SchemaRefs []SchemaRef

View File

@ -9,11 +9,12 @@ package goai_test
import (
"context"
"fmt"
"testing"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/protocol/goai"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/util/gmeta"
"testing"
)
func Test_Basic(t *testing.T) {
@ -105,7 +106,7 @@ func TestOpenApiV3_Add(t *testing.T) {
Object: f,
})
t.AssertNil(err)
//fmt.Println(oai.String())
// fmt.Println(oai.String())
// Schema asserts.
t.Assert(len(oai.Components.Schemas), 3)
t.Assert(oai.Components.Schemas[`github.com.gogf.gf.v2.protocol.goai_test.CreateResourceReq`].Value.Type, goai.TypeObject)
@ -317,7 +318,7 @@ func TestOpenApiV3_CommonRequest_WithoutDataField_Setting(t *testing.T) {
})
t.AssertNil(err)
// Schema asserts.
//fmt.Println(oai.String())
// fmt.Println(oai.String())
t.Assert(len(oai.Components.Schemas), 3)
t.Assert(len(oai.Paths), 1)
t.Assert(len(oai.Paths["/index"].Put.RequestBody.Value.Content["application/json"].Schema.Value.Properties), 5)
@ -357,7 +358,7 @@ func TestOpenApiV3_CommonRequest_EmptyRequest(t *testing.T) {
})
t.AssertNil(err)
// Schema asserts.
//fmt.Println(oai.String())
// fmt.Println(oai.String())
t.Assert(len(oai.Components.Schemas), 3)
t.Assert(len(oai.Paths), 1)
t.Assert(len(oai.Paths["/index"].Put.RequestBody.Value.Content["application/json"].Schema.Value.Properties), 3)
@ -412,7 +413,7 @@ func TestOpenApiV3_CommonRequest_SubDataField(t *testing.T) {
})
t.AssertNil(err)
// Schema asserts.
//fmt.Println(oai.String())
// fmt.Println(oai.String())
t.Assert(len(oai.Components.Schemas), 4)
t.Assert(len(oai.Paths), 1)
t.Assert(len(oai.Paths["/index"].Put.RequestBody.Value.Content["application/json"].Schema.Value.Properties), 1)
@ -543,7 +544,7 @@ func TestOpenApiV3_CommonResponse_EmptyResponse(t *testing.T) {
})
t.AssertNil(err)
// Schema asserts.
//fmt.Println(oai.String())
// fmt.Println(oai.String())
t.Assert(len(oai.Components.Schemas), 3)
t.Assert(len(oai.Paths), 1)
t.Assert(oai.Paths["/index"].Put.RequestBody.Value.Content["application/json"].Schema.Ref, `github.com.gogf.gf.v2.protocol.goai_test.Req`)
@ -599,7 +600,7 @@ func TestOpenApiV3_CommonResponse_SubDataField(t *testing.T) {
})
t.AssertNil(err)
// Schema asserts.
//fmt.Println(oai.String())
// fmt.Println(oai.String())
t.Assert(len(oai.Components.Schemas), 4)
t.Assert(len(oai.Paths), 1)
t.Assert(len(oai.Paths["/index"].Get.Responses["200"].Value.Content["application/json"].Schema.Value.Properties), 1)
@ -654,7 +655,7 @@ func TestOpenApiV3_ShortTags(t *testing.T) {
Object: f,
})
t.AssertNil(err)
//fmt.Println(oai.String())
// fmt.Println(oai.String())
// Schema asserts.
t.Assert(len(oai.Components.Schemas), 3)
t.Assert(oai.Paths[`/test1/{appId}`].Summary, `CreateResourceReq sum`)
@ -690,7 +691,7 @@ func TestOpenApiV3_HtmlResponse(t *testing.T) {
})
t.AssertNil(err)
//fmt.Println(oai.String())
// fmt.Println(oai.String())
t.Assert(oai.Components.Schemas[`github.com.gogf.gf.v2.protocol.goai_test.Res`].Value.Type, goai.TypeString)
})
}
@ -737,7 +738,7 @@ func TestOpenApiV3_HtmlResponseWithCommonResponse(t *testing.T) {
})
t.AssertNil(err)
//fmt.Println(oai.String())
// fmt.Println(oai.String())
t.Assert(oai.Components.Schemas[`github.com.gogf.gf.v2.protocol.goai_test.Res`].Value.Type, goai.TypeString)
})
}

View File

@ -8,7 +8,6 @@ package gtest
import (
"fmt"
"github.com/gogf/gf/v2/internal/empty"
"io/ioutil"
"os"
"path/filepath"
@ -16,7 +15,7 @@ import (
"testing"
"github.com/gogf/gf/v2/debug/gdebug"
"github.com/gogf/gf/v2/internal/empty"
"github.com/gogf/gf/v2/util/gconv"
)