{"id":28966679,"url":"https://github.com/pactflow/openapi-pact-comparator","last_synced_at":"2026-05-29T07:01:32.419Z","repository":{"id":273454977,"uuid":"749678922","full_name":"pactflow/openapi-pact-comparator","owner":"pactflow","description":null,"archived":false,"fork":false,"pushed_at":"2026-05-27T08:20:18.000Z","size":1980,"stargazers_count":8,"open_issues_count":6,"forks_count":4,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-05-27T10:15:33.943Z","etag":null,"topics":["open-source","pactflow"],"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/pactflow.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-01-29T07:11:01.000Z","updated_at":"2026-05-24T23:07:19.000Z","dependencies_parsed_at":"2025-01-21T02:29:51.060Z","dependency_job_id":"e30d4e06-063a-42a1-a3fb-da942b8d4d29","html_url":"https://github.com/pactflow/openapi-pact-comparator","commit_stats":null,"previous_names":["pactflow/openapi-pact-comparator"],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/pactflow/openapi-pact-comparator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactflow%2Fopenapi-pact-comparator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactflow%2Fopenapi-pact-comparator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactflow%2Fopenapi-pact-comparator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactflow%2Fopenapi-pact-comparator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pactflow","download_url":"https://codeload.github.com/pactflow/openapi-pact-comparator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactflow%2Fopenapi-pact-comparator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33637486,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"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":["open-source","pactflow"],"created_at":"2025-06-24T07:40:54.133Z","updated_at":"2026-05-29T07:01:32.413Z","avatar_url":"https://github.com/pactflow.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAPI-Pact-Comparator\n\n## What is this?\n\nThis compares OpenAPI schemas and Pact contracts to determine if they are\ncompatible. It is inspired by\n[swagger-mock-validator](https://github.com/pactflow/swagger-mock-validator)\nand aims to retain a mostly compatible interface.\n\n## Why rewrite it?\n\n[swagger-mock-validator](https://github.com/pactflow/swagger-mock-validator)\nhas aged, and is very difficult to extend and improve on.\n\nIt is also very slow primarily due to inefficient use of\n[ajv](https://ajv.js.org/); schemas are unnecessarily recompiled everytime\ninstead of being cached.\n\n## How is this better?\n\n**Schemas are compiled once, and reused where possible**. In practical terms,\nthis gives us an improvement exceeding 20x in real-world comparisons. In some\ncases, this was 50x faster!\n\n**Referenced schemas are NOT inlined**. They are kept as references to keep the\nsize of complex schemas down. We need to do this anyway to support circular\nreferences. Further, unused references are skipped to speed up schema\ncompilation in AJV.\n\n**Multiple pacts can be compared in one invocation to maximise schema reuse**.\nInstead of performing the comparison per pair of OAS + Pact, we can reuse the\ncompiled OAS schemas across multiple Pacts.\n\n**A fast HTTP router is used to match provider routes**. Instead of iterating\nthrough an array of routes, we use [Radix\nTree](https://en.wikipedia.org/wiki/Radix_tree) search using\n[find-my-way](https://github.com/delvedor/find-my-way) This allows large\nproviders to be traversed quickly.\n\n**Computation is broken up to small units using async generators**. This leads\nto low event loop delays, suitable for high concurrency servers.\n\n## Usage\n\nWith error handling omitted for brevity:\n\n```\nimport { Comparator } from \"openapi-pact-comparator\";\n\n// openapi is object from JSON.parse() or yaml.load()\nconst comparator = new Comparator(openapi);\n\n// pacts is array of objects the same way\nfor (const pact of pacts) {\n  for await (const result of comparator.compare(pact)) {\n    console.log(result);\n  }\n}\n```\n\n## Quirks mode\n\nTo retain compatibility with\n[swagger-mock-validator](https://github.com/pactflow/swagger-mock-validator),\nan environment variable `QUIRKS` can be set [to any value]. When this is true,\nall of SMV quirks are reproduced in case you are unable to migrate immediately.\n\nThe quirks can also be enabled/disabled by adding to the `info` section of the\nOAS some extensions in the form of `x-opc-config-${quirk-name}`, where quirks\nare listed [here](./src/utils/config.ts).\n\nThis mode may be removed eventually, so you should always endeavour to try to\nupdate your comparisons to use the latest functionality.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpactflow%2Fopenapi-pact-comparator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpactflow%2Fopenapi-pact-comparator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpactflow%2Fopenapi-pact-comparator/lists"}