diff --git a/api/csolution-openapi.yml b/api/csolution-openapi.yml index 46cb27f..bb95ac0 100644 --- a/api/csolution-openapi.yml +++ b/api/csolution-openapi.yml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: csolution rpc - version: 0.0.7 + version: 0.0.8 description: Specification of remote procedure call methods for CMSIS csolution integration license: name: Apache 2.0 @@ -87,6 +87,17 @@ paths: '200': description: OK content: {application/json: {schema: {$ref: '#/components/schemas/GetUsedItemsResponse'}}} + /rpc/GetContextInfo: + post: + summary: Get combined context info + description: Get combined context info (device, board, variables, components and packs used) + tags: [/rpc] + requestBody: + content: {application/json: {schema: {$ref: '#/components/schemas/GetContextInfoRequest'}}} + responses: + '200': + description: OK + content: {application/json: {schema: {$ref: '#/components/schemas/GetContextInfoResponse'}}} /rpc/GetPacksInfo: post: summary: Get packs information @@ -288,6 +299,10 @@ components: description: optional error/warning/info message required: - success + Attributes: + type: object + additionalProperties: + type: string Common: type: object properties: @@ -391,9 +406,8 @@ components: type: string description: Processor core type attributes: - type: object - additionalProperties: - type: string + $ref: '#/components/schemas/Attributes' + description: Processor attributes required: - core Memory: @@ -724,6 +738,32 @@ components: required: - components - packs + Variables: + type: object + additionalProperties: + type: string + description: Resolved context variables + ContextInfo: + allOf: + - $ref: '#/components/schemas/UsedItems' + - properties: + board: + $ref: '#/components/schemas/Board' + device: + $ref: '#/components/schemas/Device' + pname: + type: string + description: Processor name used in context + variables: + $ref: '#/components/schemas/Variables' + attributes: + $ref: '#/components/schemas/Attributes' + description: RTE target attributes + required: + - device + - pname + - attributes + - variables LogMessages: allOf: - $ref: '#/components/schemas/SuccessResult' @@ -918,10 +958,7 @@ components: - $ref: '#/components/schemas/SuccessResult' - properties: variables: - type: object - additionalProperties: - type: string - description: Resolved context variables + $ref: '#/components/schemas/Variables' required: - variables GetVariablesRequest: @@ -1127,6 +1164,26 @@ components: - properties: result: $ref: '#/components/schemas/UsedItems' + GetContextInfoRequest: + allOf: + - $ref: '#/x-jsonrpc-envelope-request-with-params' + - properties: + method: + type: string + const: GetContextInfo + params: + type: object + properties: + context: + type: string + required: + - context + GetContextInfoResponse: + allOf: + - $ref: '#/x-jsonrpc-envelope-response' + - properties: + result: + $ref: '#/components/schemas/ContextInfo' GetDeviceListRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' diff --git a/codegen/src/codegen.ts b/codegen/src/codegen.ts index fe74710..ed4f1e7 100644 --- a/codegen/src/codegen.ts +++ b/codegen/src/codegen.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025 Arm Limited. All rights reserved. + * Copyright (c) 2025-2026 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 */ @@ -44,10 +44,16 @@ export interface Member { optional?: boolean; } +export interface CustomType { + cppType: string; + tsType: string; +} + export interface Struct { description?: string; members?: Member[]; extends?: string[]; + customType?: CustomType; } export interface Function { @@ -66,7 +72,7 @@ export class Codegen { readonly header = `/* - * Copyright (c) 2025 Arm Limited. All rights reserved. + * Copyright (c) 2025-2026 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * @@ -257,6 +263,12 @@ using namespace jsonrpccxx;\n`; this.collectStructs(this.getTypeName(name), item); } this.collectStruct(parent, obj.items ?? obj); + } else if (obj.additionalProperties) { + // Handle types defined with additionalProperties (e.g., map/record types) + const {cpp, ts} = this.getType(parent, obj); + this.structs[parent] = { + description: obj.description, + customType: { cppType: cpp, tsType: ts } }; } if (obj.allOf && Array.isArray(obj.allOf)) { for (const item of obj.allOf) { @@ -394,6 +406,9 @@ using namespace jsonrpccxx;\n`; let structContent = ''; const forwardDeclaration = new Set; //TODO: content += `${struct.description ? ` // ${struct.description}\n` : ''}`; + if (struct.customType) { + structContent += ` using ${name} = ${struct.customType.cppType};\n`; + } if (struct.members) { structContent += ` struct ${name}`; if (struct.extends) { @@ -464,6 +479,9 @@ ${this.genCppNamespace()}\n${this.genCppClass()}\n${this.cppFooter}\n`; let content = ''; for (const name in this.structs) { const struct = this.structs[name]; + if (struct.customType) { + content += `export type ${name} = ${struct.customType.tsType};\n`; + } if (struct.members) { content += `export interface ${name}`; if (struct.extends) {