Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix global overrides for any/interface ref types #1835

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 4 additions & 3 deletions operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading