nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: RobinTail/express-zod-api
Pull request #548 (2022-08-15 11:10:20)

Supporting ZodBranded in OpenAPI generator.


Patch:
diff --git a/src/open-api-helpers.ts b/src/open-api-helpers.ts
index e9b8b2da..9ec19684 100644
--- a/src/open-api-helpers.ts
+++ b/src/open-api-helpers.ts
@@ -489,6 +489,11 @@ export const depictEffect: DepictHelper<z.ZodEffects<z.ZodTypeAny>> = ({
   return { ...initial, ...input };
 };
 
+export const depictZodBranded: DepictHelper<
+  z.ZodBranded<z.ZodTypeAny, any>
+> = ({ schema, initial, isResponse }) =>
+  depictSchema({ schema: schema.unwrap(), isResponse, initial });
+
 export const depictIOExamples = <T extends IOSchema>(
   schema: T,
   isResponse: boolean,
@@ -611,6 +616,7 @@ const depictHelpers: DepictingRules = {
   ZodOptional: depictOptionalOrNullable,
   ZodNullable: depictOptionalOrNullable,
   ZodDiscriminatedUnion: depictDiscriminatedUnion,
+  ZodBranded: depictZodBranded,
 };
 
 export const depictSchema: DepictHelper<z.ZodTypeAny> = ({


Test patch:
diff --git a/tests/unit/__snapshots__/open-api-helpers.spec.ts.snap b/tests/unit/__snapshots__/open-api-helpers.spec.ts.snap
index 5af5b933..6b0e4189 100644
--- a/tests/unit/__snapshots__/open-api-helpers.spec.ts.snap
+++ b/tests/unit/__snapshots__/open-api-helpers.spec.ts.snap
@@ -676,6 +676,13 @@ Object {
 
 exports[`Open API helpers depictUpload() should throw when using in response 1`] = `[Error: Please use z.upload() only for input.]`;
 
+exports[`Open API helpers depictZodBranded should depict the actual schema 1`] = `
+Object {
+  "minLength": 2,
+  "type": "string",
+}
+`;
+
 exports[`Open API helpers excludeExampleFromDepiction() should remove example property of supplied object 1`] = `
 Object {
   "test": "some",
diff --git a/tests/unit/open-api-helpers.spec.ts b/tests/unit/open-api-helpers.spec.ts
index 49e6fba3..e5348308 100644
--- a/tests/unit/open-api-helpers.spec.ts
+++ b/tests/unit/open-api-helpers.spec.ts
@@ -39,6 +39,7 @@ import {
   extractObjectSchema,
   depictSecurity,
   depictSecurityNames,
+  depictZodBranded,
 } from "../../src/open-api-helpers";
 import { serializeSchemaForTest } from "../helpers";
 
@@ -824,6 +825,17 @@ describe("Open API helpers", () => {
     });
   });
 
+  describe("depictZodBranded", () => {
+    test("should depict the actual schema", () => {
+      expect(
+        depictZodBranded({
+          schema: z.string().min(2).brand<"Test">(),
+          isResponse: true,
+        })
+      ).toMatchSnapshot();
+    });
+  });
+
   describe("depictSecurity()", () => {
     test("should handle Basic, Bearer and CustomHeader Securities", () => {
       expect(
Repository: RobinTail/express-zod-api
Pull request #701 (2022-11-19 11:17:13)

Allow nested top-level refinements.
Fixes issue #662 


Patch:
diff --git a/src/io-schema.ts b/src/io-schema.ts
index 24194fd5..ca7e552f 100644
--- a/src/io-schema.ts
+++ b/src/io-schema.ts
@@ -6,7 +6,7 @@ import { AnyMiddlewareDef } from "./middleware";
 type UnknownKeysParam = "passthrough" | "strict" | "strip";
 
 type Refined<T extends z.ZodType> = T extends z.ZodType<infer O>
-  ? z.ZodEffects<T, O, O>
+  ? z.ZodEffects<T | Refined<T>, O, O>
   : never;
 
 /**


Test patch:
diff --git a/tests/unit/io-schema.spec.ts b/tests/unit/io-schema.spec.ts
index fa2d1814..29bb4352 100644
--- a/tests/unit/io-schema.spec.ts
+++ b/tests/unit/io-schema.spec.ts
@@ -63,6 +63,20 @@ describe("I/O Schema and related helpers", () => {
           })
         );
       });
+      test("Issue 662: accepts nested refinements", () => {
+        expectType<IOSchema>(
+          z
+            .object({})
+            .refine(() => true)
+            .refine(() => true)
+        );
+        expectType<IOSchema>(
+          z
+            .object({})
+            .superRefine(() => true)
+            .superRefine(() => true)
+        );
+      });
       test("does not accept transformation of object", () => {
         expectNotType<IOSchema>(z.object({}).transform(() => true));
       });
Repository: RobinTail/express-zod-api
Pull request #806 (2023-02-09 23:30:52)

Fix client-helpers `cleanId` function to properly clean the entire string
The current function will only replace the first occurence of an invalid character. This fixes it to handle multiple invalid characters. Also, update the unit test for `client.ts` to exercise this code.

This resolves https://github.com/RobinTail/express-zod-api/issues/805


Patch:
diff --git a/src/client-helpers.ts b/src/client-helpers.ts
index 4c836146..b43ace67 100644
--- a/src/client-helpers.ts
+++ b/src/client-helpers.ts
@@ -200,7 +200,7 @@ export const cleanId = (path: string, method: string, suffix: string) => {
   return [method]
     .concat(path.split("/"))
     .concat(suffix)
-    .map((entry) => entry.replace(/[^A-Z0-9]/i, ""))
+    .flatMap((entry) => entry.split(/[^A-Z0-9]/gi))
     .map(
       (entry) => entry.slice(0, 1).toUpperCase() + entry.slice(1).toLowerCase()
     )


Test patch:
diff --git a/tests/unit/__snapshots__/client.spec.ts.snap b/tests/unit/__snapshots__/client.spec.ts.snap
index 5ec1f813..2bf4c585 100644
--- a/tests/unit/__snapshots__/client.spec.ts.snap
+++ b/tests/unit/__snapshots__/client.spec.ts.snap
@@ -130,11 +130,11 @@ export class ExpressZodAPIClient {
 `;
 
 exports[`API Client Generator Should treat optionals the same way as z.infer() 1`] = `
-"type PostV1TestInput = {
+"type PostV1TestWithDashesInput = {
     opt?: string | undefined;
 };
 
-type PostV1TestResponse = {
+type PostV1TestWithDashesResponse = {
     status: "success";
     data: {
         similar?: number | undefined;
@@ -146,21 +146,21 @@ type PostV1TestResponse = {
     };
 };
 
-export type Path = "/v1/test";
+export type Path = "/v1/test-with-dashes";
 
 export type Method = "get" | "post" | "put" | "delete" | "patch";
 
 export type MethodPath = \`\${Method} \${Path}\`;
 
 export interface Input extends Record<MethodPath, any> {
-    "post /v1/test": PostV1TestInput;
+    "post /v1/test-with-dashes": PostV1TestWithDashesInput;
 }
 
 export interface Response extends Record<MethodPath, any> {
-    "post /v1/test": PostV1TestResponse;
+    "post /v1/test-with-dashes": PostV1TestWithDashesResponse;
 }
 
-export const jsonEndpoints = { "post /v1/test": true };
+export const jsonEndpoints = { "post /v1/test-with-dashes": true };
 
 export type Provider = <M extends Method, P extends Path>(method: M, path: P, params: Input[\`\${M} \${P}\`]) => Promise<Response[\`\${M} \${P}\`]>;
 
diff --git a/tests/unit/client.spec.ts b/tests/unit/client.spec.ts
index dd3fd51d..79eca629 100644
--- a/tests/unit/client.spec.ts
+++ b/tests/unit/client.spec.ts
@@ -10,7 +10,7 @@ describe("API Client Generator", () => {
   test("Should treat optionals the same way as z.infer()", () => {
     const client = new Client({
       v1: {
-        test: defaultEndpointsFactory.build({
+        "test-with-dashes": defaultEndpointsFactory.build({
           method: "post",
           input: z.object({
             opt: z.string().optional(),
Repository: RobinTail/express-zod-api
Pull request #978 (2023-05-06 09:50:51)

Hotfix: for integration DIY: include the dictionaries of IO types.
Related to https://github.com/RobinTail/express-zod-api/discussions/931#discussioncomment-5823213


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4e99bb75..647152f6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,11 @@
 
 ## Version 10
 
+### v10.7.1
+
+- For the `new Integration({ variant: "types" })` the following types added:
+  - `Path`, `Method`, `MethodPath`, `Input`, `Response`.
+
 ### v10.7.0
 
 - Reverting the changes made in v10.2.0: restoring `openapi3-ts` dependency.
diff --git a/src/integration.ts b/src/integration.ts
index 33583218..3e52da04 100644
--- a/src/integration.ts
+++ b/src/integration.ts
@@ -128,10 +128,6 @@ export class Integration {
 
     this.agg = Object.values<ts.Node>(this.aliases).concat(this.agg);
 
-    if (variant === "types") {
-      return;
-    }
-
     const pathNode = makePublicLiteralType("Path", this.paths);
     const methodNode = makePublicLiteralType("Method", methods);
 
@@ -162,6 +158,18 @@ export class Integration {
       )
     );
 
+    this.agg.push(
+      pathNode,
+      methodNode,
+      methodPathNode,
+      inputNode,
+      responseNode
+    );
+
+    if (variant === "types") {
+      return;
+    }
+
     const jsonEndpointsNode = f.createVariableStatement(
       exportModifier,
       makeConst(
@@ -318,11 +326,6 @@ export class Integration {
     );
 
     this.agg.push(
-      pathNode,
-      methodNode,
-      methodPathNode,
-      inputNode,
-      responseNode,
       jsonEndpointsNode,
       providerNode,
       implementationNode,


Test patch:
diff --git a/tests/unit/__snapshots__/integration.spec.ts.snap b/tests/unit/__snapshots__/integration.spec.ts.snap
index 72545bc7..69d7445c 100644
--- a/tests/unit/__snapshots__/integration.spec.ts.snap
+++ b/tests/unit/__snapshots__/integration.spec.ts.snap
@@ -411,7 +411,29 @@ type PostV1AvatarUploadResponse = {
     error: {
         message: string;
     };
-};"
+};
+
+export type Path = "/v1/user/retrieve" | "/v1/user/:id" | "/v1/avatar/send" | "/v1/avatar/stream" | "/v1/avatar/upload";
+
+export type Method = "get" | "post" | "put" | "delete" | "patch";
+
+export type MethodPath = \`\${Method} \${Path}\`;
+
+export interface Input extends Record<MethodPath, any> {
+    "get /v1/user/retrieve": GetV1UserRetrieveInput;
+    "post /v1/user/:id": PostV1UserIdInput;
+    "get /v1/avatar/send": GetV1AvatarSendInput;
+    "get /v1/avatar/stream": GetV1AvatarStreamInput;
+    "post /v1/avatar/upload": PostV1AvatarUploadInput;
+}
+
+export interface Response extends Record<MethodPath, any> {
+    "get /v1/user/retrieve": GetV1UserRetrieveResponse;
+    "post /v1/user/:id": PostV1UserIdResponse;
+    "get /v1/avatar/send": GetV1AvatarSendResponse;
+    "get /v1/avatar/stream": GetV1AvatarStreamResponse;
+    "post /v1/avatar/upload": PostV1AvatarUploadResponse;
+}"
 `;
 
 exports[`API Integration Generator Should treat optionals the same way as z.infer() by default 1`] = `