directus-extension-api-docs 1.3.2 → 1.3.4

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";const e=require("swagger-ui-express"),s=require("express-openapi-validator"),{findWorkspaceDir:n}=require("@pnpm/find-workspace-dir"),t=require("path"),o=process.cwd();let i;const a=function(){try{return require(t.join(o,"./extensions/endpoints/oasconfig.js"))}catch(e){return{}}}();async function r(e,s){if(i)return JSON.parse(i);const{SpecificationService:n}=e,t=new n({accountability:{admin:!0},schema:s});return i=JSON.stringify(await t.oas.generate()),JSON.parse(i)}function c(e,s){for(const n of Object.keys(s))s[n]instanceof Object&&Object.assign(s[n],c(e[n],s[n]));return Object.assign(e||{},s),e}const p=(null==a?void 0:a.docsPath)||"api-docs";var u={id:p,validate:async function(e,n,t,o){if(null==a?void 0:a.paths){const i=await r(n,t);if(o)for(const e of o)i.paths[e]=a.paths[e];else i.paths=a.paths;a.components?i.components=a.components:(delete i.components.definitions,delete i.components.schemas),e.use(s.middleware({apiSpec:i})),e.use(((e,s,n,t)=>{n.status(e.status||500).json({message:e.message,errors:e.errors})}))}return e},handler:(s,{services:t,exceptions:o,logger:i,getSchema:u})=>{const{ServiceUnavailableException:f}=o,d={swaggerOptions:{url:`/${p}/oas`}};s.use("/",e.serve),s.get("/",e.setup({},d)),s.get("/oas",(async(e,s,o)=>{try{const e=await u(),o=await r(t,e),p=require(`${await n(".")}/package.json`);o.info.title=p.name,o.info.version=p.version,o.info.description=p.description;try{if(null==a?void 0:a.paths)for(const e in a.paths)o.paths[e]=a.paths[e];if(null==a?void 0:a.tags)for(const e of a.tags)o.tags.push(e);(null==a?void 0:a.components)&&(o.components=c(a.components,o.components))}catch(e){i.info("No custom definitions")}s.json(o)}catch(e){return o(new f(e.message||e[0].message))}}))}};module.exports=u;
1
+ "use strict";const e=require("swagger-ui-express"),s=require("express-openapi-validator"),{findWorkspaceDir:t}=require("@pnpm/find-workspace-dir"),n=require("path"),o=process.cwd();let i;const r=function(){try{return require(n.join(o,"./extensions/endpoints/oasconfig.js"))}catch(e){return{}}}();async function a(e,s){if(i)return JSON.parse(i);const{SpecificationService:t}=e,n=new t({accountability:{admin:!0},schema:s});return i=JSON.stringify(await n.oas.generate()),JSON.parse(i)}function c(e,s){return Object.entries(s).reduce(((e,[s,t])=>(e[s]=t&&"object"==typeof t?c(e[s]=e[s]||(Array.isArray(t)?[]:{}),t):t,e)),e)}const p=(null==r?void 0:r.docsPath)||"api-docs";var u={id:p,validate:async function(e,t,n,o){if(null==r?void 0:r.paths){const i=await a(t,n);if(o)for(const e of o)i.paths[e]=r.paths[e];else i.paths=r.paths;r.components?i.components=r.components:(delete i.components.definitions,delete i.components.schemas),e.use(s.middleware({apiSpec:i})),e.use(((e,s,t,n)=>{t.status(e.status||500).json({message:e.message,errors:e.errors})}))}return e},handler:(s,{services:n,exceptions:o,logger:i,getSchema:u})=>{const{ServiceUnavailableException:d}=o,f={swaggerOptions:{url:`/${p}/oas`}};s.use("/",e.serve),s.get("/",e.setup({},f)),s.get("/oas",(async(e,s,o)=>{try{const e=await u(),o=await a(n,e),p=require(`${await t(".")}/package.json`);o.info.title=p.name,o.info.version=p.version,o.info.description=p.description;try{if(null==r?void 0:r.paths)for(const e in r.paths)o.paths[e]=r.paths[e];if(null==r?void 0:r.tags)for(const e of r.tags)o.tags.push(e);(null==r?void 0:r.components)&&(o.components=c(r.components,o.components))}catch(e){i.info("No custom definitions")}s.json(o)}catch(e){return o(new d(e.message||e[0].message))}}))}};module.exports=u;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "directus-extension-api-docs",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
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",
@@ -43,8 +43,8 @@
43
43
  "@types/express": "^4.17.14",
44
44
  "@types/jest": "^29.2.2",
45
45
  "@types/node": "^18.11.9",
46
- "@typescript-eslint/eslint-plugin": "^5.42.1",
47
- "@typescript-eslint/parser": "^5.42.1",
46
+ "@typescript-eslint/eslint-plugin": "^5.43.0",
47
+ "@typescript-eslint/parser": "^5.43.0",
48
48
  "babel-jest": "^29.3.1",
49
49
  "eslint": "^8.27.0",
50
50
  "eslint-config-prettier": "^8.5.0",