-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkaitai_struct_engine_openapi.yaml
217 lines (216 loc) · 6.37 KB
/
kaitai_struct_engine_openapi.yaml
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
#$schema: https://spec.openapis.org/oas/3.1/schema/2022-10-07
openapi: 3.1.0
info:
title: Kaitai Struct Engine API
description: |
Defines standard API for use .ksy parser sources to parse
arbitrary binary files and explore resulting object tree.
Supposed to be used by hex viewer/editor visualizers to
get a tree of object represented in a particular binary
stream, when it's interpreted according to a .ksy spec.
version: 1.0.0
servers:
- url: http://localhost:5000/
paths:
/struct:
get:
operationId: structList
summary: List loaded struct parsers
description: Retrieve list of struct parsers loaded into this session and ready to be used.
responses:
"200":
description: Success
content:
json/application:
schema:
type: array
items:
type: string
/struct/load_local:
post:
operationId: structLoadLocal
summary: Load local .ksy as struct parser into the engine
description: Given .ksy file, compiles the parser for this structure and imports it into the engine.
parameters:
- name: local_file
in: query
description: |
Path to the local file on the server to be loaded. Implementations will likely want to restrict this to a
specific directory.
required: true
schema:
type: string
responses:
"200":
description: Success
content:
json/application:
schema:
type: object
properties:
status:
type: string
example: success
"500":
description: Error
content:
json/application:
schema:
"$ref": "#/components/schemas/Error"
/struct/upload:
post:
operationId: structUpload
summary: Load uploaded .ksy as struct parser into the engine
description: Given .ksy file, compiles the parser for this structure and imports it into the engine.
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
description: The file contents to be uploaded
responses:
"200":
description: Success
content:
json/application:
schema:
type: object
properties:
status:
type: string
example: success
"500":
description: Error
content:
json/application:
schema:
"$ref": "#/components/schemas/Error"
/engine/load_local:
post:
operationId: engineLoadLocal
summary: Load a local file with a specific parser
description: |
Load and parse a local file with a specific parser. Results in a tree of objects created in
memory of the engine, which can be explored afterwards with /engine/explore.
parameters:
- name: local_file
in: query
description: Path to the local file to be loaded
required: true
schema:
type: string
- name: struct
in: query
description: Struct parser ID to use for loading the file
required: true
schema:
type: string
responses:
"200":
description: Success
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: success
"500":
description: Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/engine/explore:
get:
operationId: engineExplore
summary: Explore a path in object tree of the engine
description: |
Given a path in the object tree, returns the node at this path.
parameters:
- name: path
in: query
description: Path to explore, delimited by dots. If empty, returns the root node.
required: false
schema:
type: string
- name: depth
in: query
description: Number of levels to recurse into the tree
required: false
#default: 1
schema:
type: integer
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: "#/components/schemas/Node"
"500":
description: Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Error:
type: object
required:
- message
properties:
message:
type: string
Node:
type: object
properties:
io:
type: string
description: Identifier of I/O stream associated with the node
example: 123
path:
type: array
items:
type: string
description: Path to the node in the object tree.
example:
- some_collection
- 5
- name
id:
type: string
description: Identifier of the node
example: some_collection
start:
type: integer
description: Start offset of the node in the stream
example: 0
end:
type: integer
description: End offset of the node in the stream
example: 4
type:
type: string
description: Type of the node, if it's a KaitaiStruct
example: string
seq:
type: array
items:
$ref: "#/components/schemas/Node"
description:
Sequence attributes, if the node is KaitaiStruct
instances:
type: object
description: Instances of the node, if it's a KaitaiStruct
additionalProperties:
$ref: "#/components/schemas/Node"
value:
description: Value of the node, if it's a leaf