code: func newCodecFactory(scheme *runtime.Scheme, serializers []serializerType) CodecFactory {
  	decoders := make([]runtime.Decoder, 0, len(serializers))
  	var accepts []runtime.SerializerInfo
  	alreadyAccepted := make(map[string]struct{})
  
  	var legacySerializer runtime.Serializer
  	for _, d := range serializers {
  		decoders = append(decoders, d.Serializer)
  		for _, mediaType := range d.AcceptContentTypes {
  			if _, ok := alreadyAccepted[mediaType]; ok {
  				continue
  			}
  			alreadyAccepted[mediaType] = struct{}{}
  			info := runtime.SerializerInfo{
  				MediaType:        d.ContentType,
  				EncodesAsText:    d.EncodesAsText,
  				Serializer:       d.Serializer,
  				PrettySerializer: d.PrettySerializer,
  			}
  
  			mediaType, _, err := mime.ParseMediaType(info.MediaType)
  			if err != nil {
  				panic(err)
  			}
  			parts := strings.SplitN(mediaType, "/", 2)
  			info.MediaTypeType = parts[0]
  			info.MediaTypeSubType = parts[1]
  
  			if d.StreamSerializer != nil {
  				info.StreamSerializer = &runtime.StreamSerializerInfo{
  					Serializer:    d.StreamSerializer,
  					EncodesAsText: d.EncodesAsText,
  					Framer:        d.Framer,
  				}
  			}
  			accepts = append(accepts, info)
  			if mediaType == runtime.ContentTypeJSON {
  				legacySerializer = d.Serializer
  			}
  		}
  	}
  	if legacySerializer == nil {
  		legacySerializer = serializers[0].Serializer
  	}
  
  	return CodecFactory{
  		scheme:      scheme,
  		serializers: serializers,
  		universal:   recognizer.NewDecoder(decoders...),
  
  		accepts: accepts,
  
  		legacySerializer: legacySerializer,
  	}
  }
docs: // newCodecFactory is a helper for testing that allows a different metafactory to be specified.