Skip to content

Commit

Permalink
Merge branch 'master' into simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
sdghchj committed Dec 3, 2020
2 parents 1e76f0f + 62e4d9b commit 27da651
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
11 changes: 11 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
build:
main: cmd/swag/main.go
goos:
- linux
- darwin
goarch:
- amd64
- arm64
- 386
ignore:
- goos: darwin
goarch: arm64
archive:
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
arm64: aarch64
checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
2 changes: 1 addition & 1 deletion example/object-map-example/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/gin-gonic/gin v1.6.3
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14
github.com/swaggo/gin-swagger v1.2.0
github.com/swaggo/gin-swagger v1.3.0
github.com/swaggo/swag v1.5.1
)
8 changes: 4 additions & 4 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ func BuildCustomSchema(types []string) (*spec.Schema, error) {
}

switch types[0] {
case "primitive":
case PRIMITIVE:
if len(types) == 1 {
return nil, errors.New("need primitive type after primitive")
}
return BuildCustomSchema(types[1:])
case "array":
case ARRAY:
if len(types) == 1 {
return nil, errors.New("need array item type after array")
}
Expand All @@ -169,9 +169,9 @@ func BuildCustomSchema(types []string) (*spec.Schema, error) {
return nil, err
}
return spec.ArrayProperty(schema), nil
case "object":
case OBJECT:
if len(types) == 1 {
return nil, errors.New("need object item type after object")
return PrimitiveSchema(types[0]), nil
}
schema, err := BuildCustomSchema(types[1:])
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ func TestBuildCustomSchema(t *testing.T) {
assert.Equal(t, schema.SchemaProps.Items.Schema.SchemaProps.Type, spec.StringOrArray{"string"})

schema, err = BuildCustomSchema([]string{"object"})
assert.Error(t, err)
assert.Nil(t, schema)
assert.NoError(t, err)
assert.Equal(t, schema.SchemaProps.Type, spec.StringOrArray{"object"})

schema, err = BuildCustomSchema([]string{"object", "oops"})
assert.Error(t, err)
Expand Down

0 comments on commit 27da651

Please sign in to comment.