@strapi/plugin-documentation 4.25.13 → 4.25.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/plugin-documentation",
3
- "version": "4.25.13",
3
+ "version": "4.25.15",
4
4
  "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,9 +46,9 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@strapi/design-system": "1.19.0",
49
- "@strapi/helper-plugin": "4.25.13",
49
+ "@strapi/helper-plugin": "4.25.15",
50
50
  "@strapi/icons": "1.19.0",
51
- "@strapi/utils": "4.25.13",
51
+ "@strapi/utils": "4.25.15",
52
52
  "bcryptjs": "2.4.3",
53
53
  "cheerio": "^1.0.0-rc.12",
54
54
  "formik": "2.4.0",
@@ -67,7 +67,7 @@
67
67
  "devDependencies": {
68
68
  "@apidevtools/swagger-parser": "^10.1.0",
69
69
  "@strapi/pack-up": "4.23.0",
70
- "@strapi/strapi": "4.25.13",
70
+ "@strapi/strapi": "4.25.15",
71
71
  "@testing-library/react": "14.0.0",
72
72
  "@testing-library/user-event": "14.4.3",
73
73
  "msw": "1.3.0",
@@ -93,5 +93,5 @@
93
93
  "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
94
94
  "kind": "plugin"
95
95
  },
96
- "gitHead": "a41497dc67f990cc50ce1d0cf57f957d54e14b1a"
96
+ "gitHead": "58e6475628cf07196abad0fcb152ee7a089ee9bb"
97
97
  }
@@ -98,6 +98,36 @@ module.exports = {
98
98
  }
99
99
  },
100
100
 
101
+ async openapiJson(ctx) {
102
+ try {
103
+ const { major, minor, patch } = ctx.params;
104
+ const version =
105
+ major && minor && patch
106
+ ? `${major}.${minor}.${patch}`
107
+ : strapi.plugin('documentation').service('documentation').getDocumentationVersion();
108
+
109
+ const openAPISpecsPath = path.join(
110
+ strapi.dirs.app.extensions,
111
+ 'documentation',
112
+ 'documentation',
113
+ version,
114
+ 'full_documentation.json'
115
+ );
116
+
117
+ try {
118
+ const documentation = fs.readFileSync(openAPISpecsPath, 'utf8');
119
+ const response = JSON.parse(documentation);
120
+
121
+ ctx.send(response);
122
+ } catch (e) {
123
+ strapi.log.error(e);
124
+ ctx.badRequest(null, e.message);
125
+ }
126
+ } catch (e) {
127
+ strapi.log.error(e);
128
+ }
129
+ },
130
+
101
131
  async loginView(ctx, next) {
102
132
  // lazy require cheerio
103
133
  const cheerio = require('cheerio');
@@ -21,6 +21,24 @@ module.exports = [
21
21
  middlewares: [restrictAccess],
22
22
  },
23
23
  },
24
+ {
25
+ method: 'GET',
26
+ path: '/openapi.json',
27
+ handler: 'documentation.openapiJson',
28
+ config: {
29
+ auth: false,
30
+ middlewares: [restrictAccess],
31
+ },
32
+ },
33
+ {
34
+ method: 'GET',
35
+ path: '/v:major(\\d+).:minor(\\d+).:patch(\\d+)/openapi.json',
36
+ handler: 'documentation.openapiJson',
37
+ config: {
38
+ auth: false,
39
+ middlewares: [restrictAccess],
40
+ },
41
+ },
24
42
  {
25
43
  method: 'GET',
26
44
  path: '/login',
package/tests/server.js CHANGED
@@ -19,6 +19,9 @@ const handlers = [
19
19
  })
20
20
  );
21
21
  }),
22
+ rest.post('*/openapi.json', (req, res, ctx) => {
23
+ return res(ctx.status(200));
24
+ }),
22
25
  rest.post('*/regenerateDoc', (req, res, ctx) => {
23
26
  return res(ctx.status(200));
24
27
  }),