karenetheridge / OpenAPI-Modern

Validate HTTP requests and responses against an OpenAPI v3.1 document
https://metacpan.org/release/OpenAPI-Modern/
Other
3 stars 3 forks source link

support validating requests, responses against callbacks and webhooks - split up find_path usecases #74

Open karenetheridge opened 5 months ago

karenetheridge commented 5 months ago

Most of the request and response validation can be applied equally well to descriptions in callbacks and webhooks -- just the initial bit where we take the request and call find_path on it to match the request URI against entries in /paths/{path description} doesn't apply here.

So, pull out the meat of the validation into separate subs which are called by multiple entry points - some of which would not require a path template for matching (instead, the inner sub takes the path-item location, which could be calculated by find_path or could be supplied directly, e.g. by an earlier call of validate_request that is processing a callback section.

karenetheridge commented 5 months ago

This will make it possible to call validate_response with just an operation_id, or path_item_path + http method. We don't care about the path template or path captures variables as they are not used for responses.

karenetheridge commented 4 days ago

In version 0.068, it is now possible to call validate_response purely by operation_id, without providing a request or providing a path_template value. This can be used to validate responses associated with a callback or webhook.

However, callback requests and webhook requests are not yet recognized by validate_request, as the request is still matched against path templates in /paths/*.