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)
41
-
-`useAuthentication`_optional_ (default false). When enabled, access to `/api-docs` and `/api-docs/oas`requires a Directus admin cookie, static token, or Bearer JWT. Authorization is applied per endpoint based on Directus Access Policies, ensuring users only see endpoints they are allowed to access.
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.
42
40
43
41
Example below:
44
42
@@ -71,15 +69,15 @@ components:
71
69
72
70
## Definitions (optional)
73
71
74
-
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.
75
73
76
74
Properties:
77
75
78
76
-`tags`_optional_ openapi custom tags
79
77
-`paths`_optional_ openapi custom paths
80
78
-`components`_optional_ openapi custom components
81
79
82
-
Exemple below (`./extensions/my-endpoint-extensions/oas.yaml`):
80
+
Example below (`./extensions/my-endpoint-extensions/oas.yaml`):
83
81
84
82
```
85
83
tags:
@@ -129,7 +127,7 @@ components:
129
127
130
128
### Legacy mode
131
129
132
-
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):
133
131
134
132
```
135
133
- ./extensions/
@@ -143,11 +141,11 @@ Configuration and definitions can also be managed in this structure:
143
141
144
142
## Validations (optional)
145
143
146
-
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.
147
145
148
-
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`).
149
147
150
-
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.
0 commit comments