diff --git a/demo_sdk/openrpc/simple.json b/demo_sdk/openrpc/simple.json index a8a2ce3b..2e3f2417 100644 --- a/demo_sdk/openrpc/simple.json +++ b/demo_sdk/openrpc/simple.json @@ -68,11 +68,8 @@ ] }, { - "name": "testMarkdownDescription", - "summary": "A method that pulls it's description from an external markdown file.", - "description": { - "$ref": "file:../descriptions/modules/Simple/methodWithMarkdownDescription.md" - }, + "name": "testMethodWithoutParams", + "summary": "A method.", "tags": [ { "name": "capabilities", @@ -81,16 +78,8 @@ ] } ], - "params": [ - { - "name": "parameter", - "required": true, - "schema": { - "type": "boolean" - }, - "summary": "A test parameter." - } - ], + "description": "Validates basic method generation with no parameters and a simple object result.", + "params": [], "result": { "name": "result", "summary": "A result for testing basic method generation.", @@ -112,6 +101,50 @@ "additionalProperties": false } }, + "examples": [ + { + "name": "Default Example", + "params": [], + "result": { + "name": "Default Result", + "value": { + "foo": "here's foo" + } + } + } + ] + }, + { + "name": "testMarkdownDescription", + "summary": "A method that pulls its description from an external markdown file.", + "description": { + "$ref": "file:../descriptions/modules/Simple/methodWithMarkdownDescription.md" + }, + "tags": [ + { + "name": "capabilities", + "x-uses": [ + "xrn:firebolt:capability:test:test" + ] + } + ], + "params": [ + { + "name": "parameter", + "required": true, + "schema": { + "type": "boolean" + }, + "summary": "A test parameter." + } + ], + "result": { + "name": "result", + "summary": "A result string.", + "schema": { + "type": "string" + } + }, "examples": [ { "name": "Default Example", @@ -123,9 +156,7 @@ ], "result": { "name": "Default Result", - "value": { - "foo": "here's foo" - } + "value": "here's the result" } } ] @@ -213,7 +244,7 @@ "name": "result", "summary": "A result for testing basic method generation.", "schema": { - "type": "null" + "type": "integer" } }, "examples": [ @@ -227,7 +258,7 @@ ], "result": { "name": "Default Result", - "value": null + "value": 123 } } ] diff --git a/demo_sdk/test/component/manualTest.mjs b/demo_sdk/test/component/manualTest.mjs index ee39253e..a395bd04 100644 --- a/demo_sdk/test/component/manualTest.mjs +++ b/demo_sdk/test/component/manualTest.mjs @@ -8,20 +8,36 @@ import { triggerRaw } from './utils/httpClientHelper.js'; let result = null; +result = await new Promise((resolve) => { + let listenerId = null; + EventExtension.once("onBasicEvent", (data) => { + console.log("Subscribe callback:", data); + EventExtension.clear(listenerId); + resolve(data); + }).then((id) => { + listenerId = id; + console.log("Subscribe ID:", listenerId); + triggerRaw('{"jsonrpc":"2.0","method":"EventExtension.onBasicEvent","params":{ "value": "foo param"}}'); + }); +}); + +console.log("Final Result:", result); + +/* result = await new Promise((resolve) => { let listenerId = null; - EventExtension.once("onEventWithThreeParams", (param1, param2, param3) => { - console.log("Subscribe callback:", param1, param2, param3); + EventExtension.once("onEventWithThreeParams", (param1, param2, param3) => { + console.log("Subscribe callback:", param1, param2, param3); - EventExtension.clear(listenerId); - resolve({ param1, param2, param3 }); - }).then((id) => { - listenerId = id; - console.log("Subscribe ID:", listenerId); - triggerRaw('{"jsonrpc":"2.0","method":"EventExtension.onEventWithThreeParams","params":{"appId": "someAppId", "value": "foo param", "extra": {"foo":"bar"}}}'); - }); + EventExtension.clear(listenerId); + resolve({ param1, param2, param3 }); + }).then((id) => { + listenerId = id; + console.log("Subscribe ID:", listenerId); + triggerRaw('{"jsonrpc":"2.0","method":"EventExtension.onEventWithThreeParams","params":{"appId": "someAppId", "value": "foo param", "extra": {"foo":"bar"}}}'); + }); }); console.log("Final Result:", result); @@ -43,4 +59,4 @@ result = await new Promise((resolve) => { console.log("Final Result:", result); - +*/ diff --git a/src/macrofier/engine.mjs b/src/macrofier/engine.mjs index 90a22e5a..7bd550e4 100644 --- a/src/macrofier/engine.mjs +++ b/src/macrofier/engine.mjs @@ -1961,6 +1961,12 @@ function insertExampleMacros(template, examples, method, json, templates, appApi let first = true let languages = '' Object.entries(example.languages).forEach(([name, language]) => { + + //In the generated documentation, the example code for JSON-RPC is deprecated, so we omit it. + if (name.toLowerCase() === 'json-rpc') { + return; + } + let languageContent = language.template //getTemplateForExample(method, templates) // wrap example in collapsible HTML if not first if (!first) {