-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
APIS-6465: Expose parts of published definitions when publishing (#99)
* APIS-6465: Expose parts of published definitions when publishing * APIS-6465: Use a map instead of includeDefinition
- Loading branch information
Showing
13 changed files
with
189 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
app/uk/gov/hmrc/apipublisher/models/PublisherResponse.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2023 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.apipublisher.models | ||
|
||
import play.api.libs.json._ | ||
|
||
case class PublicationResult(approved: Boolean, publisherResponse: Option[PublisherResponse]) | ||
|
||
case class PublisherResponse(name: String, serviceName: String, context: String, description: String, versions: List[PartialApiVersion]) | ||
|
||
object PublisherResponse { | ||
implicit val format: OFormat[PublisherResponse] = Json.format[PublisherResponse] | ||
} | ||
|
||
case class PartialApiVersion(version: String, status: ApiStatus, endpointsEnabled: Option[Boolean]) | ||
|
||
object PartialApiVersion { | ||
implicit val format: OFormat[PartialApiVersion] = Json.format[PartialApiVersion] | ||
} | ||
|
||
sealed trait ApiStatus | ||
|
||
object ApiStatus { | ||
case object ALPHA extends ApiStatus | ||
case object BETA extends ApiStatus | ||
case object STABLE extends ApiStatus | ||
case object DEPRECATED extends ApiStatus | ||
case object RETIRED extends ApiStatus | ||
|
||
def apply(text: String): Option[ApiStatus] = text.toUpperCase() match { | ||
case "ALPHA" => Some(ALPHA) | ||
case "BETA" => Some(BETA) | ||
case "STABLE" => Some(STABLE) | ||
case "DEPRECATED" => Some(DEPRECATED) | ||
case "RETIRED" => Some(RETIRED) | ||
case _ => None | ||
} | ||
|
||
private val convert: String => JsResult[ApiStatus] = s => ApiStatus(s).fold[JsResult[ApiStatus]](JsError(s"$s is not a status"))(status => JsSuccess(status)) | ||
|
||
implicit val reads: Reads[ApiStatus] = JsPath.read[String].flatMapResult(convert(_)) | ||
|
||
implicit val writes: Writes[ApiStatus] = Writes[ApiStatus](status => JsString(status.toString)) | ||
|
||
implicit val format: Format[ApiStatus] = Format(reads, writes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
|
||
sm --start API_DEFINITION API_SCOPE API_SUBSCRIPTION_FIELDS API_EXAMPLE_MICROSERVICE API_DOCUMENTATION_FRONTEND | ||
sm2 --start API_DEFINITION API_SCOPE API_SUBSCRIPTION_FIELDS API_EXAMPLE_MICROSERVICE API_DOCUMENTATION_FRONTEND | ||
|
||
./run_local.sh |
Oops, something went wrong.