hapi-swaggered icon indicating copy to clipboard operation
hapi-swaggered copied to clipboard

Array of objects turns to array of strings

Open idoshamun opened this issue 9 years ago • 1 comments

I define my response schema as follows:

    response: {
        schema: Joi.object().keys({
            code: models.familyCode,
            familyName: models.name.required().description('Family name'),
            accessToken: models.accessToken,
            members: Joi.array(models.familyMember)
        }).meta({ className: 'Login output' }),
        status: {
            400: models.error,
            500: models.error
        }
    }

where models.familyMember is as follows:

familyMember: Joi.object().keys({
        firstName: name.required(),
        lastName: name.required(),
        lastAlive: Joi.date().required(),
        battery: Joi.number().required().min(-1).max(100)
    }).meta({ className: 'Family member' })

Swagger shows the input as follows:

{
  "code": "string",
  "familyName": "string",
  "accessToken": {
    "token": "string",
    "expiration": "2015-11-01T16:18:44.613Z"
  },
  "members": [
    "string"
  ]
}

I can't figure how to solve this issue

idoshamun avatar Nov 01 '15 16:11 idoshamun

I'm seeing this as well. I have an object that is returned for a /path/id (let's call it testObject) and for /path/ I specify the response as joi.array ().items (testObject) but the doc generates array [ string ].

fluky avatar Apr 09 '16 20:04 fluky