From b32bc839da77c370e4a9153d0e4f4cb755c2839c Mon Sep 17 00:00:00 2001 From: webdestroya Date: Tue, 8 Nov 2022 00:48:28 -0800 Subject: [PATCH] Renaming JSONSchemaPost to JSONSchemaExtend --- reflect.go | 16 ++++++++-------- reflect_test.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/reflect.go b/reflect.go index a8dc6f6..7545697 100644 --- a/reflect.go +++ b/reflect.go @@ -110,12 +110,12 @@ type customSchemaImpl interface { // Function to be run after the schema has been generated. // this will let you modify a schema afterwards -type postSchemaImpl interface { - JSONSchemaPost(*Schema) +type extendSchemaImpl interface { + JSONSchemaExtend(*Schema) } var customType = reflect.TypeOf((*customSchemaImpl)(nil)).Elem() -var postType = reflect.TypeOf((*postSchemaImpl)(nil)).Elem() +var extendType = reflect.TypeOf((*extendSchemaImpl)(nil)).Elem() // customSchemaGetFieldDocString type customSchemaGetFieldDocString interface { @@ -402,7 +402,7 @@ func (r *Reflector) reflectTypeToSchema(definitions Definitions, t reflect.Type) panic("unsupported type " + t.String()) } - r.reflectSchemaPost(definitions, t, st) + r.reflectSchemaExtend(definitions, t, st) // Always try to reference the definition which may have just been created if def := r.refDefinition(definitions, t); def != nil { @@ -431,11 +431,11 @@ func (r *Reflector) reflectCustomSchema(definitions Definitions, t reflect.Type) return nil } -func (r *Reflector) reflectSchemaPost(definitions Definitions, t reflect.Type, s *Schema) *Schema { - if t.Implements(postType) { +func (r *Reflector) reflectSchemaExtend(definitions Definitions, t reflect.Type, s *Schema) *Schema { + if t.Implements(extendType) { v := reflect.New(t) - o := v.Interface().(postSchemaImpl) - o.JSONSchemaPost(s) + o := v.Interface().(extendSchemaImpl) + o.JSONSchemaExtend(s) if ref := r.refDefinition(definitions, t); ref != nil { return ref } diff --git a/reflect_test.go b/reflect_test.go index 349b767..645a78d 100644 --- a/reflect_test.go +++ b/reflect_test.go @@ -306,7 +306,7 @@ type SchemaPostTest struct { SchemaPostTestBase `json:",inline"` } -func (SchemaPostTest) JSONSchemaPost(base *Schema) { +func (SchemaPostTest) JSONSchemaExtend(base *Schema) { base.Properties.Delete("FirstName") base.Properties.Delete("age") val, _ := base.Properties.Get("LastName")