mirror of
https://github.com/SigNoz/signoz.git
synced 2026-05-12 02:51:33 -05:00
9e118ded1f
* feat(ruletypes): publish OpenAPI 3 discriminator on RuleThresholdData and EvaluationEnvelope
Both types model `{kind, spec}` discriminated unions on the wire but
the generated OpenAPI lacked the `discriminator:` keyword, so
codegen tools (oapi-codegen, terraform-plugin-codegen-openapi) fell
back to opaque `Spec: any` and consumers had to hand-write
JSON-bridges instead of typed Expand/Flatten.
Add the discriminator declaration via a marker convention:
- Each parent type implements `jsonschema.Preparer` to set an
`x-signoz-discriminator` extra property carrying `propertyName` and
the per-kind `mapping`.
- A small `attachDiscriminators` pass in pkg/signoz/openapi.go runs
after spec reflection, walks every component schema, promotes the
marker into a real openapi3.Discriminator, and removes the marker
so it doesn't leak into the rendered YAML.
The two-step is required because jsonschema-go.Schema has no
Discriminator field of its own and openapi-go only carries through
`x-`-prefixed extras unchanged. The wire shape is unchanged —
`{kind: "<value>", spec: <variant>}` is still what's sent and
received.
Adding a new variant: append to JSONSchemaOneOf and add a
mapping entry on PrepareJSONSchema.
* refactor(openapi): inline discriminator constant and tighten attachDiscriminators
* chore(ruletypes): trim discriminator comments
* fix(ruletypes): mark evaluation variant kind/spec required
* fix(ruletypes): keep envelope kind/spec out of the parent schema via json:"-"
* refactor(ruletypes): strip envelope parent properties in attachDiscriminators
Revert the json:"-" + custom MarshalJSON dance on the envelope
structs. Restore the original tags (json:"kind" / json:"spec"),
keep the discriminator marker, and clear the parent's redundant
properties / required block in attachDiscriminators after the
discriminator is promoted.
* style(openapi): add blank lines between logical blocks in attachDiscriminators
* style(ruletypes): add blank lines in PrepareJSONSchema
* fix(ruletypes): mark threshold variant kind/spec required
542 KiB
542 KiB