{"id":20135533,"url":"https://github.com/raisely/sequelize-to-json-schema-tester","last_synced_at":"2025-06-12T05:06:54.055Z","repository":{"id":57356668,"uuid":"130006432","full_name":"raisely/sequelize-to-json-schema-tester","owner":"raisely","description":"Test helper for sequelize-to-json-schema","archived":false,"fork":false,"pushed_at":"2018-07-13T02:05:01.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-09T13:15:43.552Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raisely.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-18T05:04:14.000Z","updated_at":"2019-12-20T12:33:07.000Z","dependencies_parsed_at":"2022-09-26T16:31:51.640Z","dependency_job_id":null,"html_url":"https://github.com/raisely/sequelize-to-json-schema-tester","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/raisely/sequelize-to-json-schema-tester","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Fsequelize-to-json-schema-tester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Fsequelize-to-json-schema-tester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Fsequelize-to-json-schema-tester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Fsequelize-to-json-schema-tester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raisely","download_url":"https://codeload.github.com/raisely/sequelize-to-json-schema-tester/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Fsequelize-to-json-schema-tester/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259401993,"owners_count":22851864,"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","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-11-13T21:15:20.497Z","updated_at":"2025-06-12T05:06:54.036Z","avatar_url":"https://github.com/raisely.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Utility library to help test the json schemas created by\n[sequelize-to-json-schema](https://github.com/raisely/sequelize-to-json-schema)\n\n# Install\n\n```\nnpm install --save-dev sequelize-to-json-schema-tester\n```\n\n# Usage\n\n```js\nconst TestHelper = require('sequelize-to-json-schema-tester');\nconst SchemaFactory = require('sequelize-to-json-schema');\n\nconst Models = // your sequelize models;\nconst associations = { users: { profile: 'ref', friends: 'ref', address: 'inline' } };\n\nconst virtualProperties = {\n\tusers: {\n\t\tfollowers: { type: 'INTEGER' },\n\t},\n};\n\nconst factory = new SchemaFactory({ associations, virtualProperties, hrefBase: '//myurl' });\n\nconst helper = TestHelper.getTestHelper(Models.subscriptions, factory.options);\n\ndescribe('User schema endpoint', () =\u003e {\n  let response;\n  before(() =\u003e {\n    response = get('/myapi/schema/users.json');\n  });\n  it('describes all properties', () =\u003e {\n    const allProperties = [\n      'name', // An actual attribute of the model\n      'followers', // A virtual attribute not on the model but calculated\n    ];\n\n    // Assert that the schema contains all expected attributes\n    helper.assertProperties(response, allProperties);\n  });\n  it('describes all associations', () =\u003e {\n    // Assert that all associations are present in the schema\n    helper.assertAssociations(response, ['profile', 'friends', 'address']);    \n  });\n  it('fully describes all properties and associations', () =\u003e {\n    // Will recursively look through all inline associations\n    helper.assertAllPropertiesDescribed(response);    \n  });\n\tit('looks like an example json', () =\u003e {\n\t\tconst exampleUser = {\n\t\t\tname: 'Gerald',\n\t\t\tfollowers: 3,\n\t\t};\n\n\t\thelper.assertAllExampleFields(response, exampleUser);\t\t\n\t})\n});\n```\n\n## assertProperties(response, allProperties)\n\nAsserts that the schema contains all of the properties in the array of\nproperties given.\nIt ignores any properties present in the schema that are not in the array\nof property names to check\n\n## assertAllPropertiesDescribed(response, [fields])\n\nThis checks that all the properties in the response are fully described.\nBy default, this means checking that each property includes\nid, description, title, type and examples\n(It will still pass if any of these are empty strings/arrays)\n\nFor properties that are objects or arrays, it will check the nested\nelements within them\n\n## assertAllExampleFields(response, exampleObject)\n\nThis allows for a quick check by passing an example object and verifying that\nthe schema describes that object.\n\n## assertAssociations(response, associations)\n\nAssociations is an array of strings being the property names of expected associations\nChecks that those associations are described and that they are appropriately described\nby either $ref or described inline depending on the settings passed to the SchemaFactory\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraisely%2Fsequelize-to-json-schema-tester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraisely%2Fsequelize-to-json-schema-tester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraisely%2Fsequelize-to-json-schema-tester/lists"}