WSO2 API 管理器中的有效负载字段验证

Payload field validation in WSO2 API Manager

我写了一个 swagger 并导入了它,它将验证手机号码的长度,它应该采用 10 位数字,还有一个输入类型,它应该只接受 1 个字符作为输入,否则它应该抛出一个错误。但是消息从 APIM 公平地发送到 ESB。我是否应该在 API 管理器或代码中进行更多更改。请建议,

swagger: "2.0"
info:
  version: v1.0.0
  title: TestValidation
  description: "This API to Test length Validation\n\n\nSupported operations :\n\n1.  validation"
schemes:
  - https
  - http
consumes:
  - application/json
produces:
  - application/json
paths:
  /validation:
    post:
      summary: dfgdf
      description: fghfg
      parameters:
        - in: body
          name: Payload
          description: Request Body
          required: false
          schema:
            $ref: "#/definitions/validation-request"
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/validation-response"
        "400":
          schema:
            $ref: "#/definitions/TestValidation-api-error"
          description: Bad Request. Invalid request or validation error.
        "415":
          schema:
            $ref: "#/definitions/TestValidation-api-error"
          description: Unsupported Media Type. The entity of the request was in a not supported format.
        "500":
          schema:
            $ref: "#/definitions/TestValidation-api-error"
          description: Internal Server Error
      produces:
        - application/json
      consumes:
        - application/json
      x-auth-type: "Application & Application User"
      x-throttling-tier: Unlimited
definitions:
  validation-request:
    type: object
    properties:
      MobileNum:
        format: int64
        type: number
        minLength: 10
        maxLength: 10
      inputType:
        type: string
        minLength: 1
        maxLength: 1
  validation-response:
    type: object
    properties:
      response:
        type: object
  TestValidation-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

此功能在 APIM 3.0.0 中可用。您必须为每个 API 启用它。

这是文档。 https://apim.docs.wso2.com/en/3.0.0/Learn/APISecurity/APIRequestResponseSchemaValidation/json-schema-validator/