Skip to content

Commit 69c7dc2

Browse files
committed
Make all calls return SuccessResult values
1 parent 4402dfa commit 69c7dc2

2 files changed

Lines changed: 99 additions & 83 deletions

File tree

api/csolution-openapi.yml

Lines changed: 83 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ paths:
167167

168168
components:
169169
schemas:
170+
SuccessResult:
171+
type: object
172+
properties:
173+
success:
174+
type: boolean
175+
description: true if requested operation has been performed successfully or selection has been modified
176+
message:
177+
type: string
178+
description: optional error/warning/info message
179+
required:
180+
- success
170181
Common:
171182
type: object
172183
properties:
@@ -197,15 +208,16 @@ components:
197208
items:
198209
type: string
199210
PacksInfo:
200-
type: object
201-
properties:
202-
packs:
203-
type: array
204-
description: List of packs information
205-
items:
206-
$ref: '#/components/schemas/Pack'
207-
required:
208-
- packs
211+
allOf:
212+
- $ref: '#/components/schemas/SuccessResult'
213+
- properties:
214+
packs:
215+
type: array
216+
description: List of packs information
217+
items:
218+
$ref: '#/components/schemas/Pack'
219+
required:
220+
- packs
209221
Component:
210222
allOf:
211223
- $ref: '#/components/schemas/Common'
@@ -367,16 +379,16 @@ components:
367379
required:
368380
- bundles
369381
CtRoot:
370-
type: object
371-
description: Root of Component Tree
372-
properties:
373-
classes:
374-
type: array
375-
description: Array of Component Classes
376-
items:
377-
$ref: '#/components/schemas/CtClass'
378-
required:
379-
- classes
382+
allOf:
383+
- $ref: '#/components/schemas/SuccessResult'
384+
- properties:
385+
classes:
386+
type: array
387+
description: Array of Component Classes
388+
items:
389+
$ref: '#/components/schemas/CtClass'
390+
required:
391+
- classes
380392
Condition:
381393
type: object
382394
properties:
@@ -413,46 +425,50 @@ components:
413425
- id
414426
- result
415427
Results:
416-
type: object
417-
properties:
418-
result:
419-
type: string
420-
description: 'Condition result: https://github.com/Open-CMSIS-Pack/devtools/blob/tools/projmgr/2.8.0/libs/rtemodel/include/RteItem.h#L78-L95'
421-
validation:
422-
type: array
423-
items:
424-
$ref: '#/components/schemas/Result'
425-
required:
426-
- result
428+
allOf:
429+
- $ref: '#/components/schemas/SuccessResult'
430+
- properties:
431+
result:
432+
type: string
433+
description: 'Condition result: https://github.com/Open-CMSIS-Pack/devtools/blob/tools/projmgr/2.8.0/libs/rtemodel/include/RteItem.h#L78-L95'
434+
validation:
435+
type: array
436+
items:
437+
$ref: '#/components/schemas/Result'
438+
required:
439+
- result
427440
UsedItems:
428-
type: object
429-
properties:
430-
components:
431-
type: array
432-
items:
433-
$ref: '#/components/schemas/ComponentInstance'
434-
packs:
435-
type: array
436-
items:
437-
$ref: '#/components/schemas/Pack'
438-
required:
439-
- components
440-
- packs
441+
allOf:
442+
- $ref: '#/components/schemas/SuccessResult'
443+
- properties:
444+
components:
445+
type: array
446+
items:
447+
$ref: '#/components/schemas/ComponentInstance'
448+
packs:
449+
type: array
450+
items:
451+
$ref: '#/components/schemas/Pack'
452+
required:
453+
- components
454+
- packs
455+
441456
LogMessages:
442-
type: object
443-
properties:
444-
info:
445-
type: array
446-
items:
447-
type: string
448-
errors:
449-
type: array
450-
items:
451-
type: string
452-
warnings:
453-
type: array
454-
items:
455-
type: string
457+
allOf:
458+
- $ref: '#/components/schemas/SuccessResult'
459+
- properties:
460+
info:
461+
type: array
462+
items:
463+
type: string
464+
errors:
465+
type: array
466+
items:
467+
type: string
468+
warnings:
469+
type: array
470+
items:
471+
type: string
456472

457473
GetVersionRequest:
458474
allOf:
@@ -461,12 +477,20 @@ components:
461477
method:
462478
type: string
463479
const: GetVersion
480+
481+
GetVersionResult:
482+
allOf:
483+
- $ref: '#/components/schemas/SuccessResult'
484+
- properties:
485+
version:
486+
type: string
487+
description: Tool version
464488
GetVersionResponse:
465489
allOf:
466490
- $ref: '#/x-jsonrpc-envelope-response'
467491
- properties:
468492
result:
469-
type: string
493+
$ref: '#/components/schemas/GetVersionResult'
470494
ShutdownRequest:
471495
allOf:
472496
- $ref: '#/x-jsonrpc-envelope-request'
@@ -479,7 +503,7 @@ components:
479503
- $ref: '#/x-jsonrpc-envelope-response'
480504
- properties:
481505
result:
482-
type: boolean
506+
$ref: '#/components/schemas/SuccessResult'
483507
ApplyRequest:
484508
allOf:
485509
- $ref: '#/x-jsonrpc-envelope-request-with-params'
@@ -641,17 +665,6 @@ components:
641665
- id
642666
- count
643667
- options
644-
SuccessResult:
645-
type: object
646-
properties:
647-
success:
648-
type: boolean
649-
description: true if requested operation has been performed successfully or selection has been modified
650-
message:
651-
type: string
652-
description: optional error/warning/info message
653-
required:
654-
- success
655668
SelectComponentResponse:
656669
allOf:
657670
- $ref: '#/x-jsonrpc-envelope-response'

examples/vscode-extension-client/src/rpc-interface.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
* json-rpc-codegen generated file: DO NOT EDIT!
77
*/
88

9+
export interface SuccessResult {
10+
success: boolean,
11+
message?: string,
12+
}
913
export interface Common {
1014
id: string,
1115
description?: string,
@@ -16,7 +20,7 @@ export interface Pack extends Common {
1620
used?: boolean,
1721
references?: string[],
1822
}
19-
export interface PacksInfo {
23+
export interface PacksInfo extends SuccessResult {
2024
packs: Pack[],
2125
}
2226
export interface Component extends Common {
@@ -73,7 +77,7 @@ export interface CtClass extends CtItem {
7377
activeBundle?: string,
7478
bundles: CtBundle[],
7579
}
76-
export interface CtRoot {
80+
export interface CtRoot extends SuccessResult {
7781
classes: CtClass[],
7882
}
7983
export interface Condition {
@@ -86,19 +90,22 @@ export interface Result {
8690
aggregates?: string[],
8791
conditions?: Condition[],
8892
}
89-
export interface Results {
93+
export interface Results extends SuccessResult {
9094
result: string,
9195
validation?: Result[],
9296
}
93-
export interface UsedItems {
97+
export interface UsedItems extends SuccessResult {
9498
components: ComponentInstance[],
9599
packs: Pack[],
96100
}
97-
export interface LogMessages {
101+
export interface LogMessages extends SuccessResult {
98102
info?: string[],
99103
errors?: string[],
100104
warnings?: string[],
101105
}
106+
export interface GetVersionResult extends SuccessResult {
107+
version?: string,
108+
}
102109
export interface ApplyParams {
103110
context: string,
104111
}
@@ -124,10 +131,6 @@ export interface SelectComponentParams {
124131
count: number,
125132
options: Options,
126133
}
127-
export interface SuccessResult {
128-
success: boolean,
129-
message?: string,
130-
}
131134
export interface SelectVariantParams {
132135
context: string,
133136
id: string,
@@ -143,8 +146,8 @@ export interface ValidateComponentsParams {
143146
}
144147

145148
export interface RpcInterface {
146-
getVersion(): Promise<string>;
147-
shutdown(): Promise<boolean>;
149+
getVersion(): Promise<GetVersionResult>;
150+
shutdown(): Promise<SuccessResult>;
148151
apply(args: ApplyParams): Promise<SuccessResult>;
149152
resolve(args: ResolveParams): Promise<SuccessResult>;
150153
loadPacks(): Promise<SuccessResult>;
@@ -163,10 +166,10 @@ export abstract class RpcMethods implements RpcInterface {
163166

164167
abstract get<TArgs, TResponse>(remoteMethod: string, args?: TArgs): Promise<TResponse>;
165168

166-
public async getVersion(): Promise<string> {
169+
public async getVersion(): Promise<GetVersionResult> {
167170
return this.get('GetVersion');
168171
}
169-
public async shutdown(): Promise<boolean> {
172+
public async shutdown(): Promise<SuccessResult> {
170173
return this.get('Shutdown');
171174
}
172175
public async apply(args: ApplyParams): Promise<SuccessResult> {

0 commit comments

Comments
 (0)