Summary
Add support for loading AsyncAPI, OpenAPI, and JSON Schema specifications from remote URLs (HTTP/HTTPS) with optional authentication headers.
Current Behavior
All input processors only support local file paths:
src/codegen/inputs/asyncapi/parser.ts:29 - uses fromFile()
src/codegen/inputs/openapi/parser.ts:24 - uses readFileSync()
src/codegen/inputs/jsonschema/parser.ts:72 - uses readFileSync()
Passing a URL like https://api.example.com/spec.yaml results in file system errors.
Proposed Behavior
URL Detection
Automatically detect URLs in inputPath:
// codegen.config.mjs
export default {
inputType: 'asyncapi',
inputPath: 'https://raw.githubusercontent.com/org/repo/main/asyncapi.yaml',
// ...
};
Authentication Support
Support common auth patterns for secure specifications:
export default {
inputType: 'openapi',
inputPath: 'https://api.internal.company.com/openapi.json',
// Option 1: Bearer token
auth: {
type: 'bearer',
token: process.env.API_TOKEN
},
// Option 2: API Key header
auth: {
type: 'apiKey',
header: 'X-API-Key',
value: process.env.API_KEY
},
// Option 3: Custom headers
auth: {
type: 'custom',
headers: {
'Authorization': `Bearer ${process.env.TOKEN}`,
'X-Tenant-ID': 'acme-corp'
}
}
};
Implementation Notes
URL Detection
function isRemoteUrl(path: string): boolean {
return path.startsWith('http://') || path.startsWith('https://');
}
Fetching
- Use
fetch or node-fetch for HTTP requests
- Support timeout configuration
- Handle redirects
- Cache responses (optional, for watch mode)
Error Handling
- Network errors (timeout, connection refused)
- Auth errors (401, 403)
- Not found (404)
- Rate limiting (429)
Acceptance Criteria
Related
- Prerequisite for EventCatalog integration (services may reference remote specs)
- Similar to how EventCatalog generators support remote URLs
Summary
Add support for loading AsyncAPI, OpenAPI, and JSON Schema specifications from remote URLs (HTTP/HTTPS) with optional authentication headers.
Current Behavior
All input processors only support local file paths:
src/codegen/inputs/asyncapi/parser.ts:29- usesfromFile()src/codegen/inputs/openapi/parser.ts:24- usesreadFileSync()src/codegen/inputs/jsonschema/parser.ts:72- usesreadFileSync()Passing a URL like
https://api.example.com/spec.yamlresults in file system errors.Proposed Behavior
URL Detection
Automatically detect URLs in
inputPath:Authentication Support
Support common auth patterns for secure specifications:
Implementation Notes
URL Detection
Fetching
fetchornode-fetchfor HTTP requestsError Handling
Acceptance Criteria
Related