@strapi/plugin-documentation 4.2.1-alpha.0 → 4.3.0-beta.2

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 CHANGED
@@ -1,7 +1,6 @@
1
1
  # Plugin documentation
2
2
 
3
3
  This plugin automates your API documentation creation. It basically generates a swagger file. It follows the [Open API specification version 3.0.1](https://swagger.io/specification/).
4
- The documentation plugin is not release on npm yet, Here's how to install it.
5
4
 
6
5
  ## Usage
7
6
 
@@ -1,9 +1,10 @@
1
1
  {
2
+ "coming-soon": "Zawartość w trakcie budowy, wróci w ciągu kilku tygodni!",
2
3
  "components.Row.open": "Otwórz",
3
4
  "components.Row.regenerate": "Wygeneruj ponownie",
4
5
  "containers.HomePage.Block.title": "Wersje",
5
6
  "containers.HomePage.Button.update": "Zaktualizuj",
6
- "containers.HomePage.PluginHeader.title": "Dokuemntacja - Ustawienia",
7
+ "containers.HomePage.PluginHeader.title": "Dokumentacja - Ustawienia",
7
8
  "containers.HomePage.PopUpWarning.confirm": "Rozumiem",
8
9
  "containers.HomePage.PopUpWarning.message": "Czy jesteś pewien, że chcesz usunąć tę wersję?",
9
10
  "containers.HomePage.copied": "Token skopiowany do schowka",
@@ -11,14 +12,28 @@
11
12
  "containers.HomePage.form.jwtToken.description": "Skopiuj token i użyj go w swaggerze aby wykonać request",
12
13
  "containers.HomePage.form.password": "Hasło",
13
14
  "containers.HomePage.form.password.inputDescription": "Ustaw hasło aby uzyskać dostęp do dokumentacji",
14
- "containers.HomePage.form.restrictedAccess": "Dostęp Ograniczony",
15
+ "containers.HomePage.form.restrictedAccess": "Dostęp ograniczony",
15
16
  "containers.HomePage.form.restrictedAccess.inputDescription": "Ustaw endpoint dokumentacji jako prywatny. Domyślnie dostęp jest publiczny.",
16
17
  "containers.HomePage.form.showGeneratedFiles": "Pokaż wygenerowane pliki",
17
- "containers.HomePage.form.showGeneratedFiles.inputDescription": "Przydatne, gdy chcesz nadpisać wygenerowaną dokumentację. \nWtyczka wygeneruje pliki i podzieli je według modelu i wtyczki. \nWłączenie tej opcji ułatwi dostosowywanie dokumentacji",
18
+ "containers.HomePage.form.showGeneratedFiles.inputDescription": "Przydatne, gdy chcesz nadpisać wygenerowaną dokumentację. \nPlugin wygeneruje pliki i podzieli je według modelu i pluginu. \nWłączenie tej opcji ułatwi dostosowywanie dokumentacji",
18
19
  "error.deleteDoc.versionMissing": "Wersja, którą próbujesz usunąć nie istnieje.",
19
20
  "error.noVersion": "Wersja jest wymagana",
20
21
  "error.regenerateDoc": "Wystąpił błąd podczas ponownego generowania dokumentacji",
21
- "error.regenerateDoc.versionMissing": "Wersja, którą prubujesz wygenerować nie istnieje.",
22
+ "error.regenerateDoc.versionMissing": "Wersja, którą próbujesz wygenerować nie istnieje.",
23
+ "notification.delete.success": "Dokumentacja usunięta",
24
+ "notification.generate.success": "Dokumentacja wygenerowana",
22
25
  "notification.update.success": "Ustawienia zaktualizowane pomyślnie",
26
+ "pages.PluginPage.Button.open": "Otwórz dokumentację",
27
+ "pages.PluginPage.header.description": "Skonfiguruj plugin dokumentacji",
28
+ "pages.PluginPage.table.generated": "Ostatnio wygenerowane",
29
+ "pages.PluginPage.table.icon.regenerate": "Wygeneruj ponownie {target}",
30
+ "pages.PluginPage.table.icon.show": "Otwórz {target}",
31
+ "pages.PluginPage.table.version": "Wersja",
32
+ "pages.SettingsPage.Button.description": "Skonfiguruj plugin dokumentacji",
33
+ "pages.SettingsPage.header.save": "Zapisz",
34
+ "pages.SettingsPage.toggle.hint": "Ustaw endpoint dokumentacji na prywatny",
35
+ "pages.SettingsPage.toggle.label": "Dostęp ograniczony",
36
+ "plugin.description.long": "Stwórz dokument OpenAPI i zwizualizuj swoje API z SWAGGER UI.",
37
+ "plugin.description.short": "Stwórz dokument OpenAPI i zwizualizuj swoje API z SWAGGER UI.",
23
38
  "plugin.name": "Dokumentacja"
24
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/plugin-documentation",
3
- "version": "4.2.1-alpha.0",
3
+ "version": "4.3.0-beta.2",
4
4
  "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,25 +24,26 @@
24
24
  "test": "echo \"no tests yet\""
25
25
  },
26
26
  "dependencies": {
27
- "@strapi/helper-plugin": "4.2.1-alpha.0",
28
- "@strapi/utils": "4.2.1-alpha.0",
27
+ "@strapi/helper-plugin": "4.3.0-beta.2",
28
+ "@strapi/utils": "4.3.0-beta.2",
29
29
  "bcryptjs": "2.4.3",
30
30
  "cheerio": "^1.0.0-rc.5",
31
31
  "fs-extra": "10.0.0",
32
32
  "koa-static": "^5.0.0",
33
33
  "lodash": "4.17.21",
34
- "path-to-regexp": "6.2.0",
34
+ "path-to-regexp": "6.2.1",
35
35
  "pluralize": "8.0.0",
36
36
  "react": "^17.0.2",
37
- "react-copy-to-clipboard": "^5.0.3",
37
+ "react-copy-to-clipboard": "^5.1.0",
38
38
  "react-dom": "^17.0.2",
39
39
  "react-intl": "5.20.2",
40
- "react-redux": "7.2.3",
40
+ "react-redux": "7.2.8",
41
41
  "react-router": "^5.2.0",
42
42
  "react-router-dom": "5.2.0",
43
43
  "redux": "^4.0.1",
44
44
  "reselect": "^4.0.0",
45
- "swagger-ui-dist": "4.11.1"
45
+ "swagger-ui-dist": "4.11.1",
46
+ "yaml": "1.10.2"
46
47
  },
47
48
  "peerDependencies": {
48
49
  "@strapi/strapi": "^4.0.0"
@@ -57,5 +58,5 @@
57
58
  "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
58
59
  "kind": "plugin"
59
60
  },
60
- "gitHead": "90bd3b9e294a69cd9538bde4e2e853e6de60f238"
61
+ "gitHead": "42aba356ad1b0751584d3b375e83baa4a2c18f65"
61
62
  }
@@ -49,7 +49,7 @@ module.exports = {
49
49
  .getDocumentationVersion();
50
50
 
51
51
  const openAPISpecsPath = path.join(
52
- strapi.dirs.extensions,
52
+ strapi.dirs.app.extensions,
53
53
  'documentation',
54
54
  'documentation',
55
55
  version,
@@ -69,7 +69,7 @@ module.exports = {
69
69
 
70
70
  try {
71
71
  const layoutPath = path.resolve(
72
- strapi.dirs.extensions,
72
+ strapi.dirs.app.extensions,
73
73
  'documentation',
74
74
  'public',
75
75
  'index.html'
@@ -81,7 +81,11 @@ module.exports = {
81
81
  ctx.url = path.basename(`${ctx.url}/index.html`);
82
82
 
83
83
  try {
84
- const staticFolder = path.resolve(strapi.dirs.extensions, 'documentation', 'public');
84
+ const staticFolder = path.resolve(
85
+ strapi.dirs.app.extensions,
86
+ 'documentation',
87
+ 'public'
88
+ );
85
89
  return koaStatic(staticFolder)(ctx, next);
86
90
  } catch (e) {
87
91
  strapi.log.error(e);
@@ -116,7 +120,7 @@ module.exports = {
116
120
 
117
121
  try {
118
122
  const layoutPath = path.resolve(
119
- strapi.dirs.extensions,
123
+ strapi.dirs.app.extensions,
120
124
  'documentation',
121
125
  'public',
122
126
  'login.html'
@@ -127,7 +131,7 @@ module.exports = {
127
131
  ctx.url = path.basename(`${ctx.url}/login.html`);
128
132
 
129
133
  try {
130
- const staticFolder = path.resolve(strapi.dirs.extensions, 'documentation', 'public');
134
+ const staticFolder = path.resolve(strapi.dirs.app.extensions, 'documentation', 'public');
131
135
  return koaStatic(staticFolder)(ctx, next);
132
136
  } catch (e) {
133
137
  strapi.log.error(e);
@@ -11,17 +11,28 @@ const { builApiEndpointPath, buildComponentSchema } = require('./helpers');
11
11
  module.exports = ({ strapi }) => {
12
12
  const config = strapi.config.get('plugin.documentation');
13
13
 
14
+ const registeredDocs = [];
15
+
14
16
  return {
17
+ registerDoc(doc) {
18
+ // parseYaml
19
+ if (typeof doc === 'string') {
20
+ doc = require('yaml').parse(doc);
21
+ }
22
+ // receive an object we can register it directly
23
+ registeredDocs.push(doc);
24
+ },
15
25
  getDocumentationVersion() {
16
26
  return _.get(config, 'info.version');
17
27
  },
18
28
 
19
29
  getFullDocumentationPath() {
20
- return path.join(strapi.dirs.extensions, 'documentation', 'documentation');
30
+ return path.join(strapi.dirs.app.extensions, 'documentation', 'documentation');
21
31
  },
22
32
 
23
33
  getCustomDocumentationPath() {
24
- return path.join(strapi.dirs.extensions, 'documentation', 'config', 'settings.json');
34
+ // ??
35
+ return path.join(strapi.dirs.app.extensions, 'documentation', 'config', 'settings.json');
25
36
  },
26
37
 
27
38
  getDocumentationVersions() {
@@ -71,10 +82,10 @@ module.exports = ({ strapi }) => {
71
82
  */
72
83
  getApiDocumentationPath(api) {
73
84
  if (api.getter === 'plugin') {
74
- return path.join(strapi.dirs.extensions, api.name, 'documentation');
85
+ return path.join(strapi.dirs.app.extensions, api.name, 'documentation');
75
86
  }
76
87
 
77
- return path.join(strapi.dirs.api, api.name, 'documentation');
88
+ return path.join(strapi.dirs.app.api, api.name, 'documentation');
78
89
  },
79
90
 
80
91
  async deleteDocumentation(version) {
@@ -173,8 +184,26 @@ module.exports = ({ strapi }) => {
173
184
  const customConfig = await this.getCustomConfig();
174
185
  const config = _.merge(defaultConfig, customConfig);
175
186
 
187
+ const finalDoc = { ...config, paths };
188
+
189
+ registeredDocs.forEach(doc => {
190
+ // Add tags
191
+ finalDoc.tags = finalDoc.tags || [];
192
+ finalDoc.tags.push(...(doc.tags || []));
193
+
194
+ // Add Paths
195
+ _.assign(finalDoc.paths, doc.paths);
196
+
197
+ // Add components
198
+ _.forEach(doc.components || {}, (val, key) => {
199
+ finalDoc.components[key] = finalDoc.components[key] || {};
200
+
201
+ _.assign(finalDoc.components[key], val);
202
+ });
203
+ });
204
+
176
205
  await fs.ensureFile(fullDocJsonPath);
177
- await fs.writeJson(fullDocJsonPath, { ...config, paths }, { spaces: 2 });
206
+ await fs.writeJson(fullDocJsonPath, finalDoc, { spaces: 2 });
178
207
  },
179
208
  };
180
209
  };
package/yarn-error.log DELETED
@@ -1,95 +0,0 @@
1
- Arguments:
2
- /Users/alex/.nvm/versions/node/v16.13.2/bin/node /Users/alex/.nvm/versions/node/v16.13.2/bin/yarn
3
-
4
- PATH:
5
- /Users/alex/.nvm/versions/node/v16.13.2/bin:/Users/alex/.nvm/versions/node/v18.1.0/bin:/Users/alex/.nvm/versions/node/v16.13.2/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Users/alex/.nvm/versions/node/v16.13.2/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/alex/.yarn/bin:/Users/alex/.yarn/bin
6
-
7
- Yarn version:
8
- 1.22.17
9
-
10
- Node version:
11
- 16.13.2
12
-
13
- Platform:
14
- darwin arm64
15
-
16
- Trace:
17
- SyntaxError: /Users/alex/dev/strapi/strapi/packages/plugins/documentation/package.json: Unexpected token < in JSON at position 1187
18
- at JSON.parse (<anonymous>)
19
- at /Users/alex/.nvm/versions/node/v16.13.2/lib/node_modules/yarn/lib/cli.js:1625:59
20
- at Generator.next (<anonymous>)
21
- at step (/Users/alex/.nvm/versions/node/v16.13.2/lib/node_modules/yarn/lib/cli.js:310:30)
22
- at /Users/alex/.nvm/versions/node/v16.13.2/lib/node_modules/yarn/lib/cli.js:321:13
23
-
24
- npm manifest:
25
- {
26
- "name": "@strapi/plugin-documentation",
27
- "version": "4.1.12",
28
- "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
29
- "repository": {
30
- "type": "git",
31
- "url": "https://github.com/strapi/strapi.git",
32
- "directory": "packages/plugins/documentation"
33
- },
34
- "license": "SEE LICENSE IN LICENSE",
35
- "author": {
36
- "name": "Strapi Solutions SAS",
37
- "email": "hi@strapi.io",
38
- "url": "https://strapi.io"
39
- },
40
- "maintainers": [
41
- {
42
- "name": "Strapi Solutions SAS",
43
- "email": "hi@strapi.io",
44
- "url": "https://strapi.io"
45
- }
46
- ],
47
- "scripts": {
48
- "test": "echo \"no tests yet\""
49
- },
50
- "dependencies": {
51
- "@strapi/helper-plugin": "4.1.12",
52
- "@strapi/utils": "4.1.12",
53
- "bcryptjs": "2.4.3",
54
- "cheerio": "^1.0.0-rc.5",
55
- "fs-extra": "10.0.0",
56
- "koa-static": "^5.0.0",
57
- "lodash": "4.17.21",
58
- "path-to-regexp": "6.2.0",
59
- "pluralize": "8.0.0",
60
- "react": "^17.0.2",
61
- "react-copy-to-clipboard": "^5.0.3",
62
- "react-dom": "^17.0.2",
63
- "react-intl": "5.20.2",
64
- "react-redux": "7.2.3",
65
- "react-router": "^5.2.0",
66
- "react-router-dom": "5.2.0",
67
- "redux": "^4.0.1",
68
- "reselect": "^4.0.0",
69
- <<<<<<< HEAD
70
- "swagger-ui-dist": "3.47.1",
71
- "yaml": "1.10.2"
72
- =======
73
- "swagger-ui-dist": "4.11.1"
74
- >>>>>>> master
75
- },
76
- "peerDependencies": {
77
- "@strapi/strapi": "^4.0.0"
78
- },
79
- "engines": {
80
- "node": ">=12.22.0 <=16.x.x",
81
- "npm": ">=6.0.0"
82
- },
83
- "strapi": {
84
- "displayName": "Documentation",
85
- "name": "documentation",
86
- "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
87
- "kind": "plugin"
88
- }
89
- }
90
-
91
- yarn manifest:
92
- No manifest
93
-
94
- Lockfile:
95
- No lockfile