Skip to content

Commit 2c385a3

Browse files
authored
Add deprecated and writeOnly as part of schema (#125)
1 parent 8a67fbf commit 2c385a3

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ These tags can be used:
9090
* [`example`](https://json-schema.org/draft/2020-12/json-schema-validation.html#name-examples), a scalar value that matches type of parent property, for an array it is applied to items
9191
* [`examples`](https://json-schema.org/draft/2020-12/json-schema-validation.html#name-examples), a JSON array value
9292
* [`const`](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.1.3), can be scalar or JSON value
93+
* [`deprecated`](https://json-schema.org/draft/2020-12/json-schema-validation#name-deprecated), boolean
94+
* [`readOnly`](https://json-schema.org/draft/2020-12/json-schema-validation#name-deprecated), boolean
95+
* [`writeOnly`](https://json-schema.org/draft/2020-12/json-schema-validation#name-deprecated), boolean
9396
* [`pattern`](https://json-schema.org/draft-04/json-schema-validation.html#rfc.section.5.2.3), string
9497
* [`format`](https://json-schema.org/draft-04/json-schema-validation.html#rfc.section.7), string
9598
* [`multipleOf`](https://json-schema.org/draft-04/json-schema-validation.html#rfc.section.5.1.1), float > 0
@@ -274,4 +277,4 @@ s, err := r.Reflect(My{}, jsonschema.InterceptProp(func(params jsonschema.Interc
274277

275278
return nil
276279
}))
277-
```
280+
```

entities.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

entities_test.go

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

reflect.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,13 +1161,6 @@ func (r *Reflector) walkProperties(v reflect.Value, parent *Schema, rc *ReflectC
11611161
return err
11621162
}
11631163

1164-
deprecated := false
1165-
if err := refl.ReadBoolTag(field.Tag, "deprecated", &deprecated); err != nil {
1166-
return err
1167-
} else if deprecated {
1168-
propertySchema.WithExtraPropertiesItem("deprecated", true)
1169-
}
1170-
11711164
if !rc.SkipNonConstraints {
11721165
if err := reflectExamples(rc, &propertySchema, field); err != nil {
11731166
return err

0 commit comments

Comments
 (0)