Skip to content

Commit

Permalink
Revert object
Browse files Browse the repository at this point in the history
  • Loading branch information
mbilski authored and jdabrowski committed Aug 13, 2024
1 parent 5ba8a21 commit d47633d
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 35 deletions.
4 changes: 1 addition & 3 deletions codescan/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import (
"testing"

"github.com/go-openapi/spec"

"github.com/stretchr/testify/assert"

"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -47,7 +45,7 @@ func loadClassificationPkgsCtx(t testing.TB, extra ...string) *scanCtx {
func TestApplication_LoadCode(t *testing.T) {
sctx := loadClassificationPkgsCtx(t)
require.NotNil(t, sctx)
require.Len(t, sctx.app.Models, 32)
require.Len(t, sctx.app.Models, 31)
require.Len(t, sctx.app.Meta, 1)
require.Len(t, sctx.app.Routes, 7)
require.Empty(t, sctx.app.Operations)
Expand Down
2 changes: 0 additions & 2 deletions codescan/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ func swaggerSchemaForType(typeName string, prop swaggerTypable) error {
prop.Typed("integer", "uint8")
case "uintptr":
prop.Typed("integer", "uint64")
case "object":
prop.Typed("object", "")
default:
return fmt.Errorf("unsupported type %q", typeName)
}
Expand Down
6 changes: 1 addition & 5 deletions codescan/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,6 @@ func (s *schemaBuilder) buildFromType(tpe types.Type, tgt swaggerTypable) error
cmt = new(ast.CommentGroup)
}

if typeName, ok := typeName(cmt); ok {
_ = swaggerSchemaForType(typeName, tgt)
return nil
}

if s.decl.Spec.Assign.IsValid() {
return s.buildFromType(titpe.Underlying(), tgt)
}
Expand Down Expand Up @@ -476,6 +471,7 @@ func (s *schemaBuilder) buildFromType(tpe types.Type, tgt swaggerTypable) error

func (s *schemaBuilder) buildFromInterface(decl *entityDecl, it *types.Interface, schema *spec.Schema, seen map[string]string) error {
if it.Empty() {
schema.Typed("object", "")
return nil
}

Expand Down
17 changes: 1 addition & 16 deletions codescan/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ func TestInterfaceField(t *testing.T) {
require.NoError(t, prs.Build(models))

schema := models["Interfaced"]
assertProperty(t, &schema, "", "custom_data", "", "CustomData")
assertProperty(t, &schema, "object", "custom_data", "", "CustomData")
}

func TestAliasedTypes(t *testing.T) {
Expand Down Expand Up @@ -833,21 +833,6 @@ func TestEmbeddedAllOf(t *testing.T) {
assertProperty(t, &asch, "string", "cat", "", "Cat")
}

func TestSwaggerTypeNamed(t *testing.T) {
sctx := loadClassificationPkgsCtx(t)
decl := getClassificationModel(sctx, "NamedWithType")
require.NotNil(t, decl)
prs := &schemaBuilder{
ctx: sctx,
decl: decl,
}
models := make(map[string]spec.Schema)
require.NoError(t, prs.Build(models))
schema := models["namedWithType"]

assertProperty(t, &schema, "object", "some_map", "", "SomeMap")
}

func TestSwaggerTypeStruct(t *testing.T) {
sctx := loadClassificationPkgsCtx(t)
decl := getClassificationModel(sctx, "NullString")
Expand Down
10 changes: 1 addition & 9 deletions fixtures/goparsing/classification/models/nomodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"net/url"
"time"

"github.com/go-openapi/strfmt"
"github.com/cloudentity/go-swagger/fixtures/goparsing/classification/transitive/mods"
"github.com/go-openapi/strfmt"
)

// NoModel is a struct without an annotation.
Expand Down Expand Up @@ -753,11 +753,3 @@ type TextMarshalModel struct {
StructStrfmtPtr *MarshalTextStructStrfmtPtr `json:"structStrfmtPtr"`
CustomURL URL `json:"customUrl"`
}

// swagger:type object
type SomeObjectMap interface{}

// swagger:model namedWithType
type NamedWithType struct {
SomeMap SomeObjectMap `json:"some_map"`
}

0 comments on commit d47633d

Please sign in to comment.