Skip to content

Restructure artifacts directory for $ref consumption and bundling #603

@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 (#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/ 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           # Event-specific schemas (CloudEvent, Source, DateTime)
├── api-templates/                         # Copy-and-adapt API templates (maps to API_definitions)
│   ├── sample-service.yaml                # Request-response pattern
│   ├── sample-implicit-events.yaml        # Implicit subscription (callbacks inline)
│   └── sample-service-subscriptions.yaml  # Explicit subscription management
├── event-templates/                       # Event-type specific templates (maps to Event_definitions)
│   └── sample-event-type.yaml             # Can be added later, for #600 work
└── notification-templates/                # 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 serve as 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.
  • Directory mapping: api-templates/ maps to API_definitions, event-templates/ maps to Event_definitions — clear correspondence between template directories and API repo directories.
  • Three API patterns covered: request-response, implicit subscription, and explicit subscription — each with a dedicated template.

The event-templates/ directory can be added later as part of #600 resolution. 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 structure discussed and refined in hdamker#1 with input from @rartych.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions