code: func (s *specAggregator) buildOpenAPISpec() (specToReturn *spec.Swagger, err error) {
  	specs := []openAPISpecInfo{}
  	for _, specInfo := range s.openAPISpecs {
  		if specInfo.spec == nil {
  			continue
  		}
  		specs = append(specs, *specInfo)
  	}
  	if len(specs) == 0 {
  		return &spec.Swagger{}, nil
  	}
  	sortByPriority(specs)
  	for _, specInfo := range specs {
  		if specToReturn == nil {
  			specToReturn = &spec.Swagger{}
  			*specToReturn = *specInfo.spec
  			// Paths and Definitions are set by MergeSpecsIgnorePathConflict
  			specToReturn.Paths = nil
  			specToReturn.Definitions = nil
  		}
  		if err := aggregator.MergeSpecsIgnorePathConflict(specToReturn, specInfo.spec); err != nil {
  			return nil, err
  		}
  	}
  
  	return specToReturn, nil
  }
docs: // buildOpenAPISpec aggregates all OpenAPI specs.  It is not thread-safe. The caller is responsible to hold proper locks.