krakenjs / hapi-openapi

Build design-driven apis with OpenAPI (formerly swagger) 2.0 and hapi.
Other
211 stars 75 forks source link

Problem with optional strings #185

Open neilsouth opened 3 years ago

neilsouth commented 3 years ago

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