zfcampus / zf-apigility

BSD 3-Clause "New" or "Revised" License
258 stars 52 forks source link

Apigility API Default Version issue #164

Closed WADS94 closed 6 years ago

WADS94 commented 8 years ago

Hi Zend Team, Just encountered a issue while trying to set a default version per API in my application . First I tried using the 'Set default version' feature from Admin UI and apigility does that by adding in that API module.config.php the following code:

    'zf-versioning' => array(
        'default_version' => {version_number}
    ),

The problem with this is the default_version is under zf-versioning key and has no connection with the API and at config merge from all my APIS the last config merged which has a default_version will give the default_version for the entire application and so for all my APIS .

And in ZF\Versioning\PrototypeRouteListener in onMergeConfig function where the default version is set on each route options at line 116 a merge is made with route defined options and versionRouteOptions which contains the default_version , because of the parameters order the versionRouteOptions overrides the route options defined in config , and as you can see in the versionRouteOptions definition by default cotains default_version 1 .

So if I set a default_version from Admin UI under zf-versioning key this will be the default version for all my APIS but if I am not using the Admin UI and add in config for each route under options key a default_version this will be overide by default_version 1 from the PrototypeRouteListener as I've explained earlier.

In conclusion Apigility allow me to set a single default_version for all my APIs. I hope this can be changed and be able to define a default_version per API or even per Service using the route options.

Thank you!

poldekch commented 8 years ago

The issue still persist in Apigility 1.4 The only way is to explicitly force version in url or header as cannot rely on 'default version' at the moment. Looking forward for fix.