You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Request and Response validator for OpenAPI Specification 3.
3
4
4
-
# Installation
5
-
## npm
6
-
```
5
+
## Installation
6
+
7
+
### npm
8
+
9
+
```sh
7
10
npm install --save koa-oas3
8
11
```
9
-
## yarn
10
-
```
12
+
13
+
### yarn
14
+
15
+
```sh
11
16
yarn add koa-oas3
12
17
```
13
18
14
-
# API
19
+
## API
20
+
15
21
By default, this library will use `koa-bodyparser` to parse request body. See config of `requestBodyHandler`.
16
22
17
23
```ts
18
-
import*asbodyParserfrom'koa-bodyparser';
19
-
import { oas } from'koa-oas3';
24
+
import*asbodyParserfrom'koa-bodyparser'
25
+
import { oas } from'koa-oas3'
20
26
21
-
const app =newKoa();
22
-
app.use(bodyParser());
27
+
const app =newKoa()
28
+
app.use(bodyParser())
23
29
const oasMw =awaitoas({
24
30
file: `${__dirname}/../openapi.yaml`,
25
31
endpoint: '/openapi.json',
26
32
uiEndpoint: '/'
27
33
})
28
-
app.use(oasMw);
34
+
app.use(oasMw)
29
35
30
-
app.listen(8080);
36
+
app.listen(8080)
31
37
```
32
38
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 }`
-`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 }`
Pull requests, issues and comments welcome. For pull requests:
76
83
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`
83
90
84
91
For bigger changes, make sure you start a discussion first by creating an issue and explaining the intended change.
85
92
86
93
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).
87
94
88
95
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.
89
96
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