Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Allowing for configurable default version #1

Closed
wants to merge 2 commits into from
Closed

Allowing for configurable default version #1

wants to merge 2 commits into from

Conversation

michaelmoussa
Copy link
Contributor

This change allows the API developer to choose which version should act as the default if none is specified in the URL or headers.

This is accomplished by setting [zf-versioning][default-version] in module.config.php (which defaults to 1). If this setting is omitted, then the existing default value of 1 in the PrototypeRouteListener will be used.

I modified the dataProvider in the test class to provide an optional $apiVersion to allow for testing various possibilities, such as:

  • Developer-specified default version of 1
  • Developer-specified default version of "not 1"
  • No developer-specified default version. (defaults automatically to 1 as is done presently)

@weierophinney
Copy link
Member

@michaelmoussa Can you also do a similar PR against zfcampus/zf-apigility-admin for setting a default per-API?

@michaelmoussa
Copy link
Contributor Author

@weierophinney Sure.

Is there anything else needed for this particular PR against zf-versioning so I can tackle that too? I started the zf-apigility-admin work already and so far haven't seen any updates that I would need to make to this PR.

@michaelmoussa
Copy link
Contributor Author

@weierophinney WIP for zf-apigility-admin here if you're interested and want to comment.

It updates the configuration file already and everything. I just need to have the new default version value persist on the admin frontend between refreshes. That information is not presently available in the /admin/api/module response.

@@ -15,6 +15,8 @@
// Example:
// '#^application/vendor\.(?P<vendor>mwop)\.v(?P<version>\d+)\.(?P<resource>status|user)$#',
),
// Default version number to use if none is provided by the API consumer. Default: 1
'default-version' => 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an underscore, not a dash here. (top-level, namespace keys use dash, otherwise, underscore-separated)

@weierophinney
Copy link
Member

Looking good -- can you rebase your zf-apigility-admin changes against most recent master, please, and then submit a PR for it? I'll go ahead and merge this one, with the changes I suggested, in the meantime.

weierophinney added a commit that referenced this pull request Nov 15, 2013
Allowing for configurable default version
@michaelmoussa
Copy link
Contributor Author

Sure. Will take care of it late next week. Thanks for the merge.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants