kuzzle 2.16.4 → 2.16.5
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.
|
@@ -47,7 +47,11 @@ class ServerController extends NativeController {
|
|
|
47
47
|
'publicApi',
|
|
48
48
|
'openapi',
|
|
49
49
|
]);
|
|
50
|
-
|
|
50
|
+
|
|
51
|
+
this._openApiDefinition = {
|
|
52
|
+
json: null,
|
|
53
|
+
yaml: null,
|
|
54
|
+
};
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
/**
|
|
@@ -55,7 +59,7 @@ class ServerController extends NativeController {
|
|
|
55
59
|
*
|
|
56
60
|
* @param {Request} request
|
|
57
61
|
* @returns {Promise<Object>}
|
|
58
|
-
*
|
|
62
|
+
*
|
|
59
63
|
* @deprecated
|
|
60
64
|
*/
|
|
61
65
|
getStats (request) {
|
|
@@ -66,7 +70,7 @@ class ServerController extends NativeController {
|
|
|
66
70
|
* Returns the last statistics frame
|
|
67
71
|
*
|
|
68
72
|
* @returns {Promise<Object>}
|
|
69
|
-
*
|
|
73
|
+
*
|
|
70
74
|
* @deprecated
|
|
71
75
|
*/
|
|
72
76
|
getLastStats () {
|
|
@@ -77,7 +81,7 @@ class ServerController extends NativeController {
|
|
|
77
81
|
* Returns all stored statistics frames
|
|
78
82
|
*
|
|
79
83
|
* @returns {Promise<Object>}
|
|
80
|
-
*
|
|
84
|
+
*
|
|
81
85
|
* @deprecated
|
|
82
86
|
*/
|
|
83
87
|
getAllStats () {
|
|
@@ -242,25 +246,34 @@ class ServerController extends NativeController {
|
|
|
242
246
|
}
|
|
243
247
|
|
|
244
248
|
async openapi (request) {
|
|
245
|
-
const format = request.
|
|
246
|
-
|
|
247
|
-
: 'json';
|
|
248
|
-
const contentType = format === 'yaml'
|
|
249
|
-
? 'application/yaml'
|
|
250
|
-
: 'application/json';
|
|
251
|
-
const specifications = format === 'yaml'
|
|
252
|
-
? jsonToYaml.stringify(this._docOpenapi)
|
|
253
|
-
: this._docOpenapi;
|
|
249
|
+
const format = request.getString('format', 'json');
|
|
250
|
+
const specifications = this.getOpenApiDefinition(format);
|
|
254
251
|
|
|
255
252
|
request.response.configure({
|
|
256
253
|
format: 'raw',
|
|
257
|
-
headers: { 'Content-Type':
|
|
254
|
+
headers: { 'Content-Type': `application/${format}` },
|
|
258
255
|
status: 200,
|
|
259
256
|
});
|
|
260
257
|
|
|
261
258
|
return specifications;
|
|
262
259
|
}
|
|
263
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Lazy loading of OpenAPI definition.
|
|
263
|
+
*
|
|
264
|
+
* Mainly because we need to wait all plugin to be loaded
|
|
265
|
+
* to generate the definition.
|
|
266
|
+
*/
|
|
267
|
+
getOpenApiDefinition (format) {
|
|
268
|
+
if (! this._openApiDefinition[format]) {
|
|
269
|
+
this._openApiDefinition[format] = format === 'json'
|
|
270
|
+
? generateOpenApi()
|
|
271
|
+
: jsonToYaml.stringify(generateOpenApi());
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return this._openApiDefinition[format];
|
|
275
|
+
}
|
|
276
|
+
|
|
264
277
|
/**
|
|
265
278
|
* Fetches and returns Kuzzle core metrics
|
|
266
279
|
* @returns {Promise<Object>}
|
package/package-lock.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.16.
|
|
4
|
+
"version": "2.16.5",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"bin": {
|
|
7
7
|
"kuzzle": "bin/start-kuzzle-server"
|