SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
chore(openapi): keep field descriptions on referenced properties (#13194)
Srikanth Chekuri9af140729489
diff --git a/docs/api/openapi.yml b/docs/api/openapi.ymlindex 9ff454df46..ef10773d87 100644--- a/docs/api/openapi.yml+++ b/docs/api/openapi.yml@@ -1442,9 +1442,13 @@ components:AuthtypesAuthDomainConfigGoogle:properties:kind:- $ref: '#/components/schemas/AuthtypesAuthNProvider'+ allOf:+ - $ref: '#/components/schemas/AuthtypesAuthNProvider'+ description: The kind of authn provider.spec:- $ref: '#/components/schemas/AuthtypesGoogleConfig'+ allOf:+ - $ref: '#/components/schemas/AuthtypesGoogleConfig'+ description: The google auth configuration.required:- kind- spec@@ -1452,9 +1456,13 @@ components:AuthtypesAuthDomainConfigOIDC:properties:kind:- $ref: '#/components/schemas/AuthtypesAuthNProvider'+ allOf:+ - $ref: '#/components/schemas/AuthtypesAuthNProvider'+ description: The kind of authn provider.spec:- $ref: '#/components/schemas/AuthtypesOIDCConfig'+ allOf:+ - $ref: '#/components/schemas/AuthtypesOIDCConfig'+ description: The oidc configuration.required:- kind- spec@@ -1462,9 +1470,13 @@ components:AuthtypesAuthDomainConfigSAML:properties:kind:- $ref: '#/components/schemas/AuthtypesAuthNProvider'+ allOf:+ - $ref: '#/components/schemas/AuthtypesAuthNProvider'+ description: The kind of authn provider.spec:- $ref: '#/components/schemas/AuthtypesSamlConfig'+ allOf:+ - $ref: '#/components/schemas/AuthtypesSamlConfig'+ description: The saml configuration.required:- kind- spec@@ -8220,9 +8232,13 @@ components:Querybuildertypesv5BucketOptionsLinear:properties:kind:- $ref: '#/components/schemas/Querybuildertypesv5BucketsKind'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5BucketsKind'+ description: How the upper bounds are spaced.spec:- $ref: '#/components/schemas/Querybuildertypesv5LinearBucketsSpec'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5LinearBucketsSpec'+ description: The evenly spaced bucket specification.required:- kind- spec@@ -8230,9 +8246,13 @@ components:Querybuildertypesv5BucketOptionsLog:properties:kind:- $ref: '#/components/schemas/Querybuildertypesv5BucketsKind'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5BucketsKind'+ description: How the upper bounds are spaced.spec:- $ref: '#/components/schemas/Querybuildertypesv5LogBucketsSpec'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5LogBucketsSpec'+ description: The logarithmic bucket specification.required:- kind- spec@@ -8821,54 +8841,78 @@ components:Querybuildertypesv5QueryEnvelopeBuilder:properties:spec:- $ref: '#/components/schemas/Querybuildertypesv5BuilderQuerySpec'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5BuilderQuerySpec'+ description: The builder query specification.type:- $ref: '#/components/schemas/Querybuildertypesv5QueryType'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5QueryType'+ description: The type of the query.required:- typetype: objectQuerybuildertypesv5QueryEnvelopeBuilderAI:properties:spec:- $ref: '#/components/schemas/Querybuildertypesv5QueryBuilderQueryGithubComSigNozSignozPkgTypesQuerybuildertypesQuerybuildertypesv5TraceAggregation'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5QueryBuilderQueryGithubComSigNozSignozPkgTypesQuerybuildertypesQuerybuildertypesv5TraceAggregation'+ description: The AI builder query specification.type:- $ref: '#/components/schemas/Querybuildertypesv5QueryType'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5QueryType'+ description: The type of the query.required:- typetype: objectQuerybuildertypesv5QueryEnvelopeClickHouseSQL:properties:spec:- $ref: '#/components/schemas/Querybuildertypesv5ClickHouseQuery'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5ClickHouseQuery'+ description: The ClickHouse SQL query specification.type:- $ref: '#/components/schemas/Querybuildertypesv5QueryType'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5QueryType'+ description: The type of the query.required:- typetype: objectQuerybuildertypesv5QueryEnvelopeFormula:properties:spec:- $ref: '#/components/schemas/Querybuildertypesv5QueryBuilderFormula'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5QueryBuilderFormula'+ description: The formula specification.type:- $ref: '#/components/schemas/Querybuildertypesv5QueryType'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5QueryType'+ description: The type of the query.required:- typetype: objectQuerybuildertypesv5QueryEnvelopePromQL:properties:spec:- $ref: '#/components/schemas/Querybuildertypesv5PromQuery'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5PromQuery'+ description: The PromQL query specification.type:- $ref: '#/components/schemas/Querybuildertypesv5QueryType'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5QueryType'+ description: The type of the query.required:- typetype: objectQuerybuildertypesv5QueryEnvelopeTraceOperator:properties:spec:- $ref: '#/components/schemas/Querybuildertypesv5QueryBuilderTraceOperator'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5QueryBuilderTraceOperator'+ description: The trace operator specification.type:- $ref: '#/components/schemas/Querybuildertypesv5QueryType'+ allOf:+ - $ref: '#/components/schemas/Querybuildertypesv5QueryType'+ description: The type of the query.required:- typetype: object@@ -9428,9 +9472,13 @@ components:RuletypesEvaluationCumulative:properties:kind:- $ref: '#/components/schemas/RuletypesEvaluationKind'+ allOf:+ - $ref: '#/components/schemas/RuletypesEvaluationKind'+ description: The kind of evaluation.spec:- $ref: '#/components/schemas/RuletypesCumulativeWindow'+ allOf:+ - $ref: '#/components/schemas/RuletypesCumulativeWindow'+ description: The cumulative window evaluation specification.required:- kind- spec@@ -9453,9 +9501,13 @@ components:RuletypesEvaluationRolling:properties:kind:- $ref: '#/components/schemas/RuletypesEvaluationKind'+ allOf:+ - $ref: '#/components/schemas/RuletypesEvaluationKind'+ description: The kind of evaluation.spec:- $ref: '#/components/schemas/RuletypesRollingWindow'+ allOf:+ - $ref: '#/components/schemas/RuletypesRollingWindow'+ description: The rolling window evaluation specification.required:- kind- spec@@ -9836,9 +9888,13 @@ components:RuletypesThresholdBasic:properties:kind:- $ref: '#/components/schemas/RuletypesThresholdKind'+ allOf:+ - $ref: '#/components/schemas/RuletypesThresholdKind'+ description: The kind of threshold.spec:- $ref: '#/components/schemas/RuletypesBasicRuleThresholds'+ allOf:+ - $ref: '#/components/schemas/RuletypesBasicRuleThresholds'+ description: The basic threshold specification (array of thresholds).required:- kind- specdiff --git a/frontend/src/api/generated/services/sigNoz.schemas.ts b/frontend/src/api/generated/services/sigNoz.schemas.tsindex a80cef1c35..6655612d1f 100644--- a/frontend/src/api/generated/services/sigNoz.schemas.ts+++ b/frontend/src/api/generated/services/sigNoz.schemas.ts@@ -2949,6 +2949,9 @@ export interface AuthtypesAttributeMappingDTO {role?: string;}+/**+ * The kind of authn provider.+ */export enum AuthtypesAuthDomainConfigSAMLDTOKind {saml = 'saml',}@@ -2976,11 +2979,18 @@ export interface AuthtypesAuthDomainConfigSAMLDTO {/*** @type string* @enum saml+ * @description The kind of authn provider.*/kind: AuthtypesAuthDomainConfigSAMLDTOKind;+ /**+ * @description The saml configuration.+ */spec: AuthtypesSamlConfigDTO;}+/**+ * The kind of authn provider.+ */export enum AuthtypesAuthDomainConfigGoogleDTOKind {google = 'google',}@@ -3029,11 +3039,18 @@ export interface AuthtypesAuthDomainConfigGoogleDTO {/*** @type string* @enum google+ * @description The kind of authn provider.*/kind: AuthtypesAuthDomainConfigGoogleDTOKind;+ /**+ * @description The google auth configuration.+ */spec: AuthtypesGoogleConfigDTO;}+/**+ * The kind of authn provider.+ */export enum AuthtypesAuthDomainConfigOIDCDTOKind {oidc = 'oidc',}@@ -3070,8 +3087,12 @@ export interface AuthtypesAuthDomainConfigOIDCDTO {/*** @type string* @enum oidc+ * @description The kind of authn provider.*/kind: AuthtypesAuthDomainConfigOIDCDTOKind;+ /**+ * @description The oidc configuration.+ */spec: AuthtypesOIDCConfigDTO;}@@ -4572,6 +4593,9 @@ export interface Querybuildertypesv5TraceAggregationDTO {expression?: string;}+/**+ * How the upper bounds are spaced.+ */export enum Querybuildertypesv5BucketOptionsLinearDTOKind {linear = 'linear',}@@ -4591,11 +4615,18 @@ export interface Querybuildertypesv5BucketOptionsLinearDTO {/*** @type string* @enum linear+ * @description How the upper bounds are spaced.*/kind: Querybuildertypesv5BucketOptionsLinearDTOKind;+ /**+ * @description The evenly spaced bucket specification.+ */spec: Querybuildertypesv5LinearBucketsSpecDTO;}+/**+ * How the upper bounds are spaced.+ */export enum Querybuildertypesv5BucketOptionsLogDTOKind {log = 'log',}@@ -4610,8 +4641,12 @@ export interface Querybuildertypesv5BucketOptionsLogDTO {/*** @type string* @enum log+ * @description How the upper bounds are spaced.*/kind: Querybuildertypesv5BucketOptionsLogDTOKind;+ /**+ * @description The logarithmic bucket specification.+ */spec: Querybuildertypesv5LogBucketsSpecDTO;}@@ -5834,26 +5869,40 @@ export type Querybuildertypesv5BuilderQuerySpecDTO =| Querybuildertypesv5QueryBuilderQueryGithubComSigNozSignozPkgTypesQuerybuildertypesQuerybuildertypesv5LogAggregationDTO| Querybuildertypesv5QueryBuilderQueryGithubComSigNozSignozPkgTypesQuerybuildertypesQuerybuildertypesv5MetricAggregationDTO;+/**+ * The type of the query.+ */export enum Querybuildertypesv5QueryEnvelopeBuilderDTOType {builder_query = 'builder_query',}export interface Querybuildertypesv5QueryEnvelopeBuilderDTO {+ /**+ * @description The builder query specification.+ */spec?: Querybuildertypesv5BuilderQuerySpecDTO;/*** @type string* @enum builder_query+ * @description The type of the query.*/type: Querybuildertypesv5QueryEnvelopeBuilderDTOType;}+/**+ * The type of the query.+ */export enum Querybuildertypesv5QueryEnvelopeBuilderAIDTOType {builder_ai_query = 'builder_ai_query',}export interface Querybuildertypesv5QueryEnvelopeBuilderAIDTO {+ /**+ * @description The AI builder query specification.+ */spec?: Querybuildertypesv5QueryBuilderQueryGithubComSigNozSignozPkgTypesQuerybuildertypesQuerybuildertypesv5TraceAggregationDTO;/*** @type string* @enum builder_ai_query+ * @description The type of the query.*/type: Querybuildertypesv5QueryEnvelopeBuilderAIDTOType;}@@ -5891,14 +5940,21 @@ export interface Querybuildertypesv5QueryBuilderFormulaDTO {order?: Querybuildertypesv5OrderByDTO[] | null;}+/**+ * The type of the query.+ */export enum Querybuildertypesv5QueryEnvelopeFormulaDTOType {builder_formula = 'builder_formula',}export interface Querybuildertypesv5QueryEnvelopeFormulaDTO {+ /**+ * @description The formula specification.+ */spec?: Querybuildertypesv5QueryBuilderFormulaDTO;/*** @type string* @enum builder_formula+ * @description The type of the query.*/type: Querybuildertypesv5QueryEnvelopeFormulaDTOType;}@@ -5961,14 +6017,21 @@ export interface Querybuildertypesv5QueryBuilderTraceOperatorDTO {stepInterval?: Querybuildertypesv5StepDTO;}+/**+ * The type of the query.+ */export enum Querybuildertypesv5QueryEnvelopeTraceOperatorDTOType {builder_trace_operator = 'builder_trace_operator',}export interface Querybuildertypesv5QueryEnvelopeTraceOperatorDTO {+ /**+ * @description The trace operator specification.+ */spec?: Querybuildertypesv5QueryBuilderTraceOperatorDTO;/*** @type string* @enum builder_trace_operator+ * @description The type of the query.*/type: Querybuildertypesv5QueryEnvelopeTraceOperatorDTOType;}@@ -5997,14 +6060,21 @@ export interface Querybuildertypesv5PromQueryDTO {step?: Querybuildertypesv5StepDTO;}+/**+ * The type of the query.+ */export enum Querybuildertypesv5QueryEnvelopePromQLDTOType {promql = 'promql',}export interface Querybuildertypesv5QueryEnvelopePromQLDTO {+ /**+ * @description The PromQL query specification.+ */spec?: Querybuildertypesv5PromQueryDTO;/*** @type string* @enum promql+ * @description The type of the query.*/type: Querybuildertypesv5QueryEnvelopePromQLDTOType;}@@ -6028,14 +6098,21 @@ export interface Querybuildertypesv5ClickHouseQueryDTO {query?: string;}+/**+ * The type of the query.+ */export enum Querybuildertypesv5QueryEnvelopeClickHouseSQLDTOType {clickhouse_sql = 'clickhouse_sql',}export interface Querybuildertypesv5QueryEnvelopeClickHouseSQLDTO {+ /**+ * @description The ClickHouse SQL query specification.+ */spec?: Querybuildertypesv5ClickHouseQueryDTO;/*** @type string* @enum clickhouse_sql+ * @description The type of the query.*/type: Querybuildertypesv5QueryEnvelopeClickHouseSQLDTOType;}@@ -10722,6 +10799,9 @@ export interface RuletypesCumulativeWindowDTO {timezone: string;}+/**+ * The kind of evaluation.+ */export enum RuletypesEvaluationCumulativeDTOKind {cumulative = 'cumulative',}@@ -10729,11 +10809,18 @@ export interface RuletypesEvaluationCumulativeDTO {/*** @type string* @enum cumulative+ * @description The kind of evaluation.*/kind: RuletypesEvaluationCumulativeDTOKind;+ /**+ * @description The cumulative window evaluation specification.+ */spec: RuletypesCumulativeWindowDTO;}+/**+ * The kind of evaluation.+ */export enum RuletypesEvaluationRollingDTOKind {rolling = 'rolling',}@@ -10752,8 +10839,12 @@ export interface RuletypesEvaluationRollingDTO {/*** @type string* @enum rolling+ * @description The kind of evaluation.*/kind: RuletypesEvaluationRollingDTOKind;+ /**+ * @description The rolling window evaluation specification.+ */spec: RuletypesRollingWindowDTO;}@@ -10959,16 +11050,28 @@ export enum RuletypesSeasonalityDTO {daily = 'daily',weekly = 'weekly',}+/**+ * The kind of threshold.+ */export enum RuletypesThresholdBasicDTOKind {basic = 'basic',}+/**+ * The basic threshold specification (array of thresholds).+ */+export type RuletypesThresholdBasicDTOSpec = RuletypesBasicRuleThresholdsDTO | null;+export interface RuletypesThresholdBasicDTO {/*** @type string* @enum basic+ * @description The kind of threshold.*/kind: RuletypesThresholdBasicDTOKind;- spec: RuletypesBasicRuleThresholdsDTO | null;+ /**+ * @description The basic threshold specification (array of thresholds).+ */+ spec: RuletypesThresholdBasicDTOSpec;}export type RuletypesRuleThresholdDataDTO = RuletypesThresholdBasicDTO;diff --git a/pkg/signoz/openapi.go b/pkg/signoz/openapi.goindex 708aa61080..fb979f1e6a 100644--- a/pkg/signoz/openapi.go+++ b/pkg/signoz/openapi.go@@ -130,7 +130,7 @@ func NewOpenAPI(ctx context.Context, instrumentation instrumentation.Instrumenta}return defaultDefName- }))+ }), jsonschema.InterceptProp(keepDescriptionOnReferencedProperty))reflector.Spec.WithInfo(*(&openapi3.Info{}).WithTitle("SigNoz").@@ -169,6 +169,27 @@ func NewOpenAPI(ctx context.Context, instrumentation instrumentation.Instrumenta}, nil}+// keepDescriptionOnReferencedProperty wraps a referenced property schema in+// allOf when the field carries a description. OpenAPI 3.0 allows no siblings+// next to $ref, so without this the description tag on a field whose type is a+// named schema (an enum or a struct) is silently dropped from the spec.+func keepDescriptionOnReferencedProperty(params jsonschema.InterceptPropParams) error {+ if !params.Processed || params.PropertySchema == nil {+ return nil+ }++ schema := params.PropertySchema+ if schema.Ref == nil || schema.Description == nil || *schema.Description == "" {+ return nil+ }++ ref := *schema.Ref+ schema.Ref = nil+ schema.AllOf = []jsonschema.SchemaOrBool{(&jsonschema.Schema{}).WithRef(ref).ToSchemaOrBool()}++ return nil+}+func (openapi *OpenAPI) CreateAndWrite(path string) error {if err := openapi.apiserver.Router().Walk(openapi.collector.Walker); err != nil {return errdiff --git a/pkg/signoz/openapi_test.go b/pkg/signoz/openapi_test.gonew file mode 100644index 0000000000..868b82df74--- /dev/null+++ b/pkg/signoz/openapi_test.go@@ -0,0 +1,46 @@+package signoz++import (+ "encoding/json"+ "testing"++ "github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/require"+ "github.com/swaggest/jsonschema-go"+)++type describedKind string++func (describedKind) Enum() []any { return []any{"a", "b"} }++type describedNested struct {+ Value string `json:"value"`+}++type describedParent struct {+ Kind describedKind `json:"kind" description:"The kind of thing."`+ Nested describedNested `json:"nested" description:"The nested thing."`+ Undescribed describedKind `json:"undescribed"`+ Plain string `json:"plain" description:"A plain string."`+}++func TestKeepDescriptionOnReferencedProperty(t *testing.T) {+ reflector := jsonschema.Reflector{}+ reflector.DefaultOptions = append(reflector.DefaultOptions, jsonschema.InterceptProp(keepDescriptionOnReferencedProperty))++ schema, err := reflector.Reflect(describedParent{})+ require.NoError(t, err)++ raw, err := json.Marshal(schema)+ require.NoError(t, err)++ var got struct {+ Properties map[string]json.RawMessage `json:"properties"`+ }+ require.NoError(t, json.Unmarshal(raw, &got))++ assert.JSONEq(t, `{"description":"The kind of thing.","allOf":[{"$ref":"#/definitions/SignozDescribedKind"}]}`, string(got.Properties["kind"]))+ assert.JSONEq(t, `{"description":"The nested thing.","allOf":[{"$ref":"#/definitions/SignozDescribedNested"}]}`, string(got.Properties["nested"]))+ assert.JSONEq(t, `{"$ref":"#/definitions/SignozDescribedKind"}`, string(got.Properties["undescribed"]))+ assert.JSONEq(t, `{"description":"A plain string.","type":"string"}`, string(got.Properties["plain"]))+}