Closed xargi closed 8 years ago
I have a route definition as follows:
{ method: 'GET', path: '/hello/{name}', config: { tags: ['api'], description: 'Write "Hello, {name}"', handler: Handlers.writeHelloName, validate: { params: { name: Joi.string().required().example('Bob') .description('Name to hello to'), }, }, }, }
Hapi-swagger produces the following spec for the route:
"/hello/{name}": { "get": { "responses": { "default": { "schema": { "type": "string" }, "description": "Successful" } }, "parameters": [ { "description": "Name to hello to", "in": "path", "example": "Bob", "required": true, "name": "name", "type": "string" } ], "tags": [ "hello" ], "operationId": "getHelloName", "summary": "Write \"Hello, {name}\"" } }
Attempting to validate this causes a validation error: "Additional properties not allowed: example" for the parameters block. Removing the examples from the Joi-schema for the parameters causes the generated swagger.json to pass validation.
Thanks for pointing this out fix in v6.2.0.
Its now formatted in JSON as x-example which will validate correctly.
x-example
I have a route definition as follows:
Hapi-swagger produces the following spec for the route:
Attempting to validate this causes a validation error: "Additional properties not allowed: example" for the parameters block. Removing the examples from the Joi-schema for the parameters causes the generated swagger.json to pass validation.