camaraproject / Commonalities

Repository to describe, develop, document and test the common guidelines and assets for CAMARA APIs
Apache License 2.0
9 stars 24 forks source link

[Subscriptions-template]: Setting a `minItems: 1` & `maxItems: 1` for `types` in subscription-requests #235

Closed maxl2287 closed 1 week ago

maxl2287 commented 3 weeks ago

Problem description It's required to set the types-attribute in the subscription-request. But it's not defined that minimum one item has to be set. But without even one type a subscription does not make sense.

Also, at least for this the upcoming meta-release v0.4.0, we should limit the maximum as well to 1.

    SubscriptionRequest:
      description: The request for creating a event-type event subscription
      type: object
      required:
        - sink
        - protocol
        - config
        - types
      properties:
       #...
        types:
          description: |
            Camara Event types eligible to be delivered by this subscription.
            Note: As of now we enforce to have only event type per subscription.
          type: array
          items:
            $ref: "#/components/schemas/SubscriptionEventType"
       #...

Expected behavior

    SubscriptionRequest:
      description: The request for creating a event-type event subscription
      type: object
      required:
        - sink
        - protocol
        - config
        - types
      properties:
       #...
        types:
          description: |
            Camara Event types eligible to be delivered by this subscription.
            Note: As of now we enforce to have only event type per subscription.
          type: array
          minItems: 1
          maxItems: 1
          items:
            $ref: "#/components/schemas/SubscriptionEventType"
       #...

Source https://github.com/camaraproject/Commonalities/blob/main/artifacts/camara-cloudevents/event-subscription-template.yaml#L305-L312