Skip to content

Commit ca67d8d

Browse files
committed
- Added query and path parameter serialization from OpenAPI / Swagger
metadata - Added support for array and object-style query parameters such as `deepObject`, `pipeDelimited`, and Swagger 2 collection formats - Added automatic API base URL detection from OAS `servers` - Added automatic API base URL detection from Swagger 2 `host`, `basePath`, and `schemes` - Added operation-level and path-level server overrides when the spec defines endpoint-specific targets
1 parent cfbc395 commit ca67d8d

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/cli.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const defaultHttpClient: HttpClient = {
3434
};
3535

3636
interface AddProfileArgs {
37-
"api-base-url": string;
37+
"api-base-url"?: string;
3838
"openapi-spec": string;
3939
"api-basic-auth"?: string;
4040
"api-bearer-token"?: string;
@@ -530,7 +530,7 @@ export async function run(argv: string[], options?: RunOptions): Promise<void> {
530530

531531
const profile: Profile = {
532532
name: profileName,
533-
apiBaseUrl: args["api-base-url"],
533+
apiBaseUrl: args["api-base-url"] ?? "",
534534
apiBasicAuth: args["api-basic-auth"] ?? "",
535535
apiBearerToken: args["api-bearer-token"] ?? "",
536536
openapiSpecSource: args["openapi-spec"],
@@ -541,7 +541,11 @@ export async function run(argv: string[], options?: RunOptions): Promise<void> {
541541
customHeaders,
542542
};
543543

544-
await openapiLoader.loadSpec(profile, { refresh: true });
544+
const spec = await openapiLoader.loadSpec(profile, { refresh: true });
545+
profile.apiBaseUrl = profile.apiBaseUrl || deriveApiBaseUrlFromSpec(spec);
546+
if (!profile.apiBaseUrl) {
547+
throw new Error("Unable to determine API base URL. Provide --api-base-url explicitly.");
548+
}
545549
profileStore.saveProfile(cwd, profile, { makeCurrent: true });
546550
};
547551

0 commit comments

Comments
 (0)