[WIP] Updating the Create Rule API to support new params. #707
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Connected with this issue.
Summary
I want to add support for a few new fields in the Create rule API. For that, I generated a new
bundled.yml
and tried re-generating the alerting client.I followed the steps below:
bundled.yaml
following [these instructions](https://github.com/elastic/kibana//tree/8.14/x-pack/plugins/alerting/docs/openapi).bundled.yaml
togenerated/alerting/bundled.yaml
make generate-alerting-client
I also see an
openapi.yaml
file insidegenerated/alerting
. Is this one generated based onbundled.yaml
? Do I need to do anything there? Were the steps above enough?Issues
Calls to
alerting.CreateRuleRequest
inalerting.go
now throw a linting error because some fields are unrecognized.The problem is the definition of
create_rule_request
inbundled.yaml
line 4486.The above leads to the definition of
CreateRuleRequest
ingenerated/alerting/model_create_rule_request.go
.This struct is wrong, all these different rule-type requests are the same and have the same properties.
See for example:
and
They are the same. What differs between rule-type requests are the accepted keys for the
params
map.The documentation elaborates on those keys but it should make no difference for us as long as the request has
params
.What should alternatively be in
generated/alerting/model_create_rule_request.go
is:Any idea how I can achieve this?
One thing I can think of is editing the alerting documentation before generating the
bundled.yaml
but that feels very error prone and a not very sustainable way to update alerting here.Maybe there is some param or configuration I can add to
make generate-alerting-client
?PS.: There seemed to be some issues with
oneOf
and the openapi generator. The roadmap mentions:But! I am not too knowledgeable about all this so I'm still investigating. Maybe you guys are familiar with it?