@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.js CHANGED
@@ -19,7 +19,7 @@ var compatibility = {
19
19
  "node": ">=22.22"
20
20
  };
21
21
  // package.json
22
- var version = "5.16.1";
22
+ var version = "5.17.0";
23
23
  // src/constants.ts
24
24
  /**
25
25
  * Default parser options applied when no explicit options are provided.
@@ -1204,6 +1204,30 @@ function resolveServerUrl(server, overrides) {
1204
1204
  }
1205
1205
  return url;
1206
1206
  }
1207
+ /**
1208
+ * Maps OpenAPI servers to `InputServer` entries: drops entries without a `url` and fills `{variable}` defaults.
1209
+ */
1210
+ function toInputServers(servers) {
1211
+ return servers.filter((entry) => entry.url).map(({ url, description, variables }) => {
1212
+ const declared = variables && Object.keys(variables).length > 0 ? { variables } : {};
1213
+ try {
1214
+ return {
1215
+ url: resolveServerUrl({
1216
+ url,
1217
+ variables
1218
+ }),
1219
+ description,
1220
+ ...declared
1221
+ };
1222
+ } catch {
1223
+ return {
1224
+ url,
1225
+ description,
1226
+ ...declared
1227
+ };
1228
+ }
1229
+ });
1230
+ }
1207
1231
  // src/model/mediaType.ts
1208
1232
  /**
1209
1233
  * The media type without its parameters, so `text/event-stream; charset=utf-8` matches the bare name.
@@ -1812,6 +1836,7 @@ function parseOperation({ operation, ...ctx }) {
1812
1836
  const fallback = operation.pathItem[key];
1813
1837
  return typeof fallback === "string" ? fallback : void 0;
1814
1838
  };
1839
+ const servers = operation.schema.servers ?? operation.pathItem.servers;
1815
1840
  return ast.factory.createOperation({
1816
1841
  pointer,
1817
1842
  operationId,
@@ -1825,7 +1850,8 @@ function parseOperation({ operation, ...ctx }) {
1825
1850
  parameters,
1826
1851
  requestBody,
1827
1852
  responses,
1828
- extensions: pickExtensions(operation.schema)
1853
+ extensions: pickExtensions(operation.schema),
1854
+ ...servers && { servers: toInputServers(servers) }
1829
1855
  });
1830
1856
  }
1831
1857
  // src/emit/createNode.ts
@@ -3384,25 +3410,7 @@ const adapterOas = defineExtension({
3384
3410
  document,
3385
3411
  server
3386
3412
  }),
3387
- servers: (document.servers ?? []).filter((entry) => entry.url).map(({ url, description, variables }) => {
3388
- const declared = variables && Object.keys(variables).length > 0 ? { variables } : {};
3389
- try {
3390
- return {
3391
- url: resolveServerUrl({
3392
- url,
3393
- variables
3394
- }),
3395
- description,
3396
- ...declared
3397
- };
3398
- } catch {
3399
- return {
3400
- url,
3401
- description,
3402
- ...declared
3403
- };
3404
- }
3405
- }),
3413
+ servers: toInputServers(document.servers ?? []),
3406
3414
  securitySchemes: Object.entries(document.components?.securitySchemes ?? {}).flatMap(([name, value]) => {
3407
3415
  const scheme = refs.deref(value);
3408
3416
  return scheme?.type ? [{