directus-extension-api-docs 1.4.5 → 1.4.7
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/dist/index.js +1 -1
- package/package.json +18 -18
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("js-yaml"),
|
|
1
|
+
"use strict";const e=require("js-yaml"),s=require("path"),t=require("fs"),n=process.cwd();let o;async function a(e,s){if(o)return JSON.parse(o);const{SpecificationService:t}=e,n=new t({accountability:{admin:!0},schema:s});return o=JSON.stringify(await n.oas.generate()),JSON.parse(o)}function i(e,s){return Object.entries(s).reduce(((e,[s,t])=>(e[s]=t&&"object"==typeof t?i(e[s]=e[s]||(Array.isArray(t)?[]:{}),t):t,e)),e)}const c=require("swagger-ui-express"),r=require("express-openapi-validator"),{findWorkspaceDir:p}=require("@pnpm/find-workspace-dir"),u=function(){const o=function(){const o={docsPath:"api-docs",tags:[],paths:{},components:{}};try{const a=s.join(n,"./extensions/endpoints/oasconfig.yaml"),i=e.load(t.readFileSync(a,{encoding:"utf-8"}));return i.docsPath=i.docsPath||o.docsPath,i.tags=i.tags||o.tags,i.paths=i.paths||o.paths,i.components=i.components||o.components,i}catch{return o}}();try{const a=s.join(n,"./extensions/endpoints"),c=t.readdirSync(a,{withFileTypes:!0});for(const s of c){const n=`${a}/${s.name}/oas.yaml`;if(s.isDirectory()&&t.existsSync(n)){const s=e.load(t.readFileSync(n,{encoding:"utf-8"}));o.tags=[...o.tags,...s.tags],o.paths={...o.paths,...s.paths},o.components=i(o.components||{},s.components||{})}}return o}catch(e){return o}}(),d=u.docsPath;var l={id:d,validate:async function(e,s,t,n){if(null==u?void 0:u.paths){const o=await a(s,t);if(n)for(const e of n)o.paths[e]=u.paths[e];else o.paths=u.paths;u.components?o.components=u.components:(delete o.components.definitions,delete o.components.schemas),e.use(r.middleware({apiSpec:o})),e.use(((e,s,t,n)=>{t.status(e.status||500).json({message:e.message,errors:e.errors})}))}return e},handler:(e,{services:s,exceptions:t,logger:n,getSchema:o})=>{const{ServiceUnavailableException:r}=t,l={swaggerOptions:{url:`/${d}/oas`}};e.use("/",c.serve),e.get("/",c.setup({},l)),e.get("/oas",(async(e,t,c)=>{try{const e=await o(),c=await a(s,e);try{const e=require(`${await p(".")}/package.json`);(null==e?void 0:e.name)&&(c.info.title=null==e?void 0:e.name),(null==e?void 0:e.version)&&(c.info.version=null==e?void 0:e.version),(null==e?void 0:e.description)&&(c.info.description=null==e?void 0:e.description)}catch(e){}try{if(null==u?void 0:u.paths)for(const e in u.paths)c.paths[e]=u.paths[e];if(null==u?void 0:u.tags)for(const e of u.tags)c.tags.push(e);(null==u?void 0:u.components)&&(c.components=i(u.components,c.components))}catch(e){n.info("No custom definitions")}t.json(c)}catch(e){return c(new r(e.message||e[0].message))}}))}};module.exports=l;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "directus-extension-api-docs",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.7",
|
|
4
4
|
"description": "directus extension for swagger interface and custom endpoints definitions",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -33,31 +33,31 @@
|
|
|
33
33
|
"dev": "directus-extension build -w --no-minify"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@pnpm/find-workspace-dir": "^5.0.
|
|
36
|
+
"@pnpm/find-workspace-dir": "^5.0.1",
|
|
37
37
|
"express-openapi-validator": "^4.13.8",
|
|
38
38
|
"js-yaml": "^4.1.0",
|
|
39
39
|
"swagger-ui-express": "^4.6.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@directus/extensions-sdk": "^9.22.
|
|
43
|
-
"@directus/shared": "^9.22.
|
|
44
|
-
"@types/express": "^4.17.
|
|
45
|
-
"@types/jest": "^29.
|
|
46
|
-
"@types/node": "^18.
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
48
|
-
"@typescript-eslint/parser": "^5.
|
|
49
|
-
"eslint": "^8.
|
|
50
|
-
"eslint-config-prettier": "^8.
|
|
51
|
-
"eslint-plugin-import": "^2.
|
|
42
|
+
"@directus/extensions-sdk": "^9.22.4",
|
|
43
|
+
"@directus/shared": "^9.22.3",
|
|
44
|
+
"@types/express": "^4.17.17",
|
|
45
|
+
"@types/jest": "^29.4.0",
|
|
46
|
+
"@types/node": "^18.13.0",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
|
48
|
+
"@typescript-eslint/parser": "^5.51.0",
|
|
49
|
+
"eslint": "^8.33.0",
|
|
50
|
+
"eslint-config-prettier": "^8.6.0",
|
|
51
|
+
"eslint-plugin-import": "^2.27.5",
|
|
52
52
|
"eslint-plugin-prettier": "^4.2.1",
|
|
53
53
|
"express": "^4.18.2",
|
|
54
|
-
"jest": "^29.
|
|
55
|
-
"jest-extended": "^3.2.
|
|
54
|
+
"jest": "^29.4.2",
|
|
55
|
+
"jest-extended": "^3.2.3",
|
|
56
56
|
"openapi-schema-validator": "^12.1.0",
|
|
57
|
-
"pino": "^8.
|
|
58
|
-
"prettier": "^2.8.
|
|
59
|
-
"ts-jest": "^29.0.
|
|
57
|
+
"pino": "^8.10.0",
|
|
58
|
+
"prettier": "^2.8.4",
|
|
59
|
+
"ts-jest": "^29.0.5",
|
|
60
60
|
"ts-node": "^10.9.1",
|
|
61
|
-
"typescript": "^4.9.
|
|
61
|
+
"typescript": "^4.9.5"
|
|
62
62
|
}
|
|
63
63
|
}
|