Skip to content

Commit

Permalink
[PS|SS] TAV-223 - Add json and raml api definitions for address-lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
beyond-code-github committed Feb 1, 2021
1 parent b85086a commit 17fea89
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
32 changes: 32 additions & 0 deletions app/apiplatform/DocumentationController.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2021 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 apiplatform

import controllers.Assets
import javax.inject.Inject
import play.api.mvc.{Action, AnyContent, ControllerComponents}
import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController

class DocumentationController @Inject()(assets: Assets, cc: ControllerComponents) extends BackendController(cc) {
def definition(): Action[AnyContent] = {
assets.at("/public/api", "definition.json")
}

def raml(version: String, file: String): Action[AnyContent] = {
assets.at(s"/public/api/conf/$version", file)
}
}
3 changes: 3 additions & 0 deletions conf/app.routes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# We need the /address-lookup prefix because the Nginx reverse proxy passes requests through to us
# with that prefix. Some of the entry points need to be both with and without the prefix.

-> / definition.Routes
GET /ping/ping uk.gov.hmrc.play.health.HealthController.ping

# Kenshoo metrics https://github.com/kenshoo/metrics-play
Expand All @@ -15,6 +16,8 @@ GET /v1/uk/addresses osgb.AddressSearchController.sea
GET /v2/gb/addresses osgb.AddressSearchController.searchV2()
GET /v2/uk/addresses osgb.AddressSearchController.searchV2()

GET /lookup osgb.AddressSearchController.searchV2()

# original style - now deprecated
GET /v1/gb/addresses.json osgb.AddressSearchController.searchV1()
GET /v1/uk/addresses.json osgb.AddressSearchController.searchV1()
Expand Down
2 changes: 2 additions & 0 deletions conf/definition.routes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GET /api/definition apiplatform.DocumentationController.definition()
GET /api/conf/:version/*file apiplatform.DocumentationController.raml(version, file)
39 changes: 39 additions & 0 deletions public/api/conf/1.0/application.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#%RAML 1.0
---
title: Address Lookup
version: 1.0

protocols: [ HTTPS ]
baseUri: https://address-lookup.service.hmrc.gov.uk/

documentation:
- title: Overview
content: !include docs/overview.md
- title: Versioning
content: !include https://developer.service.hmrc.gov.uk/api-documentation/assets/common/docs/versioning.md
- title: Errors
content: !include https://developer.service.hmrc.gov.uk/api-documentation/assets/common/docs/errors.md

mediaType: application/hal+json

uses:
sec: https://developer.service.hmrc.gov.uk/api-documentation/assets/common/modules/securitySchemes.raml
headers: https://developer.service.hmrc.gov.uk/api-documentation/assets/common/modules/headers.raml
annotations: https://developer.service.hmrc.gov.uk/api-documentation/assets/common/modules/annotations.raml
types: https://developer.service.hmrc.gov.uk/api-documentation/assets/common/modules/types.raml

/lookup:
/address:
get:
displayName: Lookup address
description: |
Lookup of postal and BFPO (British Forces Post Office) address details within the UK
is: [headers.acceptHeader]
responses:
200:
body:
application/json:
example: |
{
"message" : "Hello World"
}
21 changes: 21 additions & 0 deletions public/api/definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"scopes": [
{
"key": "lookup-address",
"name": "Lookup address",
"description": "Lookup of postal and BFPO (British Forces Post Office) address details within the UK"
}
],
"api": {
"name": "Lookup address",
"description": "Lookup of postal and BFPO (British Forces Post Office) address details within the UK",
"context": "misc/address-validation",
"versions": [
{
"version": "1.0",
"status": "ALPHA",
"endpointsEnabled": true
}
]
}
}

0 comments on commit 17fea89

Please sign in to comment.