From b1a7f835aa9fb42ff7e724257ed147a977437e82 Mon Sep 17 00:00:00 2001
From: BEAUVAIS ANTOINE <antoine.beauvais@etu.unistra.fr>
Date: Fri, 24 Sep 2021 21:43:02 +0200
Subject: [PATCH] Added stub OpenAPI specification.

Use https://editor.swagger.io/ to view.
---
 back-openapi.yaml                             | 160 ++++++++++++++++++
 .../sil/erp/back/model/Transaction.java       |   1 -
 2 files changed, 160 insertions(+), 1 deletion(-)
 create mode 100644 back-openapi.yaml

diff --git a/back-openapi.yaml b/back-openapi.yaml
new file mode 100644
index 0000000..3e1eac8
--- /dev/null
+++ b/back-openapi.yaml
@@ -0,0 +1,160 @@
+openapi: "3.0.0"
+info:
+  version: 0.0.1-20210924
+  title: SIL ERP BACK
+  description: Interface API between the SIL ERP services and the BACK component.
+#  termsOfService: https://git.unistra.fr/erp-sil/back
+  contact:
+    name: Antoine Beauvais
+    email: antoine.beauvais@etu.unistra.fr
+    url: https://git.unistra.fr/antoine.beauvais
+  license:
+    name: CeCILL-B
+    url: https://cecill.info/licences/Licence_CeCILL-B_V1-en.html
+paths:
+  /retrieveItems:
+    get:
+      description: |
+        Returns the list of all available items.
+        
+        It is also possible to filter items by category.
+      operationId: retrieveItems
+      parameters:
+        - name: category
+          in: query
+          description: category ID to filter results by
+          required: false
+          schema:
+            type: integer
+            format: int32
+      responses:
+        '200':
+          description: List of items.
+          content:
+            application/json:
+              schema:
+                type: array
+                items:
+                  $ref: '#/components/schemas/Item'
+        '204':
+          description: No Content (no items in the given category)
+        '400':
+          description: Bad Request (invalid category parameter)
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/ErrorMessage'
+        '500':
+          description: Internal Server Error
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/ErrorMessage'
+  /retrieveCategories:
+    get:
+      description: |
+        Returns the list of all existing categories.
+      operationId: retrieveCategories
+      responses:
+        '200':
+          description: List of categories.
+          content:
+            application/json:
+              schema:
+                type: array
+                items:
+                  $ref: '#/components/schemas/Category'
+        '500':
+          description: Internal Server Error
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/ErrorMessage'
+  /submitTransaction:
+    post:
+      description: Submits a new transaction into the system.
+      operationId: submitTransaction
+      requestBody:
+        description: Transaction to process.
+        required: true
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/Transaction'
+      responses:
+        '201':
+          description: Created transaction.
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/Transaction'
+        '400':
+          description: Bad Request (invalid JSON)
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/ErrorMessage'
+        '500':
+          description: Internal Server Error
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/ErrorMessage'
+components:
+  schemas:
+    Category:
+      type: object
+      required:
+        - id
+        - name
+      properties:
+        id:
+          type: integer
+          example: 1
+        name:
+          type: string
+          example: "Boissons"
+    Item:
+      type: object
+      required:
+        - id
+        - name
+        - price
+        - subscriberPrice
+      properties:
+        id:
+          type: integer
+          example: 1
+        name:
+          type: string
+          example: "Jus d'orange"
+        price:
+          type: number
+          example: 1.5
+        subscriberPrice:
+          type: number
+          example: 0.8
+    Transaction:
+      type: object
+      required:
+        - item
+        - quantity
+        - amount
+      properties:
+        item:
+          type: integer
+          example: 1
+        quantity:
+          type: integer
+          example: 5
+        amount:
+          type: number
+          example: 4.0
+    ErrorMessage:
+      type: object
+      required:
+        - message
+      properties:
+        message:
+          type: string
+          example: "Database failure."
\ No newline at end of file
diff --git a/src/main/java/fr/unistra/sil/erp/back/model/Transaction.java b/src/main/java/fr/unistra/sil/erp/back/model/Transaction.java
index fe41245..57efe19 100644
--- a/src/main/java/fr/unistra/sil/erp/back/model/Transaction.java
+++ b/src/main/java/fr/unistra/sil/erp/back/model/Transaction.java
@@ -38,7 +38,6 @@ public class Transaction {
      * Class constructor.
      * @param item Item's identifier.
      * @param type Transaction type.
-     * @param amount Transaction's amount.
      * @param quantity Quantity of items involved.
      */
     public Transaction(Integer item, Integer type, Integer quantity)
-- 
GitLab