openapi-jsonrpc-jsdoc 1.0.3 → 1.1.0

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 (35) hide show
  1. package/README.md +139 -19
  2. package/index.js +5 -2
  3. package/out/fonts/OpenSans-Bold-webfont.eot +0 -0
  4. package/out/fonts/OpenSans-Bold-webfont.svg +1830 -0
  5. package/out/fonts/OpenSans-Bold-webfont.woff +0 -0
  6. package/out/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  7. package/out/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  8. package/out/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  9. package/out/fonts/OpenSans-Italic-webfont.eot +0 -0
  10. package/out/fonts/OpenSans-Italic-webfont.svg +1830 -0
  11. package/out/fonts/OpenSans-Italic-webfont.woff +0 -0
  12. package/out/fonts/OpenSans-Light-webfont.eot +0 -0
  13. package/out/fonts/OpenSans-Light-webfont.svg +1831 -0
  14. package/out/fonts/OpenSans-Light-webfont.woff +0 -0
  15. package/out/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  16. package/out/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  17. package/out/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  18. package/out/fonts/OpenSans-Regular-webfont.eot +0 -0
  19. package/out/fonts/OpenSans-Regular-webfont.svg +1831 -0
  20. package/out/fonts/OpenSans-Regular-webfont.woff +0 -0
  21. package/out/index.html +65 -0
  22. package/out/scripts/linenumber.js +25 -0
  23. package/out/scripts/prettify/Apache-License-2.0.txt +202 -0
  24. package/out/scripts/prettify/lang-css.js +2 -0
  25. package/out/scripts/prettify/prettify.js +28 -0
  26. package/out/styles/jsdoc-default.css +358 -0
  27. package/out/styles/prettify-jsdoc.css +111 -0
  28. package/out/styles/prettify-tomorrow.css +132 -0
  29. package/out/v1.js.html +58 -0
  30. package/package.json +19 -13
  31. package/.github/workflows/nodejs.yml +0 -25
  32. package/.github/workflows/npmpublish.yml +0 -45
  33. package/test/api/v1.js +0 -8
  34. package/test/api/v2.js +0 -8
  35. package/test/index.test.js +0 -39
package/README.md CHANGED
@@ -1,25 +1,34 @@
1
1
  # openapi-jsonrpc-jsdoc
2
2
 
3
- Install
3
+ ## Install
4
+
4
5
  ```fish
5
6
  npm i openapi-jsonrpc-jsdoc --save-dev
6
7
  ```
7
8
 
8
- ## Example
9
- ### Create JSON-RPC Methoc
9
+ ## Examples
10
+
11
+ ### Create JSON-RPC Method
12
+
10
13
  ```js
11
14
  // api/api-v1.js
12
15
  /**
13
- * @description Название API
14
- * @param {object} parameters - params
15
- * @param {string} parameters.id - id
16
- */
16
+ * @description Название API
17
+ * @param {object} parameters - params
18
+ * @param {string} parameters.id - id
19
+ * @example
20
+ * {
21
+ * "@context": "https://www.w3.org/ns/activitystreams",
22
+ * "type": "Note"
23
+ * }
24
+ */
17
25
  module.exports = (parameters) => {
18
26
  return parameters.id;
19
27
  }
20
28
  ```
21
29
 
22
30
  ### Run package
31
+
23
32
  ```js
24
33
  // index.js
25
34
  const fs = require('fs');
@@ -39,7 +48,7 @@ openapiJSONRpcJSDoc({
39
48
  ```
40
49
 
41
50
  <details>
42
- <summary>Result</summary>
51
+ <summary>See Swagger result</summary>
43
52
 
44
53
  ```json
45
54
  {
@@ -56,21 +65,21 @@ openapiJSONRpcJSDoc({
56
65
  "javascript"
57
66
  ],
58
67
  "info": {
59
- "version": "1.0.0",
60
- "title": "project-name",
61
- "description": "project-description"
68
+ "version": "1.0.4",
69
+ "title": "openapi-jsonrpc-jsdoc",
70
+ "description": "OpenAPI generator"
62
71
  },
63
72
  "servers": [
64
73
  {
65
- "url": "0.0.0.0:8080"
74
+ "url": "http://0.0.0.0:9000"
66
75
  }
67
76
  ],
68
77
  "paths": {
69
- "/api/api-v1": {
78
+ "/api/v1": {
70
79
  "post": {
71
- "operationId": "api-v1.js",
80
+ "operationId": "v1.js",
72
81
  "deprecated": false,
73
- "summary": "/api-v1",
82
+ "summary": "/v1",
74
83
  "description": "Название API",
75
84
  "tags": [
76
85
  "JSONRPC"
@@ -78,7 +87,24 @@ openapiJSONRpcJSDoc({
78
87
  "parameters": [],
79
88
  "responses": {
80
89
  "200": {
81
- "description": "OK"
90
+ "description": "OK",
91
+ "content": {
92
+ "application/json": {
93
+ "schema": {
94
+ "type": "object"
95
+ }
96
+ }
97
+ }
98
+ },
99
+ "default": {
100
+ "description": "unexpected error",
101
+ "content": {
102
+ "application/json": {
103
+ "schema": {
104
+ "$ref": "#/components/schemas/Error"
105
+ }
106
+ }
107
+ }
82
108
  }
83
109
  },
84
110
  "requestBody": {
@@ -95,8 +121,8 @@ openapiJSONRpcJSDoc({
95
121
  "properties": {
96
122
  "method": {
97
123
  "type": "string",
98
- "default": "api-v1",
99
- "description": "API method api-v1"
124
+ "default": "v1",
125
+ "description": "API method v1"
100
126
  },
101
127
  "id": {
102
128
  "type": "integer",
@@ -112,7 +138,14 @@ openapiJSONRpcJSDoc({
112
138
  "params": {
113
139
  "title": "Parameters",
114
140
  "type": "object",
141
+ "default": {
142
+ "@context": "https://www.w3.org/ns/activitystreams",
143
+ "type": "Note"
144
+ },
115
145
  "required": [
146
+ "method",
147
+ "id",
148
+ "jsonrpc",
116
149
  "id"
117
150
  ],
118
151
  "properties": {
@@ -128,6 +161,72 @@ openapiJSONRpcJSDoc({
128
161
  }
129
162
  }
130
163
  }
164
+ },
165
+ "/api/v2": {
166
+ "post": {
167
+ "operationId": "v2.js",
168
+ "deprecated": true,
169
+ "summary": "/v2",
170
+ "description": "Название API 2",
171
+ "tags": [
172
+ "JSONRPC"
173
+ ],
174
+ "parameters": [],
175
+ "responses": {
176
+ "200": {
177
+ "description": "OK",
178
+ "content": {
179
+ "application/json": {
180
+ "schema": {
181
+ "type": "object"
182
+ }
183
+ }
184
+ }
185
+ },
186
+ "default": {
187
+ "description": "unexpected error",
188
+ "content": {
189
+ "application/json": {
190
+ "schema": {
191
+ "$ref": "#/components/schemas/Error"
192
+ }
193
+ }
194
+ }
195
+ }
196
+ },
197
+ "requestBody": {
198
+ "content": {
199
+ "application/json": {
200
+ "schema": {
201
+ "type": "object",
202
+ "required": [
203
+ "method",
204
+ "id",
205
+ "jsonrpc"
206
+ ],
207
+ "properties": {
208
+ "method": {
209
+ "type": "string",
210
+ "default": "v2",
211
+ "description": "API method v2"
212
+ },
213
+ "id": {
214
+ "type": "integer",
215
+ "default": 1,
216
+ "format": "int32",
217
+ "description": "Request ID"
218
+ },
219
+ "jsonrpc": {
220
+ "type": "string",
221
+ "default": "2.0",
222
+ "description": "JSON-RPC Version (2.0)"
223
+ }
224
+ }
225
+ }
226
+ }
227
+ }
228
+ }
229
+ }
131
230
  }
132
231
  },
133
232
  "components": {
@@ -136,6 +235,27 @@ openapiJSONRpcJSDoc({
136
235
  "type": "http",
137
236
  "scheme": "digest"
138
237
  }
238
+ },
239
+ "schemas": {
240
+ "Error": {
241
+ "required": [
242
+ "error",
243
+ "id",
244
+ "jsonrpc"
245
+ ],
246
+ "properties": {
247
+ "id": {
248
+ "type": "integer",
249
+ "format": "int32"
250
+ },
251
+ "error": {
252
+ "type": "object"
253
+ },
254
+ "jsonrpc": {
255
+ "type": "string"
256
+ }
257
+ }
258
+ }
139
259
  }
140
260
  },
141
261
  "security": [
@@ -147,4 +267,4 @@ openapiJSONRpcJSDoc({
147
267
  }
148
268
  ```
149
269
 
150
- </details>
270
+ </details>
package/index.js CHANGED
@@ -5,9 +5,12 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
5
5
  files,
6
6
  package: packageUrl,
7
7
  access: 'public',
8
+ encoding: 'utf8',
8
9
  module: true,
9
10
  undocumented: false,
10
11
  sort: 'scope',
12
+ allowUnknownTags: true,
13
+ dictionaries: ['jsdoc'],
11
14
  hierarchy: true,
12
15
  });
13
16
  const temporaryDocument = {
@@ -143,7 +146,6 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
143
146
  ...accumulator.properties,
144
147
  [name]: {
145
148
  type,
146
- // default: ...,// fixme: настроить выдачу default значения по JSON-DOC
147
149
  description,
148
150
  },
149
151
  };
@@ -152,6 +154,7 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
152
154
  {
153
155
  title: 'Parameters',
154
156
  type: 'object',
157
+ 'default': module.examples.length ? JSON.parse(module.examples[0]) : null,
155
158
  required: ['method', 'id', 'jsonrpc'],
156
159
  properties: {},
157
160
  },
@@ -168,4 +171,4 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
168
171
  return temporaryDocument;
169
172
  }
170
173
 
171
- module.exports = openapiJsonrpcJsdoc;
174
+ module.exports = openapiJsonrpcJsdoc;