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

问题描述 投票:0回答:1

我写了一个大字并输入了相同的字母,这将验证手机号码的长度,该长度应为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
wso2 swagger wso2-am swagger-2.0
1个回答
0
投票
此功能在APIM 3.0.0中可用。您必须为每个所需的API启用它。

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

© www.soinside.com 2019 - 2024. All rights reserved.