Проверка поля полезной нагрузки в WSO2 API Manager - PullRequest
1 голос
/ 21 января 2020

Я написал swagger и импортировал его, который будет проверять длину номера мобильного телефона, которая должна принимать 10 цифр, а также тип ввода, который должен принимать только 1 символ в качестве ввода, иначе он должен выдать ошибку. Но сообщение шло от APIM к ESB честно. Должен ли я сделать какие-либо изменения в API Manager или Code. Пожалуйста, предложите,

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

1 Ответ

3 голосов
/ 21 января 2020

Эта функция доступна в APIM 3.0.0. Вы должны включить его для каждого API, который вам нужен.

Вот что делает c. https://apim.docs.wso2.com/en/3.0.0/Learn/APISecurity/APIRequestResponseSchemaValidation/json-schema-validator/

...