@@ -342,7 +342,7 @@ func (w *Writer) serializePublishedRestService(svc *model.PublishedRestService)
342342 "ExportMapping" : "" ,
343343 "ImportMapping" : "" ,
344344 "ObjectHandlingBackup" : "Create" ,
345- "Parameters" : bson. A { int32 ( 2 )} ,
345+ "Parameters" : serializePublishedRestParams ( op . Path , op . Parameters ) ,
346346 }
347347 ops = append (ops , opDoc )
348348 }
@@ -377,6 +377,42 @@ func (w *Writer) serializePublishedRestService(svc *model.PublishedRestService)
377377 return bson .Marshal (doc )
378378}
379379
380+ // serializePublishedRestParams builds the Parameters array for a published REST operation.
381+ // It auto-extracts path parameters from {paramName} placeholders in the path string,
382+ // then appends any explicitly declared parameters.
383+ func serializePublishedRestParams (path string , _ []string ) bson.A {
384+ params := bson.A {int32 (2 )}
385+ // Extract {paramName} from path
386+ for _ , name := range extractPathParams (path ) {
387+ params = append (params , bson.M {
388+ "$ID" : idToBsonBinary (generateUUID ()),
389+ "$Type" : "Rest$RestOperationParameter" ,
390+ "Name" : name ,
391+ "DataType" : "String" ,
392+ "Description" : "" ,
393+ })
394+ }
395+ return params
396+ }
397+
398+ // extractPathParams returns parameter names from {param} placeholders in a path.
399+ func extractPathParams (path string ) []string {
400+ var names []string
401+ for {
402+ start := strings .Index (path , "{" )
403+ if start < 0 {
404+ break
405+ }
406+ end := strings .Index (path [start :], "}" )
407+ if end < 0 {
408+ break
409+ }
410+ names = append (names , path [start + 1 :start + end ])
411+ path = path [start + end + 1 :]
412+ }
413+ return names
414+ }
415+
380416// httpMethodToMendix converts uppercase HTTP method names to Mendix casing.
381417func httpMethodToMendix (method string ) string {
382418 switch strings .ToUpper (method ) {
0 commit comments