Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Open API Spec #205

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

imyousuf
Copy link
Collaborator

@imyousuf imyousuf commented Jan 9, 2025

No description provided.

This is to help with the APIs and their hyperlinking to be used.
@imyousuf imyousuf added the documentation Improvements or additions to documentation label Jan 9, 2025
@imyousuf imyousuf requested a review from MunifTanjim January 9, 2025 00:46
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a /openapi/specification.json endpoint that serves this as json?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't push to this PR. but here are some fixes:

diff --git a/docs/open-api-spec/api-spec.yaml b/docs/open-api-spec/api-spec.yaml
index 6936b7f..732f403 100644
--- a/docs/open-api-spec/api-spec.yaml
+++ b/docs/open-api-spec/api-spec.yaml
@@ -19,16 +19,16 @@ paths:
         '400':
           description: Bad request
   /producer/{producerId}:
+    parameters:
+      - name: producerId
+        in: path
+        required: true
+        schema:
+          type: string
     get:
       summary: Get a specific producer
       tags:
         - Producers
-      parameters:
-        - name: producerId
-          in: path
-          required: true
-          schema:
-            type: string
       responses:
         '200':
           description: Successful response
@@ -40,25 +40,29 @@ paths:
           description: Producer not found
     put:
       summary: Update a specific producer
-      tags:
-        - Producers
       parameters:
-        - name: producerId
-          in: path
+        - in: header
+          name: If-Unmodified-Since
           required: true
           schema:
             type: string
+            format: date-time
+      tags:
+        - Producers
       requestBody:
         required: true
         content:
           application/x-www-form-urlencoded:
             schema:
               type: object
+              required:
+                - name
+                - token
               properties:
-                token:
-                  type: string
                 name:
                   type: string
+                token:
+                  type: string
       responses:
         '200':
           description: Successful update
@@ -85,16 +89,16 @@ paths:
         '400':
           description: Bad request
   /channel/{channelId}:
+    parameters:
+      - name: channelId
+        in: path
+        required: true
+        schema:
+          type: string
     get:
       summary: Get a specific channel
       tags:
         - Channels
-      parameters:
-        - name: channelId
-          in: path
-          required: true
-          schema:
-            type: string
       responses:
         '200':
           description: Successful response
@@ -109,22 +113,26 @@ paths:
       tags:
         - Channels
       parameters:
-        - name: channelId
-          in: path
+        - in: header
+          name: If-Unmodified-Since
           required: true
           schema:
             type: string
+            format: date-time
       requestBody:
         required: true
         content:
           application/x-www-form-urlencoded:
             schema:
               type: object
+              required:
+                - name
+                - token
               properties:
-                token:
-                  type: string
                 name:
                   type: string
+                token:
+                  type: string
       responses:
         '200':
           description: Successful update
@@ -137,16 +145,16 @@ paths:
         '404':
           description: Channel not found
   /channel/{channelId}/consumers:
+    parameters:
+      - name: channelId
+        in: path
+        required: true
+        schema:
+          type: string
     get:
       summary: Get list of consumers for a channel
       tags:
         - Consumers
-      parameters:
-        - name: channelId
-          in: path
-          required: true
-          schema:
-            type: string
       responses:
         '200':
           description: Successful response
@@ -157,21 +165,21 @@ paths:
         '400':
           description: Bad request
   /channel/{channelId}/consumer/{consumerId}:
+    parameters:
+      - name: channelId
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: consumerId
+        in: path
+        required: true
+        schema:
+          type: string
     get:
       summary: Get a specific consumer
       tags:
         - Consumers
-      parameters:
-        - name: channelId
-          in: path
-          required: true
-          schema:
-            type: string
-        - name: consumerId
-          in: path
-          required: true
-          schema:
-            type: string
       responses:
         '200':
           description: Successful response
@@ -186,16 +194,12 @@ paths:
       tags:
         - Consumers
       parameters:
-        - name: channelId
-          in: path
-          required: true
-          schema:
-            type: string
-        - name: consumerId
-          in: path
+        - in: header
+          name: If-Unmodified-Since
           required: true
           schema:
             type: string
+            format: date-time
       requestBody:
         required: true
         content:
@@ -203,14 +207,15 @@ paths:
             schema:
               type: object
               properties:
-                token:
+                callbackUrl:
                   type: string
                 name:
                   type: string
-                callbackUrl:
+                token:
                   type: string
                 type:
                   type: string
+                  enum: [pull, push]
       responses:
         '200':
           description: Successful update
@@ -227,16 +232,12 @@ paths:
       tags:
         - Consumers
       parameters:
-        - name: channelId
-          in: path
-          required: true
-          schema:
-            type: string
-        - name: consumerId
-          in: path
+        - in: header
+          name: If-Unmodified-Since
           required: true
           schema:
             type: string
+            format: date-time
       responses:
         '204':
           description: Successful deletion
@@ -271,27 +272,38 @@ paths:
         '500':
           description: Internal server error
   /channel/{channelId}/consumer/{consumerId}/queued-jobs:
+    parameters:
+      - name: channelId
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: consumerId
+        in: path
+        required: true
+        schema:
+          type: string
     get:
       summary: Get queued jobs for a consumer
       tags:
         - Jobs
       parameters:
-        - name: channelId
-          in: path
-          required: true
-          schema:
-            type: string
-        - name: consumerId
-          in: path
-          required: true
-          schema:
-            type: string
         - name: limit
           in: query
           schema:
             type: integer
             default: 25
             maximum: 100
+        - in: header
+          name: X-Broker-Channel-Token
+          required: true
+          schema:
+            type: string
+        - in: header
+          name: X-Broker-Consumer-Token
+          required: true
+          schema:
+            type: string
       responses:
         '200':
           description: Successful response
@@ -302,26 +314,26 @@ paths:
         '400':
           description: Bad request
   /channel/{channelId}/consumer/{consumerId}/job/{jobId}/requeue-dead-job:
+    parameters:
+      - name: channelId
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: consumerId
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: jobId
+        in: path
+        required: true
+        schema:
+          type: string
     post:
       summary: Requeue a dead job for a consumer
       tags:
         - Jobs
-      parameters:
-        - name: channelId
-          in: path
-          required: true
-          schema:
-            type: string
-        - name: consumerId
-          in: path
-          required: true
-          schema:
-            type: string
-        - name: jobId
-          in: path
-          required: true
-          schema:
-            type: string
       responses:
         '202':
           description: Job requeued successfully
@@ -330,26 +342,26 @@ paths:
         '404':
           description: Job not found
   /channel/{channelId}/consumer/{consumerId}/job/{jobId}:
+    parameters:
+      - name: channelId
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: consumerId
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: jobId
+        in: path
+        required: true
+        schema:
+          type: string
     get:
       summary: Get a specific job
       tags:
         - Jobs
-      parameters:
-        - name: channelId
-          in: path
-          required: true
-          schema:
-            type: string
-        - name: consumerId
-          in: path
-          required: true
-          schema:
-            type: string
-        - name: jobId
-          in: path
-          required: true
-          schema:
-            type: string
       responses:
         '200':
           description: Successful response
@@ -364,18 +376,13 @@ paths:
       tags:
         - Jobs
       parameters:
-        - name: channelId
-          in: path
+        - in: header
+          name: X-Broker-Channel-Token
           required: true
           schema:
             type: string
-        - name: consumerId
-          in: path
-          required: true
-          schema:
-            type: string
-        - name: jobId
-          in: path
+        - in: header
+          name: X-Broker-Consumer-Token
           required: true
           schema:
             type: string
@@ -385,6 +392,8 @@ paths:
           application/json:
             schema:
               type: object
+              required:
+                - NextState
               properties:
                 NextState:
                   type: string
@@ -398,19 +407,53 @@ paths:
         '404':
           description: Job not found
   /channel/{channelId}/broadcast:
+    parameters:
+      - name: channelId
+        in: path
+        required: true
+        schema:
+          type: string
     post:
       summary: Broadcast a message to a channel
       tags:
         - Broadcast
       parameters:
-        - name: channelId
-          in: path
+        - in: header
+          name: X-Broker-Channel-Token
           required: true
           schema:
             type: string
+        - in: header
+          name: X-Broker-Producer-ID
+          required: true
+          schema:
+            type: string
+        - in: header
+          name: X-Broker-Producer-Token
+          required: true
+          schema:
+            type: string
+        - in: header
+          name: X-Broker-Message-ID
+          schema:
+            type: string
+        - in: header
+          name: X-Broker-Message-Priority
+          schema:
+            type: integer
+        - in: header
+          name: X-Broker-Message-Metadata-Headers
+          schema:
+            type: string
       requestBody:
         required: true
         content:
+          application/json:
+            schema:
+              type: object
+          application/x-www-form-urlencoded:
+            schema:
+              type: object
           application/octet-stream:
             schema:
               type: string
@@ -422,21 +465,21 @@ paths:
         '409':
           description: Conflict - Duplicate message ID
   /channel/{channelId}/message/{messageId}:
+    parameters:
+      - name: channelId
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: messageId
+        in: path
+        required: true
+        schema:
+          type: string
     get:
       summary: Get a specific message
       tags:
         - Messages
-      parameters:
-        - name: channelId
-          in: path
-          required: true
-          schema:
-            type: string
-        - name: messageId
-          in: path
-          required: true
-          schema:
-            type: string
       responses:
         '200':
           description: Successful response
@@ -447,16 +490,17 @@ paths:
         '404':
           description: Message not found
   /channel/{channelId}/messages:
+    parameters:
+      - name: channelId
+        in: path
+        required: true
+        schema:
+          type: string
     get:
       summary: Get list of messages for a channel
       tags:
         - Messages
       parameters:
-        - name: channelId
-          in: path
-          required: true
-          schema:
-            type: string
         - name: status
           in: query
           schema:
@@ -471,16 +515,16 @@ paths:
         '400':
           description: Bad request
   /channel/{channelId}/messages-status:
+    parameters:
+      - name: channelId
+        in: path
+        required: true
+        schema:
+          type: string
     get:
       summary: Get message status counts for a channel
       tags:
         - Messages
-      parameters:
-        - name: channelId
-          in: path
-          required: true
-          schema:
-            type: string
       responses:
         '200':
           description: Successful response
@@ -491,21 +535,21 @@ paths:
         '500':
           description: Internal server error
   /channel/{channelId}/consumer/{consumerId}/dlq:
+    parameters:
+      - name: channelId
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: consumerId
+        in: path
+        required: true
+        schema:
+          type: string
     get:
       summary: Get dead letter queue for a consumer
       tags:
         - DLQ
-      parameters:
-        - name: channelId
-          in: path
-          required: true
-          schema:
-            type: string
-        - name: consumerId
-          in: path
-          required: true
-          schema:
-            type: string
       responses:
         '200':
           description: Successful response
@@ -567,11 +611,13 @@ components:
           type: array
           items:
             type: string
-            format: uri
         Pages:
           type: object
-          additionalProperties:
-            type: string
+          properties:
+            next:
+              type: string
+            previous:
+              type: string
     ChannelModel:
       type: object
       properties:
@@ -602,6 +648,7 @@ components:
           format: uri
         Type:
           type: string
+          enum: [pull, push]
     AppData:
       type: object
       properties:
@@ -611,8 +658,7 @@ components:
           type: object
     JobStatus:
       type: object
-      properties:
-        <add properties here as per your exact schema>
+      properties: {}
     JobListResult:
       type: object
       properties:
@@ -725,8 +771,11 @@ components:
             $ref: '#/components/schemas/DeadDeliveryJobModel'
         Pages:
           type: object
-          additionalProperties:
-            type: string
+          properties:
+            next:
+              type: string
+            previous:
+              type: string
     DeadDeliveryJobModel:
       type: object
       properties:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants