This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Request Payload Validation for UK
This feature is available as a product update from June 25, 2019 (06-25-2019) onwards. Apply the update and follow the instructions given below to use the feature.
Request Payload Validation adds flexibility to validate an incoming request against any customisations done to the swagger definition. For example, remove an enumeration from an existing set and check whether the incoming request contains the defined enumerations.
According to the following sample payload, the given account number formats are accepted.
If your API supports only the UK.OBIE.IBAN
and UK.OBIE.SortCodeAccountNumber
account number formats, you can simply modify the published swagger file and republish the API for the modifications to take effect.
When an API is published, the swagger file is added as a local entry and saved under the <WSO2_OB_APIM_HOME>/repository/deployment/server/synapse-configs/default/local-entries
directory.
To add the swagger as a local entry, the created and published API lifecycles are extended using customised API executor named com.wso2.finance.open.banking.api.executor.OBAPIPublisherExecutor
. For more information on executors, see Extension Points of API Life cycle.
Extend API lifecycle
- Go to API Manager - Management Console at
https://<WSO2_OB_APIM_HOST>:9443/carbon
. - Navigate to the Extensions tab and click lifecycles.
- Select View/Edit of APILifeCycle.
Add the following changes to the XML file, under the respective tags to enable publishing the swagger as a local entry in the
<WSO2_OB_APIM_HOST>/repository/deployment/server/synapse-configs/default/local-entries
directory.In the
state id= "Published"
element, add a newexecution
element under data name="transitionExecution"
with the properties below:<state id="Published"> <datamodel> <data name="transitionExecution"> <execution forEvent="Publish" class="com.wso2.finance.open.banking.api.executor.OBAPIPublisherExecutor"> </execution> </data> </datamodel> </state>
In the
state id=“Created”
element, underdata name=“transitionExecution”
find the default execution class value for event “Publish”
. Replace that default execution class withcom.wso2.finance.open.banking.api.executor.OBAPIPublisherExecutor
as follows:<state id="Created"> <datamodel> <data name="transitionExecution"> <execution forEvent="Publish" class="com.wso2.finance.open.banking.api.executor.OBAPIPublisherExecutor"> </execution> </data> </datamodel> </state>
Configure request validation handler
Open the <WSO2_OB_APIM_HOME>/repository/resources/api_templates/velocity_template.xml
file and configure RequestSchemaValidationHandler as follows:
#if($apiObj.additionalProperties.get("ob-spec") == "uk") ##add request validation handler ##Request validator should come before Signature validator. #if($!apiVersion == "v3.0" || $!apiVersion == "v3.1" || $!apiVersion == "v3.1.1" || $!apiVersion == "v2.0") <handler class="com.wso2.finance.open.banking.gateway.api.schema.validation.RequestSchemaValidationHandler"/> #end
Republish APIs
You need to republish the API to apply the swagger based validations. Therefore, follow the steps below:
- Sign in to the API Publisher at
https://<WSO2_OB_APIM_HOST>:9443/publisher
using the credentials of a user, whose role is an API Publisher. For more information on users and roles, see here. - Select the respective API and click Edit API.
- You are redirected to the Design phase. Click the Edit Source button under API Definition section.
- In the Swagger Editor menu bar, select File>Import File.
Browse for the intended swagger file
(.yaml)
in the<WSO2_OB_APIM_HOME>/repository/resources/finance/apis
directory and click Open File.WSO2 Open Banking has improved the UK specific payment swagger files of version-3 APIs as their existing data definitions do not allow swagger-based validations. Following are the improved swagger files:
Do the customisations to the improved swagger file and upload the swagger before republishing the API.
- Click Apply Changes to save the changes and go back to the Design page.
- Scroll down and click Save.
Click Next: Implement > Next: Manage and Save and Publish.