openapi-jsonrpc-jsdoc 1.0.4 → 1.1.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.
Files changed (34) hide show
  1. package/README.md +135 -16
  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 +4 -4
  31. package/.idea/misc.xml +0 -6
  32. package/.idea/modules.xml +0 -8
  33. package/.idea/openapi-jsonrpc-jsdoc.iml +0 -9
  34. package/.idea/vcs.xml +0 -6
package/README.md CHANGED
@@ -1,26 +1,34 @@
1
1
  # openapi-jsonrpc-jsdoc
2
2
 
3
3
  ## Install
4
+
4
5
  ```fish
5
6
  npm i openapi-jsonrpc-jsdoc --save-dev
6
7
  ```
7
8
 
8
- ## Example
9
+ ## Examples
9
10
 
10
11
  ### Create JSON-RPC Method
12
+
11
13
  ```js
12
14
  // api/api-v1.js
13
15
  /**
14
- * @description Название API
15
- * @param {object} parameters - params
16
- * @param {string} parameters.id - id
17
- */
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
+ */
18
25
  module.exports = (parameters) => {
19
26
  return parameters.id;
20
27
  }
21
28
  ```
22
29
 
23
30
  ### Run package
31
+
24
32
  ```js
25
33
  // index.js
26
34
  const fs = require('fs');
@@ -40,7 +48,7 @@ openapiJSONRpcJSDoc({
40
48
  ```
41
49
 
42
50
  <details>
43
- <summary>See result</summary>
51
+ <summary>See Swagger result</summary>
44
52
 
45
53
  ```json
46
54
  {
@@ -57,21 +65,21 @@ openapiJSONRpcJSDoc({
57
65
  "javascript"
58
66
  ],
59
67
  "info": {
60
- "version": "1.0.0",
61
- "title": "project-name",
62
- "description": "project-description"
68
+ "version": "1.0.4",
69
+ "title": "openapi-jsonrpc-jsdoc",
70
+ "description": "OpenAPI generator"
63
71
  },
64
72
  "servers": [
65
73
  {
66
- "url": "0.0.0.0:8080"
74
+ "url": "http://0.0.0.0:9000"
67
75
  }
68
76
  ],
69
77
  "paths": {
70
- "/api/api-v1": {
78
+ "/api/v1": {
71
79
  "post": {
72
- "operationId": "api-v1.js",
80
+ "operationId": "v1.js",
73
81
  "deprecated": false,
74
- "summary": "/api-v1",
82
+ "summary": "/v1",
75
83
  "description": "Название API",
76
84
  "tags": [
77
85
  "JSONRPC"
@@ -79,7 +87,24 @@ openapiJSONRpcJSDoc({
79
87
  "parameters": [],
80
88
  "responses": {
81
89
  "200": {
82
- "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
+ }
83
108
  }
84
109
  },
85
110
  "requestBody": {
@@ -96,8 +121,8 @@ openapiJSONRpcJSDoc({
96
121
  "properties": {
97
122
  "method": {
98
123
  "type": "string",
99
- "default": "api-v1",
100
- "description": "API method api-v1"
124
+ "default": "v1",
125
+ "description": "API method v1"
101
126
  },
102
127
  "id": {
103
128
  "type": "integer",
@@ -113,7 +138,14 @@ openapiJSONRpcJSDoc({
113
138
  "params": {
114
139
  "title": "Parameters",
115
140
  "type": "object",
141
+ "default": {
142
+ "@context": "https://www.w3.org/ns/activitystreams",
143
+ "type": "Note"
144
+ },
116
145
  "required": [
146
+ "method",
147
+ "id",
148
+ "jsonrpc",
117
149
  "id"
118
150
  ],
119
151
  "properties": {
@@ -129,6 +161,72 @@ openapiJSONRpcJSDoc({
129
161
  }
130
162
  }
131
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
+ }
132
230
  }
133
231
  },
134
232
  "components": {
@@ -137,6 +235,27 @@ openapiJSONRpcJSDoc({
137
235
  "type": "http",
138
236
  "scheme": "digest"
139
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
+ }
140
259
  }
141
260
  },
142
261
  "security": [
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;