FriendsOfSymfony / FOSJsRoutingBundle

A pretty nice way to expose your Symfony routing to client applications.
1.48k stars 260 forks source link

Handle nullable route defaults #436

Closed davidkmenta closed 2 years ago

davidkmenta commented 2 years ago

Since Symfony 4.1, route parameters may declared optional/nullable:

To give a null default value to any parameter, add nothing after the ? character (e.g. /blog/{page?}). If you do this, don't forget to update the types of the related controller arguments to allow passing null values (e.g. replace int $page by ?int $page).

Such parameters are then represented in generated list of routes in the defaults node like this (JSON):

"defaults": {
     "page": null
},

Unfortunately the RouteDefaults interface only allows value to be a string. This PR adds support of null to the interface to comply with the Symfony behavior.

tobias-93 commented 2 years ago

Thanks @davidkmenta