Skip to content

Load API specifications from a remote URL with authentication (Apicurio Registry / HTTP)#385

Merged
jemacineiras merged 5 commits into
sngular:mainfrom
joseegman-idoneea:feat/remote-spec-loading
Jul 24, 2026
Merged

Load API specifications from a remote URL with authentication (Apicurio Registry / HTTP)#385
jemacineiras merged 5 commits into
sngular:mainfrom
joseegman-idoneea:feat/remote-spec-loading

Conversation

@joseegman-idoneea

@joseegman-idoneea joseegman-idoneea commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Loads spec files from a remote URL for both OpenAPI and AsyncAPI, including authentication for protected registries. Implements joseegman-idoneea#7 and joseegman-idoneea#8.

What

specFile.filePath accepts an http/https/file URL; the spec is fetched at generation time. This is the mechanism to consume a spec published in an Apicurio Registry (artifacts served over HTTP) or any URL-addressable source.

<specFile>
    <filePath>https://my-apicurio-host/apis/registry/v2/groups/default/artifacts/my-api</filePath>
    <apiPackage>com.example.api</apiPackage>
    <modelPackage>com.example.model</modelPackage>
</specFile>

How

  • PathUtil.isRemoteUri detects URL-scheme paths; SchemaUtil.readFile fetches remote specs — the shared main-spec reader for both generators, so one change covers OpenAPI and AsyncAPI.
  • RemoteFileLocation resolves external $refs relative to a remote spec's base URL; AsyncApiGenerator/BaseAsyncApiHandler/ApiTool/OpenApiGenerator handle remote locations and $ref bases.

Security / robustness

  • Bounded timeouts (connect 15s / read 30s) — an unresponsive server can't hang the build.
  • Scheme allowlist: http/https/file only (no ftp).
  • Authentication from system properties / environment variables (never from build files): bearer token, basic auth, or an arbitrary header (e.g. X-Registry-ApiKey). Applied only to http/https.
  • Host scoping (scs.multiapi.remote.host / SCS_MULTIAPI_REMOTE_HOST): credentials are sent only to the configured host, so a token is never leaked to another host via an external $ref or cross-host redirect. Credentials are never logged; TLS validation is unchanged.

Tests

  • PathUtilTest (scheme detection, bearer/basic/custom-header, host scoping) and a SchemaUtil file:// URL-loading test — network-free and deterministic.
  • Full multiapi-engine suite: 118/118 (mvn clean test).

Docs & version

🤖 Generated with Claude Code

@codacy-production

codacy-production Bot commented Jul 24, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 23 complexity · 0 duplication

Metric Results
Complexity 23
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

`specFile.filePath` may now be an http/https/ftp/file URL; the spec is fetched
from that URL at generation time instead of the filesystem/classpath. This
enables consuming specs published in an Apicurio Registry (artifacts served over
HTTP) and any URL-addressable source, for both the OpenAPI and AsyncAPI
generators.

- PathUtil.isRemoteUri detects URL-scheme paths.
- SchemaUtil.readFile fetches remote specs directly (shared main-spec reader for
  both generators).
- New RemoteFileLocation resolves external $refs relative to a remote spec's URL.
- AsyncApiGenerator / BaseAsyncApiHandler resolve remote spec locations.
- ApiTool.nodeFromFile handles URL references.
- OpenApiGenerator uses the URL parent as the $ref base when the spec is remote.

Adds PathUtilTest and a SchemaUtil URL-loading test (file:// URL, network-free).
Documents the Apicurio/URL usage in the README.

Bumps version 6.5.1 -> 6.6.0 (new feature).

Closes #7

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@joseegman-idoneea
joseegman-idoneea force-pushed the feat/remote-spec-loading branch from 069abfa to d17195a Compare July 24, 2026 11:50
- Add bounded connect (15s) / read (30s) timeouts to all URL fetches via
  PathUtil.openUrlStream, so an unresponsive remote spec server cannot hang the
  build. Timeouts are harmless for file:/jar: schemes.
- Drop `ftp` from the accepted URL schemes (plaintext, effectively unused for API
  specs) — remote specs are now http/https/file only, reducing attack surface.
- Document TLS expectations for https registries with internal/self-signed certs
  (must be trusted by the build JVM; validation is not disabled).

Full multiapi-engine suite: 113/113 (mvn clean test).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds authentication for remote spec fetching, resolving credentials from system
properties (preferred) or environment variables - never from build files:
bearer token, basic auth, and an arbitrary header (e.g. X-Registry-ApiKey).

Headers are applied only to http/https fetches. Optional host scoping
(scs.multiapi.remote.host) sends credentials only to the configured host, so a
token is never leaked to a different host via an external $ref or cross-host
redirect. Credentials are never logged; TLS validation is unchanged.

Adds PathUtilTest coverage and documents the setup in the README.

Full multiapi-engine suite: 118/118 (mvn clean test).

Closes #8

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@joseegman-idoneea joseegman-idoneea changed the title Load API specifications from a remote URL (Apicurio Registry / HTTP) Load API specifications from a remote URL with authentication (Apicurio Registry / HTTP) Jul 24, 2026
joseegarcia and others added 2 commits July 24, 2026 15:08
- Replace deprecated new URL(String) with URI.create(...).toURL() (ApiTool, SchemaUtil)
- Remove fully-qualified names (java.net.URL, StandardCharsets in test)
- Route AsyncApi remote read through PathUtil.openUrlStream (timeouts + shorter line)
- Wrap long lines

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…st spacing)

The 17 Codacy issues were all markdownlint on the new README section: lines
over 80 chars and a list not surrounded by blank lines. Rewrap prose to <=80,
replace the wide auth table with a wrapped bullet list, and add blank lines
around lists.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jemacineiras
jemacineiras merged commit 267aa2d into sngular:main Jul 24, 2026
6 of 7 checks passed
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.

2 participants