@strapi/plugin-documentation 4.3.0-beta.1 → 4.3.1

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
 
@@ -17,7 +16,7 @@ The documentation plugin is not release on npm yet, Here's how to install it.
17
16
 
18
17
  ### Config
19
18
 
20
- The plugin comes with a `settings.json` file located in `./my-project/plugins/documentation/config` folder where you can specify all your environment variables, licenses, external documentation and so one...
19
+ Create a `settings.json` file located in `src/extensions/documentation/config` folder where you can specify all your environment variables, licenses, external documentation and so one...
21
20
  You can add all the entries listed in the [specification](https://swagger.io/specification/).
22
21
 
23
22
  _NOTE_ if you need to add a custom key you can do it by prefixing your key by `x-{something}`
@@ -48,7 +47,7 @@ When you start your server with this plugin installed it will automatically crea
48
47
 
49
48
  #### full_documentation.json
50
49
 
51
- The combined documentation is merged into the `full_documentation.json` file and it's located in `./plugins/documentation/{version}/full_documentation.json`
50
+ The combined documentation is merged into the `full_documentation.json` file and it's located in `src/extensions/documentation/documentation/{version}/full_documentation.json`
52
51
 
53
52
  It has the following structure
54
53
 
@@ -84,7 +83,7 @@ Overriding the `full_documentation.json` is a bad idea since it will be regenera
84
83
 
85
84
  **_NOTE 2_**
86
85
 
87
- You can easily modify the description, summary, parameters of a path however, for a response like the `200` you will need to write the full object. Take a look at the `./plugins/users-permissions/documentation/overrides/1.0.0/users-permissions-User.json` for a complete example.
86
+ You can modify the `tags`, `paths`, and `components` keys on the generated documentation by providing replacement values. You can see how the API is used in the users-permissions plugin: `packages/plugins/users-permissions/server/register.js`
88
87
 
89
88
  ### FAQ
90
89
 
@@ -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.3.0-beta.1",
3
+ "version": "4.3.1",
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.3.0-beta.1",
28
- "@strapi/utils": "4.3.0-beta.1",
27
+ "@strapi/helper-plugin": "4.3.1",
28
+ "@strapi/utils": "4.3.1",
29
29
  "bcryptjs": "2.4.3",
30
- "cheerio": "^1.0.0-rc.5",
30
+ "cheerio": "^1.0.0-rc.12",
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.12.0",
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": "9d6555398960c39159d66bb4eea3bcb0362e37e3"
61
+ "gitHead": "1eab2fb08c7a4d3d40a5a7ff3b2f137ce0afcf8a"
61
62
  }
@@ -11,7 +11,17 @@ 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
  },
@@ -174,8 +184,26 @@ module.exports = ({ strapi }) => {
174
184
  const customConfig = await this.getCustomConfig();
175
185
  const config = _.merge(defaultConfig, customConfig);
176
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
+
177
205
  await fs.ensureFile(fullDocJsonPath);
178
- await fs.writeJson(fullDocJsonPath, { ...config, paths }, { spaces: 2 });
206
+ await fs.writeJson(fullDocJsonPath, finalDoc, { spaces: 2 });
179
207
  },
180
208
  };
181
209
  };