Skip to content

Commit 16c2776

Browse files
committed
#164 Upgrade dependencies and allow Koa V3
1 parent 77b9888 commit 16c2776

File tree

9 files changed

+2102
-3014
lines changed

9 files changed

+2102
-3014
lines changed

.changeset/funny-symbols-follow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'koa-oas3': minor
3+
---
4+
5+
Upgraded dependencies and now allow Koa Version 3. Fixed commas instead of semi-colons in config.

README.md

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,60 @@
11
# koa-oas3
2+
23
Request and Response validator for OpenAPI Specification 3.
34

4-
# Installation
5-
## npm
6-
```
5+
## Installation
6+
7+
### npm
8+
9+
```sh
710
npm install --save koa-oas3
811
```
9-
## yarn
10-
```
12+
13+
### yarn
14+
15+
```sh
1116
yarn add koa-oas3
1217
```
1318

14-
# API
19+
## API
20+
1521
By default, this library will use `koa-bodyparser` to parse request body. See config of `requestBodyHandler`.
1622

1723
```ts
18-
import * as bodyParser from 'koa-bodyparser';
19-
import { oas } from 'koa-oas3';
24+
import * as bodyParser from 'koa-bodyparser'
25+
import { oas } from 'koa-oas3'
2026

21-
const app = new Koa();
22-
app.use(bodyParser());
27+
const app = new Koa()
28+
app.use(bodyParser())
2329
const oasMw = await oas({
2430
file: `${__dirname}/../openapi.yaml`,
2531
endpoint: '/openapi.json',
2632
uiEndpoint: '/'
2733
})
28-
app.use(oasMw);
34+
app.use(oasMw)
2935

30-
app.listen(8080);
36+
app.listen(8080)
3137
```
3238

33-
## oas(option)
34-
35-
### options:
36-
37-
* `file` - The absolute path to your Openapi file
38-
* `spec` - javascript object defining the api, either this or `file` must be given.
39-
* `enableUi`(default: true) - Whether to enable serving Openapi JSON and UI
40-
* `endpoint`(default: /openapi.json) - The endpoint for serving Openapi JSON
41-
* `uiEndpoint`:(default: /openapi.html) - The endpoint for serving Openapi UI
42-
* `validateResponse`:(default: false) - Validate response against Openapi schemas
43-
* `validatePaths`:(default ['/']) - Only endpoints starting with the values specified here will be validated
44-
* `swaggerUiBundleBasePath`: (default use swagger-ui-dist from [unpkg](https://unpkg.com/)) - [swaggerUiAssetPath](https://www.npmjs.com/package/swagger-ui-dist) needed for loading the swagger-ui
45-
* `validationOptions`: Optional - options for sending to oas3-chow-chow/AJV
46-
* `oasValidatorOptions`: Optional - options for sending to oas-validator. https://github.com/Mermade/oas-kit/blob/main/docs/options.md
47-
* `qsParseOptions: { [key: string]: any}`: Optional - Options to be passed to the [query string](https://github.com/ljharb/qs) parse command. Default: `{ comma: true }`
48-
* `errorHandler: (error: Error, ctx: Context) => void,`: Optional - custom error hanlder.
49-
* `requestBodyHandler: { [key: string]: koa.Middleware }`: Optional - custom body handler. Defaults:
50-
```
39+
### oas(option)
40+
41+
#### options
42+
43+
- `file` - The absolute path to your Openapi file
44+
- `spec` - javascript object defining the api, either this or `file` must be given.
45+
- `enableUi`(default: true) - Whether to enable serving Openapi JSON and UI
46+
- `endpoint`(default: /openapi.json) - The endpoint for serving Openapi JSON
47+
- `uiEndpoint`:(default: /openapi.html) - The endpoint for serving Openapi UI
48+
- `validateResponse`:(default: false) - Validate response against Openapi schemas
49+
- `validatePaths`:(default ['/']) - Only endpoints starting with the values specified here will be validated
50+
- `swaggerUiBundleBasePath`: (default use swagger-ui-dist from [unpkg](https://unpkg.com/)) - [swaggerUiAssetPath](https://www.npmjs.com/package/swagger-ui-dist) needed for loading the swagger-ui
51+
- `validationOptions`: Optional - options for sending to oas3-chow-chow/AJV
52+
- `oasValidatorOptions`: Optional - options for sending to oas-validator. https://github.com/Mermade/oas-kit/blob/main/docs/options.md
53+
- `qsParseOptions: { [key: string]: any}`: Optional - Options to be passed to the [query string](https://github.com/ljharb/qs) parse command. Default: `{ comma: true }`
54+
- `errorHandler: (error: Error, ctx: Context) => void,`: Optional - custom error hanlder.
55+
- `requestBodyHandler: { [key: string]: koa.Middleware }`: Optional - custom body handler. Defaults:
56+
57+
```ts
5158
{
5259
'application/json': bodyParser({
5360
extendTypes: {
@@ -70,22 +77,22 @@ app.listen(8080);
7077
}
7178
```
7279

73-
## Contributors
80+
### Contributors
7481

7582
Pull requests, issues and comments welcome. For pull requests:
7683

77-
* Add tests for new features and bug fixes
78-
* Follow the existing style
79-
* Separate unrelated changes into multiple pull requests
80-
* See the existing issues for things to start contributing.
81-
* Generate changeset using `yarn changeset`
82-
* If there are dependency changes, update lock file with `yarn install`
84+
- Add tests for new features and bug fixes
85+
- Follow the existing style
86+
- Separate unrelated changes into multiple pull requests
87+
- See the existing issues for things to start contributing.
88+
- Generate changeset using `yarn changeset`
89+
- If there are dependency changes, update lock file with `yarn install`
8390

8491
For bigger changes, make sure you start a discussion first by creating an issue and explaining the intended change.
8592

8693
Atlassian requires contributors to sign a Contributor License Agreement, known as a CLA. This serves as a record stating that the contributor is entitled to contribute the code/documentation/translation to the project and is willing to have it used in distributions and derivative works (or is willing to transfer ownership).
8794

8895
Prior to accepting your contributions we ask that you please follow the appropriate link below to digitally sign the CLA. The Corporate CLA is for those who are contributing as a member of an organization and the individual CLA is for those contributing as an individual.
8996

90-
* [CLA for corporate contributors](https://na2.docusign.net/Member/PowerFormSigning.aspx?PowerFormId=e1c17c66-ca4d-4aab-a953-2c231af4a20b)
91-
* [CLA for individuals](https://na2.docusign.net/Member/PowerFormSigning.aspx?PowerFormId=3f94fbdc-2fbe-46ac-b14c-5d152700ae5d)
97+
- [CLA for corporate contributors](https://na2.docusign.net/Member/PowerFormSigning.aspx?PowerFormId=e1c17c66-ca4d-4aab-a953-2c231af4a20b)
98+
- [CLA for individuals](https://na2.docusign.net/Member/PowerFormSigning.aspx?PowerFormId=3f94fbdc-2fbe-46ac-b14c-5d152700ae5d)

0 commit comments

Comments
 (0)