Skip to content

fix: restructure artifacts directory for $ref consumption - #606

Merged
rartych merged 18 commits into
camaraproject:mainfrom
hdamker:fix/restructure-artifacts-v2
Apr 13, 2026
Merged

fix: restructure artifacts directory for $ref consumption#606
rartych merged 18 commits into
camaraproject:mainfrom
hdamker:fix/restructure-artifacts-v2

Conversation

@hdamker

@hdamker hdamker commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • enhancement/feature

What this PR does / why we need it:

Restructures the artifacts/ directory for $ref consumption and bundling (#603).

Phase 1 — common schemas:

  • Moves CAMARA_common.yaml to artifacts/common/, adds DateTime schema
  • Adds artifacts/api-templates/sample-service.yaml — CRUD template demonstrating $ref to common schemas

Phase 2 — event and subscription schemas:

  • Adds artifacts/common/CAMARA_event_common.yaml — CloudEvents envelope, subscription management, protocol settings, credentials, lifecycle data, and subscription-specific error responses
  • Adds artifacts/api-templates/sample-service-subscriptions.yaml — explicit subscription template rewritten with $ref (624 lines, down from 1397)
  • Adds artifacts/notification-templates/sample-notification.yaml — notification callback template with $ref (77 lines, down from 345)
  • Moves event-subscription-template.feature to artifacts/testing/
  • Removes notification-as-cloud-event.yaml and camara-cloudevents/ directory

Phase 3 — clean up unused protocol and credential definitions:

  • Comments out non-HTTP protocol support (MQTT3, MQTT5, AMQP, NATS, KAFKA) in both sample-service-subscriptions.yaml and CAMARA_event_common.yaml — only HTTP is used in CAMARA, comments signal future extensibility
  • Comments out PLAIN sink credential (enum, discriminator mapping, PlainCredential schema) — not used in CAMARA, only ACCESSTOKEN and PRIVATE_KEY_JWT are supported

Common files use a components-only format (no openapi/paths stub) — they are consumed via $ref, not deployed as standalone APIs.

Which issue(s) this PR fixes:

Fixes #603

Does this PR introduce a breaking change?

  • Yes
  • No

Special notes for reviewers:

Deferred: sample-implicit-events.yaml (callback-based event pattern template) — tracked as a follow-up issue.

All templates validated with redocly bundle (all $ref resolved) and spectral lint (no new errors). Phase 3 changes also validated on ReleaseTest#64 — bundled output contains only HTTP schemas and no PLAIN credential.

Changelog input

 release-note
fix: restructure artifacts directory for $ref consumption — common schemas, event/subscription schemas, and API templates

Additional documentation

docs
Updated README.md with new directory structure and file descriptions.

…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
@hdamker
hdamker marked this pull request as draft March 30, 2026 18:46
@hdamker

hdamker commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator Author

Converted to draft as I have discussed with @rartych to add also the restructure of event related artifacts after
#604 is merged. Plan is to do that tomorrow.

hdamker added 2 commits March 31, 2026 13:34
…onsumption

- Add artifacts/common/CAMARA_event_common.yaml with CloudEvents envelope,
  subscription management, protocol settings, credentials, lifecycle data,
  and subscription-specific error responses
- Add artifacts/api-templates/sample-service-subscriptions.yaml (624 lines,
  down from 1397 — 55% reduction via $ref to common files)
- Add artifacts/notification-templates/sample-notification.yaml (77 lines,
  replacing 345-line notification-as-cloud-event.yaml)
- Add DateTime schema to CAMARA_common.yaml
- Switch common files to components-only format (no openapi/paths stub)
- Move event-subscription-template.feature to artifacts/testing/
- Remove notification-as-cloud-event.yaml and camara-cloudevents/ directory
- Update README.md with new directory structure
@hdamker

hdamker commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator Author

Design note: boundary between CAMARA_event_common.yaml and sample-service-subscriptions.yaml

The restructuring extracts Commonalities-owned schemas into CAMARA_event_common.yaml so that API repositories can consume them via $ref. However, several schemas that are structurally Commonalities-owned remain in the subscription template. This is intentional.

What moved to CAMARA_event_common.yaml

Schemas that are identical across all APIs with no placeholders:

  • CloudEvents envelope: CloudEvent, Source (+ DateTime in CAMARA_common.yaml)
  • Subscription management: Config, CreateSubscriptionDetail, SubscriptionId
  • Protocol support: Protocol, HTTPSettings, MQTTSettings, AMQPSettings, ApacheKafkaSettings, NATSSettings
  • Credentials: SinkCredential, PlainCredential, AccessTokenCredential, PrivateKeyJWTCredential
  • Lifecycle data: SubscriptionStarted, SubscriptionUpdated, SubscriptionEnded, InitiationReason, UpdateReason, TerminationReason
  • Subscription error responses: CreateSubscriptionBadRequest400, SubscriptionIdRequired400, SubscriptionPermissionDenied403, CreateSubscriptionUnprocessableEntity422
  • Security schemes: notificationsBearerAuth (notification bearer auth)

What stays in the template — and why

Several schemas that look generic actually contain api-name placeholders in enum values or discriminator mappings. These must be adapted by each API project, so they cannot be consumed as-is via $ref:

  • SubscriptionRequest and Subscription — their types field references ApiEventType, which has api-name in its enum values
  • Protocol-specific Request/Response schemas (e.g., HTTPSubscriptionRequest) — extend SubscriptionRequest/Subscription via allOf
  • SubscriptionLifecycleEvent and SubscriptionLifecycleEventType — lifecycle event type strings contain api-name (e.g., org.camaraproject.api-name.v0.subscription-started)
  • EventSubscriptionStarted/Updated/Ended — extend SubscriptionLifecycleEvent
  • ApiNotificationEvent, ApiEventType, NotificationEvent, EventApiSpecific1/2 — API-specific by design

The root cause is that SubscriptionLifecycleEventType enum values embed the API name. A future discussion (see #604 review thread) may introduce a common naming pattern like org.camaraproject.subscription-event.v0.subscription-* which would allow moving these schemas to the common file as well.

Comment thread artifacts/common/CAMARA_common.yaml
Comment thread artifacts/api-templates/sample-service-subscriptions.yaml Outdated
Comment thread artifacts/api-templates/sample-service.yaml
Comment thread artifacts/api-templates/sample-service.yaml
- sample-service.yaml: title without "API", add externalDocs, fix apiRoot
  description, add pagination (minItems/maxItems), add maxLength to UUID
- CAMARA_common.yaml: add description to openId securityScheme
- sample-service-subscriptions.yaml: openId via $ref to CAMARA_common.yaml
@hdamker

hdamker commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @rartych for the review! All suggestions applied in the latest push:

  • openId description in CAMARA_common.yaml: added description: OpenID Connect authentication via discovery metadata.
  • openId via $ref in sample-service-subscriptions.yaml: replaced inline definition with $ref: "../common/CAMARA_common.yaml#/components/securitySchemes/openId"
  • Pagination in sample-service.yaml list response: added minItems: 0, maxItems: 1000
  • ResourceId maxLength in sample-service.yaml: added maxLength: 36 for UUID format

Additional fixes found during Design Guide compliance check:

  • Title: removed "API" from title (Sample CAMARA Service APISample Service) — Design Guide 5.3.1: "title SHALL NOT include the term API"
  • externalDocs: added missing externalDocs object — Design Guide 5.4 (SHALL)
  • apiRoot description: fixed garbled text to match Design Guide 5.5 standard description

hdamker added 3 commits April 2, 2026 15:37
Comment out MQTT3, MQTT5, AMQP, NATS, KAFKA protocol references in both
sample-service-subscriptions.yaml and CAMARA_event_common.yaml. Comments
signal future extensibility; bundled output is now HTTP-only.

Changes:
- Protocol enum: converted to block sequence, only HTTP active
- Discriminator mappings: only HTTP mapping active
- Protocol-specific schemas: 8 non-HTTP schemas commented out
- Settings schemas: MQTTSettings, AMQPSettings, ApacheKafkaSettings,
  NATSSettings commented out, HTTPSettings remains

Validated on camaraproject/ReleaseTest#64 (bundling + yamllint + spectral).
…mon.yaml

No api-name placeholders, identical across all subscription APIs.
Template now uses $ref to common file, matching the openId pattern.
Comment out PLAIN enum value, discriminator mapping, and PlainCredential
schema in CAMARA_event_common.yaml. The description already states that
only ACCESSTOKEN and PRIVATE_KEY_JWT are supported.
@hdamker-bot
hdamker-bot marked this pull request as ready for review April 2, 2026 14:00
@rartych
rartych self-requested a review April 3, 2026 13:53
Comment thread artifacts/api-templates/sample-service-subscriptions.yaml Outdated
hdamker added 2 commits April 9, 2026 14:45
- Add backtick formatting for endDate in TimePeriod description
- Add template usage clarification note to sample-service-subscriptions
- Update 6 stale artifact path references in Event Subscription and
  Notification Guide to match restructured directory layout
@hdamker

hdamker commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator Author

I think also CAMARA-API-Event-Subscription-and-Notification-Guide.md needs to be updated regarding some links and file names, according to this artifacts refactor

@PedroDiez done in 58a0902, please check if there are further occurrences.

@PedroDiez

Copy link
Copy Markdown
Contributor

@hdamker One comment/observation I would like to make apart from the review.

In some of the artifacts, the are the same common references replicated N-times for different fields

As an example, in sample-service-subscriptions.yaml:

      parameters:
        - $ref: "../common/CAMARA_common.yaml#/components/parameters/x-correlator"

Other way would be to define a "common local schema" in the file for x-correlator and that "common local schema" is referenced to the CAMARA_common.yaml x-correlator schema only once.

Maybe you have seen this way better for latter applying the bundling (just in case)

PedroDiez
PedroDiez previously approved these changes Apr 10, 2026

@PedroDiez PedroDiez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in advance

Minor comment for wording aligment

Comment thread documentation/CAMARA-API-Event-Subscription-and-Notification-Guide.md Outdated
@hdamker

hdamker commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator Author

Other way would be to define a "common local schema" in the file for x-correlator and that "common local schema" is referenced to the CAMARA_common.yaml x-correlator schema only once.

@PedroDiez the bundling will do the deduplication. In the bundle there will be exactly one ("common") definition for the parameter x-correlator, and all references to it are replaced by file local references. You can see an example of the bundled API in https://github.com/camaraproject/ReleaseTest/actions/runs/24240183042/artifacts/6369710607

hdamker added a commit to hdamker/Commonalities that referenced this pull request Apr 11, 2026
Adds sample-implicit-events.yaml under artifacts/api-templates/ as the
canonical template for CAMARA APIs that deliver event notifications via
OpenAPI callbacks on a resource-creation operation, with no dedicated
/subscriptions sub-API (implicit-subscription pattern).

Follows the post-camaraproject#604 layered event-schema architecture: pure CloudEvent
envelope referenced from CAMARA_event_common.yaml, local
ApiNotificationEvent that constrains type via ApiEventType and owns the
discriminator mapping, concrete event schemas extending
ApiNotificationEvent.

Companion documentation update to
CAMARA-API-Event-Subscription-and-Notification-Guide.md is deferred to
a follow-up commit to avoid conflicts with camaraproject#606 doc edits.
@hdamker
hdamker requested a review from PedroDiez April 13, 2026 06:46
@hdamker

hdamker commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator Author

@camaraproject/commonalities_codeowners please consider to review and approve the PR upfront to todays meeting ... only after it landed in main I can finalize #612 and mark it ready for review.

cc: @tanjadegroot

@patrice-conil patrice-conil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job Herbert!
LGTM

@PedroDiez

Copy link
Copy Markdown
Contributor

@PedroDiez the bundling will do the deduplication. In the bundle there will be exactly one ("common") definition for the parameter x-correlator, and all references to it are replaced by file local references. You can see an example of the bundled API in https://github.com/camaraproject/ReleaseTest/actions/runs/24240183042/artifacts/6369710607

thanks for the info @hdamker!

@PedroDiez PedroDiez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rartych rartych left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rartych
rartych merged commit fcbc9a0 into camaraproject:main Apr 13, 2026
1 check passed
@hdamker
hdamker deleted the fix/restructure-artifacts-v2 branch April 13, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restructure artifacts directory for $ref consumption and bundling

5 participants