Skip to content

Commit

Permalink
FDN-3181 Return ApiDoc in Service for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jackl committed Jan 10, 2025
1 parent 617540d commit ed3d30d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions api/app/models/VersionsModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import builder.api_json.upgrades.ServiceParser
import cats.data.Validated.{Invalid, Valid}
import cats.data.ValidatedNec
import cats.implicits.*
import db.{Authorization, InternalApplicationsDao, InternalOrganizationsDao, InternalVersion, InternalOriginalsDao}
import db.{Authorization, InternalApplicationsDao, InternalOrganizationsDao, InternalOriginalsDao, InternalVersion}
import db.generated.cache.ServicesDao
import io.apibuilder.api.v0.models.Version
import io.apibuilder.common.v0.models.{Audit, Reference, ReferenceGuid}
import io.apibuilder.spec.v0.models.Service
import io.apibuilder.spec.v0.models.json._
import io.apibuilder.spec.v0.models.{Apidoc, Service}
import io.apibuilder.spec.v0.models.json.*
import io.flow.postgresql.OrderBy

import javax.inject.Inject
Expand Down Expand Up @@ -88,5 +88,12 @@ class VersionsModel @Inject()(
}.headOption
.toValidNec("Version does not have service json")
.map(_.json.as[Service])
.map { service =>
// Some clients need a value due to apibuilder-validation version 0.52.0
// having it as a required field.
service.apidoc match
case Some(_) => service
case None => service.copy(apidoc = Some(Apidoc(version = service.version)))
}
}
}

0 comments on commit ed3d30d

Please sign in to comment.