-
Notifications
You must be signed in to change notification settings - Fork 13
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 for {patch} level version digit to make possible YYYY-MM-DD version formats #2
Comments
Hmm, in my opinion, you shouldn't ever have 2 accessible versions of a route, where they only differ in patch version. When the patch version is incremented, the change should be backwards compatible. So I can't really think of a reason why you'd want versioning to that level. Major version changes should be backwards compatible as well, but there is probably a stronger argument for wanting versioning at that level, since there is new functionality being added. While the "YYYY-MM-DD" date format does conveniently fit the semantic versioning format, I feel like Stripe's intention is that the date is more of a single major version. They specifically say: "Although backwards-incompatible, each one contains a small set of changes that make incremental upgrades relatively easy so that integrations can stay current.". To me, this means it's a major version. |
Yes, I can agree with your position. Do we have any other pathway that would open up the ability to use three levels of versions that in-turn makes date style versioning possible? It's less about being strictly "right" than making a common API versioning format possible |
How about this?
To me, it feels like they're just using a date as a major version, instead of a single number. |
Perhaps the answer is to simply hardcode the a date with an internal version
|
Oh shoot, I just realized I have major/minor typed as ints in the decorator. Didn't realize that. I suppose I can make them be |
Okay, I just went to implement this but then realized it's more complicated than originally thought. When the If I allow for arbitrary strings, then that sort won't always do as expected. There is no easy way to distinguish which versions are older or newer, like you can with ints. In your case of dates, the sorting should work as expected (as long as you always follow "YYYY-MM-DD" format). You will just get type-checker warnings, if you even use one. You will also probably need to set the Here is a potential solution: So in you're case, you'd have something like:
which produces the following routes...
However, then there is a bit of a conflict because Another possible option is to just allow date objects to be major/minor versions, in addition to ints. This is probably the simpler solution. |
If you take the date-object approach, you might want to prevent timezone-aware date objects else you'd end up in a painful world of timezone confusion. Perhaps the even easier middle ground is to use major versions in the format
This would almost get us there; I suspect the "problem" then is with some of the generated documentation and |
I don't really see a benefit in that approach vs. just using "YYYY-MM-DD" as your major version and using prefix_format as "{major}". Both "YYYY-MM-DD" and "YYYYMMDD" should sort just fine, so I don't see it being a problem. However, that prefix format would not work in the current implementation, which just uses simple My real concern is just allowing any arbitrary string, since the user must ensure that their version format will sort properly. For example, if someone had versions like "2022-10-10" and "2022-7-10", |
Yes, breaking the strictness of the How about a This way the default good behavior of versionize does not change, while it still gives the developer a way to accept and acknowledge they know what they are stepping into if they do. Perhaps an attribute An alternative approach might be to introduce a new Anyway, I'm sure there are other oddball situations where non-integer based versions probably make sense (although less common) so it's a feature/extension that is more than just accommodating a couple of silly dash characters in a date-looking-format string. |
I think, that it should be theoretically possible to use any hashable object as a version, if That will also add support for more complex prefixes and versions. For example, I always want the last version to have "/dev" prefix, and I have to hack that right now. The sorting problem could be resolved by forcing the developer to provide a function that will be used as a |
Ok so maybe something like this:
Does this all sound about right? @kunesj Does the |
That looks OK. Also, I remembered that the versions have to be comparable (
|
@kunesj @ndejong How does this look for a solution: https://github.com/alexschimpf/fastapi-versionizer/compare/alex/non-integer-versions?expand=1 ? |
Hi -
I'd like to discuss support for the third SEMVER digit in the version format
If we make the patch level digit possible it is then possible to use versioning schemes that use the date in the same way that Amazon, Stripe and others do.
For example
/2023-01-12/users/awesome
where the instantiation of that might look something likeThe goal is to create a pathway to adopt Stripe style versioning for users -
https://stripe.com/blog/api-versioning
Happy to write this as supply a PR, but wanted to ask first to make sure there are not other approaches or limitations that others might see beforehand
The text was updated successfully, but these errors were encountered: