- edited description
string field is parsed as number
Issue #266
closed
Using com.atlassian.oai:swagger-request-validator-wiremock:2.9.0
Swagger definition for parameter mobile is
swagger: '2.0'
info:
description: Search for a mobile
consumes:
- application/x-www-form-urlencoded
produces:
- application/x-www-form-urlencoded
paths:
/v4:
post:
summary: Search for a mobile
consumes:
- application/x-www-form-urlencoded
parameters:
- name: mobile
in: formData
required: true
type: string
minLength: 0
maxLength: 10
x-example: 0123456789
The following request
POST /v4 HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 17
Host: localhost:8080
Connection: close
Accept-Encoding: gzip, deflate
mobile=0123456789
raises the following validation error
com.atlassian.oai.validator.wiremock.OpenApiValidationListener$OpenApiValidationException: {
"messages" : [ {
"key" : "validation.request.body.schema.type",
"level" : "ERROR",
"message" : "[Path '/mobile'] Instance type (integer) does not match any allowed primitive type (allowed: [\"string\"])",
"context" : {
"requestPath" : "/v4",
"apiRequestContentType" : "application/x-www-form-urlencoded",
"location" : "REQUEST",
"requestMethod" : "POST"
}
} ]
}
It seems that mobile parameter is interpreted as number because it contains only digits. If it contains letters as well, then no validation error is raised.
Comments (5)
-
Account Deactivated reporter -
Account Deactivated reporter - edited description
-
Account Deactivated reporter - edited description
-
Account Deactivated reporter - edited description
-
Account Deactivated reporter - changed status to closed
- Log in to comment