-
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
[SLO] Auto generating OpenAPI Spec (OAS) using @kbn/config-schema for a sample SLO API #184138
Comments
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
In this comment, I will log the findings that I have related to changing a sample validation to using I've started with Config schema documentationhttps://github.com/elastic/kibana/blob/main/packages/kbn-config-schema/README.md ImplementationAfter changing registering a route with
Next, I tried to recreate Findings
|
I see you're converting a schema that's pretty simple, The issue I have with this effort is that there isn't feature parity yet and I'd hate have to maintain 2 sets of schemas. I love the promise of mostly getting the OpenAPI docs for free by using the code but I think we might need to push back until the replacement library is up to par with the
|
@simianhacker Thanks for sharing the list of features that we need to evaluate. Indeed, the delete API was just a starting point for me to see how OAS works in action, but the main goal is to evaluate the gaps that we might have between config-schema and io-ts. I will use the list that you provided as a guide, thanks. |
What would be the best endpoint to choose as the next one, to highlight the gaps as starkly as possible? As Mary said, the goal here isn't to start a migration, but rather to help expose the gaps so we can provide feedback to the platform team re: config-schema limitations. The more we look at this, the less likely it seems we'd want to spend time on converting/refactoring lots of code just for auto-generated OpenAPI specs. |
The update or find APIs would be very good candidate:
|
Based on the above discussions, here is a list of items that need to be verified and related investigation: (Related POC) 1. Runtime types that are reused to create Typescript typesIt is possible to return type a schema using type CreateSLOInputConfigSchema = TypeOf<typeof createSLOParamsConfigSchema.body> The challenge comes from supporting type transformation, which will be discussed in the third section, the Duration type. 2.Type guards using schemas throughout the codeAt the moment, in the cases that we use Type guard (like the example that Kevin shared, e.g. 🗒️ I've created a ticket for adding support for is type checking. 3.Custom types like the Duration typeFor custom types, the validation can be done using config schema custom validation. The challenge is about converting string -> Duration and having proper input and output types as defined here. 🗒️ I've created a ticket to add transform functionality to the config-schema. 4. Documentation with examplesHere is schema-config documentation which has lots of good examples. Maybe the only challenge is how to make it easier for developers to find this documentation and ensure it is up to date. 🗒️ I've created a ticket to cover adding Summary of related tickets |
Closing this ticket as the investigation is completed, and we decided not to change SLO's API params validation and rely on manual OAS since the API does not change that often. Also, we introduce Zod as an alternative to config-schema for automatically generating OAS. |
🍒 Summary
As mentioned in this email, platform team worked on introducing a way to automatically generate OpenAPI Spec (OAS) using
@kbn/config-schema
.Here is their first iteration on the
/api/status
API. (PR)In this ticket, we would like to use @kbn/config-schema for one of the SLO APIs and compare the result with the existing OpenAPI Spec to figure out if something is missing and, if not, how much effort is needed for this migration.
Here is the existing list of SLO OpenAPI Specifications. We need to decide which SLO API is a good candidate based on the complexity, to make sure our estimates are realistic.
✅ Acceptance criteria
The text was updated successfully, but these errors were encountered: