code: func (a *APIDefinition) Finalize() {
  	if len(a.Consumes) == 0 {
  		a.Consumes = DefaultDecoders
  	}
  	if len(a.Produces) == 0 {
  		a.Produces = DefaultEncoders
  	}
  	a.IterateResources(func(r *ResourceDefinition) error {
  		returnsError := func(resp *ResponseDefinition) bool {
  			if resp.MediaType == ErrorMediaIdentifier {
  				if a.MediaTypes == nil {
  					a.MediaTypes = make(map[string]*MediaTypeDefinition)
  				}
  				a.MediaTypes[CanonicalIdentifier(ErrorMediaIdentifier)] = ErrorMedia
  				return true
  			}
  			return false
  		}
  		for _, resp := range a.Responses {
  			if returnsError(resp) {
  				return errors.New("done")
  			}
  		}
  		for _, resp := range r.Responses {
  			if returnsError(resp) {
  				return errors.New("done")
  			}
  		}
  		return r.IterateActions(func(action *ActionDefinition) error {
  			for _, resp := range action.Responses {
  				if returnsError(resp) {
  					return errors.New("done")
  				}
  			}
  			return nil
  		})
  	})
  }
docs: // Finalize sets the Consumes and Produces fields to the defaults if empty.
  // Also it records built-in media types that are used by the user design.