code: func BuildAndRegisterAggregator(downloader *Downloader, delegationTarget server.DelegationTarget, webServices []*restful.WebService,
  	config *common.Config, pathHandler common.PathHandler) (SpecAggregator, error) {
  	s := &specAggregator{
  		openAPISpecs: map[string]*openAPISpecInfo{},
  	}
  
  	i := 0
  	// Build Aggregator's spec
  	aggregatorOpenAPISpec, err := builder.BuildOpenAPISpec(webServices, config)
  	if err != nil {
  		return nil, err
  	}
  
  	// Reserving non-name spec for aggregator's Spec.
  	s.addLocalSpec(aggregatorOpenAPISpec, nil, fmt.Sprintf(localDelegateChainNamePattern, i), "")
  	i++
  	for delegate := delegationTarget; delegate != nil; delegate = delegate.NextDelegate() {
  		handler := delegate.UnprotectedHandler()
  		if handler == nil {
  			continue
  		}
  		delegateSpec, etag, _, err := downloader.Download(handler, "")
  		if err != nil {
  			return nil, err
  		}
  		if delegateSpec == nil {
  			continue
  		}
  		s.addLocalSpec(delegateSpec, handler, fmt.Sprintf(localDelegateChainNamePattern, i), etag)
  		i++
  	}
  
  	// Build initial spec to serve.
  	specToServe, err := s.buildOpenAPISpec()
  	if err != nil {
  		return nil, err
  	}
  
  	// Install handler
  	s.openAPIVersionedService, err = handler.RegisterOpenAPIVersionedService(
  		specToServe, "/openapi/v2", pathHandler)
  	if err != nil {
  		return nil, err
  	}
  
  	return s, nil
  }
docs: // BuildAndRegisterAggregator registered OpenAPI aggregator handler. This function is not thread safe as it only being called on startup.