API Schema Validation
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

API Schema Validation

The API schema based request and/or response validator validate requests and responses coming to the API Microgateway. This validator validates requests and responses based on the API schema that is defined in the API definition. You can enable request validation, response validation, or both request and response validation. Whenever a request comes to the API Microgateway that request should be validated against the OpenAPI definition file of the requested API. If the request is valid, it is directed to the backend. If the request is invalid, error code 400 is returned. Whenever a response comes from the backend that response is validated against the OpenAPI definition file of the requested API. If the response is valid, it is directed to the user and if the response is invalid, error code 500 is returned.

When validating requests/responses, the validator gets the payload of the request/response and compares it with the relevant model defined in the OpenAPI definition file of the API. If there are any conflicts, the validator will identify that the request/response is an invalid request/response.

 

Request validation

  • Sending a valid request

 

  • Sending an invalid request

 

Response validation

  • The backend sends a valid response

 

  • The backend sends an invalid response 

 

Enable the schema validation

  • To enable request validation:

Copy following configuration from default-micro-gw.conf.template to micro-gw.conf file.

 

 

micro-gw.conf
[validationConfig] enableRequestValidation = true

 

  • To enable the response validation:

Copy following configuration from default-micro-gw.conf.template to micro-gw.conf file.

 

 

micro-gw.conf
[validationConfig] enableResponseValidation = true

 

 

Both request and response validation can be enabled by adding the both of the configurations to micro-gw.conf file.

Copy all the .jar files which are inside the <tool-kit-home>/lib/dependencies/validation to the <project>/lib directory before building the project.

Limitations

Micro-gateway currently supports only validation of application/json schemas. Furthermore the schema validation is limited to the validation of required fields.

 

Sample - Request Validation

Example
paths: /pet: post: tags: - pet summary: Add a new pet to the store description: Add a new pet to the store operationId: addPet requestBody: description: Create a new pet in the store content: application/json: schema: $ref: '#/components/schemas/Pet' required: true responses: '200': description: Successful operation content: application/json: schema: $ref: '#/components/schemas/Pet' '405': description: Invalid input components: schemas: Pet: required: - name - photoUrls type: object properties: id: type: integer format: int64 example: 10 name: type: string example: doggie photoUrls: type: array xml: wrapped: true items: type: string xml: name: photoUrl status: type: string description: pet status in the store enum: - available - pending - sold

 

 

     

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.