@@ -267,6 +267,7 @@ type Schema struct {
267
267
// "$id", the base URI is that of the entire document, as
268
268
// determined per RFC 3986 section 5 [RFC3986].
269
269
ID string `json:"$id,omitempty"`
270
+ Anchor string `json:"$anchor,omitempty"`
270
271
// Title and description can be used to decorate a user interface
271
272
// with information about the data produced by this user interface.
272
273
// A title will preferably be short.
@@ -405,6 +406,8 @@ func (s Schema) JSONProp(name string) interface{} {
405
406
switch name {
406
407
case "$id" :
407
408
return s .ID
409
+ case "$anchor" :
410
+ return s .ID
408
411
case "title" :
409
412
return s .Title
410
413
case "description" :
@@ -465,6 +468,7 @@ func (s Schema) JSONChildren() (ch map[string]JSONPather) {
465
468
// _schema is an internal struct for encoding & decoding purposes
466
469
type _schema struct {
467
470
ID string `json:"$id,omitempty"`
471
+ Anchor string `json:"$anchor,omitempty"`
468
472
Title string `json:"title,omitempty"`
469
473
Description string `json:"description,omitempty"`
470
474
Default interface {} `json:"default,omitempty"`
@@ -500,6 +504,7 @@ func (s *Schema) UnmarshalJSON(data []byte) error {
500
504
501
505
sch := & Schema {
502
506
ID : _s .ID ,
507
+ Anchor : _s .Anchor ,
503
508
Title : _s .Title ,
504
509
Description : _s .Description ,
505
510
Default : _s .Default ,
@@ -537,7 +542,7 @@ func (s *Schema) UnmarshalJSON(data []byte) error {
537
542
} else {
538
543
switch prop {
539
544
// skip any already-parsed props
540
- case "$vocabulary" , "$recursiveAnchor" , "$schema" , "$id" , "title" , "description" , "default" , "examples" , "extends" , "readOnly" , "writeOnly" , "$comment" , "$ref" , "$recursiveRef" , "$defs" , "format" :
545
+ case "$anchor" , "$ vocabulary" , "$recursiveAnchor" , "$schema" , "$id" , "title" , "description" , "default" , "examples" , "extends" , "readOnly" , "writeOnly" , "$comment" , "$ref" , "$recursiveRef" , "$defs" , "format" :
541
546
continue
542
547
default :
543
548
// assume non-specified props are "extra definitions"
@@ -597,6 +602,9 @@ func (s Schema) MarshalJSON() ([]byte, error) {
597
602
if s .ID != "" {
598
603
obj ["$id" ] = s .ID
599
604
}
605
+ if s .Anchor != "" {
606
+ obj ["$anchor" ] = s .Anchor
607
+ }
600
608
if s .Title != "" {
601
609
obj ["title" ] = s .Title
602
610
}
0 commit comments