{"id":18875812,"url":"https://github.com/wiremock/wiremock-jaxrs","last_synced_at":"2026-02-17T08:03:07.856Z","repository":{"id":57742881,"uuid":"181914219","full_name":"wiremock/wiremock-jaxrs","owner":"wiremock","description":"Automates configuration of Wiremock stubs from JAX-RS annotated resources.","archived":false,"fork":false,"pushed_at":"2024-05-01T17:12:12.000Z","size":315,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-02T12:05:56.826Z","etag":null,"topics":["mock","wiremock","wiremock-mappings"],"latest_commit_sha":null,"homepage":"","language":"Java","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/wiremock.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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},"funding":{"github":["tomasbjerre"]}},"created_at":"2019-04-17T14:58:39.000Z","updated_at":"2024-05-01T17:12:16.000Z","dependencies_parsed_at":"2024-04-10T04:14:44.192Z","dependency_job_id":"e1aa5b82-0aa8-45dc-b3c3-f080136a68ea","html_url":"https://github.com/wiremock/wiremock-jaxrs","commit_stats":null,"previous_names":["tomasbjerre/wiremock-jaxrs"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiremock%2Fwiremock-jaxrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiremock%2Fwiremock-jaxrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiremock%2Fwiremock-jaxrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiremock%2Fwiremock-jaxrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wiremock","download_url":"https://codeload.github.com/wiremock/wiremock-jaxrs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223639348,"owners_count":17177816,"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":["mock","wiremock","wiremock-mappings"],"created_at":"2024-11-08T06:09:15.512Z","updated_at":"2026-02-17T08:03:07.838Z","avatar_url":"https://github.com/wiremock.png","language":"Java","funding_links":["https://github.com/sponsors/tomasbjerre"],"categories":[],"sub_categories":[],"readme":"# Wiremock JAX-RS\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/se.bjurr.wiremock/wiremock-jaxrs/badge.svg)](https://maven-badges.herokuapp.com/maven-central/se.bjurr.wiremock/wiremock-jaxrs)\n\n[Wiremock](http://wiremock.org/) with JAX-RS support. Enables creation of stubs from JAX-RS annotated resources. It:\n\n* Automates configuration of [stubs](http://wiremock.org/docs/stubbing/) for those using JAX-RS.\n* Contains validation checks against JAX-RS which enables you to produce **type safe stubs**.\n\nGiven:\n\n* JAX-RS annotated resource\n* Called method\n* Response (unless void)\n\nIt will create a [Wiremock stub](http://wiremock.org/docs/stubbing/) by gathering information from the JAX-RS annotations on the given resource.\n\n## Usage\n\nIt extends, and works just like, [Wiremock](http://wiremock.org/docs/stubbing/) by adding a new factory method:\n\n```java\nWireMockJaxrs.invocation(Class\u003cT\u003e resource, ResourceInvocation\u003cT\u003e invocation)\n```\n\nThat is used like:\n\n```java\nimport static com.github.tomakehurst.wiremock.client.WireMock.aResponse;\nimport static com.github.tomakehurst.wiremock.client.WireMock.stubFor;\nimport static com.github.tomakehurst.wiremock.jaxrs.api.WireMockJaxrs.invocation;\nimport com.github.tomakehurst.wiremock.stubbing.StubMapping;\n...\nfinal StubMapping sm =\n    stubFor( //\n        invocation(ItemResouce.class, (r) -\u003e r.whateverMethod(anyParameterValue)) //\n            .willReturn(aResponse().withStatus(SC_ACCEPTED), responseObject));\n```\n\n### Example\n\nWhen invoked like this:\n\n```java\nimport static com.github.tomakehurst.wiremock.client.WireMock.aResponse;\nimport static com.github.tomakehurst.wiremock.client.WireMock.stubFor;\nimport static com.github.tomakehurst.wiremock.jaxrs.api.WireMockJaxrs.invocation;\n...\nfinal List\u003cItemDTO\u003e responseObject = Arrays.asList(new ItemDTO(\"pong\"));\nfinal StubMapping sm =\n    stubFor( //\n        invocation(ItemResouce.class, (r) -\u003e r.getItems()) //\n            .willReturn(aResponse().withStatus(SC_ACCEPTED), responseObject));\n```\n\nIt creates a stub (as described [here](http://wiremock.org/docs/stubbing/)):\n\n```json\n{\n  \"id\" : \"d68fb4e2-48ed-40d2-bc73-0a18f54f3ece\",\n  \"request\" : {\n    \"urlPattern\" : \".*/list$\",\n    \"method\" : \"GET\",\n    \"headers\" : {\n      \"Accept\" : {\n        \"equalTo\" : \"application/json\"\n      }\n    }\n  },\n  \"response\" : {\n    \"status\" : 202,\n    \"body\" : \"[{\\\"str\\\":\\\"pong\\\",\\\"id\\\":0}]\",\n    \"headers\" : {\n      \"Content-Type\" : \"application/json\"\n    }\n  },\n  \"uuid\" : \"d68fb4e2-48ed-40d2-bc73-0a18f54f3ece\"\n}\n```\n\nWhen `ItemResource` looks like:\n\n```java\n@Path(\"/\")\npublic interface ItemResouce {\n\n  @Path(\"/list\")\n  @GET\n  @Produces(MediaType.APPLICATION_JSON)\n  public List\u003cItemDTO\u003e getItems();\n\n  @Path(\"/create\")\n  @POST\n  @Consumes(MediaType.APPLICATION_JSON)\n  @Produces(MediaType.APPLICATION_JSON)\n  public ItemDTO post(ItemDTO item);\n}\n```\n\nIf the method consumes content, that content is also matched. When invoked like this:\n\n```java\nimport static com.github.tomakehurst.wiremock.client.WireMock.aResponse;\nimport static com.github.tomakehurst.wiremock.client.WireMock.stubFor;\nimport static com.github.tomakehurst.wiremock.jaxrs.api.WireMockJaxrs.invocation;\n...\nfinal ItemDTO responseObject = new ItemDTO(\"the item\");\nresponseObject.setId(123);\nfinal ItemDTO postedItem = new ItemDTO(\"the item\");\n\nfinal StubMapping sm =\n    stubFor( //\n        invocation(ItemResouce.class, (r) -\u003e r.post(postedItem)) //\n            .willReturn(aResponse().withStatus(SC_ACCEPTED), responseObject));\n```\n\nIt creates a stub (as described [here](http://wiremock.org/docs/stubbing/)):\n\n```json\n{\n  \"id\" : \"d68fb4e2-48ed-40d2-bc73-0a18f54f3ece\",\n  \"request\" : {\n    \"urlPattern\" : \".*/create$\",\n    \"method\" : \"POST\",\n    \"headers\" : {\n      \"Content-Type\" : {\n        \"equalTo\" : \"application/json\"\n      },\n      \"Accept\" : {\n        \"equalTo\" : \"application/json\"\n      }\n    },\n    \"bodyPatterns\" : [ {\n      \"equalToJson\" : \"{\\\"str\\\":\\\"the item\\\",\\\"id\\\":0}\",\n      \"ignoreArrayOrder\" : true,\n      \"ignoreExtraElements\" : true\n    } ]\n  },\n  \"response\" : {\n    \"status\" : 202,\n    \"body\" : \"{\\\"str\\\":\\\"the item\\\",\\\"id\\\":123}\",\n    \"headers\" : {\n      \"Content-Type\" : \"application/json\"\n    }\n  },\n  \"uuid\" : \"d68fb4e2-48ed-40d2-bc73-0a18f54f3ece\"\n}\n```\n\nCheck the test cases in this repository for more examples!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiremock%2Fwiremock-jaxrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiremock%2Fwiremock-jaxrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiremock%2Fwiremock-jaxrs/lists"}