Create Rest service versions

Asked

Viewed 271 times

2

I am creating Rest services with Java (Jersey).

This service tends to grow and evolve, and may undergo changes in existing routines, therefore, I believe that the best way would be to create versions in production so that clients do not break with changes.

Currently I deploy the system in Tomcat, access through an example URL:

http://www.meudominio.com.br:8180/minhaApi/recurso

I believe the ideal would be something like:

http://www.meudominio.com.br:8180/minhaApi/v1/recurso
http://www.meudominio.com.br:8180/minhaApi/v2/recurso

How to do this?

  • Aren’t you putting the cart before the horse? If you haven’t even launched the first version yet, why worry about the second?

  • Because a second phase is already planned and I know how things happen. A "simple" change request will arrive in a resource that is already in production.

  • There I think which is a small misconception of yours. Are you sure this "simple request to change a resource" will have to be released in a different (major) version? Of course it’s up to you when your API version changes, but I think.

  • My fear is (assumption mode on): I will have a mobile app running on n users. Suddenly I need to modify something in a feature that will break the use in these customers. I didn’t want to have to change, upload the new app to the store and force all users to update. If I have this control I do not need to force anything, because everyone will continue accessing the previous version, got?

1 answer

-1

Versions of an application are not managed programmatically, but rather through version control systems (GIT, SVN, ...). When you need to close a version that should not be modified and is stable you create a tag of that version. Thus, you can generate your artifact published in production from this tag and evolve your code without fear that it breaks what is being used by the customer. With each new stable version, a new tag would be created and so you would evolve your project.

If you don’t have versioning experience, I recommend using git: https://git-scm.com/

  • I already use GIT. My problem is getting endpoint.

  • But endpoint is in the configuration files, which in turn are versioned. There is no way to do this separation, nor does it make sense.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.