All Blog Posts  |  Next Post  |  Previous Post

TMS XData 4.5: Parameter Binding and SwaggerUI


Wednesday, June 19, 2019

TMS XData 4.5 has been released with two major new features: parameter binding and Swagger UI.

SwaggerUI is a great new addition, just by setting two simple properties in TXDataServer component (you can do it from the object inspector at design-time):
XDataServer1.SwaggerOptions.Enabled := True;
XDataServer1.SwaggerUIOptions.Enabled := True;
A new endpoint "swaggerui" is added to your API. Just navigate to it and you will get the nice SwaggerUI which automatically displays all your API endpoints, how they should invoke, which parameters they receive, and even more, test it right away, from the browser:

Parameter Binding
Flexible parameter binding via attributes is another nice addition that provides you more control on how the API method must be invoked via raw HTTP requests - note that if you use Delphi XData Client or TMS Web Core XData Web Client, this is transparent to you, you just specify the method and parameter, and binding and routing is automatic.

But if you intend to call your API from non-Delphi platforms, you can now fully control how it works. You can declare methods like this:

  procedure Process(
    [FromPath] PathA: Integer; 
    [FromQuery] QueryA: string;
    BodyA, BodyB: string;
    [FromQuery] QueryB: Boolean;
    [FromPath] PathB: string;
  ): double;
And that means the action would be invoked with a request like this:

POST /tms/xdata/MyService/Process/5/value?QueryA=queryvalue&QueryB=true HTTP/1.1
  "BodyA": "one",
  "BodyB": "two"
Note how FromPath, FromQuery (and implicit FromBody) parameter changes the parameter binding so that the API knows that PathA and PathB parameters are 5 and value respectively (coming from the URL path), QueryA comes from the query string, and BodyA and BodyB comes from JSON in request body.

If you want to see both parameter binding and SwaggerUI in action, take a look at this new video about it:

Wagner Landgraf


This blog post has received 9 comments.

1. Wednesday, June 19, 2019 at 9:49:04 PM


Piffer Claudio

2. Wednesday, June 19, 2019 at 11:40:11 PM

Woo hoo!!!

Price Rhett

3. Thursday, June 20, 2019 at 2:16:55 PM

So awesome!

Bosnjak Boris

4. Thursday, June 20, 2019 at 7:24:36 PM

Good new functions!

Juhász Zsolt

5. Friday, June 21, 2019 at 2:49:14 PM

Parameter Binding is a GREAT addition ! Congrats and Thanks!

Farias Anderson

6. Friday, June 21, 2019 at 3:18:11 PM

Thank you all for the great comments, I''m happy for all the positive feedback on this release!

Wagner R. Landgraf

7. Tuesday, February 11, 2020 at 1:36:31 PM

Just started using swagger in my testing - what a great feature!

Jason Chapman

8. Tuesday, February 11, 2020 at 1:42:35 PM

Thanks, Jason!

Wagner R. Landgraf

9. Thursday, April 9, 2020 at 9:06:27 PM

Hi Wagner, in specification by client we have such path:

How we can implement that with use of [FromPath] ?


Add a new comment

You will receive a confirmation mail with a link to validate your comment, please use a valid email address.
All fields are required.

All Blog Posts  |  Next Post  |  Previous Post