We are trying to validate a json in APIM 3.1.0 by defining the validation conditions in swagger definition and by enabling the schema validation under runtime configurations. PFA the Swagger definition.
When additional fields are passed in the request json apart from the fields defined in the swagger, the validation must fail or gateway should ignore those additional fields and shouldn't be passing it to the backend. But this is not happening currently, Could you please suggest us if we are missing anything here.
Sample Request JSON
Note : In this JSON, "test" field is an additional parameter sent in the request.
{ "applicationId": "Test123_3211", "name": "Bala krishna", "dateOfBirth": "1981-04-11", "gender": "FEMALE", "phonenumber": "9039283630", "altphonenumber": "9979979971", "panCard": "AAAAV1234N", "nomineeName": "Ramji Ambedkar", "nomineeDOB": "1976-04-14", "source": "ONLINE", "process": "Canara HSBC", "callDate": "2018-08-24", "callTime": "17:00", "merType": "VIDEOMER", "instantCall": true, "test": "abcd" }
Below is the swagger API :
swagger: "2.0" info: version: v1.0.0 title: MedicalBookAppointmentAPI description: "This API is for booking medical appointments. \n\nSupported operations :\n\n\t1. Docs APP " schemes:
- https
- http produces:
- application/json paths: /docs-app: post: summary: This API will be used to add cases and to schedule appointments. description: This API will be used to add cases and to schedule appointments. parameters: - in: body name: Payload description: Request Body required: true schema: $ref: "#/definitions/docs-app-request" responses: "200": description: OK schema: $ref: "#/definitions/docs-app-response" "400": schema: $ref: "#/definitions/book-appointment-api-error" description: Bad Request. Invalid request or validation error. "415": schema: $ref: "#/definitions/book-appointment-api-error" description: " Unsupported Media Type. The entity of the request was in a not supported format." "500": schema: $ref: "#/definitions/book-appointment-api-error" description: Internal Server Error produces: - application/json consumes: - application/json x-auth-type: "Application & Application User" x-throttling-tier: Unlimited definitions: docs-app-request: type: "object" required: - "applicationId" - "process" properties: applicationId: type: "string" name: type: "string" dateOfBirth: type: "string" pattern: "^\d{4}-\d{2}-\d{2}$" gender: type: "string" phonenumber: type: "number" altphonenumber: type: "number" panCard: type: "string" nomineeName: type: "string" nomineeDOB: type: "string" pattern: "^\d{4}-\d{2}-\d{2}$" source: type: "string" process: type: "string" planDetails: type: "string" priorityStatus: type: "string" callDate: type: "string" pattern: "^\d{4}-\d{2}-\d{2}$" callTime: type: "string" metaInfo: type: "string" instantCall: type: "boolean" merType: type: "string" enum: - "TELEMER" - "VIDEOMER" - "OTHERS" docs-app-response: type: object properties: data: type: object properties: approved: type: boolean isInternational: type: boolean id: format: int64 type: integer applicationId: type: string name: type: string dateOfBirth: type: string gender: type: string phonenumber: type: string altphonenumber: type: string panCard: type: string nomineeName: type: string nomineeDOB: type: string merType: type: string vendor: type: string updatedAt: type: string createdAt: type: string success: type: integer
book-appointment-api-error: title: Error object returned with HTTP status type: object properties: fault: type: object properties: code: format: int64 type: integer type: type: string message: description: Error message. type: string description: description: A detail description about the error message. type: string required: - code - message