diff --git a/example/README.md b/example/README.md index 566889a1..de491602 100644 --- a/example/README.md +++ b/example/README.md @@ -153,7 +153,10 @@ new OpenApiValidator({ .then(app => { // 5. Define routes using Express app.get('/v1/pets', function(req, res, next) { - res.json([{ id: 1, name: 'max' }, { id: 2, name: 'mini' }]); + res.json([ + { id: 1, name: 'max' }, + { id: 2, name: 'mini' }, + ]); }); app.post('/v1/pets', function(req, res, next) { @@ -364,7 +367,7 @@ new OpenApiValidator(options).install({ validateResponses: true, ignorePaths: /.*\/pets$/ unknownFormats: ['phone-number', 'uuid'], - multerOpts: { ... }, + fileUploader: { ... }, securityHandlers: { ApiKeyAuth: (req, scopes, schema) => { throw { status: 401, message: 'sorry' } @@ -461,10 +464,22 @@ Defines how the validator should behave if an unknown or custom format is encoun - `"ignore"` - to log warning during schema compilation and always pass validation. This option is not recommended, as it allows to mistype format name and it won't be validated without any error message. -### ▪️ multerOpts (optional) +### ▪️ fileUploader (optional) Specifies the options to passthrough to multer. express-openapi-validator uses multer to handle file uploads. see [multer opts](https://github.com/expressjs/multer) +- `true` (**default**) - enables multer and provides simple file(s) upload capabilities +- `false` - disables file upload capability. Upload capabilities may be provided by the user +- `{...}` - multer options to be passed-through to multer. see [multer opts](https://github.com/expressjs/multer) for possible options + + e.g. + + ```javascript + fileUploader: { + dest: 'uploads/'; + } + ``` + ### ▪️ coerceTypes (optional) Determines whether the validator should coerce value types to match the type defined in the OpenAPI spec. diff --git a/test/multipart.disabled.spec.ts b/test/multipart.disabled.spec.ts index 21b66633..80fe7158 100644 --- a/test/multipart.disabled.spec.ts +++ b/test/multipart.disabled.spec.ts @@ -58,8 +58,8 @@ describe(packageJson.name, () => { .send('form_p1=stuff&form_p2=morestuff') .expect(200)); - // TODO make this work when fileUpload i.e. multer is disabled - it.skip('should return 200 for multipart/form-data with p1 and p2 fields present (with fileUpload false)', async () => + // TODO make this work when fileUploader i.e. multer is disabled + it.skip('should return 200 for multipart/form-data with p1 and p2 fields present (with fileUploader false)', async () => request(app) .post(`${app.basePath}/sample_1`) .set('Content-Type', 'multipart/form-data')