-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem description
The artifacts/ directory currently contains template files (CAMARA_common.yaml, notification-as-cloud-event.yaml, event-subscription-template.yaml) in a flat layout. These templates duplicate schemas (ErrorInfo, XCorrelator, CloudEvent, Source, DateTime are defined identically in multiple files) and are structured as standalone APIs rather than as $ref-consumable components.
With the move toward $ref-based consumption of common schemas (camaraproject#577) and the bundling model proposed in ReleaseManagement#436, API repositories will adopt a canonical layout:
code/
API_definitions/ # API source files
common/ # Cached copy of Commonalities common schemas
The $ref paths in API source files (e.g., ../common/CAMARA_common.yaml#/components/schemas/ErrorInfo) are relative to this layout. Currently, the Commonalities templates do not use this layout, so their $ref paths differ from what API repos actually use. Templates also duplicate schemas instead of referencing a single authoritative source.
Possible evolution
Restructure artifacts/ to mirror the canonical API repo layout, so that relative $ref paths in templates are identical to those in API repositories:
artifacts/
common/ # Authoritative common schema files
CAMARA_common.yaml
CAMARA_event_common.yaml # New: event-specific common schemas (CloudEvent, Source, DateTime)
API_definition_templates/ # Copy-and-adapt API templates
sample-service.yaml # Request-response pattern (also base for explicit subscription APIs)
sample-implicit-events.yaml # Implicit subscription pattern (callbacks inline)
sample-service-subscriptions.yaml # Explicit subscription management
Notification_template/ # Copy-and-adapt notification callback template
sample-notification.yaml
A $ref like ../common/CAMARA_common.yaml#/components/schemas/ErrorInfo works identically in templates and in API repositories — templates are living proof that the structure works.
This achieves:
- Identical
$refpaths: Templates use the same relative paths as API repositories. No path adjustment needed when copying a template. - No schema duplication: Templates reference
common/instead of embedding their own copies of ErrorInfo, XCorrelator, CloudEvent, etc. - Separation of common schemas and templates:
common/contains only$ref-consumable component files. Templates show how to use them for each API pattern. - Event schema separation:
CAMARA_event_common.yamlcontains event-specific schemas (CloudEvent, Source, DateTime) separate from general data types. Request-response APIs only needCAMARA_common.yaml. - OWASP compliance from the start: New and reworked files include proper constraints (maxLength, format, min/max).
- Three API patterns covered: request-response, implicit subscription, and explicit subscription — each with a dedicated template.
The existing flat files (notification-as-cloud-event.yaml, event-subscription-template.yaml) would be superseded by the new structure.
Alternative solution
Keep the flat layout and add CAMARA_event_common.yaml alongside the existing files. This avoids the restructuring effort but leaves schema duplication in place and means template $ref paths don't match API repo paths.
Additional context
Related issues and PRs:
- Establish guidance for consuming schemas from CAMARA_common.yaml camaraproject/Commonalities#577 — Commonalities consumption discussion (proposed
common/+ template layout) - Refactor event definition in Event Subscription Template camaraproject/Commonalities#600 — Event definition refactoring (decoupling CloudEvent as reusable base)
- Improve CloudEvents Compliance and Consolidate Subscription API Design Across CAMARA Subprojects camaraproject/Commonalities#556 — CloudEvents compliance and subscription API consolidation
- docs: add Commonalities consumption and bundling design camaraproject/ReleaseManagement#436 — Bundling design document
- Implement CAMARA Validation Framework v1 camaraproject/ReleaseManagement#448 — Validation framework v1 umbrella
Directory and file naming is open for discussion. The key design point is that the relative path structure in artifacts/ matches the canonical layout in API repositories, so that $ref paths work identically in both places.