From 4d72b35724f575a545a59685ba2d12b937273c69 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Thu, 3 May 2018 16:22:46 +0200
Subject: [PATCH] FEAT #7640 add schema json rest

---
 rest/schema.json | 283 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 283 insertions(+)
 create mode 100644 rest/schema.json

diff --git a/rest/schema.json b/rest/schema.json
new file mode 100644
index 00000000000..cc47c34d8c2
--- /dev/null
+++ b/rest/schema.json
@@ -0,0 +1,283 @@
+{
+    "swagger" : "2.0",
+    "info" : {
+        "title" : "Maarch Courrier",
+        "version" : "18.10",
+        "description" : "Documentation de l'API Maarch Courrier V18.10",
+        "contact" : {
+            "name" : "Maarch",
+            "email" : "info@maarch.org"
+        }
+    },
+    "paths" : {
+        "/rest/res/resource/status" : {
+            "put" :  {
+                "description" : "Update documents status",
+                "operationId" : " Resource/controllers/ResController::updateStatus",
+                "parameters" : [
+                    {
+                        "name" : "resId",
+                        "description" : "Documents identifier",
+                        "in" : "body",
+                        "required" : false,
+                        "schema": {
+                            "type" : "array",
+                            "items" : {
+                                "type" : "integer",
+                                "example" : 101
+                            }
+                        }
+                    },
+                    {
+                        "name" : "chrono",
+                        "description" : "Documents chrono number",
+                        "in" : "body",
+                        "required" : false,
+                        "schema": {
+                            "type" : "array",
+                            "items" : {
+                                "type" : "string",
+                                "maxLength" : 255,
+                                "example" : "MAARCH/2017A/91"
+                            }
+                        }
+                    },
+                    {
+                        "name" : "status",
+                        "description" : "New status",
+                        "in" : "body",
+                        "required" : false,
+                        "schema": {
+                            "type" : "string",
+                            "maxLength" : 10,
+                            "default" : "COU",
+                            "example" : "NEW"
+                        }
+                    },
+                    {
+                        "name" : "historyMessage",
+                        "description" : "Message in history table",
+                        "in" : "body",
+                        "required" : false,
+                        "schema": {
+                            "type" : "string",
+                            "default" : "status update",
+                            "example" : "Document is reopen"
+                        }
+                    }  
+                ],
+                "responses" : {
+                    "200" : {
+                        "description" : "Status updated",
+                        "schema": {
+                            "type" : "object",
+                            "properties" : {
+                                "success" : {
+                                    "type" : "string"
+                                }
+                            }
+                        },
+                        "examples" : {
+                            "application/json": {
+                                "success": "success"
+                            }
+                        }
+                    },
+                    "400" : {
+                        "description" : "Status or document not found",
+                        "schema": {
+                            "type" : "object",
+                            "properties" : {
+                                "errors" : {
+                                    "type" : "string"
+                                }
+                            }
+                        },
+                        "examples" : {
+                            "application/json": {
+                                "errors": "Status not found"
+                            }
+                        }
+                    },
+                    "403" : {
+                        "description" : "Document is out of perimeter",
+                        "schema": {
+                            "type" : "object",
+                            "properties" : {
+                                "errors" : {
+                                    "type" : "string"
+                                }
+                            }
+                        },
+                        "examples" : {
+                            "application/json": {
+                                "errors": "Document out of perimeter"
+                            }
+                        }
+                    }
+                }
+            } 
+        },
+        "/rest/entities/{id}" : {
+            "get" : {
+                "description" : "Get entity informations",
+                "operationId" : "Entity/controllers/EntityController::getById",
+                "parameters" : [
+                    {
+                        "name" : "id",
+                        "description" : "Entity identifier",
+                        "in" : "path",
+                        "required" : true,
+                        "type" : "string",
+                        "maxLength" : 32
+                    }
+                ],
+                "responses" : {
+                    "200" : {
+                        "description" : "Return entity informations",
+                        "schema" : {
+                            "$ref": "#/definitions/EntityRead"
+                        },
+                        "examples" : {
+                            "application/json": {
+                                "entity": {
+                                    "entity_id" : "VILLE",
+                                    "entity_label" : "Ville de Maarch-Les-Bains",
+                                    "short_label" : "Ville de Maarch-Les-Bains",
+                                    "enabled" : "Y",
+                                    "adrs_1" : "11 Bd du sud-est",
+                                    "adrs_2" : "",
+                                    "adrs_3" : "",
+                                    "zipcode" : "92000",
+                                    "city" : "Nanterre",
+                                    "country" : "FRANCE",
+                                    "email" : "info@maarchlesbains.org",
+                                    "business_id" : "",
+                                    "parent_entity_id" : "",
+                                    "entity_type" : "Direction",
+                                    "entity_path" : "",
+                                    "ldap_id" : "",
+                                    "archival_agency" : "",
+                                    "archival_agreement" : "",
+                                    "entity_full_name" : ""
+                                } 
+                            }
+                        }
+                    },
+                    "400" : {
+                        "description" : "Entity not found",
+                        "schema": {
+                            "type" : "object",
+                            "properties" : {
+                                "errors" : {
+                                    "type" : "string"
+                                }
+                            }
+                        },
+                        "examples" : {
+                            "application/json": {
+                                "errors": "Entity not found"
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    },
+    "definitions" : {
+        "EntityRead" : {
+            "type" : "object",
+            "required" : [
+                "entity"
+            ],
+            "properties": {
+                "entity" : {
+                    "required" : [
+                        "entity_id",
+                        "entity_label",
+                        "short_label",
+                        "entity_type",
+                        "enabled",
+                    ],
+                    "properties" : {
+                        "entity_id" : {
+                            "type" : "string",
+                            "maxLength" : 32
+                        },                       
+                        "entity_label" : {
+                            "type" : "string",
+                            "maxLength" : 255
+                        },                       
+                        "short_label" : {
+                            "type" : "string",
+                            "maxLength" : 50
+                        },                       
+                        "enabled" : {
+                            "type" : "string",
+                            "maxLength" : 1
+                        },                       
+                        "adrs_1" : {
+                            "type" : "string",
+                            "maxLength" : 255
+                        },                       
+                        "adrs_2" : {
+                            "type" : "string",
+                            "maxLength" : 255
+                        },                       
+                        "adrs_3" : {
+                            "type" : "string",
+                            "maxLength" : 255
+                        },                       
+                        "zipcode" : {
+                            "type" : "string",
+                            "maxLength" : 32
+                        },                       
+                        "city" : {
+                            "type" : "string",
+                            "maxLength" : 255
+                        },                       
+                        "country" : {
+                            "type" : "string",
+                            "maxLength" : 255
+                        },                       
+                        "email" : {
+                            "type" : "string",
+                            "maxLength" : 255
+                        },                       
+                        "business_id" : {
+                            "type" : "string",
+                            "maxLength" : 32
+                        },                       
+                        "parent_entity_id" : {
+                            "type" : "string",
+                            "maxLength" : 32
+                        },                       
+                        "entity_type" : {
+                            "type" : "string",
+                            "maxLength" : 64
+                        },                       
+                        "entity_path" : {
+                            "type" : "string",
+                            "maxLength" : 2048
+                        },                       
+                        "ldap_id" : {
+                            "type" : "string",
+                            "maxLength" : 255
+                        },                       
+                        "archival_agency" : {
+                            "type" : "string",
+                            "maxLength" : 255
+                        },                       
+                        "archival_agreement" : {
+                            "type" : "string",
+                            "maxLength" : 255
+                        },                       
+                        "entity_full_name" : {
+                            "type" : "string"
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
-- 
GitLab