Open no-more opened 8 years ago
HI
Try like that:
config: { description: 'Testing.', notes: ['Testing.'], tags: ['api', 'test'], handler: handler, validate: validate, response: { schema: respSchema }, plugins: { 'hapi-swagger': { responses: { 400: { 'description': 'Bad Request' }, 401: { 'description': 'Unauthorized' }, default: { 'description': 'Default response' } } } } }
Indrek
Thanks, I'll try that, do you think it's possible to :
Thanks
When I'm trying to registrer it at root level with glue :
{
plugin: {
register: 'hapi-swagger',
options: {
info: {
'title': Config.get('/server').title,
'version': Config.get('/server').version,
},
documentationPage: false,
swaggerUI: false,
tags: Config.get('/api').tags,
basePath: '/api/frontend',
pathPrefixSize: 3,
responses: {
default: {
schema: Joi.object(
{
test: Joi.string()
}
).label("testResponse")
}
}
}
}
},
I have the following swagger definition :
"responses": {
"default": {
"schema": {
"isJoi": true,
"_type": "object",
"_settings": null,
"_valids": {
"_set": []
},
"_invalids": {
"_set": []
},
"_tests": [],
"_refs": [],
"_flags": {
"label": "testResponse"
},
"_description": null,
"_unit": null,
"_notes": [],
"_tags": [],
"_examples": [],
"_meta": [],
"_inner": {
"children": [
{
"key": "test",
"schema": {
"isJoi": true,
"_type": "string",
"_settings": null,
"_valids": {
"_set": []
},
"_invalids": {
"_set": [
""
]
},
"_tests": [],
"_refs": [],
"_flags": {},
"_description": null,
"_unit": null,
"_notes": [],
"_tags": [],
"_examples": [],
"_meta": [],
"_inner": {}
}
}
],
"renames": [],
"dependencies": [],
"patterns": []
}
}
}
},
Hi,
Did you had time to have a look onto this please ?
Thanks a lot.
I'm also looking for something like this, any update?
Context
What are you trying to achieve or the steps to reproduce ?
I would like to define a default response for not 200 status code. This seems to be possible in swagger (http://swagger.io/specification/#responsesObject) but I wasn't able to define it in hapi.
Describe your issue here, include example
route
or JOI schemas.What result did you get?
I got an error,
Invalid routeConfig options
..."default" is not allowed
What did you expect ?
I know this might not be directly related to this plugin but I would like to know if you have some clues on how to deal with that or if I have to open a ticket on hapi ?
Thanks.