Skip to content

Commit 305d5db

Browse files
authored
doc: Clean up README and Nestjs Example (#559)
* doc: Remove Q&A for Upgrade from v2 to v3 The `installSync` method and `synchronous` README section mentioned in the answer no longer exist in v4. * doc: Fix Typos in README * doc: Remove Vestiges of Config Module from NestJS Example
1 parent 45a40b7 commit 305d5db

File tree

4 files changed

+22
-61
lines changed

4 files changed

+22
-61
lines changed

README.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Use express-openapi-validator's OpenAPI `x-eov-operation-*` vendor extensions. S
172172

173173
**Here's the gist**
174174

175-
- First, specifiy the `operationHandlers` option to set the base directory that contains your operation handler files.
175+
- First, specify the `operationHandlers` option to set the base directory that contains your operation handler files.
176176

177177
```javascript
178178
app.use(
@@ -205,7 +205,7 @@ app.use(
205205

206206
```javascript
207207
module.exports = {
208-
// the express handler implementaiton for ping
208+
// the express handler implementation for ping
209209
ping: (req, res) => res.status(200).send('pong'),
210210
};
211211
```
@@ -275,7 +275,7 @@ module.exports = app;
275275
# OpenAPI's operationId may be used to to specify the operation id
276276
operationId: ping
277277
# x-eov-operation-id may be used to specify the operation id
278-
# Used when operationId is omiited. Overrides operationId when both are specified
278+
# Used when operationId is omitted. Overrides operationId when both are specified
279279
x-eov-operation-id: ping
280280
# specifies the path to the operation handler.
281281
# the path is relative to the operationHandlers option
@@ -518,7 +518,7 @@ OpenApiValidator.middleware({
518518

519519
### ▪️ apiSpec (required)
520520

521-
Specifies the path to an OpenAPI 3 specification or a JSON object representing the OpenAPI 3 specificiation
521+
Specifies the path to an OpenAPI 3 specification or a JSON object representing the OpenAPI 3 specification
522522

523523
```javascript
524524
apiSpec: './path/to/my-openapi-spec.yaml';
@@ -600,7 +600,7 @@ Determines whether the validator should validate requests.
600600

601601
**removeAdditional:**
602602

603-
Determines whether to keep or remove additional properties in request body or to fail validation if schema has `additionalProperties` set to `false`. For futher details, refer to [AJV documentation](https://ajv.js.org/docs/validation.html#removing-additional-properties)
603+
Determines whether to keep or remove additional properties in request body or to fail validation if schema has `additionalProperties` set to `false`. For further details, refer to [AJV documentation](https://ajv.js.org/docs/validation.html#removing-additional-properties)
604604

605605
- `false` (**default**) - not to remove additional properties
606606
- `"all"` - all additional properties are removed, regardless of additionalProperties keyword in schema (and no validation is made for them).
@@ -683,14 +683,14 @@ Determines whether the validator should validate securities e.g. apikey, basic,
683683

684684
Determines whether the validator should validate the OpenAPI specification. Useful if you are certain that the api spec is syntactically correct and want to bypass this check.
685685

686-
*Warning:* e certain your spec is valid. And be sure you know what you're doing! express-openapi-validator _*expects*_ are valid spec. If incorrect, the validator will behave erradically and/or throw Javascript errors.
686+
*Warning:* Be certain your spec is valid. And be sure you know what you're doing! express-openapi-validator _*expects*_ a valid spec. If incorrect, the validator will behave erratically and/or throw Javascript errors.
687687

688688
- `true` (**default**) - validate the OpenAPI specification.
689689
- `false` - do not validate the OpenAPI specification.
690690

691691
### ▪️ formats (optional)
692692

693-
Defines a list of custome formats.
693+
Defines a list of custom formats.
694694

695695
- `[{ ... }]` - array of custom format objects. Each object must have the following properties:
696696
- name: string (required) - the format name
@@ -728,7 +728,7 @@ my_property:
728728
729729
Specifies the strictness of validation of string formats.
730730
731-
- `"fast"` (**default**) - only validate syntax, but not semantics. E.g. `2010-13-30T23:12:35Z` will pass validation eventhough it contains month 13.
731+
- `"fast"` (**default**) - only validate syntax, but not semantics. E.g. `2010-13-30T23:12:35Z` will pass validation even though it contains month 13.
732732
- `"full"` - validate both syntax and semantics. Illegal dates will not pass.
733733
- `false` - do not validate formats at all.
734734

@@ -796,7 +796,7 @@ See [mongo-serdes-js](https://github.com/pilerou/mongo-serdes-js) for additional
796796

797797
Defines the base directory for operation handlers. This is used in conjunction with express-openapi-validator's OpenAPI vendor extensions, `x-eov-operation-id`, `x-eov-operation-handler` and OpenAPI's `operationId`. See [example](https://github.com/cdimascio/express-openapi-validator/tree/master/examples/3-eov-operations).
798798

799-
Additionally, if you want to change how modules are resolved e.g. use dot deliminted operation ids e.g. `path.to.module.myFunction`, you may optionally add a custom `resolver`. See [documentation and example](https://github.com/cdimascio/express-openapi-validator/tree/master/examples/5-custom-operation-resolver)
799+
Additionally, if you want to change how modules are resolved e.g. use dot delimited operation ids e.g. `path.to.module.myFunction`, you may optionally add a custom `resolver`. See [documentation and example](https://github.com/cdimascio/express-openapi-validator/tree/master/examples/5-custom-operation-resolver)
800800

801801
- `string` - the base directory containing operation handlers
802802
- `false` - (default) disable auto wired operation handlers
@@ -833,7 +833,7 @@ Complete example [here](https://github.com/cdimascio/express-openapi-validator/t
833833
# OpenAPI's operationId may be used to to specify the operation id
834834
operationId: ping
835835
# x-eov-operation-id may be used to specify the operation id
836-
# Used when operationId is omiited. Overrides operationId when both are specified
836+
# Used when operationId is omitted. Overrides operationId when both are specified
837837
x-eov-operation-id: ping
838838
# specifies the path to the operation handler.
839839
# the path is relative to the operationHandlers option
@@ -909,7 +909,7 @@ $refParser: {
909909

910910
### ▪️ coerceTypes (optional) - _deprecated_
911911

912-
Determines whether the validator should coerce value types to match the those defined in the OpenAPI spec. This option applies **only** to path params, query strings, headers, and cookies. _It is **highly unlikley** that will want to disable this. As such this option is deprecated and will be removed in the next major version_
912+
Determines whether the validator should coerce value types to match the those defined in the OpenAPI spec. This option applies **only** to path params, query strings, headers, and cookies. _It is **highly unlikely** that you will want to disable this. As such this option is deprecated and will be removed in the next major version_
913913

914914
- `true` (**default**) - coerce scalar data types.
915915
- `"array"` - in addition to coercions between scalar types, coerce scalar data to an array with one element and vice versa (as required by the schema).
@@ -939,7 +939,7 @@ In some cases, it may be necessary to _**skip validation** for paths **under the
939939

940940
## Security handlers
941941

942-
> **Note:** security `handlers` are an optional component. security `handlers` provide a convenience, whereby the request, declared scopes, and the security schema itself are provided as parameters to each security `handlers` callback that you define. The code you write in each callback can then perform authentication and authorization checks. **_Note that the same can be achieved using standard Express middleware_. The difference** is that security `handlers` provide you the OpenAPI schema data described in your specification\_. Ulimately, this means, you don't have to duplicate that information in your code.
942+
> **Note:** security `handlers` are an optional component. security `handlers` provide a convenience, whereby the request, declared scopes, and the security schema itself are provided as parameters to each security `handlers` callback that you define. The code you write in each callback can then perform authentication and authorization checks. **_Note that the same can be achieved using standard Express middleware_. The difference** is that security `handlers` provide you the OpenAPI schema data described in your specification\_. Ultimately, this means, you don't have to duplicate that information in your code.
943943

944944
> All in all, security `handlers` are purely optional and are provided as a convenience.
945945

@@ -1144,7 +1144,7 @@ module.exports = app;
11441144

11451145
**A:** OpenAPI 3.0 does not support RFC-6570. That said, we provide a minimalistic mechanism that conforms syntactically to OpenAPI 3 and accomplishes a common use case. For example, matching file paths and storing the matched path in `req.params`
11461146

1147-
Using the following OpenAPI 3.x defintion
1147+
Using the following OpenAPI 3.x definition
11481148

11491149
```yaml
11501150
/files/{path}*:
@@ -1157,7 +1157,7 @@ Using the following OpenAPI 3.x defintion
11571157
type: string
11581158
```
11591159
1160-
With the following Express route defintion
1160+
With the following Express route definition
11611161
11621162
```javascript
11631163
app.get(`/files/:path(*)`, (req, res) => { /* do stuff */ }`
@@ -1194,10 +1194,6 @@ properties:
11941194
type: string
11951195
```
11961196
1197-
**Q:** I upgraded from from v2 to v3 and validation no longer works. How do I fix it?
1198-
1199-
**A**: In version 2.x.x, the `install` method was executed synchronously, in 3.x it's executed asynchronously. To get v2 behavior in v3, use the `installSync` method. See the [synchronous](#synchronous) section for details.
1200-
12011197
**Q:** Can I use `express-openapi-validator` with `swagger-ui-express`?
12021198

12031199
**A:** Yes. Be sure to `use` the `swagger-ui-express` serve middleware prior to installing `OpenApiValidator`. This will ensure that `swagger-ui-express` is able to fully prepare the spec before before OpenApiValidator attempts to use it. For example:

examples/9-nestjs/package-lock.json

Lines changed: 6 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/9-nestjs/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
},
2020
"dependencies": {
2121
"@nestjs/common": "^7.6.12",
22-
"@nestjs/config": "^0.6.3",
2322
"@nestjs/core": "^7.6.12",
2423
"@nestjs/platform-express": "^7.6.12",
25-
"express-openapi-validator": "^4.10.11",
24+
"express-openapi-validator": "^4.12.4",
2625
"reflect-metadata": "^0.1.13",
2726
"rxjs": "^6.6.3",
2827
"shx": "^0.3.3"

examples/9-nestjs/src/app.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
2-
import { ConfigModule } from '@nestjs/config';
32
import { APP_FILTER } from '@nestjs/core';
43
import * as OpenApiValidator from 'express-openapi-validator';
54
import { join } from 'path';
65
import { PingModule } from './modules/ping/ping.module';
76
import { OpenApiExceptionFilter } from './filters/openapi-exception.filter';
87

98
@Module({
10-
imports: [ConfigModule.forRoot(), PingModule],
9+
imports: [PingModule],
1110
providers: [{ provide: APP_FILTER, useClass: OpenApiExceptionFilter }],
1211
})
1312
export class AppModule implements NestModule {

0 commit comments

Comments
 (0)