{"id":16178116,"url":"https://github.com/charlypoly/functional-json-schema","last_synced_at":"2025-10-29T05:35:51.795Z","repository":{"id":40944519,"uuid":"133929058","full_name":"charlypoly/functional-json-schema","owner":"charlypoly","description":"Build a JSON Schema with functions","archived":false,"fork":false,"pushed_at":"2023-01-05T12:28:04.000Z","size":880,"stargazers_count":12,"open_issues_count":17,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-09T06:37:48.482Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charlypoly.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-18T08:53:42.000Z","updated_at":"2024-05-13T01:28:40.000Z","dependencies_parsed_at":"2023-02-04T04:33:12.922Z","dependency_job_id":null,"html_url":"https://github.com/charlypoly/functional-json-schema","commit_stats":null,"previous_names":["wittydeveloper/functional-json-schema"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/charlypoly/functional-json-schema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlypoly%2Ffunctional-json-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlypoly%2Ffunctional-json-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlypoly%2Ffunctional-json-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlypoly%2Ffunctional-json-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charlypoly","download_url":"https://codeload.github.com/charlypoly/functional-json-schema/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlypoly%2Ffunctional-json-schema/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270836842,"owners_count":24654366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T05:12:16.425Z","updated_at":"2025-10-29T05:35:51.698Z","avatar_url":"https://github.com/charlypoly.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# functional-json-schema\nBuild a JSON Schema with functions\n\n\n\n## Schema DSL\n\n### Simple schema\n\n```js\n\nimport * as schema from 'functional-json-schema';\n\nconst JsonSchema = schema.schema({\n  person: {\n    friends: schema.types.arrayOf(schema.types.definition('user')),\n        id: 'string*',\n        friend_ids: schema.types.arrayOf(schema.types.definition('User'), { required: true }),\n    }\n}, null, { schema: 'http://json-schema.org/draft-06/schema#' })\n\n/*\n=\u003e {\n  $schema: 'http://json-schema.org/draft-06/schema#',\n  type: 'object',\n  properties: {\n    person: {\n      type: 'object',\n      properties: {\n        friends: {\n          \"type\": \"array\",\n          \"items\": {\n            \"$ref\": \"#/definitions/User\"\n          }\n        },\n        (...)\n      },\n      required: ['friends', 'id']\n    }\n  }\n}\n*/\n```\n### Schema with definitions\n\n```js\n\nimport * as schema from 'functional-json-schema';\n\nconst schemaWithDefinitions = schema(\n  {\n    community_list: {\n      portfolio_ids: types.arrayOf(\"string\", { required: true }),\n      project_id: types.type(\"string\", { required: true }),\n      status: types.enumOf(\"active\", \"inactive\"),\n      user: types.anyOf(types.definition(\"User\"), types.definition(\"Admin\")),\n    },\n  }, {\n    User: {\n      firstName: types.type(\"string\"),\n      lastName: types.type(\"string\"),\n      jobTitle: types.type(\"string\"),\n      companyId: types.type(\"string\"),\n    },\n  },\n  { schema: 'http://json-schema.org/draft-06/schema#' }\n);\n\n/*\n=\u003e {\n  $schema: 'http://json-schema.org/draft-06/schema#',\n  type: \"object\",\n  properties: {\n    community_list: {\n      type: \"object\",\n      properties: {\n        portfolio_ids: {\n          type: \"array\",\n          items: {\n            type: \"string\",\n          },\n        },\n        project_id: {\n          type: \"string\",\n        },\n        user: {\n          anyOf: [\n            { $ref: \"#/definitions/User\" },\n            { $ref: \"#/definitions/Admin\" },\n          ],\n        },\n        status: {\n          enum: [\"active\", \"inactive\"],\n        },\n      },\n      required: [\"portfolio_ids\", \"project_id\"],\n    },\n  },\n  definitions: {\n    User: {\n      type: \"object\",\n      properties: {\n        firstName: {\n          type: \"string\",\n        },\n        lastName: {\n          type: \"string\",\n        },\n        jobTitle: {\n          type: \"string\",\n        },\n        companyId: {\n          type: \"string\",\n        },\n      },\n      required: [],\n    },\n  }\n}\n*/\n```\n\n## standalone definition DSL\n\n```js\n\nimport * as schema from 'functional-json-schema';\n\nconst JsonSchemaDefinition = schema.definition(\n  'User',\n  {\n    firstName: schema.types.type('string'),\n    lastName: schema.types.type('string'),\n    jobTitle: schema.types.type('string'),\n    companyId: schema.types.type('string'),\n  },\n  { title: \"User\", description: \"Fake User Object\" }\n)\n\n/*\n=\u003e {\n  \"$ref\": \"#/definitions/User\",\n  \"definitions\": {\n      \"User\": {\n          \"type\": \"object\",\n          \"title\": \"User\",\n          \"description\": \"Fake User Object\",\n          \"properties\": {\n              \"firstName\": {\n                  \"type\": \"string\"\n              },\n              \"lastName\": {\n                  \"type\": \"string\"\n              },\n              \"jobTitle\": {\n                  \"type\": \"string\"\n              },\n              \"companyId\": {\n                  \"type\": \"string\"\n              }\n          },\n          required: [],\n      }\n  }\n}\n*/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlypoly%2Ffunctional-json-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharlypoly%2Ffunctional-json-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlypoly%2Ffunctional-json-schema/lists"}