Cloudevents decoupled from EventTypeNotification scheme in Event Subscription Template#604
Conversation
…ect#603) Phase 1 of artifacts restructuring: - Move CAMARA_common.yaml to artifacts/common/ directory - Add api-templates/sample-service.yaml demonstrating $ref consumption - Update documentation references to new path The sample-service template demonstrates two patterns for error responses: - Option A: pure $ref for responses using only generic error codes - Option B: local response definition extending generic errors with API-specific codes (ResourceNotFound404 example) Next steps (after camaraproject#604 merges): - Add CAMARA_event_common.yaml with CloudEvent/Source/DateTime schemas - Add notification-templates/sample-notification.yaml - Add event-related API templates (implicit events, subscriptions) - Migrate camara-cloudevents/ content to new structure
| url: https://www.apache.org/licenses/LICENSE-2.0.html | ||
| version: 0.4.0-rc.1 | ||
| version: wip | ||
| x-camara-commonalities: "0.7" |
There was a problem hiding this comment.
do we take advantage and also update it?
There was a problem hiding this comment.
It's already done in #599 and need to be aligned to resolve the merge conflict.
There was a problem hiding this comment.
I have resolved it, but diffs the file as completely new.
There was a problem hiding this comment.
The diffs shown on all lines are whitespace diffs, more precisely changes from LF to CRLF. https://github.com/camaraproject/Commonalities/pull/604/changes?w=1 is looking good and shows only the actual changes.
The main culprit is 939d6f6 which introduced four changed lines with CRLF (no clue why). The Merge conflict resolution in c67a8ea then aligned all lines to CRLF (Lines changed: 1396 additions & 1396 deletions) :-(
We might can avoid this behavior by deploying the .gitattributes file as proposed in camaraproject/tooling#112 ... would be worth to give it a try.
There was a problem hiding this comment.
I tried what would happen with adding .gitattributes and then git . add --renormalize:
artifacts/CAMARA_common.yaml | 1654 +++++------
.../event-subscription-template.feature | 758 ++---
.../event-subscription-template.yaml | 2794 +++++++++----------
artifacts/testing/C01-device-errors.feature | 216 +-
artifacts/testing/C02-phoneNumber-errors.feature | 158 +-
documentation/API-DocumentationTemplate.md | 40 +-
documentation/CAMARA-API-Design-Guide.md | 2888 ++++++++++----------
documentation/Linting-rules.md | 924 +++----
.../Nokia_Open_APIs_Lab_NEF_access.md | 52 +-
.../SupportingDocuments/UE-Identification.md | 262 +-
So several main documents have currently CRLF line endings instead of LF. We need to do the introduction of .gitattributes and renormalization in a quiet phase to avoid merge conflicts.
| mapping: | ||
| org.camaraproject.api-name.v0.subscription-started: "#/components/schemas/EventSubscriptionStarted" | ||
| org.camaraproject.api-name.v0.subscription-updated: "#/components/schemas/EventSubscriptionUpdated" | ||
| org.camaraproject.api-name.v0.subscription-ended: "#/components/schemas/EventSubscriptionEnded" |
There was a problem hiding this comment.
When SubscriptionLifecycleEvent moves to CAMARA_event_common.yaml as proposed, should the discriminator mapping with api-name-specific prefixes stay in the API template, or should the common file carry a generic mapping?
There was a problem hiding this comment.
Good point.
Currently org.camaraproject.api-name.v0.subscription-* event names are API specific (although the guidelines are not explicit about the naming pattern for this events).
I propose to keep the schemas SubscriptionLifecycleEvent and SubscriptionLifecycleEventType in the api definitions, and in the future analyse the consequences of having common naming like org.camaraproject.subscription-event.v0.subscription-* in all subscription APIs.
| - org.camaraproject.api-name.v0.subscription-started | ||
| - org.camaraproject.api-name.v0.subscription-updated | ||
| - org.camaraproject.api-name.v0.subscription-ended |
There was a problem hiding this comment.
Same as above ... if "these are managed by Commonalities and are identical across all CAMARA APIs that support explicit subscriptions" then they should not contain the api-name placeholder.
There was a problem hiding this comment.
As in #604 (comment) - the comments in the file can be improved to indicate that schemas are managed by Commonalities, and only event names should be updated with correct api-name
Co-authored-by: Pedro Díez García <pedro.diezgarcia@telefonica.com> Co-authored-by: Herbert Damker <herbert.damker@telekom.de>
|
As explained in #604 (comment) Github diff is not readable. |
nice view in "mergely" ... but also readable in GitHub if you hide the whitespace changes: https://github.com/camaraproject/Commonalities/pull/604/changes?w=1 (also available via the UI, at the settings buttons in file changes view). PR looks good to me as well. |
…ect#603) Phase 1 of artifacts restructuring: - Move CAMARA_common.yaml to artifacts/common/ directory - Add api-templates/sample-service.yaml demonstrating $ref consumption - Update documentation references to new path The sample-service template demonstrates two patterns for error responses: - Option A: pure $ref for responses using only generic error codes - Option B: local response definition extending generic errors with API-specific codes (ResourceNotFound404 example) Next steps (after camaraproject#604 merges): - Add CAMARA_event_common.yaml with CloudEvent/Source/DateTime schemas - Add notification-templates/sample-notification.yaml - Add event-related API templates (implicit events, subscriptions) - Migrate camara-cloudevents/ content to new structure
What type of PR is this?
What this PR does / why we need it:
Refactors the notification event schema hierarchy in the subscription template to decouple the CloudEvents 1.0 envelope from CAMARA-specific type constraints and discriminator routing.
The original
CloudEventschema mixed up three separate issues — the message format, the event types, and the routing rules — which made it hard to reuse the basic schema for different APIs or to add new event groups without changing shared parts.This PR introduces a layered schema model:
CloudEvent(Commonalities-owned) — pure CloudEvents 1.0 envelope.typeis astring. No CAMARA-specific enum values, no discriminator. This schema is now stable and requires no modification regardless of how many APIs or event types are added.ApiNotificationEvent(API project-owned) — extendsCloudEventviaallOf. ConstrainstypetoApiEventTypeand owns the discriminator mapping for API-specific concrete event schemas. Adding a new event type requires only a new enum value inApiEventTypeand a new discriminator mapping entry here.ApiEventType(API project-owned) — standalone enum of API-specific event type strings. Separated from the discriminated schema so the valid type strings can be referenced independently (e.g. inSubscriptionRequest.types).SubscriptionLifecycleEvent+SubscriptionLifecycleEventType(Commonalities-owned) — structurally parallel to the API-specific group. Coverssubscription-started,subscription-updated,subscription-ended.NotificationEvent(API project-owned) —oneOfunion used as the callbackrequestBodyschema. Adding a new event group requires a single line in theoneOf.As a secondary fix,
SubscriptionRequest.typesandSubscription.typesnow referenceApiEventTypeinstead of the previousSubscriptionEventType/EventTypeNotificationenums, which incorrectly included lifecycle event types. Lifecycle events are server-initiated and must not appear as subscribable types in a POST body.Which issue(s) this PR fixes:
Fixes #600
Does this PR introduce a breaking change?
Special notes for reviewers:
CloudEvent,SubscriptionLifecycleEvent, andSubscriptionLifecycleEventTypeare candidates forCAMARA_event_common.yaml;ApiNotificationEvent,ApiEventType, andNotificationEventbelong in thesample-service-subscriptions.yaml. Note: ForSubscriptionLifecycleEvent, andSubscriptionLifecycleEventTypethe special events naming pattern should be reviewed to make them reusable in the future.propertyNamefield appear in the schema that declares the discriminator, not only in a parent viaallOf. Thetypeproperty override inApiNotificationEventandSubscriptionLifecycleEventsatisfies this constraint.NotificationEventintentionally carries no discriminator. Without a top-level discriminator, tooling resolves theoneOfby evaluating each branch in order. This is correct behaviour — the two groups are distinguished by non-overlappingtypeenum values, so evaluation is unambiguous.EventApiSpecific1/EventApiSpecific2concrete schemas now extendApiNotificationEventrather thanCloudEventdirectly, preserving the full inheritance chain and can be placed insample-event-type.yaml.Changelog input
Additional documentation