directus-extension-api-docs 1.4.3 → 1.4.5
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 +9 -1
- package/dist/index.js +1 -1
- package/package.json +62 -62
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/types.d.ts +0 -22
- package/dist/types.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -6
- package/dist/utils.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ components:
|
|
|
55
55
|
|
|
56
56
|
## Definitions (optional)
|
|
57
57
|
|
|
58
|
-
For each custom endpoints group, you can define api's including a file `oas.yaml` in
|
|
58
|
+
For each custom endpoints group, you can define api's including a file `oas.yaml` in root path of your group folder.
|
|
59
59
|
|
|
60
60
|
Properties:
|
|
61
61
|
|
|
@@ -72,6 +72,8 @@ tags:
|
|
|
72
72
|
paths:
|
|
73
73
|
"/my-custom-path/my-endpoint":
|
|
74
74
|
post:
|
|
75
|
+
summary: Validate email
|
|
76
|
+
description: Validate email
|
|
75
77
|
tags:
|
|
76
78
|
- MyCustomTag2
|
|
77
79
|
- MyCustomTag
|
|
@@ -90,6 +92,12 @@ paths:
|
|
|
90
92
|
'401':
|
|
91
93
|
description: Unauthorized
|
|
92
94
|
content: {}
|
|
95
|
+
'422':
|
|
96
|
+
description: Unprocessable Entity
|
|
97
|
+
content: {}
|
|
98
|
+
'500':
|
|
99
|
+
description: Server Error
|
|
100
|
+
content: {}
|
|
93
101
|
components:
|
|
94
102
|
schemas:
|
|
95
103
|
Users:
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("js-yaml"),
|
|
1
|
+
"use strict";const e=require("js-yaml"),n=require("path"),s=require("fs"),t=process.cwd();let o;async function i(e,n){if(o)return JSON.parse(o);const{SpecificationService:s}=e,t=new s({accountability:{admin:!0},schema:n});return o=JSON.stringify(await t.oas.generate()),JSON.parse(o)}function a(e,n){return Object.entries(n).reduce(((e,[n,s])=>(e[n]=s&&"object"==typeof s?a(e[n]=e[n]||(Array.isArray(s)?[]:{}),s):s,e)),e)}const r=require("swagger-ui-express"),c=require("express-openapi-validator"),{findWorkspaceDir:p}=require("@pnpm/find-workspace-dir"),l=function(){try{const o=n.join(t,"./extensions/endpoints/oasconfig.yaml"),i=e.load(s.readFileSync(o,{encoding:"utf-8"})),r=n.join(t,"./extensions/endpoints"),c=s.readdirSync(r,{withFileTypes:!0});for(const n of c){const t=`${r}/${n.name}/oas.yaml`;if(n.isDirectory()&&s.existsSync(t)){const n=e.load(s.readFileSync(t,{encoding:"utf-8"}));i.tags=[...i.tags,...n.tags],i.paths={...i.paths,...n.paths},i.components=a(i.components||{},n.components||{})}}return i}catch(e){return{}}}(),u=(null==l?void 0:l.docsPath)||"api-docs";var d={id:u,validate:async function(e,n,s,t){if(null==l?void 0:l.paths){const o=await i(n,s);if(t)for(const e of t)o.paths[e]=l.paths[e];else o.paths=l.paths;l.components?o.components=l.components:(delete o.components.definitions,delete o.components.schemas),e.use(c.middleware({apiSpec:o})),e.use(((e,n,s,t)=>{s.status(e.status||500).json({message:e.message,errors:e.errors})}))}return e},handler:(e,{services:n,exceptions:s,logger:t,getSchema:o})=>{const{ServiceUnavailableException:c}=s,d={swaggerOptions:{url:`/${u}/oas`}};e.use("/",r.serve),e.get("/",r.setup({},d)),e.get("/oas",(async(e,s,r)=>{try{const e=await o(),r=await i(n,e);try{const e=require(`${await p(".")}/package.json`);(null==e?void 0:e.name)&&(r.info.title=null==e?void 0:e.name),(null==e?void 0:e.version)&&(r.info.version=null==e?void 0:e.version),(null==e?void 0:e.description)&&(r.info.description=null==e?void 0:e.description)}catch(e){}try{if(null==l?void 0:l.paths)for(const e in l.paths)r.paths[e]=l.paths[e];if(null==l?void 0:l.tags)for(const e of l.tags)r.tags.push(e);(null==l?void 0:l.components)&&(r.components=a(l.components,r.components))}catch(e){t.info("No custom definitions")}s.json(r)}catch(e){return r(new c(e.message||e[0].message))}}))}};module.exports=d;
|
package/package.json
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
2
|
+
"name": "directus-extension-api-docs",
|
|
3
|
+
"version": "1.4.5",
|
|
4
|
+
"description": "directus extension for swagger interface and custom endpoints definitions",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"!*.map"
|
|
10
|
+
],
|
|
11
|
+
"repository": "https://github.com/sacconazzo/directus-extension-api-docs",
|
|
12
|
+
"homepage": "https://github.com/sacconazzo/directus-extension-api-docs#readme",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"directus",
|
|
15
|
+
"directus-extension",
|
|
16
|
+
"directus-custom-endpoint",
|
|
17
|
+
"swagger",
|
|
18
|
+
"custom endpoints",
|
|
19
|
+
"openapi definition",
|
|
20
|
+
"openapi"
|
|
21
|
+
],
|
|
22
|
+
"directus:extension": {
|
|
23
|
+
"type": "endpoint",
|
|
24
|
+
"path": "dist/index.js",
|
|
25
|
+
"source": "src/index.ts",
|
|
26
|
+
"host": "^9.19.2"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"test": "jest --verbose=true",
|
|
30
|
+
"lint": "eslint --ignore-path .gitignore --ext .ts tests/ src/",
|
|
31
|
+
"lint:fix": "pnpm lint --fix",
|
|
32
|
+
"build": "directus-extension build",
|
|
33
|
+
"dev": "directus-extension build -w --no-minify"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@pnpm/find-workspace-dir": "^5.0.0",
|
|
37
|
+
"express-openapi-validator": "^4.13.8",
|
|
38
|
+
"js-yaml": "^4.1.0",
|
|
39
|
+
"swagger-ui-express": "^4.6.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@directus/extensions-sdk": "^9.22.1",
|
|
43
|
+
"@directus/shared": "^9.22.1",
|
|
44
|
+
"@types/express": "^4.17.15",
|
|
45
|
+
"@types/jest": "^29.2.4",
|
|
46
|
+
"@types/node": "^18.11.18",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^5.47.1",
|
|
48
|
+
"@typescript-eslint/parser": "^5.47.1",
|
|
49
|
+
"eslint": "^8.30.0",
|
|
50
|
+
"eslint-config-prettier": "^8.5.0",
|
|
51
|
+
"eslint-plugin-import": "^2.26.0",
|
|
52
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
53
|
+
"express": "^4.18.2",
|
|
54
|
+
"jest": "^29.3.1",
|
|
55
|
+
"jest-extended": "^3.2.0",
|
|
56
|
+
"openapi-schema-validator": "^12.1.0",
|
|
57
|
+
"pino": "^8.8.0",
|
|
58
|
+
"prettier": "^2.8.1",
|
|
59
|
+
"ts-jest": "^29.0.3",
|
|
60
|
+
"ts-node": "^10.9.1",
|
|
61
|
+
"typescript": "^4.9.4"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Router } from 'express';
|
|
2
|
-
declare function validate(router: Router, services: any, schema: any, paths: Array<string>): Promise<Router>;
|
|
3
|
-
declare const _default: {
|
|
4
|
-
id: string;
|
|
5
|
-
validate: typeof validate;
|
|
6
|
-
handler: any;
|
|
7
|
-
};
|
|
8
|
-
export default _default;
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAmC,MAAM,SAAS,CAAC;AAWlE,iBAAe,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAsCzG;;;;;;AAED,wBAiDE"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface oasconfig {
|
|
2
|
-
docsPath?: string;
|
|
3
|
-
tags?: Array<object>;
|
|
4
|
-
paths?: {
|
|
5
|
-
[key: string]: object;
|
|
6
|
-
};
|
|
7
|
-
components?: {
|
|
8
|
-
[key: string]: object;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export interface oas {
|
|
12
|
-
info: any;
|
|
13
|
-
docsPath: string;
|
|
14
|
-
tags: Array<any>;
|
|
15
|
-
paths: {
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
};
|
|
18
|
-
components: {
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,KAAK,CAAC,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACzB,CAAC;IACF,UAAU,CAAC,EAAE;QACT,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACzB,CAAC;CACL;AAED,MAAM,WAAW,GAAG;IAChB,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,KAAK,EAAE;QACH,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACtB,CAAC;IACF,UAAU,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACtB,CAAC;CACL"}
|
package/dist/utils.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SchemaOverview } from '@directus/shared/types';
|
|
2
|
-
import { oas, oasconfig } from './types';
|
|
3
|
-
export declare function getConfig(): oasconfig;
|
|
4
|
-
export declare function getOas(services: any, schema: SchemaOverview): Promise<oas>;
|
|
5
|
-
export declare function merge(a: any, b: any): any;
|
|
6
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAUzC,wBAAgB,SAAS,IAAI,SAAS,CAqBrC;AAED,wBAAsB,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,CAYhF;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,OAKnC"}
|