Skip to content

Support bundling OpenAPI descriptions in the bundle command - #891

Merged
jviotti merged 7 commits into
mainfrom
openapi-bundle
Sep 25, 2026
Merged

jviotti merged 7 commits into
mainfrom
openapi-bundle

Conversation

@jviotti

@jviotti jviotti commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Signed-off-by: Juan Cruz Viotti jv@jviotti.com

Review in cubic

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@jviotti
jviotti marked this pull request as ready for review September 25, 2026 14:15

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 32 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="test/bundle/pass_openapi_mixed_resolve.clitest">

<violation number="1" location="test/bundle/pass_openapi_mixed_resolve.clitest:58">
P3: This test only asserts stdout (INTO result.txt + COMPARE) and discards the stderr stream of `bundle`. Any diagnostic noise or regression on stderr would pass unnoticed. Run the command with `--verbose` and assert the stderr stream is empty (or contains only expected content) using the harness's multi-stream assertion, as done in `pass_resolve_default_dialect_config.clitest` which already invokes `bundle ... --verbose`.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/resolver.h Outdated
Comment thread test/bundle/fail_openapi_description_not_a_schema.clitest
Comment thread test/bundle/fail_openapi_revision_mismatch_older.clitest
Comment thread test/bundle/fail_openapi_referenced_revision.clitest
Comment thread src/command_bundle.cc Outdated
Comment thread src/command_bundle.cc Outdated
Comment thread test/bundle/fail_openapi_self_in_3_1.clitest
Comment thread test/bundle/pass_openapi_yaml_resolve_yaml.clitest
}
EOF

RUN bundle entry.json --resolve shared.json --resolve withid.json --resolve noid.json STDIN /dev/null IN . INTO result.txt EXPECTING 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This test only asserts stdout (INTO result.txt + COMPARE) and discards the stderr stream of bundle. Any diagnostic noise or regression on stderr would pass unnoticed. Run the command with --verbose and assert the stderr stream is empty (or contains only expected content) using the harness's multi-stream assertion, as done in pass_resolve_default_dialect_config.clitest which already invokes bundle ... --verbose.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At test/bundle/pass_openapi_mixed_resolve.clitest, line 58:

<comment>This test only asserts stdout (INTO result.txt + COMPARE) and discards the stderr stream of `bundle`. Any diagnostic noise or regression on stderr would pass unnoticed. Run the command with `--verbose` and assert the stderr stream is empty (or contains only expected content) using the harness's multi-stream assertion, as done in `pass_resolve_default_dialect_config.clitest` which already invokes `bundle ... --verbose`.</comment>

<file context>
@@ -0,0 +1,111 @@
+}
+EOF
+
+RUN bundle entry.json --resolve shared.json --resolve withid.json --resolve noid.json STDIN /dev/null IN . INTO result.txt EXPECTING 0
+
+WRITE expected.txt UNTIL EOF
</file context>

Comment thread test/bundle/fail_openapi_reference_names_a_schema.clitest
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@augmentcode

augmentcode Bot commented Sep 25, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR adds OpenAPI Description support to the bundle command.



Changes:

  • Detects supported OpenAPI 3.1 and 3.2 inputs and bundles them through Core's OpenAPI bundler.
  • Separates OpenAPI-document resolution from JSON Schema resolution while sharing imported inputs.
  • Allows --resolve inputs to contain both descriptions and schemas, including YAML sources.
  • Recognizes OpenAPI 3.2 $self identities and reports conflicting description identifiers.
  • Rejects unsupported OpenAPI revisions and --without-id for descriptions.
  • Adds OpenAPI-specific error context, including the originating base URI.
  • Moves the OpenAPI default-identity helper into shared utilities for lint and bundle.
  • Documents behavior and adds coverage for resolution, revision, stdin, YAML, and failure paths.
Technical notes: Schema Objects within OpenAPI descriptions continue to use JSON Schema bundling semantics; output formatting preserves the original JSON or YAML representation.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread src/resolver.h Outdated
// goes to the resolver above rather than being reported from here
auto openapi(std::string_view identifier)
-> sourcemeta::core::OpenAPIResolverResult {
const std::string target{canonical_resolve_key(identifier)};

@augmentcode augmentcode Bot Sep 25, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

openapi() bypasses the configured resolve map: unlike operator(), it canonicalizes the requested URI and fetches it directly. An OpenAPI $ref mapped to a local description in jsonschema.json is therefore ignored (or tries the network), even though resolver mappings are the established way to redirect such URI lookups.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread src/resolver.h

const auto cached{this->fetched_.find(target)};
if (cached != this->fetched_.cend()) {
return cached->second;

@augmentcode augmentcode Bot Sep 25, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This cache is keyed by the mapped fetch target, but anonymous schemas are reidentified below with the original requested URI. If two resolve entries point different external URIs at the same no-$id file, the second reference receives the cached schema carrying the first URI as its identity, so bundling resolves it under the wrong identifier.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment thread src/resolver.h
base_dialect.value());
return schema;
const auto &stored{
this->descriptions_.emplace(target, std::move(document)).first->second};

@augmentcode augmentcode Bot Sep 25, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lazily fetched descriptions are indexed only by their retrieval URI here, whereas import_description() also indexes a 3.2 document by its declared $self. After a local shared.json with $self: "https://example.com/shared" is fetched once, a later reference to that $self URI cannot reuse it and fails without --http (or embeds a second copy with HTTP enabled).

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread test/bundle/fail_openapi_description_not_a_schema.clitest
Comment thread docs/bundle.markdown
Comment thread src/resolver.h
@jviotti
jviotti merged commit fe4951a into main Sep 25, 2026
16 checks passed
@jviotti
jviotti deleted the openapi-bundle branch September 25, 2026 18:25
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.

1 participant