Skip to content

Commit

Permalink
ease
Browse files Browse the repository at this point in the history
  • Loading branch information
candiduslynx committed Oct 8, 2023
1 parent d1c5c03 commit e987e0a
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,31 +573,27 @@ func (r *Reflector) lookupComment(t reflect.Type, name string) string {

// addDefinition will append the provided schema. If needed, an ID and anchor will also be added.
func (r *Reflector) addDefinition(definitions Definitions, t reflect.Type, s *Schema) {
name := r.typeName(t)
// we save both type & pkg info to match against reflected type later
s.sourceType = fullyQualifiedTypeName(t)

_, name := r.findDef(definitions, t)
if name == "" {
return
}
// we save both type & pkg info to match against reflected type later
s.sourceType = fullyQualifiedTypeName(t)

_, defName := r.findDef(definitions, t)
// either def != nil & we're overwriting, or it's a new one
definitions[defName] = s
definitions[name] = s
}

// refDefinition will provide a schema with a reference to an existing definition.
func (r *Reflector) refDefinition(definitions Definitions, t reflect.Type) *Schema {
if r.DoNotReference {
return nil
}
name := r.typeName(t)
if name == "" {
return nil
}

def, defName := r.findDef(definitions, t)
if def == nil {
// no entry present in definitions
// This is also true is r.typeName returns ""
return nil
}

Expand Down

0 comments on commit e987e0a

Please sign in to comment.