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

Fixed Hapi arrays to work as expected with swaggered-ui following swagger documentation #42

Merged
merged 1 commit into from
Aug 15, 2015

Conversation

Algiras
Copy link

@Algiras Algiras commented Aug 15, 2015

Following swagger-api/swagger-ui#982 and hapijs/joi#570 we can't pass comma separated values and use array as expected. So here is a solution that follows swagger documented approach to passing collections. In hapi terms we just add collectionFormat -> multi meta tag.

Joi.array().items(Joi.object()).meta({collectionFormat: 'multi'})

@Algiras
Copy link
Author

Algiras commented Aug 15, 2015

Just noticed, still have issue if there is only 1 parameter. :( Better then before, but there is no key[]=value type. https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md.
Current way to workaround is pass if there is only one param, to pass it twice. It's better then before, but still does not solve the main problem. There is no way to do this if swagger-spec doesn't change.

z0mt3c added a commit that referenced this pull request Aug 15, 2015
Fixed Hapi arrays to work as expected with swaggered-ui following swagger documentation
@z0mt3c z0mt3c merged commit 48dc143 into z0mt3c:master Aug 15, 2015
@z0mt3c
Copy link
Owner

z0mt3c commented Aug 15, 2015

Thanks! We should keep an eye on that one!

@z0mt3c z0mt3c self-assigned this Aug 15, 2015
@z0mt3c z0mt3c added the track label Aug 15, 2015
@Algiras
Copy link
Author

Algiras commented Aug 15, 2015

I created an issue about this: OAI/OpenAPI-Specification#442

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

Successfully merging this pull request may close these issues.

None yet

2 participants