How to disallow spaces/empty string in number field in Open API?

2.1k views Asked by At

I have defined a 'number' field in my Open API documentation. In the request if I provide a string with only spaces the field gets processed as null while any other string gives bad request response.

I want to have bad request response for all the cases where a proper number isn't provided including when an empty string or spaces are there.

Open API snippet:

 UpdateListRequest:
  type: object
  properties:
    numberField:
      type: integer
      format: int32
      minimum: 1
      maximum: 4
  required:
    - action

Note: the number field is not a required field.

This is a gradle 6.0 project and source is at java version 1.8

My dependencies are -

dependencies {

compile group: 'io.swagger.core.v3', name: 'swagger-core', version: '2.0.9'
swaggerUI group: 'org.webjars', name: 'swagger-ui', version: '3.23.8'
swaggerCodegen 'io.swagger.codegen.v3:swagger-codegen-cli:3.0.11'

}

0

There are 0 answers