{"id":47750,"library":"genson-js","title":"genson-js","description":"genson-js (v0.0.8) is a TypeScript/JavaScript library for generating JSON Schemas from JSON objects and merging multiple schemas. It ports the Python GenSON library, providing functions like createSchema, mergeSchemas, createCompoundSchema, extendSchema, areSchemasEqual, and isSubset. It ships TypeScript types and is designed for lightweight schema inference and composition. Released occasionally with basic functionality; no recent updates. Differentiated by its focus on schema merging and TypeScript support.","status":"active","version":"0.0.8","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/aspecto-io/genson-js","tags":["javascript","json","schema","json-schema","jsonschema","object","generate","generator","builder","typescript"],"install":[{"cmd":"npm install genson-js","lang":"bash","label":"npm"},{"cmd":"yarn add genson-js","lang":"bash","label":"yarn"},{"cmd":"pnpm add genson-js","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Proper ESM import. CJS require works but TypeScript may need esModuleInterop.","wrong":"const createSchema = require('genson-js').createSchema","symbol":"createSchema","correct":"import { createSchema } from 'genson-js'"},{"note":"Direct named import from package root.","wrong":"import { mergeSchemas } from 'genson-js/mergeSchemas'","symbol":"mergeSchemas","correct":"import { mergeSchemas } from 'genson-js'"},{"note":"ValueType is a named export, not default.","wrong":"import ValueType from 'genson-js'","symbol":"ValueType","correct":"import { ValueType } from 'genson-js'"}],"quickstart":{"code":"import { createSchema } from 'genson-js';\n\nconst schema = createSchema({\n  userName: 'smith',\n  languages: ['c++', 'java'],\n  age: 40,\n});\n\nconsole.log(JSON.stringify(schema, null, 2));\n/* Output:\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"userName\": { \"type\": \"string\" },\n    \"languages\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } },\n    \"age\": { \"type\": \"integer\" }\n  },\n  \"required\": [\"userName\", \"languages\", \"age\"]\n}\n*/","lang":"typescript","description":"Demonstrates creating a JSON Schema from a sample object using createSchema."},"warnings":[{"fix":"For complex schemas, consider using libraries like ajv or json-schema-generator.","message":"The library does not support all JSON Schema draft versions or features like $ref, definitions, or conditional validation.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always use ValueType enum or the corresponding string literal for type values.","message":"The ValueType enum values are strings (e.g., 'string', 'number', 'integer', etc.). Using numeric or other types may cause unexpected behavior.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Manually merge results if optimization is needed.","message":"createCompoundSchema does not deduplicate or simplify types; duplicate schemas may result in redundant entries.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'areschemasequ':36 'basic':55 'builder':80 'composit':51 'createcompoundschema':34 'createschema':32 'design':45 'differenti':60 'extendschema':35 'focus':63 'function':30,56 'generat':13,78,79 'genson':2,5,27 'genson-j':1,4 'infer':49 'issubset':38 'javascript':70 'js':3,6 'json':14,17,71,74 'json-schema':73 'jsonschema':76 'librari':11,28 'lightweight':47 'like':31 'merg':20,66 'mergeschema':33 'multipl':21 'object':18,77 'occasion':53 'port':24 'provid':29 'python':26 'recent':58 'releas':52 'schema':15,22,48,65,72,75 'ship':40 'support':69 'type':42 'typescript':41,68,81 'typescript/javascript':10 'updat':59 'v0.0.8':7","created_at":"2026-06-07T16:53:07.291232+00:00","updated_at":"2026-06-07T16:53:07.291232+00:00","problems":[{"fix":"Ensure npm install genson-js is run, and tsconfig.json has 'moduleResolution': 'node' or 'node16'.","cause":"Missing TypeScript types or module resolution issue.","error":"Cannot find module 'genson-js' or its corresponding type declarations."},{"fix":"Use import { createSchema } from 'genson-js'.","cause":"Using default import instead of named import.","error":"TypeError: createSchema is not a function"},{"fix":"Use const { createSchema } = require('genson-js') if in CommonJS environment.","cause":"Using CJS require incorrectly or mixing module systems.","error":"Uncaught TypeError: (0 , _genson_js.createSchema) is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/aspecto-io/genson-js#readme","github":"ssh://git@github.com/aspecto-io/genson-js","docs":null,"changelog":null,"pypi":null,"npm":"genson-js","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}