Skip to content

Commit a7110ce

Browse files
committed
Check the openapi spec webhooks fields
This will be part of an upcoming change, where we will only send the `webhooks` field in the openapi spec, and we will omit the `x-webhooks` field.
1 parent 5f1e6f2 commit a7110ce

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/main.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,26 @@ fn get_webhooks(spec: &OpenApi) -> Vec<String> {
197197
}
198198
}
199199
}
200+
201+
// also check the spec.webhooks
202+
for (_, webhook) in &spec.webhooks {
203+
let Some(item) = webhook.as_item() else {
204+
continue;
205+
};
206+
207+
for (_, op) in item.iter() {
208+
let schema_ref = op
209+
.request_body
210+
.as_ref()
211+
.and_then(|v| v.as_item())
212+
.and_then(|v| v.content.get("application/json"))
213+
.and_then(|v| v.schema.as_ref())
214+
.and_then(|v| v.json_schema.clone().into_object().reference)
215+
.and_then(|v| v.split('/').next_back().map(|v| v.to_string()));
216+
if let Some(schema_ref) = schema_ref {
217+
referenced_components.insert(schema_ref);
218+
}
219+
}
220+
}
200221
referenced_components.into_iter().collect::<Vec<String>>()
201222
}

0 commit comments

Comments
 (0)