diff --git a/sdk-go/inferable_test.go b/sdk-go/inferable_test.go index 49754aa5..559b17eb 100644 --- a/sdk-go/inferable_test.go +++ b/sdk-go/inferable_test.go @@ -200,6 +200,7 @@ func TestGetSchema(t *testing.T) { "name": "TestFunc", "input": { "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, "type": "object", "properties": { "a": {"type": "integer"}, @@ -212,6 +213,7 @@ func TestGetSchema(t *testing.T) { "name": "TestFunc2", "input": { "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, "type": "object", "properties": { "c": { diff --git a/sdk-go/service.go b/sdk-go/service.go index b3e2d5fd..0c9cd8f7 100644 --- a/sdk-go/service.go +++ b/sdk-go/service.go @@ -116,7 +116,7 @@ func (s *service) RegisterFunc(fn Function) (*FunctionReference, error) { } // Get the schema for the input struct - reflector := jsonschema.Reflector{DoNotReference: true, Anonymous: true} + reflector := jsonschema.Reflector{DoNotReference: true, Anonymous: true, AllowAdditionalProperties: false} schema := reflector.Reflect(reflect.New(argType).Interface()) if schema == nil { @@ -142,7 +142,7 @@ func (s *service) RegisterFunc(fn Function) (*FunctionReference, error) { return nil, fmt.Errorf("schema for function '%s' contains a $ref to an external definition. this is currently not supported. see https://go.inferable.ai/go-schema-limitation for details", fn.Name) } - defs.AdditionalProperties = nil + defs.AdditionalProperties = jsonschema.FalseSchema fn.schema = defs s.Functions[fn.Name] = fn