-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support additional API Versioning strategies #3008
Conversation
Love the PR. Small comment that will help me move these along faster is to break this up into different PRs. Maybe name changes can be done in one PR - separate from the meat. Name changes are a lot of lines, but quick and easy to review. I know this isn't always possible - but the sweet spot would be 500 lines or less in one go. Also helpful is some signal when the PR is ready for review. |
Noted your comments. I will try to break this PR up. Thanks for all the hard work doing the reviews, merges and releases. It's much appreciated. It's a little tricky to break this PR up. I think what I will do is convert this to a draft and create the smaller change PRs and when those get merged I will rebase this one until it is small enough. |
b6f6dab
to
27803d8
Compare
970e38e
to
6e1e114
Compare
int pathEnd = -1; | ||
|
||
int find = path.indexOf('/', 0); | ||
if (find != -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be simpler with a regex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I didn't profile it, since this essentially called for every request, I thought that doing string operations might be faster than a regex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. The logic looks correct to me.
Suggestion for how to start breaking this up. Let's separate the Resolvers & validators and their tests as a starting PR. I realize nothing will call these resolvers, but I think if we can break this into chunks, we can get this reviewed and merged. |
After the resolvers, maybe we can separate just the ElideSettingsBuilder changes as its own PR. |
These changes have been merged in separate PRs. |
Description
Adds support for the following API Versioning strategies
This can be customized by implementing and registering a
com.yahoo.elide.core.request.route.RouteResolver
.The default in Elide Spring Boot is now using the Path strategy instead of using the
ApiVersion
header. The Path strategy is the only one that is supported when integrating with Springdoc as the other strategies are difficult to document with OpenAPI.This can be configured back to the previous defaults using
application.yaml
.The default in Elide Standalone now accepts all the strategies and can be configured to previous defaults with the
getRouteResolver
method.Modifications were also made to ensure the entities for different API versions can be in the same OpenAPI document. This also adds
GroupedOpenApi
support for Springdoc.The following API changes were also made
com.yahoo.elide.core.security.RequestScope
interface has changed to be able to return aRoute
. This replaces thegetApiVersion()
,getRequestHeaderByName()
,getBaseUrlEndPoint()
andgetQueryParams()
methods.com.yahoo.elide.core.RequestScope
have been moved tocom.yahoo.elide.jsonapi.JsonApiRequestScope
.com.yahoo.elide.Elide
have been moved tocom.yahoo.elide.jsonapi.JsonApi
.ElideSettingsBuilder
has been changed to be more consistent with the other Lombok builders and to allow easier customization over the defaults instead of replacing it.Motivation and Context
Previously only the Header API Versioning strategy was supported it wasn't easy to customize to add other strategies. The other changes are also to make Elide easier to customize.
How Has This Been Tested?
Added the relevant unit and integration tests. Have also tested this against the example apps.
License
I confirm that this contribution is made under an Apache 2.0 license and that I have the authority necessary to make this contribution on behalf of its copyright owner.