Skip to content

Commit

Permalink
Merge pull request #998 from hmrc/DL-8692
Browse files Browse the repository at this point in the history
[DL-8692] - add OAS yaml file
  • Loading branch information
scott-goodwin authored Mar 16, 2023
2 parents 69cfff2 + a02a914 commit 73cf93a
Show file tree
Hide file tree
Showing 10 changed files with 2,294 additions and 543 deletions.
9 changes: 0 additions & 9 deletions app/config/DocumentationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package config

import config.FeatureSwitch.FinancialDataRamlFeature
import controllers.Assets
import definition.ApiDefinitionFactory
import javax.inject.{Inject, Singleton}
Expand All @@ -36,14 +35,6 @@ class DocumentationController @Inject()(vatApiDefinition: ApiDefinitionFactory,
}

def raml(version: String, file: String): Action[AnyContent] = {
if (isEnabled(FinancialDataRamlFeature)) {
if(file.equals("application.raml")) {
assets.at(s"/public/api/conf/$version", "applicationWithFinancialDetailsEndPoint.raml")
} else {
assets.at(s"/public/api/conf/$version", file)
}
} else {
assets.at(s"/public/api/conf/$version", file)
}
}
}
5 changes: 5 additions & 0 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ play.modules.enabled += "config.DIModule"
#Cant use `utils.LegacyErrorHandler` until the VAT API is re-spec'ed to remove default Play! errors
play.http.errorHandler = "utils.LegacyErrorHandler"

# CORS Filter
play.filters.enabled += "play.filters.cors.CORSFilter"
play.filters.cors {
  allowedOrigins = ["http://localhost:9680"]
}

wiremock-port = 22222
wiremock-port = ${?WIREMOCK_PORT}
Expand Down
22 changes: 1 addition & 21 deletions func/config/DocumentationControllerISpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ package config
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.typesafe.config.ConfigFactory

import config.FeatureSwitch.FinancialDataRamlFeature
import mocks.MockAppConfig
import play.api.Configuration
import play.api.http.Status
import play.api.libs.json.{JsValue, Json}
import play.api.libs.ws.WSResponse
Expand Down Expand Up @@ -66,22 +64,4 @@ class DocumentationControllerISpec extends IntegrationBaseSpec with FeatureToggl
}
}

"a documentation request" must {
"return the documentation" in {
disable(FinancialDataRamlFeature)
val response: WSResponse = await(buildRequest("/api/conf/1.0/application.raml").get())
response.status shouldBe Status.OK
response.body[String] should startWith("#%RAML 1.0")
response.body[String] should not include("/financial-details:")
}

"return the documentation with financial endpoint" in {
enable(FinancialDataRamlFeature)
val response: WSResponse = await(buildRequest("/api/conf/1.0/application.raml").get())
response.status shouldBe Status.OK
response.body[String] should startWith("#%RAML 1.0")
response.body[String] should include("/financial-details:")
}
}

}
51 changes: 51 additions & 0 deletions resources/public/api/conf/1.0/application.raml
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,54 @@ traits:
description: Invalid VRN.
value:
code: VRN_INVALID
/financial-details:
/{penaltyChargeReference}:
uriParameters:
penaltyChargeReference:
description: The late submission or late payment penalty charge reference, which has been obtained from the Retrieve VAT penalties endpoint. Only the financial details that relate to this charge will be returned.
type: string
example: "XP123456789012"
displayName: Retrieve financial details
description: Retrieves the financial details relating to a late submission or late payment penalty that has been applied to a VAT account.
get:
displayName: Retrieve financial details
description: Retrieves the financial details relating to a late submission or late payment penalty that has been applied to a VAT account.
(annotations.sandboxData): !include scenarios/vat-financial-details-scenarios.md
is: [headers.acceptHeader, testScenarioHeader, clientOrAgentNotAuthorised]
(annotations.scope): "read:vat"
securedBy: [ sec.oauth_2_0: { scopes: [ "read:vat" ] } ]
responses:
200:
headers:
X-CorrelationId:
example: c75f40a6-a3df-4429-a697-471eeec46435
description: Unique id for operation tracking <br> String, 36 characters.
body:
application/json:
type: !include schemas/penalties/FinancialDetails.json
examples:
example-1:
description: all fields example
value: !include examples/penalties/FinancialDetails.json
400:
body:
application/json:
type: types.errorResponse
examples:
invalidVrn:
description: Invalid VRN.
value:
code: VRN_INVALID
invalidChargeReference:
description: The specified penalty charge reference is invalid.
value:
code: CHARGE_REFERENCE_INVALID
404:
body:
application/json:
type: types.errorResponse
examples:
notFound:
description: The remote endpoint has indicated that no associated data is found.
value:
code: MATCHING_RESOURCE_NOT_FOUND
Loading

0 comments on commit 73cf93a

Please sign in to comment.