From d141d3acb83ea7fef5d1208d4db7affcceb7221a Mon Sep 17 00:00:00 2001 From: Ezequiel Rodriguez Date: Fri, 21 Jun 2024 22:16:42 -0700 Subject: [PATCH] Fix global overrides for any/interface ref types Closes #1834 --- operation.go | 4 ++-- operation_test.go | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/operation.go b/operation.go index 24b0496b2..ac79e3102 100644 --- a/operation.go +++ b/operation.go @@ -841,9 +841,9 @@ func parseObjectSchema(parser *Parser, refType string, astFile *ast.File) (*spec case refType == NIL: return nil, nil case refType == INTERFACE: - return PrimitiveSchema(OBJECT), nil + return &spec.Schema{}, nil case refType == ANY: - return PrimitiveSchema(OBJECT), nil + return &spec.Schema{}, nil case IsGolangPrimitiveType(refType): refType = TransToValidSchemeType(refType) diff --git a/operation_test.go b/operation_test.go index fb43a446e..50e4ac3b1 100644 --- a/operation_test.go +++ b/operation_test.go @@ -2448,15 +2448,16 @@ func TestParseObjectSchema(t *testing.T) { schema, err := operation.parseObjectSchema("interface{}", nil) assert.NoError(t, err) - assert.Equal(t, schema, PrimitiveSchema(OBJECT)) + assert.Equal(t, schema, &spec.Schema{}) schema, err = operation.parseObjectSchema("any", nil) assert.NoError(t, err) - assert.Equal(t, schema, PrimitiveSchema(OBJECT)) + assert.Equal(t, schema, &spec.Schema{}) schema, err = operation.parseObjectSchema("any{data=string}", nil) assert.NoError(t, err) - assert.Equal(t, schema, PrimitiveSchema(OBJECT).SetProperty("data", *PrimitiveSchema("string"))) + assert.Equal(t, schema, + (&spec.Schema{}).WithAllOf(spec.Schema{}, *PrimitiveSchema(OBJECT).SetProperty("data", *PrimitiveSchema("string")))) schema, err = operation.parseObjectSchema("int", nil) assert.NoError(t, err)