{"id":22772346,"url":"https://github.com/pactflow/pactflow-jsonschema-example","last_synced_at":"2025-04-30T03:44:42.488Z","repository":{"id":105899824,"uuid":"287467996","full_name":"pactflow/pactflow-jsonschema-example","owner":"pactflow","description":"Example JSON Schema Integration with Pactflow","archived":false,"fork":false,"pushed_at":"2025-04-27T22:41:26.000Z","size":72,"stargazers_count":7,"open_issues_count":4,"forks_count":0,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-30T03:44:39.298Z","etag":null,"topics":["example"],"latest_commit_sha":null,"homepage":null,"language":"Makefile","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":null,"contributing":null,"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}},"created_at":"2020-08-14T07:09:21.000Z","updated_at":"2025-04-27T22:10:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"4897e2b3-1b24-4025-aabd-e654e23cc81e","html_url":"https://github.com/pactflow/pactflow-jsonschema-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactflow%2Fpactflow-jsonschema-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactflow%2Fpactflow-jsonschema-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactflow%2Fpactflow-jsonschema-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactflow%2Fpactflow-jsonschema-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pactflow","download_url":"https://codeload.github.com/pactflow/pactflow-jsonschema-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251638750,"owners_count":21619661,"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":["example"],"created_at":"2024-12-11T17:08:12.252Z","updated_at":"2025-04-30T03:44:42.457Z","avatar_url":"https://github.com/pactflow.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON Schema Example\n\n[![Build Status](https://travis-ci.com/pactflow/pactflow-jsonschema-example.svg?branch=master)](https://travis-ci.com/pactflow/pactflow-jsonschema-example)\n\nThis example shows how you could share a JSON Schema document with the Pact Broker as a substitute for a Pact contract, and validate that the contract is valid by a provider using the same workflows you would with a standard Pact test.\n\nIt's based on the CI/CD workshop from https://docs.pactflow.io/docs/workshops/ci-cd/.\n\nIt is using a public tenant on Pactflow, which you can access [here](https://test.pact.dius.com.au) using the credentials `dXfltyFMgNOFZAxr8io9wJ37iUpY42M`/`O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1`.\n\n## Prerequisites\n\n* Docker\n* NodeJS 10+\n* jq\n\n## Setup\n\n```\nnpm i\n```\n\n## Consumer Test\n\nThis phase is analogous to the Pact unit testing phase, where the consumers' client code is tested and as an output produces a contract.\n\nIn the case of a JSON schema, this may be through static generation (e.g. using tools such as https://github.com/YousefED/typescript-json-schema), a recording proxy or otherwise.\n\nTo emulate a \"CI\" process, you can run:\n\n```\nmake fake_ci_consumer\n```\n\nThis will:\n\n1. Generate the contract (using the TS -\u003e schema generation)\n2. Publish the contract to Pactflow (any valid JSON file, so long as it has the `consumer` and `provider` properties, will be accepted by the broker CLI tooling)\n3. Run the `can-i-deploy` check (first time, this should fail)\n4. If successful, \"deploy\" to production and tag the application version as moved to `prod`\n\n## Provider Test\n\nUses https://www.npmjs.com/package/json-schema-diff to do a diff on the JSON schema to check for backwards incompatible contract changes.\n\n```\nmake fake_ci_provider\n```\n\nThis will:\n\n1. Fetch the contract (currently it specifically fetches the exact consumer, but it should really use the [\"pacts for verification\"](https://github.com/pact-foundation/pact_broker/issues/307) endpoint in a real implementation)\n1. Extract the schema from the interaction and perform a semantic diff using `json-schema-diff`.\n1. Generate a schema from it's local type (`provider/product.ts`)\n1. Compare the downloaded schema to the golden schema (`provider/schema/schema.json`) - they must be identical\n1. Compare the downloaded schema to the golden schema (`provider/schema/schema.json`) - the downloaded schema (contract) must be _compatible_ with the golden schema\n1. Send the verification results back to Pactflow\n1. Run the `can-i-deploy` check\n1. If successful, \"deploy\" to production and tag the application version as moved to `prod`\n\n## Running the Provider\n\n\n```\nnpm run build\nnpm start\ncurl localhost:3000 | jq .\n  # will produce:\n  #\n  # {\n  #   \"item\": \"pancakes\",\n  #   \"price\": 27.4\n  # }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpactflow%2Fpactflow-jsonschema-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpactflow%2Fpactflow-jsonschema-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpactflow%2Fpactflow-jsonschema-example/lists"}