-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
228 lines (213 loc) · 6.37 KB
/
openapi.yaml
File metadata and controls
228 lines (213 loc) · 6.37 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
openapi: 3.0.3
info:
title: Network Intrusion Detection API
version: 1.0.0
description: |
REST API for a Machine Learning–based Network Intrusion Detection System (IDS).
The API exposes endpoints for health checks and intrusion prediction using a
trained RandomForest model on the NSL-KDD dataset (binary: normal vs attack).
This API is part of the technical contribution evidence for Ibrahim Akintunde
Akinyera's UK Global Talent (Digital Technology) application.
contact:
name: Ibrahim Akintunde Akinyera
url: https://github.com/akinyeraakintunde
email: (optional)
servers:
- url: https://api.example.com/ids
description: Production IDS API (example)
- url: http://localhost:8000
description: Local development
tags:
- name: Health
description: Health and metadata endpoints
- name: Prediction
description: Intrusion detection inference endpoints
paths:
/health:
get:
tags:
- Health
summary: Health check
description: Simple health endpoint to verify that the API is reachable.
responses:
'200':
description: API is healthy
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
/metadata:
get:
tags:
- Health
summary: Model and dataset metadata
description: |
Returns metadata about the deployed IDS model, including model type,
training dataset, and version information.
responses:
'200':
description: Metadata describing the current model and configuration.
content:
application/json:
schema:
$ref: '#/components/schemas/MetadataResponse'
/predict:
post:
tags:
- Prediction
summary: Predict intrusion for one or more network records
description: |
Accepts one or more pre-processed network traffic records and returns
a binary classification for each: 0 = normal, 1 = attack.
Features must match the encoded feature vector used during training
(for example, the same columns as `nsl_kdd_train_binary.csv` excluding
the `binary_label` target column).
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PredictionRequest'
responses:
'200':
description: Successful prediction
content:
application/json:
schema:
$ref: '#/components/schemas/PredictionResponse'
'400':
description: Invalid input payload or missing required features
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Internal server error during prediction
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
schemas:
HealthResponse:
type: object
properties:
status:
type: string
example: ok
timestamp:
type: string
format: date-time
example: 2025-11-20T10:15:30Z
MetadataResponse:
type: object
properties:
model_name:
type: string
example: RandomForestClassifier
model_version:
type: string
example: v1.0.0
framework:
type: string
example: scikit-learn
trained_on_dataset:
type: string
example: NSL-KDD (binary: normal vs attack)
features_count:
type: integer
example: 118
created_at:
type: string
format: date-time
example: 2025-11-15T09:30:00Z
PredictionRequest:
type: object
required:
- records
properties:
records:
type: array
description: |
List of encoded feature vectors. Each record must contain the same
features used during model training (e.g., all numeric columns from
`nsl_kdd_train_binary.csv` except `binary_label`).
items:
$ref: '#/components/schemas/FeatureVector'
example:
records:
- {
"f1": 0.01,
"f2": 123.0,
"f3": 0.0,
"f4": 1.0
}
FeatureVector:
type: object
description: |
A single encoded feature vector representing one network connection.
In practice, this object will include all numeric feature columns
used during training (e.g., duration, src_bytes, dst_bytes, protocol_type_*,
service_*, flag_*, etc.).
additionalProperties:
type: number
example:
f1: 0.01
f2: 123.0
f3: 0.0
f4: 1.0
PredictionResponse:
type: object
properties:
predictions:
type: array
description: List of predictions, aligned by index to the input records.
items:
$ref: '#/components/schemas/PredictionItem'
model_version:
type: string
example: v1.0.0
example:
predictions:
- {
"index": 0,
"label": 0,
"label_name": "normal",
"score_attack": 0.12
}
- {
"index": 1,
"label": 1,
"label_name": "attack",
"score_attack": 0.94
}
model_version: v1.0.0
PredictionItem:
type: object
properties:
index:
type: integer
description: Zero-based index corresponding to the input record.
example: 0
label:
type: integer
description: Binary prediction (0 = normal, 1 = attack).
example: 1
label_name:
type: string
description: Human-readable label.
example: attack
score_attack:
type: number
format: float
description: Probability score for the positive (attack) class.
example: 0.9453
ErrorResponse:
type: object
properties:
error:
type: string
example: Invalid input format
details:
type: string
example: records field is required and must be a non-empty array