Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot display array with multiple items in Responses or Request Models #79

Open
jlouthan opened this issue Mar 30, 2016 · 0 comments
Open

Comments

@jlouthan
Copy link

First of all thank you for this module! I am really liking it so far but have run into one issue. I have the following schema

var firstObj = Joi.object({
    prop1: Joi.string().only('apple').required(),
    prop2: Joi.string().only('banana').required()
}).required();

var secondObj = Joi.object({
    prop1: Joi.number().required()
}).required();

var userId = Joi.string().only('userId').required();

var batchResponse = Joi.array().items(firstObj, secondObj, userId);

and am including it as my response using the plugin way with schema:

config: {
    plugins: {
        'hapi-swaggered': {
            responses: batchResponse
        }
    }
}

Since this models an array with three Joi objects that are each required, I would expect the Response Model schema in the docs to look something like

[
  {
    "prop1": "apple",
    "prop2": "banana",
    "prop3": "Each response object will vary depending on the requests submitted"
  },
  {
    "prop1": 0
  },
  "userId": "userId"
]

But that's not the case. What shows up in the docs instead is

[
  "string"
]

Am I missing something here? I can get one object to appear in the Response Model array if I remove the required() from the array item models, but still cannot figure out how to display an array containing multiple Joi objects in the Response Schema. Is there a way to do this?

I am using the most current versions of hapi-swaggered (2.6.0), hapi-swaggered-ui (2.3.1), and joi (8.0.5)

Thank you very much!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant