From 3b85c98e10c42d38e842889e171e19363ebb1606 Mon Sep 17 00:00:00 2001
From: Quaternions <krakow20@gmail.com>
Date: Thu, 5 Dec 2024 16:32:48 -0800
Subject: [PATCH] openapi: massive crud

---
 openapi.yaml | 288 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 270 insertions(+), 18 deletions(-)

diff --git a/openapi.yaml b/openapi.yaml
index 9b93628..77aedf6 100644
--- a/openapi.yaml
+++ b/openapi.yaml
@@ -10,6 +10,8 @@ tags:
     description: Submission operations
   - name: Scripts
     description: Script operations
+  - name: ScriptPolicy
+    description: Script policy operations
 security:
   - cookieAuth: []
 paths:
@@ -326,15 +328,38 @@ paths:
             application/json:
               schema:
                 $ref: "#/components/schemas/Error"
-  /script-policy/hash/{Hash}:
-# /script-policy/id/{ScriptPolicyID}:
+  /script-policy:
+    post:
+      summary: Create a new script policy
+      operationId: createScriptPolicy
+      tags:
+        - ScriptPolicy
+      requestBody:
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/ScriptPolicyCreate'
+      responses:
+        "200":
+          description: Successful response
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Id"
+        default:
+          description: General Error
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Error"
+  /script-policy/hash/{FromScriptHash}:
     get:
       summary: Get the policy for the given hash of script source code
       operationId: getScriptPolicyFromHash
       tags:
-        - Scripts
+        - ScriptPolicy
       parameters:
-        - name: Hash
+        - name: FromScriptHash
           in: path
           required: true
           schema:
@@ -352,6 +377,103 @@ paths:
             application/json:
               schema:
                 $ref: "#/components/schemas/Error"
+  /script-policy/id/{ScriptPolicyID}:
+    get:
+      summary: Get the specified script policy by ID
+      operationId: getScriptPolicy
+      tags:
+        - ScriptPolicy
+      parameters:
+        - name: ScriptPolicyID
+          in: path
+          required: true
+          schema:
+            type: integer
+            format: int64
+      responses:
+        "200":
+          description: Successful response
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/ScriptPolicy"
+        default:
+          description: General Error
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Error"
+    patch:
+      summary: Update the specified script policy by ID
+      operationId: updateScriptPolicy
+      tags:
+        - ScriptPolicy
+      parameters:
+        - name: ScriptPolicyID
+          in: path
+          required: true
+          schema:
+            type: integer
+            format: int64
+      requestBody:
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/ScriptPolicyUpdate'
+      responses:
+        "200":
+          description: Successful response
+        default:
+          description: General Error
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Error"
+    delete:
+      summary: Delete the specified script policy by ID
+      operationId: deleteScriptPolicy
+      tags:
+        - ScriptPolicy
+      parameters:
+        - name: ScriptPolicyID
+          in: path
+          required: true
+          schema:
+            type: integer
+            format: int64
+      responses:
+        "200":
+          description: Successful response
+        default:
+          description: General Error
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Error"
+  /scripts:
+    post:
+      summary: Create a new script
+      operationId: createScript
+      tags:
+        - Scripts
+      requestBody:
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/ScriptCreate'
+      responses:
+        "200":
+          description: Successful response
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Id"
+        default:
+          description: General Error
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Error"
   /scripts/{ScriptID}:
     get:
       summary: Get the specified script by ID
@@ -378,6 +500,53 @@ paths:
             application/json:
               schema:
                 $ref: "#/components/schemas/Error"
+    patch:
+      summary: Update the specified script by ID
+      operationId: updateScript
+      tags:
+        - Scripts
+      parameters:
+        - name: ScriptID
+          in: path
+          required: true
+          schema:
+            type: integer
+            format: int64
+      requestBody:
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/ScriptUpdate'
+      responses:
+        "200":
+          description: Successful response
+        default:
+          description: General Error
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Error"
+    delete:
+      summary: Delete the specified script by ID
+      operationId: deleteScript
+      tags:
+        - Scripts
+      parameters:
+        - name: ScriptID
+          in: path
+          required: true
+          schema:
+            type: integer
+            format: int64
+      responses:
+        "200":
+          description: Successful response
+        default:
+          description: General Error
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Error"
 components:
   securitySchemes:
     cookieAuth:
@@ -386,23 +555,27 @@ components:
       name: SESSIONID
   schemas:
     Id:
+      required:
+      - ID
       type: object
       properties:
         ID:
           type: integer
           format: int64
-    User:
-      type: object
-      properties:
-        ID:
-          type: integer
-          format: int64
-        Username:
-          type: string
-        StateID:
-          type: integer
-          format: int32
     Submission:
+      required:
+      - ID
+      - DisplayName
+      - Creator
+      - GameID
+      - Date
+      - Submitter
+      - AssetID
+      - AssetVersion
+      - Completed
+      - SubmissionType
+#     - TargetAssetID
+      - StatusID
       type: object
       properties:
         ID:
@@ -439,6 +612,8 @@ components:
           type: integer
           format: int32
     SubmissionFilter:
+      required:
+      - ID
       type: object
       properties:
         ID:
@@ -455,6 +630,16 @@ components:
           type: integer
           format: int64
     SubmissionCreate:
+      required:
+      - ID
+      - DisplayName
+      - Creator
+      - GameID
+      - Submitter
+      - AssetID
+      - AssetVersion
+      - SubmissionType
+#     - TargetAssetID
       type: object
       properties:
         DisplayName:
@@ -480,6 +665,11 @@ components:
           type: integer
           format: int64
     Script:
+      required:
+      - ID
+      - Hash
+      - Source
+#     - SubmissionID
       type: object
       properties:
         ID:
@@ -492,15 +682,77 @@ components:
         SubmissionID:
           type: integer
           format: int64
-    ScriptPolicy:
+    ScriptCreate:
+      required:
+      - Source
+#     - SubmissionID
+      type: object
+      properties:
+        Source:
+          type: string
+        SubmissionID:
+          type: integer
+          format: int64
+    ScriptUpdate:
+      required:
+      - ID
       type: object
       properties:
         ID:
           type: integer
           format: int64
-        Hash:
+        Source:
           type: string
-        ScriptID:
+        SubmissionID:
+          type: integer
+          format: int64
+    ScriptPolicy:
+      required:
+      - ID
+      - FromScriptHash
+      - ToScriptID
+      - Policy
+      type: object
+      properties:
+        ID:
+          type: integer
+          format: int64
+        FromScriptHash:
+          type: string
+        ToScriptID:
+          type: integer
+          format: int64
+        Policy:
+          type: integer
+          format: int32
+    ScriptPolicyCreate:
+      required:
+      - FromScriptID
+      - ToScriptID
+      - Policy
+      type: object
+      properties:
+        FromScriptID:
+          type: integer
+          format: int64
+        ToScriptID:
+          type: integer
+          format: int64
+        Policy:
+          type: integer
+          format: int32
+    ScriptPolicyUpdate:
+      required:
+      - ID
+      type: object
+      properties:
+        ID:
+          type: integer
+          format: int64
+        FromScriptID:
+          type: integer
+          format: int64
+        ToScriptID:
           type: integer
           format: int64
         Policy: