@@ -19,6 +19,7 @@ import (
1919 "fmt"
2020 "log"
2121 "os"
22+ "strings"
2223 "time"
2324
2425 "github.com/mongodb/openapi/tools/cli/internal/apiversion"
@@ -230,11 +231,6 @@ func NewEntriesBetweenRevisionVersions(revisionPath, exceptionFilePath string) (
230231 continue
231232 }
232233
233- // Skip upcoming version. It will be included in CLOUDP-315486
234- if apiversion .IsUpcomingStabilityLevel (fromVersion ) || apiversion .IsUpcomingStabilityLevel (toVersion ) {
235- continue
236- }
237-
238234 entry , err := newEntriesBetweenVersion (revisionMetadata , fromVersion , toVersion , exceptionFilePath )
239235 if err != nil {
240236 return nil , err
@@ -389,6 +385,14 @@ func newBaseAndRevisionSpecs(baseMetadata, revisionMetadata *Metadata) (baseSpec
389385 if err != nil {
390386 return nil , nil , err
391387 }
388+
389+ if strings .Contains (revisionMetadata .ActiveVersion , ".upcoming" ) {
390+ // Upcoming API Spec contains only endpoints marked as "upcoming". We need to remove endpoints from
391+ // the base spec that aren't present in the revision spec to avoid generating
392+ // incorrect "endpoint deleted" changelog entries.
393+ removePathsAndOperationsNotInRevision (baseSpec , revisionSpec )
394+ }
395+
392396 baseSpec .Version = baseMetadata .ActiveVersion
393397 revisionSpec .Version = revisionMetadata .ActiveVersion
394398
@@ -412,6 +416,24 @@ func newBaseAndRevisionSpecs(baseMetadata, revisionMetadata *Metadata) (baseSpec
412416 return baseSpec , revisionSpec , nil
413417}
414418
419+ // removePathsAndOperationsNotInRevision removes paths and operations not in the revision spec.
420+ func removePathsAndOperationsNotInRevision (baseSpec , revisionSpec * load.SpecInfo ) {
421+ pathsFromRevision := revisionSpec .Spec .Paths .Map ()
422+ for pathKeyFromBase , pathValueFromBase := range baseSpec .Spec .Paths .Map () {
423+ if _ , ok := pathsFromRevision [pathKeyFromBase ]; ! ok {
424+ baseSpec .Spec .Paths .Delete (pathKeyFromBase )
425+ continue
426+ }
427+
428+ operationsFromRevision := pathsFromRevision [pathKeyFromBase ].Operations ()
429+ for operationKeyFromBase := range pathValueFromBase .Operations () {
430+ if _ , ok := operationsFromRevision [operationKeyFromBase ]; ! ok {
431+ delete (pathValueFromBase .Operations (), operationKeyFromBase )
432+ }
433+ }
434+ }
435+ }
436+
415437func newOpeAPISpecFromPathAndVersion (path , version string ) (* load.SpecInfo , error ) {
416438 loader := openapi .NewOpenAPI3 ().WithExcludedPrivatePaths ()
417439 return loader .CreateOpenAPISpecFromPath (fmt .Sprintf ("%s/openapi-%s.json" , path , version ))
0 commit comments