@@ -17,7 +17,6 @@ import (
1717 "unicode/utf16"
1818
1919 "github.com/go-openapi/jsonpointer"
20- "github.com/mohae/deepcopy"
2120 "github.com/woodsbury/decimal128"
2221)
2322
@@ -2202,7 +2201,7 @@ func (schema *Schema) visitXOFOperations(settings *schemaValidationSettings, val
22022201
22032202 // make a deep copy to protect origin value from being injected default value that defined in mismatched oneOf schema
22042203 if settings.asreq || settings.asrep {
2205- tempValue = deepcopy.Copy (value)
2204+ tempValue = deepCopyJSONValue (value)
22062205 }
22072206
22082207 if err := v.visitJSON(settings, tempValue); err != nil {
@@ -2265,7 +2264,7 @@ func (schema *Schema) visitXOFOperations(settings *schemaValidationSettings, val
22652264
22662265 // make a deep copy to protect origin value from being injected default value that defined in mismatched anyOf schema
22672266 if settings.asreq || settings.asrep {
2268- tempValue = deepcopy.Copy (value)
2267+ tempValue = deepCopyJSONValue (value)
22692268 }
22702269 if err := v.visitJSON(settings, tempValue); err == nil {
22712270 ok = true
@@ -3158,6 +3157,25 @@ func unsupportedFormat(format string) error {
31583157 return fmt.Errorf("unsupported 'format' value %q", format)
31593158}
31603159
3160+ func deepCopyJSONValue(v any) any {
3161+ switch v := v.(type) {
3162+ case map[string]any:
3163+ cp := make(map[string]any, len(v))
3164+ for k, val := range v {
3165+ cp[k] = deepCopyJSONValue(val)
3166+ }
3167+ return cp
3168+ case []any:
3169+ cp := make([]any, len(v))
3170+ for i, val := range v {
3171+ cp[i] = deepCopyJSONValue(val)
3172+ }
3173+ return cp
3174+ default:
3175+ return v // string, float64, bool, nil — all immutable
3176+ }
3177+ }
3178+
31613179// UnmarshalJSON sets Schemas to a copy of data.
31623180func (schemas *Schemas) UnmarshalJSON(data []byte) (err error) {
31633181 *schemas, err = unmarshalStringMapP[SchemaRef](data)
0 commit comments