Commit 01bc4eff authored by Dr. Stefan Schimanski's avatar Dr. Stefan Schimanski

openapi-aggregation: merge without clones

parent 84f0629e
...@@ -196,13 +196,12 @@ func (s *specAggregator) buildOpenAPISpec() (specToReturn *spec.Swagger, err err ...@@ -196,13 +196,12 @@ func (s *specAggregator) buildOpenAPISpec() (specToReturn *spec.Swagger, err err
} }
sortByPriority(specs) sortByPriority(specs)
for _, specInfo := range specs { for _, specInfo := range specs {
// TODO: Make kube-openapi.MergeSpec(s) accept nil or empty spec as destination and just clone the spec in that case.
if specToReturn == nil { if specToReturn == nil {
specToReturn, err = aggregator.CloneSpec(specInfo.spec) specToReturn = &spec.Swagger{}
if err != nil { *specToReturn = *specInfo.spec
return nil, err // Paths and Definitions are set by MergeSpecsIgnorePathConflict
} specToReturn.Paths = nil
continue specToReturn.Definitions = nil
} }
if err := aggregator.MergeSpecsIgnorePathConflict(specToReturn, specInfo.spec); err != nil { if err := aggregator.MergeSpecsIgnorePathConflict(specToReturn, specInfo.spec); err != nil {
return nil, err return nil, err
...@@ -267,7 +266,7 @@ func (s *specAggregator) UpdateAPIServiceSpec(apiServiceName string, spec *spec. ...@@ -267,7 +266,7 @@ func (s *specAggregator) UpdateAPIServiceSpec(apiServiceName string, spec *spec.
// For APIServices (non-local) specs, only merge their /apis/ prefixed endpoint as it is the only paths // For APIServices (non-local) specs, only merge their /apis/ prefixed endpoint as it is the only paths
// proxy handler delegates. // proxy handler delegates.
if specInfo.apiService.Spec.Service != nil { if specInfo.apiService.Spec.Service != nil {
aggregator.FilterSpecByPaths(spec, []string{"/apis/"}) spec = aggregator.FilterSpecByPathsWithoutSideEffects(spec, []string{"/apis/"})
} }
return s.tryUpdatingServiceSpecs(&openAPISpecInfo{ return s.tryUpdatingServiceSpecs(&openAPISpecInfo{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment