krakenjs/hapi-openapi

Problem with optional strings

neilsouth opened this issue · 0 comments

Forgive me if Ive missed something but I have the following simple swagger

paths:
  /string:
    post:
      parameters:
        - name: stringBody
          in: body
          schema:
            $ref: "#/definitions/StringBody"
          required: true
      responses:
        200:
          description: All good

definitions:
  StringBody:
    type: object
    properties:
      stringBody:
        type: string
        maxLength: 13

I want Joi to have the .allow('') option on the payload of stringBody, but I cannot find a way to set this ?
so now if I curl with
curl localhost:8083/v2/string -H "Content-Type: application/json" -d '{"stringBody":""}'
I get
{"statusCode":400,"error":"Bad Request","message":"Invalid request payload input"}

it would be good to have some global option to set this for all string inputs, have I missed something ?

cheers