{"id":37223530,"url":"https://github.com/foxygoat/jig","last_synced_at":"2026-01-15T01:36:42.815Z","repository":{"id":39612864,"uuid":"254623727","full_name":"foxygoat/jig","owner":"foxygoat","description":"gRPC mocks with Jsonnet","archived":false,"fork":false,"pushed_at":"2025-03-25T22:07:41.000Z","size":285,"stargazers_count":13,"open_issues_count":2,"forks_count":5,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-21T09:05:16.232Z","etag":null,"topics":["grpc","mock","testing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foxygoat.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-04-10T11:59:39.000Z","updated_at":"2025-03-25T22:05:48.000Z","dependencies_parsed_at":"2024-06-19T04:09:45.949Z","dependency_job_id":"2bcb9ff1-7159-4f8d-a892-26c58cc573dd","html_url":"https://github.com/foxygoat/jig","commit_stats":{"total_commits":79,"total_committers":7,"mean_commits":"11.285714285714286","dds":0.5189873417721519,"last_synced_commit":"32bea44d746e240d770902c0776827719cc38b3a"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/foxygoat/jig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxygoat%2Fjig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxygoat%2Fjig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxygoat%2Fjig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxygoat%2Fjig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foxygoat","download_url":"https://codeload.github.com/foxygoat/jig/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxygoat%2Fjig/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28441031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T00:55:22.719Z","status":"ssl_error","status_checked_at":"2026-01-15T00:55:20.945Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["grpc","mock","testing"],"created_at":"2026-01-15T01:36:42.272Z","updated_at":"2026-01-15T01:36:42.810Z","avatar_url":"https://github.com/foxygoat.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jig\n\nJig lets you use [jsonnet] to implement gRPC methods, e.g.:\n\n    // Greeter.Hello\n    function(input) {\n      response: {\n        greeting: '💃 : Hello ' + input.request.firstName,\n      },\n    }\n\nThe jsonnet method definitions can be updated in real time without restarting\njig.\n\nJig uses protobuf `FileDescriptorSets`, generated by `protoc` into `.pb` files,\nas a description of valid gRPC method names, request and response types. Jig\ndoes not need any further pre-generated or pre-compiled code.\n\n[jsonnet]: https://jsonnet.org\n\n\n## Usage\n\nGenerate a FileDescriptorSet for the services to stub with:\n\n    protoc --descriptor_set_out service.pb --include_imports service.proto\n\nPut jsonnet method definitions together in a directory, each file named\n`\u003cpkg\u003e.\u003cservice\u003e.\u003cmethod\u003e.jsonnet`. The jsonnet file is (re-)evaluated when the\ngRPC server receives a call to that method.\n\nYou can generate skeleton jsonnet method definitions using `jig bones`:\n\n    jig bones --proto-set=dir/service.pb --method-dir=dir\n\nRequest protobuf messages are marshaled to JSON and passed to the jsonnet method\ndefinition function as the `input` parameter. If the method is a unary,\nserver-streaming or bidirectional streaming method, the request message is\nplaced in the `request` field of `input`:\n\n    {\n        request: { ...json-encoded gRPC request protobuf... }\n    }\n\nIf the method is a client-streaming method, the stream of request messages is\nplaced in the `stream` field of `input` as an array:\n\n    {\n        stream: [ {request1}, {request2}, ...]\n    }\n\nFor bidirectional streaming methods, the jsonnet method definition is evaluated\nonce for each message on the request stream (with a single message in the\n`request` field). Once `EOF` has been received on the request stream, the\njsonnet method definition is evaluated one more time with the `request` field\nset to `null`.\n\nResponse protobuf messages are unmarshaled from the jsonnet evaluation of the\nmethod definition. The result must evaluate as an object with fields describing\nthe response to send back to the gRPC client.\n\nIf the method is a unary or client-streaming method, the result must have a\n`response` field that contains the response message encoded as JSON:\n\n    function(input) {\n        response: { ...json-encoded gRPC response protobuf... }\n    }\n\nIf the method is a server- or bidirectional streaming method, the result must\nhave a `stream` field that contains an array of response messages encoded as\nJSON:\n\n    function(input) {\n        stream: [ {response1}, {response2}, ... ]\n    }\n\nA [gRPC status] can be returned in the `status` field:\n\n    function(input) {\n        status: {\n            code: 3,\n            message: 'Field \"foo\" failed validation: 0 \u003c foo \u003c 10',\n            details: [\n                {\n                    '@type': 'type.googleapis.com/google.protobuf.Duration',\n                    value: '15.2s',\n                },\n            ],\n        },\n    }\n\nIf a result has a `status` field, it must not have a `response` or `stream`\nfield.\n\nThe response can reference fields of the input using regular jsonnet references.\nSee the [testdata samples](./serve/testdata/greet).\n\nThe `request` and `response` fields are encoded from/to protobuf messages\naccording to the [protojson] encoding rules.\n\nTo serve these jsonnet methods, run:\n\n    jig serve \u003cdir\u003e\n\n[gRPC status]: https://www.grpc.io/docs/guides/error/\n[protojson]: https://developers.google.com/protocol-buffers/docs/proto3#json\n\n\n## Playing\n\n### jig serve\n\nBuild and start jig on the test data:\n\n    . ./bin/activate-hermit\n    make install\n    jig serve --http serve/testdata/greet\n\nin a second terminal call it with:\n\n    client world\n\nTo see streaming, call it with:\n\n    client --stream=server world\n    client --stream=client you me world\n    client --stream=bidi you me world\n\nThe `--http` flag passed to `jig serve` above allows you to make HTTP requests:\n\n    curl \\\n        -H \"Content-Type: application/json\" \\\n        -H \"Accept: application/json\" \\\n        -d '{\"firstName\": \"Kitty\"}' \\\n        localhost:8080/api/greet/hello\n\nExperiment with the jsonnet method files in the [testdata](./testdata)\ndirectory.\n\nAlternatively there is a traditional, generated gRPC server that the same client\ncan interact with. Start it with:\n\n    server\n\n### jig bones\n\nTo get started on writing a jsonnet method definition, the `jig bones`\nsubcommand generates a skeleton showing the input and output forms of a method.\n\nTo see a message with all the different types of message fields:\n\n    jig bones --proto-set pb/exemplar/exemplar.pb\n\nTo see the structure of the different method streaming types:\n\n    jig bones --proto-set pb/greet/greeter.pb\n\n\n## Development\n\n    . ./bin/activate-hermit\n    make ci\n\nRun `make help` for help on other make targets.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxygoat%2Fjig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoxygoat%2Fjig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxygoat%2Fjig/lists"}