@kubb/adapter-oas 5.16.1 → 5.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -35,7 +35,7 @@ var compatibility = {
35
35
  "node": ">=22.22"
36
36
  };
37
37
  // package.json
38
- var version = "5.16.1";
38
+ var version = "5.17.0";
39
39
  // src/constants.ts
40
40
  /**
41
41
  * Default parser options applied when no explicit options are provided.
@@ -1220,6 +1220,30 @@ function resolveServerUrl(server, overrides) {
1220
1220
  }
1221
1221
  return url;
1222
1222
  }
1223
+ /**
1224
+ * Maps OpenAPI servers to `InputServer` entries: drops entries without a `url` and fills `{variable}` defaults.
1225
+ */
1226
+ function toInputServers(servers) {
1227
+ return servers.filter((entry) => entry.url).map(({ url, description, variables }) => {
1228
+ const declared = variables && Object.keys(variables).length > 0 ? { variables } : {};
1229
+ try {
1230
+ return {
1231
+ url: resolveServerUrl({
1232
+ url,
1233
+ variables
1234
+ }),
1235
+ description,
1236
+ ...declared
1237
+ };
1238
+ } catch {
1239
+ return {
1240
+ url,
1241
+ description,
1242
+ ...declared
1243
+ };
1244
+ }
1245
+ });
1246
+ }
1223
1247
  // src/model/mediaType.ts
1224
1248
  /**
1225
1249
  * The media type without its parameters, so `text/event-stream; charset=utf-8` matches the bare name.
@@ -1828,6 +1852,7 @@ function parseOperation({ operation, ...ctx }) {
1828
1852
  const fallback = operation.pathItem[key];
1829
1853
  return typeof fallback === "string" ? fallback : void 0;
1830
1854
  };
1855
+ const servers = operation.schema.servers ?? operation.pathItem.servers;
1831
1856
  return _kubb_kit.ast.factory.createOperation({
1832
1857
  pointer,
1833
1858
  operationId,
@@ -1841,7 +1866,8 @@ function parseOperation({ operation, ...ctx }) {
1841
1866
  parameters,
1842
1867
  requestBody,
1843
1868
  responses,
1844
- extensions: pickExtensions(operation.schema)
1869
+ extensions: pickExtensions(operation.schema),
1870
+ ...servers && { servers: toInputServers(servers) }
1845
1871
  });
1846
1872
  }
1847
1873
  // src/emit/createNode.ts
@@ -3399,25 +3425,7 @@ const adapterOas = (0, _kubb_core.defineExtension)({
3399
3425
  document,
3400
3426
  server
3401
3427
  }),
3402
- servers: (document.servers ?? []).filter((entry) => entry.url).map(({ url, description, variables }) => {
3403
- const declared = variables && Object.keys(variables).length > 0 ? { variables } : {};
3404
- try {
3405
- return {
3406
- url: resolveServerUrl({
3407
- url,
3408
- variables
3409
- }),
3410
- description,
3411
- ...declared
3412
- };
3413
- } catch {
3414
- return {
3415
- url,
3416
- description,
3417
- ...declared
3418
- };
3419
- }
3420
- }),
3428
+ servers: toInputServers(document.servers ?? []),
3421
3429
  securitySchemes: Object.entries(document.components?.securitySchemes ?? {}).flatMap(([name, value]) => {
3422
3430
  const scheme = refs.deref(value);
3423
3431
  return scheme?.type ? [{