Skip to content
Merged
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
9 changes: 9 additions & 0 deletions .github/workflows/linux-arm64-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ jobs:
- uses: actions/checkout@v7

- name: Setup ROS2
id: setup_ros
if: ${{ matrix.ros_distribution != 'rolling' && matrix.ros_distribution != 'lyrical' }}
continue-on-error: true
uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: ${{ matrix.ros_distribution }}

# Retry transient repository/download failures once; a second failure is fatal.
- name: Retry ROS2 setup
if: ${{ !cancelled() && steps.setup_ros.outcome == 'failure' }}
uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: ${{ matrix.ros_distribution }}
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/linux-x64-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,16 @@ jobs:
- uses: actions/checkout@v7

- name: Setup ROS2
id: setup_ros
if: ${{ matrix.ros_distribution != 'rolling' && matrix.ros_distribution != 'lyrical' }}
continue-on-error: true
uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: ${{ matrix.ros_distribution }}

# Retry transient repository/download failures once; a second failure is fatal.
- name: Retry ROS2 setup
if: ${{ !cancelled() && steps.setup_ros.outcome == 'failure' }}
uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: ${{ matrix.ros_distribution }}
Expand Down
4 changes: 2 additions & 2 deletions bin/rclnodejs-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ if (SUBCOMMANDS.has(argv[0])) {
const httpHost = displayHost(cfg.http.host || cfg.host);
const httpBase = cfg.http.basePath || cfg.path;
const httpKinds = cfg.http.sse
? 'call/publish + subscribe (SSE)'
: 'call/publish only';
? 'call/publish/action + subscribe (SSE)'
: 'call/publish/action';
process.stdout.write(
` also http://${httpHost}:${httpTransport.port}${httpBase} (${httpKinds})\n`
);
Expand Down
96 changes: 91 additions & 5 deletions lib/openapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ function messageSchemaToJsonSchema(schema, components) {
}

/**
* Resolve a top-level capability type (message for publish/subscribe,
* service Request/Response for call) to a JSON Schema, without registering
* Resolve a capability payload (message, service Request/Response, or
* action Goal/Feedback/Result) to a JSON Schema, without registering
* it as a component itself (the top-level request/response body is inlined
* in the operation, only *nested* types become `$ref`d components — this
* matches typical OpenAPI style for RPC-shaped APIs).
Expand All @@ -195,8 +195,8 @@ function topLevelSchema(typeName, subType, components) {

/**
* Build a full OpenAPI 3.1 document from a capability registry snapshot
* (`CapabilityRegistry.list()`'s shape: `{call, publish, subscribe}`, each a
* `{name: typeName}` map).
* (`CapabilityRegistry.list()` has call, publish, subscribe, and action
* maps from capability names to ROS type names).
*
* No `servers` option: it's pure top-level metadata this function never
* reads while building `paths`, so callers (e.g. the CLI's
Expand All @@ -206,7 +206,7 @@ function topLevelSchema(typeName, subType, components) {
* not the rclnodejs release that generated the document, and there's no
* source for the former today — so it's a fixed `'0.0.0'` placeholder.
*
* @param {{call: object, publish: object, subscribe: object}} capabilities
* @param {{call: object, publish: object, subscribe: object, action?: object}} capabilities
* @param {object} [options]
* @param {string} [options.title]
* @param {string} [options.basePath] - default '/capability'
Expand Down Expand Up @@ -305,6 +305,92 @@ function buildOpenApiDocument(capabilities, options = {}) {
};
}

for (const [name, typeName] of Object.entries(capabilities.action || {})) {
const route = `${basePath}/action${name}`;
paths[route] = {
post: {
summary: `Send a ROS 2 action goal to ${name}`,
operationId: `action_${sanitizeName(name)}`,
'x-ros-capability': { kind: 'action', name, type: typeName },
description:
'POST a JSON goal to receive accepted and feedback events, then a ' +
'terminal result or error event. Result data contains status and payload. ' +
'Use fetch() or curl -N; EventSource does not support POST. ' +
'Use WebSocket for cancellation; disconnecting does not cancel the goal.',
requestBody: {
required: true,
content: {
'application/json': {
schema: topLevelSchema(typeName, 'Goal', components),
},
},
},
responses: {
200: {
description: `Server-Sent Events stream for ${typeName}`,
content: {
'text/event-stream': {
schema: {
description:
'JSON data for each SSE event; titles name the event.',
anyOf: [
{
title: 'accepted',
type: 'object',
properties: { capability: { type: 'string' } },
required: ['capability'],
},
{
title: 'feedback',
...topLevelSchema(typeName, 'Feedback', components),
},
{
title: 'result',
type: 'object',
properties: {
status: {
type: 'string',
enum: ['succeeded', 'canceled', 'aborted', 'unknown'],
},
payload: topLevelSchema(typeName, 'Result', components),
},
required: ['status', 'payload'],
},
{
title: 'error',
type: 'object',
properties: {
error: { type: 'string' },
code: { type: 'string' },
},
required: ['error', 'code'],
},
],
},
},
},
},
404: notExposedResponse(),
409: {
description: 'Action goal rejected before streaming',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
ok: { type: 'boolean', const: false },
error: { type: 'string' },
code: { type: 'string', const: 'goal_rejected' },
},
},
},
},
},
},
},
};
}

return {
openapi: '3.1.0',
info: { title, version: '0.0.0' },
Expand Down
Loading
Loading