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

Swagger schema validation failed. #157

Open
indreek opened this issue May 24, 2017 · 0 comments
Open

Swagger schema validation failed. #157

indreek opened this issue May 24, 2017 · 0 comments

Comments

@indreek
Copy link

indreek commented May 24, 2017

I have a route with joy validation.
{
method: 'GET',
path : '/users/login_history/{historyLength?}',
config: {
description: 'Get login history for current user.',
notes : 'Get login history for current user.',
tags : ['api', 'get', 'user', 'history', 'login', 'current'],
handler : userController.listLoginHistory,
validate : userValidate.listLoginHistory,
response : {schema: userModel.listLoginHistory},
plugins : {
'hapi-swagger': {
responseMessages: [
{code: 400, message: 'Bad Request'},
{code: 401, message: 'Unauthorized'}
]
}
}
}

userValidate.listLoginHistory : {
params : Joi.object({historyLength: Joi.number().integer().default(5)}).meta({className: 'listLoginHistory'}),
headers: AuthSchema.headers
}

And i get error
Swagger schema validation failed.
Data does not match any schemas from 'oneOf' at #/paths//users/login_history/{historyLength}/get/parameters/0
Data does not match any schemas from 'oneOf' at #/paths//users/login_history/{historyLength}/get/parameters/0
Missing required property: schema at #/
Data does not match any schemas from 'oneOf' at #/
No enum match for: path at #/in
No enum match for: path at #/in
No enum match for: path at #/in
No enum match for: false at #/required
Missing required property: $ref at #/paths//users/login_history/{historyLength}/get/parameters/0

JSON_OBJECT_VALIDATION_FAILED
}

If i change historyLength to .required() error dissapears. How to describe optional parameter?

Thanks,
Indrek

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