Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include support for .describe from Zod #94

Closed
thecodedrift opened this issue Feb 23, 2023 · 1 comment · Fixed by #95
Closed

Include support for .describe from Zod #94

thecodedrift opened this issue Feb 23, 2023 · 1 comment · Fixed by #95

Comments

@thecodedrift
Copy link

Currently, descriptions for the OpenAPI definition need to live on the .openapi() method. However, zod already includes a describe method, which would be redundant in most cases.

I'm a bit slammed with work, but the following test demonstrates the issue. Test would be added to /spec/metadata-overrides.spec.ts

it("considers zod metadata if set", () => {
  const ZodMetadataSchema = registerSchema(
    "ZodMetadata",
    z.object({}).describe("Test")
  );

  const TestSchema = registerSchema(
    "Test",
    z.object({ key: ZodMetadataSchema })
  );

  expectSchema([ZodMetadataSchema, TestSchema], {
    ZodMetadataSchema: {
      type: "object",
      description: "Test",
    },
    Test: {
      type: "object",
      required: ["key"],
      properties: {
        key: {
          $ref: "#/components/schemas/ZodMetadataSchema",
        },
      },
    },
  });
});
@AGalabov AGalabov linked a pull request Feb 27, 2023 that will close this issue
AGalabov added a commit that referenced this issue Feb 28, 2023
…t-for-zod-describe

#94 Added support for `zod`'s `.describe` method
@AGalabov
Copy link
Collaborator

@jakobo just released this in the 4.4.0 version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants