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
-optional validation middleware for your custom endpoints (based on merged OpenAPI spec). See details below
11
11
12
12

13
13
14
14
## Prerequisites
15
15
16
-
Working in a Directus nodejs project
16
+
You must already have a Directus Node.js project running.
17
17
18
18
Ref: https://github.com/directus/directus
19
19
20
20
## Installation
21
21
22
-
npm install directus-extension-api-docs
22
+
npm install directus-extension-api-docs
23
23
24
24
- Swagger interface: by default `http://localhost:8055/api-docs`
25
25
- Openapi documentation: by default `http://localhost:8055/api-docs/oas`
26
26
27
27
## Configuration (optional)
28
28
29
-
To include you custom endpoints in your documentation.
30
-
31
-
Create a `oasconfig.yaml` file under `/extensions` folder.
29
+
To include your custom endpoints in the documentation, create an `oasconfig.yaml` file directly under the `/extensions` folder (recommended structure). Avoid placing it under `/extensions/endpoints` unless using Legacy mode.
32
30
33
31
Options:
34
32
35
-
-`docsPath`_optional_path where the interface will be (default 'api-docs')
33
+
-`docsPath`_optional_ interface base path (default 'api-docs'). Resulting URLs: `/<docsPath>` and `/<docsPath>/oas`.
36
34
-`info`_optional_ openapi server info (default extract from package.json)
37
35
-`tags`_optional_ openapi custom tags (will be merged with all standard and all customs tags)
38
-
-`publishedTags`_optional_ if specified, will be published definitions only for specified tags
39
-
-`paths`_optional_ openapi custom paths (will be merged with all standard and all customs paths)
40
-
-`components`_optional_ openapi custom components (will be merged with all standard and all customs tags)
36
+
-`publishedTags`_optional_ if specified, only operations containing at least one of these tags are kept; all other paths and unused tags are removed.
37
+
-`paths`_optional_ custom path objects keyed by full path (e.g. `/my-custom-path/my-endpoint`). These are merged into Directus core paths.
38
+
-`components`_optional_ custom components (schemas, securitySchemes, etc.) shallow-merged over core components.
39
+
-`useAuthentication`_optional_ (default false). When true, `/api-docs` and `/api-docs/oas` stay publicly reachable: without valid auth they list only anonymous/public paths (no custom endpoints); with auth they list only paths permitted to that user under Directus Access Policies and custom endpoints.
41
40
42
41
Example below:
43
42
44
43
```
45
44
docsPath: 'api-docs'
45
+
useAuthentication: true
46
46
info:
47
47
title: my-directus-bo
48
48
version: 1.5.0
@@ -69,15 +69,15 @@ components:
69
69
70
70
## Definitions (optional)
71
71
72
-
For each endpoint extension, you can define api's including a file `oas.yaml` in root path of your extension endpoint folder.
72
+
For each endpoint extension, you can define OpenAPI partials by adding an `oas.yaml`file in the root of that endpoint's folder.
73
73
74
74
Properties:
75
75
76
76
-`tags`_optional_ openapi custom tags
77
77
-`paths`_optional_ openapi custom paths
78
78
-`components`_optional_ openapi custom components
79
79
80
-
Exemple below (`./extensions/my-endpoint-extensions/oas.yaml`):
80
+
Example below (`./extensions/my-endpoint-extensions/oas.yaml`):
81
81
82
82
```
83
83
tags:
@@ -127,7 +127,7 @@ components:
127
127
128
128
### Legacy mode
129
129
130
-
Configuration and definitions can also be managed in this structure:
130
+
Configuration and definitions can also be managed in this legacy structure (still supported, but prefer the simplified root placement):
131
131
132
132
```
133
133
- ./extensions/
@@ -141,11 +141,11 @@ Configuration and definitions can also be managed in this structure:
141
141
142
142
## Validations (optional)
143
143
144
-
You can enable a request validations middleware based on your custom definitions.
144
+
You can enable a request validation middleware based on your merged custom definitions.
145
145
146
-
Call `validate` function inside your custom endpoint source (`./extensions/my-endpoint-extensions/src/index.js`).
146
+
Call the `validate` function inside your custom endpoint source (`./extensions/my-endpoint-extensions/src/index.js`).
147
147
148
-
Pass your `router`, `services`, `schema` and a list (_optional_) of endpoints you want to validate.
148
+
Arguments: `validate(router, services, schema, paths?)`. `paths` (optional array) lets you restrict validation to only specific path keys from `oasconfig.yaml` instead of all custom paths.
Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "directus-extension-api-docs",
3
-
"version": "2.1.16",
3
+
"version": "2.2.0",
4
4
"description": "directus extension for swagger interface and openapi including custom endpoints definitions // custom endpoint validations middleware based on openapi",
0 commit comments