Skip to content

Restructure artifacts directory for $ref consumption and bundling #1

@hdamker

Description

@hdamker

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 $ref paths: 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.yaml contains event-specific schemas (CloudEvent, Source, DateTime) separate from general data types. Request-response APIs only need CAMARA_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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions