diff --git a/internal/api/client.gen.go b/internal/api/client.gen.go index 8c0cecf..beef3be 100644 --- a/internal/api/client.gen.go +++ b/internal/api/client.gen.go @@ -604,9 +604,7 @@ type ApiExecutionResponse_Action struct { // ApiSessionStartRequest defines model for ApiSessionStartRequest. type ApiSessionStartRequest struct { // AspectRatio Viewport shape preset. When set, the backend fits the largest rectangle of this aspect ratio inside the sampled available screen area. Cannot be combined with explicit viewport_width/viewport_height. - AspectRatio *string `json:"aspect_ratio,omitempty"` - - // BrowserType The browser type to use. Can be chromium, chrome or firefox. + AspectRatio *string `json:"aspect_ratio,omitempty"` BrowserType *ApiSessionStartRequestBrowserType `json:"browser_type,omitempty"` // CdpUrl The CDP URL of another remote session provider. @@ -656,7 +654,7 @@ type ApiSessionStartRequest struct { WebBotAuth *bool `json:"web_bot_auth,omitempty"` } -// ApiSessionStartRequestBrowserType The browser type to use. Can be chromium, chrome or firefox. +// ApiSessionStartRequestBrowserType defines model for ApiSessionStartRequest.BrowserType. type ApiSessionStartRequestBrowserType string // ApiSessionStartRequestProxies0 defines model for . diff --git a/scripts/gen-flags/parser.go b/scripts/gen-flags/parser.go index 0f5f220..03c0ccc 100644 --- a/scripts/gen-flags/parser.go +++ b/scripts/gen-flags/parser.go @@ -165,6 +165,8 @@ func extractCommandConfig(name, path, method string, op *Operation, schemas map[ } func processField(commandName, fieldName string, field *Field, schemas map[string]*Field) (*FieldConfig, error) { + ApplyDescriptionOverride(commandName, fieldName, field) + category, err := ClassifyField(field, schemas) if err != nil { return nil, err diff --git a/scripts/gen-flags/types.go b/scripts/gen-flags/types.go index d46fc5c..47e961d 100644 --- a/scripts/gen-flags/types.go +++ b/scripts/gen-flags/types.go @@ -58,6 +58,14 @@ var FlattenWithoutPrefix = map[string]map[string]bool{ }, } +// FieldDescriptionOverrides contains command-scoped descriptions for fields +// whose OpenAPI metadata is currently flattened away before flag generation. +var FieldDescriptionOverrides = map[string]map[string]string{ + "SessionStart": { + "browser_type": "The browser type to use. Can be chromium, chrome or firefox.", + }, +} + // Field represents a field in an OpenAPI schema type Field struct { Name string @@ -163,6 +171,17 @@ type FieldConfig struct { SubFields []*FieldConfig // For flattened objects } +func ApplyDescriptionOverride(commandName, fieldName string, field *Field) { + if field.Description != "" { + return + } + if commandOverrides, ok := FieldDescriptionOverrides[commandName]; ok { + if description, ok := commandOverrides[fieldName]; ok { + field.Description = description + } + } +} + // ClassifyField determines how to generate flags for a field func ClassifyField(field *Field, schemas map[string]*Field) (FieldCategory, error) { // Check if field should be skipped entirely @@ -183,8 +202,13 @@ func ClassifyField(field *Field, schemas map[string]*Field) (FieldCategory, erro } // Check if the referenced type is an enum if len(refField.Enum) > 0 { - // Copy enum values to field for later use + // Copy enum metadata to field for later use. Some OpenAPI + // generators put enum descriptions on the referenced schema instead + // of the field itself. field.Enum = refField.Enum + if field.Description == "" { + field.Description = refField.Description + } field.Type = "string" return CategoryEnumFlag, nil }