Commit c4f887f1 authored by canterafonsj's avatar canterafonsj
Browse files

Subscriptions OAS first stab

parent bb5216fd
Loading
Loading
Loading
Loading
+37 −0
Original line number Original line Diff line number Diff line
[
 {
  "id": "urn:ngsi-ld:Subscription:mySubscription",
  "type": "Subscription",
  "entities": [
    {
      "type": "Vehicle"
    }
  ],
  "watchedAttributes": [
    "speed"
  ],
  "q": "speed>50",
  "geoQ": {
    "georel": "near;maxDistance==2000",
    "geometry": "Point",
    "coordinates": [
      -1,
      100
    ]
  },
  "notification": {
    "attributes": [
      "speed"
    ],
    "format": "keyValues",
    "endpoint": {
      "uri": "http://my.endpoint.org/notify",
      "accept": "application/json"
    }
  },
  "@context": [
    "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/coreContext/ngsi-ld-core-context.json",
    "http://example.org/cim/vehicle.jsonld"
  ]
}
]
+111 −92
Original line number Original line Diff line number Diff line
@@ -68,18 +68,10 @@
          "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/geometry"
          "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/geometry"
        }
        }
      }
      }
    }
    },
    },
    "SubscriptionFragment": {
      "type": "object",
      "type": "object",
      "properties": {
      "properties": {
    "id": {
      "type": "string",
      "format": "uri"
    },
    "type": {
      "type": "string",
      "const": "Subscription"
    },
        "@context": {
        "@context": {
          "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/LdContext"
          "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/LdContext"
        },
        },
@@ -98,9 +90,6 @@
          "type": "string",
          "type": "string",
          "minLength": 1
          "minLength": 1
        },
        },
    "notification": {
      "$ref": "#/definitions/NotificationParams"
    },
        "watchedAttributes": {
        "watchedAttributes": {
          "type": "array",
          "type": "array",
          "minItems": 1,
          "minItems": 1,
@@ -117,14 +106,6 @@
          "type": "string",
          "type": "string",
          "format": "date-time"
          "format": "date-time"
        },
        },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "paused",
        "expired"
      ]
    },
        "isActive": {
        "isActive": {
          "type": "boolean"
          "type": "boolean"
        },
        },
@@ -141,12 +122,41 @@
        "csf": {
        "csf": {
          "type": "string"
          "type": "string"
        }
        }
      }
    },
    "Subscription": {
      "allOf": [
        {
          "$ref": "#/definitions/SubscriptionFragment"
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "format": "uri"
            },
            "type": {
              "type": "string",
              "const": "Subscription"
            },
            "notification": {
              "$ref": "#/definitions/NotificationParams"
            },
            "status": {
              "type": "string",
              "enum": [
                "active",
                "paused",
                "expired"
              ]
            },
            },
            "createdAt": {
            "createdAt": {
              "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/createdAt"
              "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/createdAt"
            },
            },
            "modifiedAt": {
            "modifiedAt": {
              "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/modifiedAt"
              "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/modifiedAt"
            }
          },
          },
          "allOf": [
          "allOf": [
            {
            {
@@ -171,3 +181,12 @@
            }
            }
          ]
          ]
        }
        }
      ]
    }
  },
  "allOf": [
    {
      "$ref": "#/definitions/Subscription"
    }
  ]
}
+17 −0
Original line number Original line Diff line number Diff line
{
  "$schema": "http://json-schema.org/schema#",
  "id": "https://uri.etsi.org/ngsi-ld/schema/SubscriptionList.json",
  "title": "NGSI-LD Subscription List",
  "description": "NGSI-LD Subscription List",
  "definitions": {
    "SubscriptionList": {
      "type": "array",
      "items": {
        "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/Subscription.json#/definitions/Subscription"
      }
    }
  },
  "allOf": [{
    "$ref": "#/definitions/SubscriptionList"
  }]
}
+170 −189

File changed.

Preview size limit exceeded, changes collapsed.

+100 −0
Original line number Original line Diff line number Diff line
{
  "openapi": "3.0.1",
  "info": {
    "title": "NGSI-LD Subscriptions",
    "version": "latest"
  },
  "components": {
    "parameters": [
      "limit": {
        "name": "limit",
        "description": "Pagination limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1
        }
      }
    ]
  },
  "paths": {
    "/subscriptions/": {
      "get": {
        "description": "Retrieves the subscriptions available in an NGSI-LD system",
        "operationId": "retrieveSubscriptions",
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json;application/ld+json": {
                "schema": {
                  "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/subscriptions/SubscriptionList.json#/definitions/SubscriptionList"
                },
                "examples": {
                  "simple": {
                    "externalValue": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/examples/SubscriptionList-example.json"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json;application/ld+json": {
                "schema": {
                  "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "post": {
        "description": "Creates a new Subscription within an NGSI-LD system",
        "operationId": "createSubscription",
        "requestBody": {
          "required": true,
          "content": {
            "application/json;application/ld+json": {
              "schema": {
                "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/subscriptions/Subscription.json#/definitions/Subscription"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created. Contains the resource URI of the created Subscription"
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json;application/ld+json": {
                "schema": {
                  "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/ProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "Already exists",
            "content": {
              "application/json;application/ld+json": {
                "schema": {
                  "$ref": "https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/schema/common.json#/definitions/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  }
}