code: func buildView(name string, mt *design.MediaTypeDefinition, at *design.AttributeDefinition) (*design.ViewDefinition, error) {
  	if at.Type == nil || !at.Type.IsObject() {
  		return nil, fmt.Errorf("invalid view DSL")
  	}
  	o := at.Type.ToObject()
  	if o != nil {
  		mto := mt.Type.ToObject()
  		if mto == nil {
  			mto = mt.Type.ToArray().ElemType.Type.ToObject()
  		}
  		for n, cat := range o {
  			if existing, ok := mto[n]; ok {
  				dup := design.DupAtt(existing)
  				dup.View = cat.View
  				o[n] = dup
  			} else if n != "links" {
  				return nil, fmt.Errorf("unknown attribute %#v", n)
  			}
  		}
  	}
  	return &design.ViewDefinition{
  		AttributeDefinition: at,
  		Name:                name,
  		Parent:              mt,
  	}, nil
  }
docs: // buildView builds a view definition given an attribute and a corresponding media type.