Skip to content

Commit

Permalink
fix map only
Browse files Browse the repository at this point in the history
  • Loading branch information
candiduslynx committed Feb 2, 2024
1 parent 0fe1690 commit 17d0196
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,7 @@ func (r *Reflector) reflectTypeToSchemaWithID(defs Definitions, t reflect.Type)
func (r *Reflector) reflectTypeToSchema(definitions Definitions, t reflect.Type) *Schema {
// only try to reflect non-pointers
if t.Kind() == reflect.Pointer {
result := r.refOrReflectTypeToSchema(definitions, t.Elem())
if r.NullableFromType {
result = makeNullable(result)
}
return result
return r.refOrReflectTypeToSchema(definitions, t.Elem())
}

// Check if the there is an alias method that provides an object
Expand Down Expand Up @@ -441,7 +437,11 @@ func (r *Reflector) reflectMap(definitions Definitions, t reflect.Type, st *Sche
return
default:
if t.Elem().Kind() != reflect.Interface {
st.AdditionalProperties = r.refOrReflectTypeToSchema(definitions, t.Elem())
additionalProperties := r.refOrReflectTypeToSchema(definitions, t.Elem())
if r.NullableFromType && isNullable(t.Elem().Kind()) {
additionalProperties = makeNullable(additionalProperties)
}
st.AdditionalProperties = additionalProperties
}
}
}
Expand Down Expand Up @@ -1051,10 +1051,7 @@ func (r *Reflector) reflectFieldName(f reflect.StructField) (string, bool, bool,

var nullable bool
if r.NullableFromType {
// we might've already added the nullability wrapper in Reflector.reflectTypeToSchema
if f.Type.Kind() != reflect.Pointer {
nullable = isNullable(f.Type.Kind())
}
nullable = isNullable(f.Type.Kind())
} else {
nullable = nullableFromJSONSchemaTags(schemaTags)
}
Expand Down

0 comments on commit 17d0196

Please sign in to comment.