func (d *Draft) listSubschemas(r *resource, base string, rr map[string]*resource) error {
	add := func(loc string, sch interface{}) error {
		url, err := d.resolveID(base, sch)
		if err != nil {
			return err
		}
		floc := r.floc + "/" + loc
		sr := &resource{url: url, floc: floc, doc: sch}
		rr[floc] = sr

		base := base
		if url != "" {
			base = url
		}
		return d.listSubschemas(sr, base, rr)
	}

	sch, ok := r.doc.(*OrderedMap)
	if !ok {
		return nil
	}
	for kw, pos := range d.subschemas {
		v, ok := sch.Get(kw)
		if !ok {
			continue
		}
		if pos&self != 0 {
			switch v := v.(type) {
			case *OrderedMap:
				if err := add(kw, v); err != nil {
					return err
				}
			case bool:
				if d.boolSchema {
					if err := add(kw, v); err != nil {
						return err
					}
				}
			}
		}
		if pos&item != 0 {
			if v, ok := v.([]interface{}); ok {
				for i, item := range v {
					if err := add(kw+"/"+strconv.Itoa(i), item); err != nil {
						return err
					}
				}
			}
		}
		if pos&prop != 0 {
			if v, ok := v.(*OrderedMap); ok {
				for pname, pval := range v.RawValues() {
					if err := add(kw+"/"+escape(pname), pval); err != nil {
						return err
					}
				}
			}
		}
	}
	return nil
}
// listSubschemas collects subschemas in r into rr.
listSubschemas collects subschemas in r into rr.
// listSubschemas collects subschemas in r into rr .
func (d *Draft) listSubschemas(r *resource, base string, rr map[string]*resource) error {
	add := func(loc string, sch interface{}) error {
		url, err := d.resolveID(base, sch)
		if err != nil {
			return err
		}
		floc := r.floc + "/" + loc
		sr := &resource{url: url, floc: floc, doc: sch}
		rr[floc] = sr
		base := base
		if url != "" {
			base = url
		}
		return d.listSubschemas(sr, base, rr)
	}
	sch, ok := r.doc.(*OrderedMap)
	if !ok {
		return nil
	}
	for kw, pos := range d.subschemas {
		v, ok := sch.Get(kw)
		if !ok {
			continue
		}
		if pos&self != 0 {
			switch v := v.(type) {
			case *OrderedMap:
				if err := add(kw, v); err != nil {
					return err
				}
			case bool:
				if d.boolSchema {
					if err := add(kw, v); err != nil {
						return err
					}
				}
			}
		}
		if pos&item != 0 {
			if v, ok := v.([]interface{}); ok {
				for i, item := range v {
					if err := add(kw+"/"+strconv.Itoa(i), item); err != nil {
						return err
					}
				}
			}
		}
		if pos&prop != 0 {
			if v, ok := v.(*OrderedMap); ok {
				for pname, pval := range v.RawValues() {
					if err := add(kw+"/"+escape(pname), pval); err != nil {
						return err
					}
				}
			}
		}
	}
	return nil
}
func ( d * Draft ) listSubschemas ( r * resource , base string , rr map [ string ] * resource ) error { add := func ( loc string , sch interface { } ) error { url , err := d . resolveID ( base , sch ) if err != nil { return err } floc := r . floc + " " + loc sr := & resource { url : url , floc : floc , doc : sch } rr [ floc ] = sr base := base if url != " " { base = url } return d . listSubschemas ( sr , base , rr ) } sch , ok := r . doc . ( * OrderedMap ) if ! ok { return nil } for kw , pos := range d . subschemas { v , ok := sch . Get ( kw ) if ! ok { continue } if pos & self != 0 { switch v := v . ( type ) { case * OrderedMap : if err := add ( kw , v ) ; err != nil { return err } case bool : if d . boolSchema { if err := add ( kw , v ) ; err != nil { return err } } } } if pos & item != 0 { if v , ok := v . ( [ ] interface { } ) ; ok { for i , item := range v { if err := add ( kw + " " + strconv . Itoa ( i ) , item ) ; err != nil { return err } } } } if pos & prop != 0 { if v , ok := v . ( * OrderedMap ) ; ok { for pname , pval := range v . RawValues ( ) { if err := add ( kw + " " + escape ( pname ) , pval ) ; err != nil { return err } } } } } return nil }
listSubschemas collects subschemas in r into rr.
listSubschemas collects subschemas in r into rr .