Options.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. };
  41. const getDefaultOptions = (options) => (typeof options === "string"
  42. ? {
  43. ...exports.defaultOptions,
  44. name: options,
  45. }
  46. : {
  47. ...exports.defaultOptions,
  48. ...options,
  49. });
  50. exports.getDefaultOptions = getDefaultOptions;