[openstreetmap/openstreetmap-website] Supporting multiple API versions (#2353)

mmd notifications at github.com
Fri Aug 30 10:39:28 UTC 2019


mmd-osm commented on this pull request.



> @@ -7,27 +7,54 @@ class CapabilitiesControllerTest < ActionController::TestCase
     def test_routes
       assert_routing(
         { :path => "/api/capabilities", :method => :get },
-        { :controller => "api/capabilities", :action => "show" }
+        { :controller => "api/v06/capabilities", :action => "show", :api_version => "0.6" }

Say we want to use semantic versioning like 1.2.0, how would this be reflected specifically in directory names like `v06`?

> @@ -10,7 +10,7 @@ OSM = {
   MAX_REQUEST_AREA:        <%= Settings.max_request_area.to_json %>,
   SERVER_PROTOCOL:         <%= Settings.server_protocol.to_json %>,
   SERVER_URL:              <%= Settings.server_url.to_json %>,
-  API_VERSION:             <%= Settings.api_version.to_json %>,
+  API_VERSION:             <%= Settings.api_versions.min_by(&:to_f).to_json %>,

Why is this value set to "min_by", and what are the implications of it? Does `&:to_f` play nice with semver (e.g. 1.2.0)?

> @@ -1,24 +1,58 @@
 OpenStreetMap::Application.routes.draw do
+  # Our api versions are decimals, but controllers cannot start with a number
+  # or contain punctuation
+  def v_string(version)
+    "v#{version.delete('.')}"

Thinking of semver again, would it be better to replace "." by "_" maybe, so it's `v0_7 ` and `v1_2 `? How about patch version number? Ignore or include?

> -           <member type='relation' role='some' ref='#{relation.id}'/>
-          </relation>
-         </create>
-        </osmChange>
+      all_api_versions.each do |api_version|
+        user = create(:user)
+        changeset = create(:changeset, :user => user)
+        node = create(:node)
+        way = create(:way_with_nodes, :nodes_count => 2)
+        relation = create(:relation)
+
+        basic_authorization user.email, "test"
+
+        # simple diff to create a node way and relation using placeholders
+        diff = <<CHANGESET.strip_heredoc
+          <osmChange>

At one point we'd also need to include a version number in `<osmChange>` (maybe not now)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/2353#pullrequestreview-281953476
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20190830/a0928c07/attachment.html>


More information about the rails-dev mailing list