-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
3104 lines (2962 loc) · 87.2 KB
/
Copy pathopenapi.yaml
File metadata and controls
3104 lines (2962 loc) · 87.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.1.0
info:
title: JArchi Model API Server
version: 1.1.0
description: |
REST API server for ArchiMate model operations running inside Archi via JArchi plugin.
## Architecture
External clients communicate via HTTP to a Java HttpServer running inside Archi's JVM.
All model operations execute on the SWT Display thread and are fully undoable (Ctrl+Z).
## Security Warning
⚠️ **NO AUTHENTICATION** - Binds to localhost only (127.0.0.1).
Do NOT expose to network. For development and local automation only.
## Prerequisites
- Open ArchiMate model in Archi
- Open at least one view from the model (required for undo/redo support)
- Port 8765 available (configurable)
contact:
name: JArchi Scripts
license:
name: MIT
servers:
- url: http://127.0.0.1:8765
description: Local development server (default)
tags:
- name: Health
description: Server health, diagnostics, and lifecycle management
- name: Model
description: Model query and mutation operations
- name: Operations
description: Async operation status tracking
- name: Scripts
description: Script execution and management
- name: Views
description: View management, export to PNG/JPEG
paths:
/health:
get:
tags:
- Health
summary: Server health check
description: |
Returns detailed server health information including memory usage,
operation queue statistics, and model information.
operationId: getHealth
responses:
'200':
description: Server health information
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
/test:
get:
tags:
- Health
summary: UI thread test
description: |
Tests that the handler is running on the SWT Display (UI) thread.
Returns thread information and model reference status.
operationId: getTest
responses:
'200':
description: Test result
content:
application/json:
schema:
$ref: '#/components/schemas/TestResponse'
/shutdown:
post:
tags:
- Health
summary: Trigger server shutdown
description: |
Initiates graceful server shutdown. The server will wait for in-flight
operations to complete (up to configured timeout) before stopping.
operationId: postShutdown
responses:
'200':
description: Shutdown initiated
content:
application/json:
schema:
$ref: '#/components/schemas/ShutdownResponse'
/model/diagnostics:
get:
tags:
- Health
summary: Model diagnostics and orphan detection
description: |
Runs diagnostics on the loaded model, including detection of orphan/ghost
objects. Ghost objects exist in the EMF model resource but are not contained
in any folder — typically caused by silent GEF command stack rollbacks.
Returns the current snapshot summary alongside any orphan elements and
relationships found via EMF-level traversal.
operationId: getModelDiagnostics
responses:
'200':
description: Diagnostics result
content:
application/json:
schema:
$ref: '#/components/schemas/DiagnosticsResponse'
'400':
description: No model loaded
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/model/query:
post:
tags:
- Model
summary: Query model snapshot
description: |
Returns a summary of the model and a sample of elements.
Optionally include relationship samples by passing `relationshipLimit`.
The snapshot is captured when the server starts and refreshed after mutations.
operationId: postModelQuery
requestBody:
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/QueryRequest'
responses:
'200':
description: Model query result
content:
application/json:
schema:
$ref: '#/components/schemas/QueryResponse'
'500':
description: Query failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/model/plan:
post:
tags:
- Model
summary: Generate change plan
description: |
Generates a change plan without mutating the model.
Use this to preview what changes would be made before applying them.
operationId: postModelPlan
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PlanRequest'
responses:
'200':
description: Change plan generated
content:
application/json:
schema:
$ref: '#/components/schemas/PlanResponse'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/model/search:
post:
tags:
- Model
summary: Search elements with filters
description: |
Search for elements and relationships matching specified criteria.
Supports filtering by type, name pattern (regex), and property key/value.
operationId: postModelSearch
requestBody:
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/SearchRequest'
responses:
'200':
description: Search results
content:
application/json:
schema:
$ref: '#/components/schemas/SearchResponse'
'500':
description: Search failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/model/element/{elementId}:
get:
tags:
- Model
summary: Get element details
description: |
Returns detailed information about a single element including:
- Name, type, documentation
- All properties
- Related relationships (incoming and outgoing)
- Views containing the element
operationId: getElementById
parameters:
- name: elementId
in: path
required: true
description: Element ID
schema:
type: string
responses:
'200':
description: Element details
content:
application/json:
schema:
$ref: '#/components/schemas/ElementDetailResponse'
'404':
description: Element not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Internal error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/model/save:
post:
tags:
- Model
summary: Save model to disk
description: |
Persists the current model state to its file on disk.
Use this after making changes to ensure they are saved.
**Auto-save behavior**: If the model has never been saved and no path is provided,
the server will automatically generate a path based on the model name in
`~/Documents/archi-models/`. The response will include `autoGeneratedPath: true`.
To specify a custom location, provide the `path` parameter.
operationId: postModelSave
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
path:
type: string
description: |
Absolute file path to save the model to (e.g. "/path/to/model.archimate").
Optional - if omitted for unsaved models, path is auto-generated.
The .archimate extension is appended automatically if missing.
responses:
'200':
description: Model saved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/SaveResponse'
'500':
description: Save failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/model/stats:
get:
tags:
- Model
summary: Get model statistics with type breakdowns
description: |
Returns detailed statistics about the model including counts of elements,
relationships, and views grouped by ArchiMate type.
This endpoint uses the model snapshot for fast response times without
traversing the live model. The snapshot is refreshed after mutations.
operationId: getModelStats
responses:
'200':
description: Model statistics
content:
application/json:
schema:
$ref: '#/components/schemas/StatsResponse'
'500':
description: Internal error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/folders:
get:
tags:
- Model
summary: List all folders
description: |
Returns the complete folder hierarchy of the model.
Includes folder type, element count, and subfolder count.
operationId: getFolders
responses:
'200':
description: Folder list
content:
application/json:
schema:
$ref: '#/components/schemas/FolderListResponse'
'500':
description: Internal error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/model/apply:
post:
tags:
- Model
summary: Apply changes asynchronously
description: |
Queues model changes for asynchronous processing. Returns immediately
with an operation ID that can be polled via `/ops/status`.
All changes are executed on the SWT Display thread and are fully undoable.
**Internal chunking**: Large batches are automatically split into smaller
GEF CompoundCommands (default: 100 sub-commands per chunk, ~20 relationship
creates). This prevents silent rollback by Eclipse's command stack on very
large compound commands. Each chunk becomes a separate undo entry.
**Post-execution verification**: After execution, created objects are verified
to still exist in model folders. If a silent rollback is detected, the
operation reports an error instead of falsely returning success.
**Recommended**: Keep batches under 20 operations when creating relationships,
or use `archicli batch apply` which handles chunking automatically and polls by default.
operationId: postModelApply
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ApplyRequest'
responses:
'200':
description: Operation queued
content:
application/json:
schema:
$ref: '#/components/schemas/ApplyResponse'
'409':
description: Idempotency conflict (same key with different payload)
content:
application/json:
schema:
$ref: '#/components/schemas/IdempotencyConflictErrorResponse'
'400':
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/ops/status:
get:
tags:
- Operations
summary: Poll operation status
description: |
Returns the current status of an async operation queued via `/model/apply`.
operationId: getOpsStatus
parameters:
- name: opId
in: query
required: true
description: Operation ID returned from `/model/apply`
schema:
type: string
- name: summaryOnly
in: query
required: false
description: Return compact status metadata without result payload rows
schema:
type: boolean
default: false
- name: cursor
in: query
required: false
description: Zero-based cursor offset for paged result rows
schema:
type: string
- name: pageSize
in: query
required: false
description: Number of result rows per page (1-1000, default 200)
schema:
type: integer
minimum: 1
maximum: 1000
default: 200
responses:
'200':
description: Operation status
content:
application/json:
schema:
$ref: '#/components/schemas/OperationStatusResponse'
'400':
description: Missing opId parameter
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Operation not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/ops/list:
get:
tags:
- Operations
summary: List recent operations
description: |
Returns recent async operations queued via `/model/apply`, sorted by newest first.
operationId: getOpsList
parameters:
- name: limit
in: query
required: false
description: Maximum number of operations to return (1-200, default 20)
schema:
type: integer
minimum: 1
maximum: 200
default: 20
- name: status
in: query
required: false
description: Optional status filter
schema:
type: string
enum: [queued, processing, complete, error]
- name: cursor
in: query
required: false
description: Zero-based cursor offset for paged operation summaries
schema:
type: string
- name: summaryOnly
in: query
required: false
description: Return compact operation summaries only
schema:
type: boolean
default: false
responses:
'200':
description: Operation list
content:
application/json:
schema:
$ref: '#/components/schemas/OperationListResponse'
'400':
description: Invalid query parameter
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/scripts/run:
post:
tags:
- Scripts
summary: Execute JArchi script code
description: |
Executes arbitrary JArchi script code synchronously on the UI thread.
Scripts can communicate results by mutating the pre-initialized `__scriptResult` object:
```javascript
// Correct - mutate the existing object properties
__scriptResult.value = { name: "example", count: 42 };
__scriptResult.files.push("path/to/file.png");
// WRONG - reassignment loses the reference
// __scriptResult = { value: "data" }; // This won't work!
```
**Available helpers:**
- `getModel()` - Returns the first loaded model, or null if none
- `findElements(type)` - Query elements (wraps $() for API use)
- `findViews(name)` - Query views by optional name pattern
- `findRelationships(type)` - Query relationships
- `__scriptsDir__` - Path to scripts directory for loading libs
**Note:** The bare `$()` selector requires UI selection context and will fail via API.
Use `getModel()` or `$.model.getLoadedModels().get(0)` instead.
**⚠️ IMPORTANT: Property Modification Limitation**
JArchi proxy property setters (`element.name = "..."`, `element.documentation = "..."`,
`element.prop("key", "value")`) will **fail with NullPointerException** when executed
via this endpoint. This is because the internal `CommandHandler.compoundcommands` field
is private and cannot be initialized from the API server context.
**For element modifications, use `/model/apply` with `updateElement` operation instead:**
```json
POST /model/apply
{
"changes": [{
"op": "updateElement",
"id": "element-id",
"name": "New Name",
"documentation": "New docs",
"properties": { "key": "value" }
}]
}
```
Scripts executed via this endpoint are best suited for:
- **Read-only operations** (queries, exports, analysis)
- **File generation** (PNG/JPG export, JSON export)
- **Operations using `undoableCommands`** directly (advanced)
**⚠️ BLOCKING RISK:** Scripts execute synchronously on the SWT UI thread.
An infinite loop or long-running computation will freeze the entire Archi application
and block all other API requests. There is no timeout or cancellation mechanism.
Keep scripts short and well-tested. Maximum code size is limited by the server's
request body size limit (default 1MB).
operationId: postScriptsRun
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ScriptRunRequest'
responses:
'200':
description: Script execution result
content:
application/json:
schema:
$ref: '#/components/schemas/ScriptRunResponse'
'400':
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Script execution error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
# ============================================================
# View Management Endpoints
# ============================================================
/views:
get:
tags:
- Views
summary: List all views
description: |
Returns a list of all views in the model with metadata.
Includes ArchiMate views, sketch views, and canvas views.
operationId: getViews
responses:
'200':
description: List of views
content:
application/json:
schema:
$ref: '#/components/schemas/ViewListResponse'
'500':
description: Internal error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
post:
tags:
- Views
summary: Create new view
description: |
Creates a new ArchiMate view in the model synchronously.
The operation is undoable via Ctrl+Z in Archi.
The view is created empty - use `/model/apply` to add elements.
operationId: postViews
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateViewRequest'
responses:
'200':
description: View created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/CreateViewResponse'
'400':
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'409':
description: View name already exists
content:
application/json:
schema:
type: object
properties:
error:
type: object
properties:
code:
type: string
enum: [ViewNameExists]
message:
type: string
existingViewId:
type: string
description: ID of the existing view with this name
'500':
description: Internal error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/views/{viewId}:
get:
tags:
- Views
summary: Get view details
description: |
Returns detailed information about a specific view including
all visual elements and connections with their positions.
operationId: getViewById
parameters:
- name: viewId
in: path
required: true
description: View ID
schema:
type: string
responses:
'200':
description: View details
content:
application/json:
schema:
$ref: '#/components/schemas/ViewDetailResponse'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: View not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Internal error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
delete:
tags:
- Views
summary: Delete view
description: |
Deletes a view from the model.
This operation removes the view and all its visual objects.
operationId: deleteView
parameters:
- name: viewId
in: path
required: true
description: View ID to delete
schema:
type: string
responses:
'200':
description: View deleted
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
viewId:
type: string
viewName:
type: string
'404':
description: View not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Delete failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/views/{viewId}/export:
post:
tags:
- Views
summary: Export view to file
description: |
Exports a view to an image file (PNG or JPEG).
Returns the absolute file path for local filesystem access.
If no `outputPath` is specified, a temporary file is created.
**Format-specific options:**
- `scale`: Image scale factor (0.5 to 4)
- `margin`: Margin in pixels
operationId: postViewExport
parameters:
- name: viewId
in: path
required: true
description: View ID to export
schema:
type: string
requestBody:
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/ExportViewRequest'
responses:
'200':
description: Export successful
content:
application/json:
schema:
$ref: '#/components/schemas/ExportViewResponse'
'400':
description: Invalid format or request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: View not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Export failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/views/{viewId}/duplicate:
post:
tags:
- Views
summary: Duplicate view
description: |
Creates a deep copy of a view with all its visual objects.
The new view is placed in the same folder as the original.
operationId: postViewDuplicate
parameters:
- name: viewId
in: path
required: true
description: Source view ID
schema:
type: string
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
name:
type: string
description: Name for the duplicated view (default adds "(Copy)" suffix)
responses:
'200':
description: View duplicated
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
sourceViewId:
type: string
newViewId:
type: string
newViewName:
type: string
'404':
description: View not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Duplicate failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/views/{viewId}/router:
put:
tags:
- Views
summary: Set connection router type
description: |
Sets the connection routing style for the view.
- `bendpoint`: Manual routing with user-defined bendpoints
- `manhattan`: Automatic orthogonal routing
operationId: putViewRouter
parameters:
- name: viewId
in: path
required: true
description: View ID
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- routerType
properties:
routerType:
type: string
enum: [bendpoint, manhattan]
responses:
'200':
description: Router set
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
viewId:
type: string
routerType:
type: string
'400':
description: Invalid router type
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: View not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/views/{viewId}/layout:
post:
tags:
- Views
summary: Apply automatic layout
description: |
Applies automatic graph layout algorithm to arrange elements in the view.
Supports Dagre and Sugiyama-style layered algorithms with configurable options.
Unknown algorithms fall back to dagre.
operationId: postViewLayout
parameters:
- name: viewId
in: path
required: true
description: View ID
schema:
type: string
requestBody:
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/LayoutRequest'
responses:
'200':
description: Layout applied
content:
application/json:
schema:
$ref: '#/components/schemas/LayoutResponse'
'404':
description: View not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'501':
description: Layout module not available
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Layout failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/views/{viewId}/validate:
get:
tags:
- Views
summary: Validate view connection integrity
description: |
Validates the integrity of connections in a view.
Checks performed:
- **Orphaned connections**: Visual connections without underlying relationship references
- **Direction mismatches**: Visual connections where source/target don't match relationship direction
Use this endpoint after populating views to verify connection integrity.
operationId: getViewValidate
parameters:
- name: viewId
in: path
required: true
description: View ID to validate
schema:
type: string
responses:
'200':
description: Validation result
content:
application/json:
schema:
$ref: '#/components/schemas/ValidateViewResponse'
'404':
description: View not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Validation failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'