Options.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getDefaultOptions = exports.defaultOptions = exports.jsonDescription = exports.ignoreOverride = void 0;
  4. exports.ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
  5. const jsonDescription = (jsonSchema, def) => {
  6. if (def.description) {
  7. try {
  8. return {
  9. ...jsonSchema,
  10. ...JSON.parse(def.description),
  11. };
  12. }
  13. catch { }
  14. }
  15. return jsonSchema;
  16. };
  17. exports.jsonDescription = jsonDescription;
  18. exports.defaultOptions = {
  19. name: undefined,
  20. $refStrategy: "root",
  21. basePath: ["#"],
  22. effectStrategy: "input",
  23. pipeStrategy: "all",
  24. dateStrategy: "format:date-time",
  25. mapStrategy: "entries",
  26. removeAdditionalStrategy: "passthrough",
  27. allowedAdditionalProperties: true,
  28. rejectedAdditionalProperties: false,
  29. definitionPath: "definitions",
  30. target: "jsonSchema7",
  31. strictUnions: false,
  32. definitions: {},
  33. errorMessages: false,
  34. markdownDescription: false,
  35. patternStrategy: "escape",
  36. applyRegexFlags: false,
  37. emailStrategy: "format:email",
  38. base64Strategy: "contentEncoding:base64",
  39. nameStrategy: "ref",
  40. openAiAnyTypeName: "OpenAiAnyType"
  41. };
  42. const getDefaultOptions = (options) => (typeof options === "string"
  43. ? {
  44. ...exports.defaultOptions,
  45. name: options,
  46. }
  47. : {
  48. ...exports.defaultOptions,
  49. ...options,
  50. });
  51. exports.getDefaultOptions = getDefaultOptions;