-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OAS PoC]OAS endpoint and lazily pass schema #164710
[OAS PoC]OAS endpoint and lazily pass schema #164710
Conversation
validate: () => ({ | ||
request: { | ||
body: z.object({ data: z.string().describe('this is a placeholder!') }), | ||
params: z.object({ id: z.string() }), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing we can lazily load the alert's params schemas here.
@@ -251,7 +251,7 @@ export interface AddVersionOpts<P, Q, B> { | |||
* Validation for this version of a route | |||
* @experimental | |||
*/ | |||
validate: false | FullValidationConfig<P, Q, B>; | |||
validate: false | FullValidationConfig<P, Q, B> | (() => FullValidationConfig<P, Q, B>); // Provide a way to lazily load validation schemas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very naive approach to implementation taken here, perhaps the lazily loaded schemas should be cached? But good enough for PoC
💔 Build FailedFailed CI Steps
Test Failures
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
Summary
Diverges a little bit from the original PoC but largely remains the same. The idea is to support lazily providing HTTP route schemas and also provide the ability to serve up OAS from an HTTP endpoint.
x-pack/plugins/alerting/server/routes/update_rule.ts
node script/generate_oas
in favor of the new endpoint for nowMuch of this can also be done for existing, non-versioned and versioned non-zod API routes if we add support for Joi.
TODO
How to test
curl -uelastic:changeme http://localhost:5601/<base-path-thingy>/api/oas
(optionally format withjq
for legibility)