Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/sync-rerum-shared-openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Sync shared RERUM OpenAPI artifact

on:
push:
branches:
- main
paths:
- openapi/components/rerum-shared-components.openapi.yaml
workflow_dispatch:

permissions:
contents: read

jobs:
dispatch-sync:
runs-on: ubuntu-latest
steps:
- name: Dispatch sync-provider-artifact workflow
uses: actions/github-script@v7
with:
github-token: ${{ secrets.BRY_PAT }}
script: |
await github.request('POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches', {
owner: 'cubap',
repo: 'rerum_openapi',
workflow_id: 'sync-provider-artifact.yml',
ref: 'main',
inputs: {
provider_repository: '${{ github.repository }}',
provider_ref: '${{ github.sha }}',
provider_artifact_path: 'openapi/components/rerum-shared-components.openapi.yaml',
target_artifact_path: 'schemas/openapi/rerum-shared-components.openapi.yaml'
}
})
34 changes: 34 additions & 0 deletions __tests__/openapi_sync_artifacts.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import fs from "fs"
import path from "path"
import { fileURLToPath } from "url"

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const repoRoot = path.resolve(__dirname, "..")

describe("Shared OpenAPI artifact sync scaffolding", () => {
it("verifies provider and target artifact files contain valid OpenAPI structure", () => {
const providerArtifactPath = path.join(repoRoot, "openapi/components/rerum-shared-components.openapi.yaml")
const targetArtifactPath = path.join(repoRoot, "schemas/openapi/rerum-shared-components.openapi.yaml")
const providerArtifact = fs.readFileSync(providerArtifactPath, "utf8")
const targetArtifact = fs.readFileSync(targetArtifactPath, "utf8")

for (const artifact of [providerArtifact, targetArtifact]) {
expect(artifact).toContain("openapi: 3.0.3")
expect(artifact).toContain("title: RERUM Shared Components")
expect(artifact).toContain("version: 0.1.0")
expect(artifact).toContain("components:")
expect(artifact).toContain("schemas: {}")
}
})

it("verifies the shared artifact sync workflow configuration", () => {
const workflowPath = path.join(repoRoot, ".github/workflows/sync-rerum-shared-openapi.yml")
const workflow = fs.readFileSync(workflowPath, "utf8")

expect(workflow).toContain("openapi/components/rerum-shared-components.openapi.yaml")
expect(workflow).toContain("sync-provider-artifact.yml")
expect(workflow).toContain("repo: 'rerum_openapi'")
expect(workflow).toContain("target_artifact_path: 'schemas/openapi/rerum-shared-components.openapi.yaml'")
})
})
13 changes: 13 additions & 0 deletions openapi/components/rerum-shared-components.openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
openapi: 3.0.3
info:
title: RERUM Shared Components
version: 0.1.0
description: Shared reusable OpenAPI components for RERUM v1 contracts.
externalDocs:
description: RERUM API reference
url: https://store.rerum.io/v1/API.html
x-upstream-provider:
name: rerum_server_nodejs
baseUrl: https://store.rerum.io/v1
components:
schemas: {}
14 changes: 14 additions & 0 deletions schemas/openapi/rerum-shared-components.openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is automatically synced from openapi/components/rerum-shared-components.openapi.yaml. Do not edit manually.
openapi: 3.0.3
info:
title: RERUM Shared Components
version: 0.1.0
description: Shared reusable OpenAPI components for RERUM v1 contracts.
externalDocs:
description: RERUM API reference
url: https://store.rerum.io/v1/API.html
x-upstream-provider:
name: rerum_server_nodejs
baseUrl: https://store.rerum.io/v1
components:
schemas: {}