directus-extension-api-docs 1.0.7 → 1.0.9
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 +10 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# directus-extension-api-docs
|
|
2
2
|
|
|
3
|
-
Directus Extension
|
|
3
|
+
Directus Extension to include a Swagger interface and custom endpoints definitions
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
@@ -25,11 +25,18 @@ Example below:
|
|
|
25
25
|
|
|
26
26
|
```
|
|
27
27
|
{
|
|
28
|
+
"docsPath": "api-docs",
|
|
29
|
+
"tags": [
|
|
30
|
+
{
|
|
31
|
+
"name":"MyCustomTag",
|
|
32
|
+
"description":"MyCustomTag description"
|
|
33
|
+
},
|
|
34
|
+
],
|
|
28
35
|
"paths": {
|
|
29
36
|
"/my-custom-path/my-endpoint": {
|
|
30
37
|
"post": {
|
|
31
|
-
"summary": "something",
|
|
32
|
-
"description": "something",
|
|
38
|
+
"summary": "do something",
|
|
39
|
+
"description": "do something",
|
|
33
40
|
"parameters": [
|
|
34
41
|
{
|
|
35
42
|
"$ref": "#/components/parameters/Meta"
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("swagger-ui-express"),{findWorkspaceDir:s}=require("@pnpm/find-workspace-dir"),i=process.cwd(),n=require("fs"),
|
|
1
|
+
"use strict";const e=require("swagger-ui-express"),{findWorkspaceDir:s}=require("@pnpm/find-workspace-dir"),i=process.cwd(),n=require("fs"),t=require("path");const o=function(){try{const e=t.join(i,"./extensions/endpoints/oas.json");return JSON.parse(n.readFileSync(e,"utf-8"))}catch(e){return{}}}(),r=(null==o?void 0:o.id)||"api-docs";var a={id:r,handler:(i,{services:n,exceptions:t,logger:a})=>{const{ServiceUnavailableException:c}=t,{SpecificationService:p}=n,u={swaggerOptions:{url:`/${r}}/oas`}};i.use("/",e.serve),i.get("/",e.setup({},u)),i.get("/oas",(async(e,i,n)=>{try{const n=new p({accountability:{admin:!0},schema:e.schema}),t=await n.oas.generate(),r=require(`${await s(".")}/package.json`);t.info.title=r.name,t.info.version=r.version,t.info.description=r.description;try{if(null==o?void 0:o.paths)for(const e in o.paths)t.paths[e]=o.paths[e];if(null==o?void 0:o.tags)for(const e of o.tags)t.tags.push(e)}catch(e){a.info("No custom definitions")}i.json(t)}catch(e){return n(new c(e.message||e[0].message))}}))}};module.exports=a;
|