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

Add support for callbacks #273

Closed
samchungy opened this issue May 20, 2024 · 0 comments · Fixed by #278
Closed

Add support for callbacks #273

samchungy opened this issue May 20, 2024 · 0 comments · Fixed by #278

Comments

@samchungy
Copy link
Owner

Screenshot 2024-05-20 at 15 53 29

example openapi

{
  "openapi": "3.0.0",
  "info": {
    "title": "Callback Example",
    "version": "1.0.0"
  },
  "paths": {
    "/streams": {
      "post": {
        "description": "subscribes a client to receive out-of-band data",
        "parameters": [
          {
            "name": "callbackUrl",
            "in": "query",
            "required": true,
            "description": "the location where data will be sent.  Must be network accessible\nby the source server\n",
            "schema": {
              "type": "string",
              "format": "uri",
              "example": "https://tonys-server.com"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "subscription successfully created",
            "content": {
              "application/json": {
                "schema": {
                  "description": "subscription information",
                  "required": [
                    "subscriptionId"
                  ],
                  "properties": {
                    "subscriptionId": {
                      "description": "this unique identifier allows management of the subscription",
                      "type": "string",
                      "example": "2531329f-fb09-4ef7-887e-84e648214436"
                    }
                  }
                }
              }
            }
          }
        },
        "callbacks": {
          "onData": {
            "{$request.query.callbackUrl}/data": {
              "post": {
                "requestBody": {
                  "description": "subscription payload",
                  "content": {
                    "application/json": {
                      "schema": {
                        "type": "object",
                        "properties": {
                          "timestamp": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "userData": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "responses": {
                  "202": {
                    "description": "Your server implementation should return this HTTP status code\nif the data was received successfully\n"
                  },
                  "204": {
                    "description": "Your server should return this HTTP status code if no longer interested\nin further updates\n"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Originally posted by @kambie10 in #272

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

Successfully merging a pull request may close this issue.

1 participant