A way to place method path segment *after* params

Define a new XData attribute to place method path segments after parameters defined with [FromPath]

ex, today one may have something like:

[URIPathSegment('User')]
TUserService = interface
[HttpGet]
[URIPathSegment('Avatar')]
function GetAvatar([FromPath] const UserId: string): string;
end

GET /User/Avatar/{user-id}

While what you really whant/need is:

GET /User/{user-id}/Avatar

So it whould be GREAT to have something like [PlaceMethodAfterParams] to get such behavior, ex:

[URIPathSegment('User')]
TUserService = interface
[HttpGet]
[URIPathSegment('Avatar')]
[PlaceMethodAfterParams]
function GetAvatar([FromPath] const UserId: string): string;
end

** OR ** to be even more flexible, it should be a param of [FromPath] attribute, eg. [FromPath(BeforeMethod)]

FromPath could be either BeforeMethod or AfterMethod (default). Ex:

[URIPathSegment('User')]
TUserService = interface
[HttpGet]
[URIPathSegment('Avatar')]
function GetAvatar([FromPath(BeforeMethod)] const UserId: string): string;
end

Regards,

Will be available in TMS XData 4.13

This feature was implemented.

1 Like