code: func buildMediaTypeSchema(api *design.APIDefinition, mt *design.MediaTypeDefinition, view string, s *JSONSchema) {
  	s.Media = &JSONMedia{Type: mt.Identifier}
  	projected, linksUT, err := mt.Project(view)
  	if err != nil {
  		panic(fmt.Sprintf("failed to project media type %#v: %s", mt.Identifier, err)) // bug
  	}
  	if linksUT != nil {
  		links := linksUT.Type.ToObject()
  		lnames := make([]string, len(links))
  		i := 0
  		for n := range links {
  			lnames[i] = n
  			i++
  		}
  		sort.Strings(lnames)
  		for _, ln := range lnames {
  			var (
  				att  = links[ln]
  				lmt  = att.Type.(*design.MediaTypeDefinition)
  				r    = lmt.Resource
  				href string
  			)
  			if r != nil {
  				href = toSchemaHref(api, r.CanonicalAction().Routes[0])
  			}
  			sm := NewJSONSchema()
  			sm.Ref = MediaTypeRef(api, lmt, "default")
  			s.Links = append(s.Links, &JSONLink{
  				Title:        ln,
  				Rel:          ln,
  				Description:  att.Description,
  				Href:         href,
  				Method:       "GET",
  				TargetSchema: sm,
  				MediaType:    lmt.Identifier,
  			})
  		}
  	}
  	buildAttributeSchema(api, s, projected.AttributeDefinition)
  }
docs: // buildMediaTypeSchema initializes s as the JSON schema representing mt for the given view.