Skip to content

Commit

Permalink
adds 'any' to operation object schema parsing (swaggo#1162)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdlaitila committed Mar 17, 2022
1 parent 2b64f78 commit d2ce216
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ func (operation *Operation) parseObjectSchema(refType string, astFile *ast.File)
return nil, nil
case refType == "interface{}":
return PrimitiveSchema(OBJECT), nil
case refType == "any":
return PrimitiveSchema(OBJECT), nil
case IsGolangPrimitiveType(refType):
refType = TransToValidSchemeType(refType)

Expand All @@ -774,7 +776,7 @@ func (operation *Operation) parseObjectSchema(refType string, astFile *ast.File)
return nil, fmt.Errorf("invalid type: %s", refType)
}
refType = refType[idx+1:]
if refType == "interface{}" {
if refType == "interface{}" || refType == "any" {
return spec.MapProperty(nil), nil
}
schema, err := operation.parseObjectSchema(refType, astFile)
Expand Down
4 changes: 4 additions & 0 deletions operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,10 @@ func TestParseObjectSchema(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, schema, PrimitiveSchema(OBJECT))

schema, err = operation.parseObjectSchema("any", nil)
assert.NoError(t, err)
assert.Equal(t, schema, PrimitiveSchema(OBJECT))

schema, err = operation.parseObjectSchema("int", nil)
assert.NoError(t, err)
assert.Equal(t, schema, PrimitiveSchema(INTEGER))
Expand Down

0 comments on commit d2ce216

Please sign in to comment.