Browse code

Merge pull request #30954 from yongtang/29448-swagger-version

Improve documentation of `Version` usage for Swarm API
(cherry picked from commit 89fe0e1b1436871e3d844f8096d1520eaacfad74)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Vincent Demeester authored on 2017/02/22 18:59:10
Showing 1 changed files
... ...
@@ -1544,6 +1544,21 @@ definitions:
1544 1544
           Settable: null
1545 1545
           Value: []
1546 1546
 
1547
+  ObjectVersion:
1548
+    description: |
1549
+      The version number of the object such as node, service, etc. This is needed to avoid conflicting writes.
1550
+      The client must send the version number along with the modified specification when updating these objects.
1551
+      This approach ensures safe concurrency and determinism in that the change on the object
1552
+      may not be applied if the version number has changed from the last read. In other words,
1553
+      if two update requests specify the same base version, only one of the requests can succeed.
1554
+      As a result, two separate update requests that happen at the same time will not
1555
+      unintentially overwrite each other.
1556
+    type: "object"
1557
+    properties:
1558
+      Index:
1559
+        type: "integer"
1560
+        format: "int64"
1561
+
1547 1562
   NodeSpec:
1548 1563
     type: "object"
1549 1564
     properties:
... ...
@@ -1580,11 +1595,7 @@ definitions:
1580 1580
       ID:
1581 1581
         type: "string"
1582 1582
       Version:
1583
-        type: "object"
1584
-        properties:
1585
-          Index:
1586
-            type: "integer"
1587
-            format: "int64"
1583
+        $ref: "#/definitions/ObjectVersion"
1588 1584
       CreatedAt:
1589 1585
         type: "string"
1590 1586
         format: "dateTime"
... ...
@@ -1807,11 +1818,7 @@ definitions:
1807 1807
         description: "The ID of the swarm."
1808 1808
         type: "string"
1809 1809
       Version:
1810
-        type: "object"
1811
-        properties:
1812
-          Index:
1813
-            type: "integer"
1814
-            format: "int64"
1810
+        $ref: "#/definitions/ObjectVersion"
1815 1811
       CreatedAt:
1816 1812
         type: "string"
1817 1813
         format: "dateTime"
... ...
@@ -1994,11 +2001,7 @@ definitions:
1994 1994
         description: "The ID of the task."
1995 1995
         type: "string"
1996 1996
       Version:
1997
-        type: "object"
1998
-        properties:
1999
-          Index:
2000
-            type: "integer"
2001
-            format: "int64"
1997
+        $ref: "#/definitions/ObjectVersion"
2002 1998
       CreatedAt:
2003 1999
         type: "string"
2004 2000
         format: "dateTime"
... ...
@@ -2206,11 +2209,7 @@ definitions:
2206 2206
       ID:
2207 2207
         type: "string"
2208 2208
       Version:
2209
-        type: "object"
2210
-        properties:
2211
-          Index:
2212
-            type: "integer"
2213
-            format: "int64"
2209
+        $ref: "#/definitions/ObjectVersion"
2214 2210
       CreatedAt:
2215 2211
         type: "string"
2216 2212
         format: "dateTime"
... ...
@@ -2418,11 +2417,7 @@ definitions:
2418 2418
       ID:
2419 2419
         type: "string"
2420 2420
       Version:
2421
-        type: "object"
2422
-        properties:
2423
-          Index:
2424
-            type: "integer"
2425
-            format: "int64"
2421
+        $ref: "#/definitions/ObjectVersion"
2426 2422
       CreatedAt:
2427 2423
         type: "string"
2428 2424
         format: "dateTime"