better-call 1.0.1 → 1.0.2

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/README.md CHANGED
@@ -459,7 +459,7 @@ const createItem = createEndpoint("/item/:id", {
459
459
  })
460
460
  }),
461
461
  metadata: {
462
- openAPI: {
462
+ openapi: {
463
463
  requestBody: {
464
464
  content: {
465
465
  "application/json": {
@@ -488,13 +488,13 @@ const createItem = createEndpoint("/item/:id", {
488
488
 
489
489
  #### Configuration
490
490
 
491
- You can configure the open api schema by passing the `openAPI` option to the router.
491
+ You can configure the open api schema by passing the `openapi` option to the router.
492
492
 
493
493
  ```ts
494
494
  const router = createRouter({
495
495
  createItem
496
496
  }, {
497
- openAPI: {
497
+ openapi: {
498
498
  disabled: false, //default false
499
499
  path: "/api/reference", //default /api/reference
500
500
  scalar: {
package/dist/client.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BetterFetchOption, BetterFetchResponse } from '@better-fetch/fetch';
2
- import { j as Router, W as UnionToIntersection, b as Endpoint, T as HasRequiredKeys } from './router-Bpb8tT1Y.cjs';
2
+ import { j as Router, W as UnionToIntersection, b as Endpoint, T as HasRequiredKeys } from './router-DUkPVacX.cjs';
3
3
 
4
4
  type HasRequired<T extends {
5
5
  body?: any;
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BetterFetchOption, BetterFetchResponse } from '@better-fetch/fetch';
2
- import { j as Router, W as UnionToIntersection, b as Endpoint, T as HasRequiredKeys } from './router-Bpb8tT1Y.js';
2
+ import { j as Router, W as UnionToIntersection, b as Endpoint, T as HasRequiredKeys } from './router-DUkPVacX.js';
3
3
 
4
4
  type HasRequired<T extends {
5
5
  body?: any;
package/dist/index.cjs CHANGED
@@ -4475,8 +4475,8 @@ function getTypeFromZodType(zodType) {
4475
4475
  }
4476
4476
  function getParameters(options) {
4477
4477
  const parameters = [];
4478
- if (options.metadata?.openAPI?.parameters) {
4479
- parameters.push(...options.metadata.openAPI.parameters);
4478
+ if (options.metadata?.openapi?.parameters) {
4479
+ parameters.push(...options.metadata.openapi.parameters);
4480
4480
  return parameters;
4481
4481
  }
4482
4482
  if (options.query instanceof ZodObject) {
@@ -4499,8 +4499,8 @@ function getParameters(options) {
4499
4499
  return parameters;
4500
4500
  }
4501
4501
  function getRequestBody(options) {
4502
- if (options.metadata?.openAPI?.requestBody) {
4503
- return options.metadata.openAPI.requestBody;
4502
+ if (options.metadata?.openapi?.requestBody) {
4503
+ return options.metadata.openapi.requestBody;
4504
4504
  }
4505
4505
  if (!options.body) return void 0;
4506
4506
  if (options.body instanceof ZodObject || options.body instanceof ZodOptional) {
@@ -4641,16 +4641,16 @@ async function generator(endpoints, config) {
4641
4641
  if (options.method === "GET") {
4642
4642
  paths[value.path] = {
4643
4643
  get: {
4644
- tags: ["Default", ...options.metadata?.openAPI?.tags || []],
4645
- description: options.metadata?.openAPI?.description,
4646
- operationId: options.metadata?.openAPI?.operationId,
4644
+ tags: ["Default", ...options.metadata?.openapi?.tags || []],
4645
+ description: options.metadata?.openapi?.description,
4646
+ operationId: options.metadata?.openapi?.operationId,
4647
4647
  security: [
4648
4648
  {
4649
4649
  bearerAuth: []
4650
4650
  }
4651
4651
  ],
4652
4652
  parameters: getParameters(options),
4653
- responses: getResponse(options.metadata?.openAPI?.responses)
4653
+ responses: getResponse(options.metadata?.openapi?.responses)
4654
4654
  }
4655
4655
  };
4656
4656
  }
@@ -4658,9 +4658,9 @@ async function generator(endpoints, config) {
4658
4658
  const body = getRequestBody(options);
4659
4659
  paths[value.path] = {
4660
4660
  post: {
4661
- tags: ["Default", ...options.metadata?.openAPI?.tags || []],
4662
- description: options.metadata?.openAPI?.description,
4663
- operationId: options.metadata?.openAPI?.operationId,
4661
+ tags: ["Default", ...options.metadata?.openapi?.tags || []],
4662
+ description: options.metadata?.openapi?.description,
4663
+ operationId: options.metadata?.openapi?.operationId,
4664
4664
  security: [
4665
4665
  {
4666
4666
  bearerAuth: []
@@ -4680,7 +4680,7 @@ async function generator(endpoints, config) {
4680
4680
  }
4681
4681
  }
4682
4682
  },
4683
- responses: getResponse(options.metadata?.openAPI?.responses)
4683
+ responses: getResponse(options.metadata?.openapi?.responses)
4684
4684
  }
4685
4685
  };
4686
4686
  }
@@ -4787,19 +4787,19 @@ async function getBody(request) {
4787
4787
 
4788
4788
  // src/router.ts
4789
4789
  var createRouter = (endpoints, config) => {
4790
- if (!config?.openAPI?.disabled) {
4791
- const openAPI = {
4790
+ if (!config?.openapi?.disabled) {
4791
+ const openapi = {
4792
4792
  path: "/api/reference",
4793
- ...config?.openAPI
4793
+ ...config?.openapi
4794
4794
  };
4795
- endpoints["openAPI"] = createEndpoint2(
4796
- openAPI.path,
4795
+ endpoints["openapi"] = createEndpoint2(
4796
+ openapi.path,
4797
4797
  {
4798
4798
  method: "GET"
4799
4799
  },
4800
4800
  async (c) => {
4801
4801
  const schema = await generator(endpoints);
4802
- return new Response(getHTML(schema, openAPI.scalar), {
4802
+ return new Response(getHTML(schema, openapi.scalar), {
4803
4803
  headers: {
4804
4804
  "Content-Type": "text/html"
4805
4805
  }