@elysiajs/openapi 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2022 saltyAom
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # @elysiajs/openapi
2
+ Plugin for [elysia](https://github.com/elysiajs/elysia) to auto-generate API documentation page.
3
+
4
+ ## Installation
5
+ ```bash
6
+ bun add @elysiajs/openapi
7
+ ```
8
+
9
+ ## Example
10
+ ```typescript
11
+ import { Elysia, t } from 'elysia'
12
+ import { openapi } from '@elysiajs/openapi'
13
+
14
+ const app = new Elysia()
15
+ .use(openapi())
16
+ .get('/', () => 'hi', { response: t.String({ description: 'sample description' }) })
17
+ .post(
18
+ '/json/:id',
19
+ ({ body, params: { id }, query: { name } }) => ({
20
+ ...body,
21
+ id,
22
+ name
23
+ }),
24
+ {
25
+ params: t.Object({
26
+ id: t.String()
27
+ }),
28
+ query: t.Object({
29
+ name: t.String()
30
+ }),
31
+ body: t.Object({
32
+ username: t.String(),
33
+ password: t.String()
34
+ }),
35
+ response: t.Object({
36
+ username: t.String(),
37
+ password: t.String(),
38
+ id: t.String(),
39
+ name: t.String()
40
+ }, { description: 'sample description' })
41
+ }
42
+ )
43
+ .listen(8080);
44
+ ```
45
+
46
+ Then go to `http://localhost:8080/openapi`.
47
+
48
+ # config
49
+
50
+ ## enabled
51
+ @default true
52
+ Enable/Disable the plugin
53
+
54
+ ## documentation
55
+ OpenAPI documentation information
56
+
57
+ @see https://spec.openapis.org/oas/v3.0.3.html
58
+
59
+ ## exclude
60
+ Configuration to exclude paths or methods from documentation
61
+
62
+ ## exclude.methods
63
+ List of methods to exclude from documentation
64
+
65
+ ## exclude.paths
66
+ List of paths to exclude from documentation
67
+
68
+ ## exclude.staticFile
69
+ @default true
70
+
71
+ Exclude static file routes from documentation
72
+
73
+ ## exclude.tags
74
+ List of tags to exclude from documentation
75
+
76
+ ## path
77
+ @default '/openapi'
78
+
79
+ The endpoint to expose OpenAPI documentation frontend
80
+
81
+ ## provider
82
+ @default 'scalar'
83
+
84
+ OpenAPI documentation frontend between:
85
+ - [Scalar](https://github.com/scalar/scalar)
86
+ - [SwaggerUI](https://github.com/openapi-api/openapi-ui)
87
+ - null: disable frontend
88
+
89
+ ## references
90
+ Additional OpenAPI reference for each endpoint
91
+
92
+ ## scalar
93
+ Scalar configuration, refers to [Scalar config](https://github.com/scalar/scalar/blob/main/documentation/configuration.md)
94
+
95
+ ## specPath
96
+ @default '/${path}/json'
97
+
98
+ The endpoint to expose OpenAPI specification in JSON format
99
+
100
+ ## swagger
101
+ Swagger config, refers to [Swagger config](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/)