From 7187fa2402cd97046cdf26acb06622b53d0f7b19 Mon Sep 17 00:00:00 2001 From: Keaton Sentak Date: Mon, 1 Jul 2024 08:47:18 -0400 Subject: [PATCH] fix: Make small adjustment to interface template and engine logic --- languages/cpp/templates/codeblocks/interface.cpp | 4 ++-- src/macrofier/engine.mjs | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/languages/cpp/templates/codeblocks/interface.cpp b/languages/cpp/templates/codeblocks/interface.cpp index b62df483..eeccf899 100644 --- a/languages/cpp/templates/codeblocks/interface.cpp +++ b/languages/cpp/templates/codeblocks/interface.cpp @@ -25,7 +25,7 @@ ProviderInvokeSession(methodName, jsonParameters, err); } - static void ProviderResultSession(std::string methodName, std::string& correlationId, ${provider.xresponse.name} result, Firebolt::Error *err = nullptr) + static void ProviderResultSession(std::string methodName, std::string& correlationId, ${provider.xresponse.name} result, Firebolt::Error *err = nullptr) { JsonObject jsonParameters; WPEFramework::Core::JSON::Variant CorrelationId(correlationId); @@ -34,7 +34,7 @@ ${provider.xresponse.serialization} ProviderInvokeSession(methodName, jsonParameters, err); } - static void ProviderErrorSession(std::string methodName, std::string& correlationId, ${provider.xerror.name} result, Firebolt::Error *err = nullptr) + static void ProviderErrorSession(std::string methodName, std::string& correlationId, ${provider.xerror.name} result, Firebolt::Error *err = nullptr) { JsonObject jsonParameters; WPEFramework::Core::JSON::Variant CorrelationId(correlationId); diff --git a/src/macrofier/engine.mjs b/src/macrofier/engine.mjs index b48877a3..8f4522c7 100644 --- a/src/macrofier/engine.mjs +++ b/src/macrofier/engine.mjs @@ -31,7 +31,7 @@ const { isObject, isArray, propEq, pathSatisfies, propSatisfies } = predicates import { isRPCOnlyMethod, isProviderInterfaceMethod, getProviderInterface, getPayloadFromEvent, providerHasNoParameters, isTemporalSetMethod, hasMethodAttributes, getMethodAttributes, isEventMethodWithContext, getSemanticVersion, getSetterFor, getProvidedCapabilities, isPolymorphicPullMethod, hasPublicAPIs, isAllowFocusMethod, hasAllowFocusMethods, createPolymorphicMethods, isExcludedMethod, isCallsMetricsMethod } from '../shared/modules.mjs' import isEmpty from 'crocks/core/isEmpty.js' -import { getPath as getJsonPath, getLinkedSchemaPaths, getSchemaConstraints, isSchema, localizeDependencies, isDefinitionReferencedBySchema, mergeAnyOf, mergeOneOf, getSafeEnumKeyName, getPropertySchema } from '../shared/json-schema.mjs' +import { getPath as getJsonPath, getLinkedSchemaPaths, getSchemaConstraints, isSchema, localizeDependencies, isDefinitionReferencedBySchema, mergeAnyOf, mergeOneOf, getSafeEnumKeyName } from '../shared/json-schema.mjs' // util for visually debugging crocks ADTs const _inspector = obj => { @@ -439,13 +439,6 @@ const promoteAndNameSubSchemas = (obj) => { } addContentDescriptorSubSchema(descriptor, '', obj) } - if (tag['x-response']) { - const descriptor = { - name: obj.info.title, - schema: tag['x-response'] - } - addContentDescriptorSubSchema(descriptor, '', obj) - } }) } }) @@ -1767,13 +1760,12 @@ function getProviderInterfaceName(iface, capability, moduleJson = {}) { return name } -function getProviderXValues(method, document) { +function getProviderXValues(method) { let xValues = [] if (method.tags.find(t => t['x-error']) || method.tags.find(t => t['x-response'])) { method.tags.forEach(tag => { if (tag['x-response']) { - const resolvedRefResponse = getPropertySchema(tag['x-response'], '', document) - xValues['x-response'] = resolvedRefResponse + xValues['x-response'] = tag['x-response'] } if (tag['x-error']) { xValues['x-error'] = tag['x-error'] @@ -1838,7 +1830,7 @@ function insertProviderInterfaceMacros(template, capability, moduleJson = {}, te if (!interfaceDeclaration) { interfaceDeclaration = getTemplate(interfaceTemplate, templates) } - xValues = getProviderXValues(method, moduleJson) + xValues = getProviderXValues(method) method.tags.unshift({ name: 'provider' })