diff --git a/tools/cli/internal/openapi/filter/bump.go b/tools/cli/internal/openapi/filter/bump.go index 2389fd8fcf..af8148882b 100644 --- a/tools/cli/internal/openapi/filter/bump.go +++ b/tools/cli/internal/openapi/filter/bump.go @@ -26,12 +26,19 @@ type BumpFilter struct { metadata *Metadata } +type State struct { + Label string `json:"label"` + Color string `json:"color"` +} + const ( - stateFieldName = "x-state" - stateFieldValueUpcoming = "UPCOMING" - stateFieldValuePreview = "PREVIEW" - betaFieldName = "x-beta" - description = `This API is in preview. Breaking changes might be introduced before it is released. Don't use preview APIs in production. + stateFieldName = "x-state" + stateFieldValueUpcoming = "UPCOMING" + stateFieldValuePreview = "PREVIEW" + stateFieldValuePreviewColor = "#B89D09" // Yellow + betaFieldName = "x-beta" + description = `This API is in preview. Breaking changes might be introduced ` + + `before it is released. Don't use preview APIs in production. ` ) @@ -71,7 +78,10 @@ func (f *BumpFilter) includeBumpFieldForPreview() error { if op.Extensions == nil { op.Extensions = map[string]any{} } - op.Extensions[stateFieldName] = stateFieldValuePreview + op.Extensions[stateFieldName] = State{ + Label: stateFieldValuePreview, + Color: stateFieldValuePreviewColor, + } op.Extensions[betaFieldName] = true op.Description = description + " " + op.Description } diff --git a/tools/cli/internal/openapi/filter/bump_test.go b/tools/cli/internal/openapi/filter/bump_test.go index 21fccdc7af..3b14f40048 100644 --- a/tools/cli/internal/openapi/filter/bump_test.go +++ b/tools/cli/internal/openapi/filter/bump_test.go @@ -67,7 +67,9 @@ func TestBumpFilter_Apply_Preview(t *testing.T) { op := testPath.Get assert.Contains(t, op.Extensions, "x-state") - assert.Equal(t, stateFieldValuePreview, op.Extensions["x-state"]) + stateProp := op.Extensions["x-state"].(State) + assert.Equal(t, stateFieldValuePreview, stateProp.Label) + assert.Equal(t, stateFieldValuePreviewColor, stateProp.Color) assert.Contains(t, op.Extensions, "x-beta") assert.Equal(t, true, op.Extensions["x-beta"]) assert.Contains(t, op.Description, description)