-
Notifications
You must be signed in to change notification settings - Fork 0
/
heta-api-schema.json
518 lines (518 loc) · 21.6 KB
/
heta-api-schema.json
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
{
"openapi": "3.0.0",
"info": {
"title": "Heta Compiler API",
"version": "0.1.1",
"description": "API for interacting with the Heta Compiler via HTTP."
},
"servers": [
{
"url": "https://heta-api.insysbio.com",
"description": "Main server for Heta API"
}
],
"paths": {
"/build": {
"post": {
"operationId": "buildPlatform",
"summary": "Trigger platform compilation",
"description": "Compiles a Heta-based platform and generates export files. It works synchronously and returns the result immediately. The result includes the list of generated files and logs. The files will be deleted after a certain time.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["inputFiles"],
"properties": {
"lifetime": {
"type": "number",
"default": 3600,
"description": "Time in seconds for keeping files on the server. It is related to the task ID. Default is 1 hour."
},
"inputFiles": {
"type": "array",
"description": "Array of files of platform.",
"minItems": 1,
"items": { "$ref": "#/components/schemas/File" },
"example": [
{
"filepath": "index.heta",
"format": "utf8",
"filebody": "include model.heta;\n\n"
}
]
},
"declaration": {
"type": "object",
"description": "Structure describing the platform compilation. This object share same structure as platform.yml in heta-compiler. If omitted, the compiler will use the default options.",
"properties": {
"importModule": {
"type": "object",
"description": "Import entry point module for compilation.",
"required": ["source"],
"properties": {
"source": {
"type": "string",
"description": "Index file for compilation. The file should be included in 'files'. It is an entry point for compilation.",
"default": "index.heta",
"example": "src/index.heta"
},
"type": {
"type": "string",
"enum": ["heta", "table", "xlsx", "json", "yaml", "sbml"],
"description": "The format of source file for compilation.",
"default": "heta",
"example": "json"
}
}
},
"options": {
"type": "object",
"description": "Compilation options.",
"properties": {
"unitsCheck": {
"type": "boolean",
"default": false,
"description": "Check for unit consistency. If 'true' the command will check the units consistency in the platform. If 'false' (default) the command will skip the units check."
},
"debug": {
"type": "boolean",
"description": "Enable debugging mode. In debug mode, the compiler will save additional files in 'metaDir' for debugging purposes.",
"default": false
},
"distDir": {
"type": "string",
"description": "Path for saving exported files as stated in 'export' option.",
"default": "dist"
},
"metaDir": {
"type": "string",
"description": "Path for saving metadata. Used for debugging when option 'debug: true'.",
"default": "meta"
},
"logMode": {
"type": "string",
"enum": ["never", "error", "always"],
"description": "Level at which log file will be generated and saved. 'never' - no logs, 'error' - only errors, 'always' - all logs.",
"default": "error"
},
"logPath": {
"type": "string",
"description": "Path for saving log file.",
"default": "build.log"
},
"logFormat": {
"type": "string",
"description": "Format of log file. 'json' - JSON format, 'text' - plain text format.",
"enum": ["json", "string"],
"default": "string"
}
}
},
"export": {
"$ref": "#/components/schemas/Export"
}
}
}
},
"example": {
"lifetime": 1800,
"inputFiles": [
{
"filepath": "index.heta",
"format": "utf8",
"filebody": "x1 @Record := 1.2;\n\nc1 @Compartment .= 5;"
}
],
"declaration": {
"importModule": {
"source": "index.heta",
"type": "heta"
},
"unitsCheck": true,
"debug": false,
"distDir": "dist",
"metaDir": "meta",
"logMode": "error",
"export": [
{ "format": "JSON" },
{ "format": "YAML" },
{ "format": "DBSolve", "version": "25" },
{ "format": "SBML", "version": "L3V2" },
{ "format": "Simbio" },
{ "format": "Mrgsolve" },
{ "format": "Table", "splitByClass": true, "omitRows": 3, "bookType": "xlsx" },
{ "format": "Matlab" },
{ "format": "Dot" },
{ "format": "Summary" }
]
}
}
}
}
}
},
"responses": {
"200": {
"description": "Compilation finished.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"outputFiles": {
"type": "array",
"description": "Array of generated files.",
"items": { "$ref": "#/components/schemas/File" }
},
"logs": {
"type": "array",
"description": "Array of log messages.",
"items": { "type": "string" }
},
"taskId": {
"type": "string",
"description": "Task ID for getting files in UIDs format.",
"example": "5f7b1b7b-0b7b-4b7b-8b7b-0b7b7b7b7b7b"
},
"lifeend": {
"type": "number",
"description": "Time when files will be deleted in Unix timestamp seconds format.",
"example": 1634025600
},
"downloadLink": {
"type": "string",
"description": "Link for downloading a ZIP file with all generated files.",
"example": "/download/5f7b1b7b-0b7b-4b7b-8b7b-0b7b7b7b7b7b"
},
"filesLink": {
"type": "string",
"description": "Link for server where all files are temporally stored. To get the full path add base server URL, e.g. https://heta-api.insysbio.com/files/5f7b1b7b-0b7b-4b7b-8b7b-0b7b7b7b7b7b",
"example": "/files/5f7b1b7b-0b7b-4b7b-8b7b-0b7b7b7b7b7b"
}
},
"example": {
"outputFiles": [
{"filepath": "index.heta"},
{"filepath": "dist/json/model.json"},
{"filepath": "dist/yaml/model.yaml"},
{"filepath": "dist/dbsolve/model.slv"},
{"filepath": "dist/sbml/model.xml"},
{"filepath": "dist/simbio/model.m"},
{"filepath": "dist/mrgsolve/model.cpp"},
{"filepath": "dist/mrgsolve/run.R"},
{"filepath": "dist/table/model.xlsx"},
{"filepath": "dist/matlab/model.m"},
{"filepath": "dist/dot/model.dot"},
{"filepath": "dist/summary/model.txt"}
],
"logs": ["Compilation finished successfully."],
"taskId": "5f7b1b7b-0b7b-4b7b-8b7b-0b7b7b7b7b7b",
"lifeend": 1634025600,
"downloadLink": "/download/5f7b1b7b-0b7b-4b7b-8b7b-0b7b7b7b7b7b",
"filesLink": "/files/5f7b1b7b-0b7b-4b7b-8b7b-0b7b7b7b7b7b"
}
}
}
}
},
"422": {
"description": "Unprocessable entity. The request is well-formed but unable to process. Compilation finished but with errors. This is usually because of platform files misconfiguration not related to the compiler or API.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"outputFiles": {
"type": "array",
"description": "Array of the generated files.",
"items": { "$ref": "#/components/schemas/File" }
},
"logs": {
"type": "array",
"description": "Array of log messages.",
"items": { "type": "string" }
},
"taskId": {
"type": "string",
"description": "Task ID for getting files in UIDs format.",
"example": "5f7b1b7b-0b7b-4b7b-8b7b-0b7b7b7b7b7b"
},
"lifeend": {
"type": "number",
"description": "Time when files will be deleted in Unix timestamp seconds format.",
"example": 1634025600
},
"downloadLink": {
"type": "string",
"description": "Link for downloading a ZIP file with all generated files.",
"example": "/download/5f7b1b7b-0b7b-4b7b-8b7b-0b7b7b7b7b7b"
},
"filesLink": {
"type": "string",
"description": "Link for server where all files are temporally stored. To get the full path add base server URL, e.g. https://heta-api.insysbio.com/files/5f7b1b7b-0b7b-4b7b-8b7b-0b7b7b7b7b7b",
"example": "/files/5f7b1b7b-0b7b-4b7b-8b7b-0b7b7b7b7b7b"
}
}
}
}
}
},
"400": {
"description": "Invalid request parameters. Request structure do not match the schema. Issues with user's API request.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"example": "ValidationError"
},
"message": {
"type": "string",
"example": "Wrong format of export option."
},
"errors": {
"type": "array",
"items": { "type": "string" }
}
}
}
}
}
},
"500": {
"description": "Internal server error. Some critical error occurred during compilation. Problem with heta-compiler or api application development.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Internal Heta compiler error."
}
}
}
}
}
}
}
}
},
"/download/{taskId}": {
"get": {
"operationId": "downloadFile",
"summary": "Download file",
"description": "Download a ZIP file associated with a whole content of the build platform.",
"parameters": [
{
"name": "taskId",
"in": "path",
"required": true,
"description": "Unique task ID from /build POST response.",
"schema": {
"type": "string",
"example": "9cc63441-a35c-4e41-b62c-505532fd79a6"
}
}
],
"responses": {
"200": {
"description": "File is ready for download.",
"content": {
"application/zip": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"404": {
"description": "File is not found.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"example": "File is not found."
}
}
}
}
}
},
"500": {
"description": "Internal server error. Problem in api application developed.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Unknown error."
}
}
}
}
}
}
}
}
},
"/info": {
"get": {
"operationId": "getInfo",
"description": "Check connectivity and get information about the Heta Compiler.",
"responses": {
"200": {
"description": "Information about the Heta Compiler.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"version": {
"type": "string",
"example": "1.0.0"
},
"node": {
"type": "string",
"example": "v14.17.0"
},
"description": {
"type": "string",
"example": "Heta Compiler API"
}
}
}
}
}
}
}
}
},
"/schema": {
"get": {
"operationId": "getSchema",
"description": "Get the OpenAPI schema for the Heta Compiler API.",
"responses": {
"200": {
"description": "OpenAPI schema for the Heta Compiler API.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"openapi": {
"type": "string",
"example": "3.1.0"
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Export": {
"type": "array",
"default": [],
"description": "Array of export formats. If omitted nothing wll be exported which is useful for testing correctness of platform.",
"items": {
"type": "object",
"required": ["format"],
"properties": {
"format": {
"type": "string",
"enum": ["JSON", "YAML", "DBSolve", "SLV", "SBML", "Simbio", "Mrgsolve", "Table", "XLSX", "Julia", "Matlab", "Dot", "Summary"],
"description": "The type of file for compilation. Case sensitive."
},
"spaceFilter": {
"type": "string",
"description": "Filter for space in RegExp format. Skip it if you want to export all spaces.",
"example": "^one|two$"
},
"omit": {
"type": "array",
"description": "Array of properties paths to exclude from output. Used in JSON, YAML and Table formats.",
"items": { "type": "string" },
"example": ["notes", "tags"]
},
"noUnitsExpr": {
"type": "boolean",
"description": "If false or not set, all units will be written in UnitsExpr format. If true, units will be written in Unit array format. Used in JSON and YAML formats."
},
"powTransform": {
"type": "string",
"enum": ["keep", "operator", "function"],
"description": "Transformation of x^y and pow(x, y). Used for DBSolve and SLV formats."
},
"version": {
"type": "string",
"enum": ["25", "26", "L2V3", "L2V4", "L2V5", "L3V1", "L3V2"],
"description": "File version for SLV, DBSolve, and SBML formats."
},
"eventsOff": {
"type": "boolean",
"description": "If true, switchers will not be exported to DBSolve events. Used for SLV format."
},
"groupConstBy": {
"type": "string",
"description": "How to group const in Initial Values of DBSolve file. Written in JSON path format.",
"example": "tags[0]"
},
"auxAsNotes": {
"type": "boolean",
"description": "If true, aux content will be appended to Simbio Notes as JSON object. Used for Simbio format."
},
"omitRows": {
"type": "number",
"description": "Creates empty rows in output sheets. Used for Table and XLSX formats.",
"example": 3
},
"bookType": {
"type": "string",
"enum": ["xlsx", "xlsm", "xlsb", "biff8", "wk3", "csv", "txt", "sylk", "biff5", "biff4", "biff3", "biff2", "html", "dif", "dbf", "wk1", "xlml", "ods", "fods", "rtf", "prn", "eth"],
"description": "Supported file types for Table format."
},
"splitByClass": {
"type": "boolean",
"description": "If true, components will be split by class and saved as separate sheets/files. Used for Table and XLSX formats."
}
}
}
},
"File": {
"type": "object",
"required": ["filepath"],
"properties": {
"filepath": {
"type": "string",
"description": "Path to the file."
},
"format": {
"type": "string",
"enum": ["binary", "utf8"],
"default": "utf8",
"description": "The type of file."
},
"filebody": {
"type": "string",
"description": "File content as binary or plain string."
}
}
}
}
}
}