directus-extension-api-docs 1.9.8 → 2.0.0
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/README.md +27 -12
- package/dist/index.js +4305 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ Directus Extension to include
|
|
|
7
7
|
-- custom endpoint definitions included
|
|
8
8
|
- validation middleware on your custom endpoints (based on your openapi)
|
|
9
9
|
|
|
10
|
+
> Compatible with latest versions of Directus and monorepo installation with packaged extension.
|
|
11
|
+
|
|
10
12
|

|
|
11
13
|
|
|
12
14
|
All directus endpoints are autogenerated on runtime.
|
|
@@ -30,7 +32,7 @@ Ref: https://github.com/directus/directus
|
|
|
30
32
|
|
|
31
33
|
To include you custom endpoints in your documentation.
|
|
32
34
|
|
|
33
|
-
Create a `oasconfig.yaml` file under `/extensions
|
|
35
|
+
Create a `oasconfig.yaml` file under `/extensions` folder.
|
|
34
36
|
|
|
35
37
|
Options:
|
|
36
38
|
|
|
@@ -71,7 +73,7 @@ components:
|
|
|
71
73
|
|
|
72
74
|
## Definitions (optional)
|
|
73
75
|
|
|
74
|
-
For each
|
|
76
|
+
For each endpoint extension, you can define api's including a file `oas.yaml` in root path of your extension endpoint folder.
|
|
75
77
|
|
|
76
78
|
Properties:
|
|
77
79
|
|
|
@@ -79,7 +81,7 @@ Properties:
|
|
|
79
81
|
- `paths` _optional_ openapi custom paths
|
|
80
82
|
- `components` _optional_ openapi custom components
|
|
81
83
|
|
|
82
|
-
Exemple below (`./extensions/
|
|
84
|
+
Exemple below (`./extensions/my-endpoint-extensions/oas.yaml`) :
|
|
83
85
|
|
|
84
86
|
```
|
|
85
87
|
tags:
|
|
@@ -120,31 +122,44 @@ components:
|
|
|
120
122
|
type: object # ref to standard components declaring it empty
|
|
121
123
|
```
|
|
122
124
|
|
|
125
|
+
### Legacy mode
|
|
126
|
+
|
|
127
|
+
Configuration and definitions can also be managed in this structure:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
- ./extensions/
|
|
131
|
+
- endpoints/
|
|
132
|
+
- oasconfig.yaml
|
|
133
|
+
- my-endpoint-extensions/
|
|
134
|
+
- oas.yaml
|
|
135
|
+
- my-endpoint-extensions2/
|
|
136
|
+
- oas.yaml
|
|
137
|
+
```
|
|
138
|
+
|
|
123
139
|
## Validations (optional)
|
|
124
140
|
|
|
125
141
|
You can enable a request validations middleware based on your custom definitions.
|
|
126
142
|
|
|
127
|
-
Call `validate` function inside your custom endpoint
|
|
143
|
+
Call `validate` function inside your custom endpoint source (`./extensions/my-endpoint-extensions/src/index.js`).
|
|
128
144
|
|
|
129
145
|
Pass your `router`, `services`, `schema` and a list (_optional_) of endpoints you want to validate.
|
|
130
146
|
|
|
131
147
|
Example below:
|
|
132
148
|
|
|
133
149
|
```
|
|
134
|
-
const { validate } = require('directus-extension-api-docs')
|
|
135
|
-
|
|
136
|
-
const id = 'my-custom-path';
|
|
150
|
+
const { validate } = require('directus-extension-api-docs')
|
|
137
151
|
|
|
138
|
-
|
|
139
|
-
id,
|
|
140
|
-
handler: async function registerEndpoint(router, { services, getSchema }) {
|
|
152
|
+
const id = 'my-custom-path'
|
|
141
153
|
|
|
154
|
+
export default {
|
|
155
|
+
id: 'info',
|
|
156
|
+
handler: async (router, { services, getSchema }) => {
|
|
142
157
|
const schema = await getSchema();
|
|
143
158
|
await validate(router, services, schema); // Enable validator
|
|
144
159
|
|
|
145
160
|
router.post('/my-endpoint', async (req, res, next) => {
|
|
146
161
|
...
|
|
147
|
-
})
|
|
162
|
+
})
|
|
148
163
|
},
|
|
149
|
-
}
|
|
164
|
+
}
|
|
150
165
|
```
|