Skip to content

Commit

Permalink
fix: default values count even if disabled (#767)
Browse files Browse the repository at this point in the history
  • Loading branch information
orshlom committed Feb 13, 2023
1 parent ecb06bc commit 4e1d51f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions openapi3/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1789,12 +1789,10 @@ func (schema *Schema) visitJSONObject(settings *schemaValidationSettings, value
reqRO := settings.asreq && propSchema.Value.ReadOnly && !settings.readOnlyValidationDisabled
repWO := settings.asrep && propSchema.Value.WriteOnly && !settings.writeOnlyValidationDisabled

if value[propName] == nil {
if dlft := propSchema.Value.Default; dlft != nil && !reqRO && !repWO {
value[propName] = dlft
if f := settings.defaultsSet; f != nil {
settings.onceSettingDefaults.Do(f)
}
if f := settings.defaultsSet; f != nil && value[propName] == nil {
if dflt := propSchema.Value.Default; dflt != nil && !reqRO && !repWO {
value[propName] = dflt
settings.onceSettingDefaults.Do(f)
}
}

Expand Down

0 comments on commit 4e1d51f

Please sign in to comment.