Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow matchesJsonSchema to be supplied as a json object. #2566

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

kyle-winkelman
Copy link
Contributor

@kyle-winkelman kyle-winkelman commented Jan 10, 2024

https://wiremock.org/docs/request-matching/#json-schema shows an example of using the matchesJsonSchema with an escaped json string:

{
  "request" : {
    "urlPath" : "/schema-match",
    "method" : "POST",
    "bodyPatterns" : [ {
      "matchesJsonSchema" : "{\n  \"type\": \"object\",\n  \"required\": [\n    \"name\"\n  ],\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\"\n    },\n    \"tag\": {\n      \"type\": \"string\"\n    }\n  }\n}",
      "schemaVersion" : "V202012"
    } ]
  },
  "response" : {
    "status" : 200
  }
}

This PR would allow us to supply a json object (similar to equalToJson). For example:

{
  "request" : {
    "urlPath" : "/schema-match",
    "method" : "POST",
    "bodyPatterns" : [ {
      "matchesJsonSchema" : {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "tag": {
            "type": "string"
          }
        }
      }
    } ]
  },
  "response" : {
    "status" : 200
  }
}

References

Submitter checklist

  • Recommended: Join WireMock Slack to get any help in #help-contributing or a project-specific channel like #wiremock-java
  • The PR request is well described and justified, including the body and the references
  • The PR title represents the desired changelog entry
  • The repository's code style is followed (see the contributing guide)
  • Test coverage that demonstrates that the change works as expected
  • For new features, there's necessary documentation in this pull request or in a subsequent PR to wiremock.org

@kyle-winkelman kyle-winkelman requested a review from a team as a code owner January 10, 2024 17:41
Copy link
Contributor

@dieppa dieppa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! It looks good! From your previous comment I assume this will complemented with a PR in the documentation project.

Thanks!

@dieppa dieppa merged commit 547f264 into wiremock:master Jan 17, 2024
7 checks passed
@kyle-winkelman kyle-winkelman deleted the jsonSchema branch January 23, 2024 20:31
@dieppa
Copy link
Contributor

dieppa commented Jan 24, 2024

Hello @kyle-winkelman , once again thanks for your contribution!

Are you planning to provide the documentation on this? There is no pressure, but just for us to plan the workload.

Thanks in advance!

@kyle-winkelman
Copy link
Contributor Author

wiremock/wiremock.org#252
Yes, I mentioned this PR, but didn't explicitly link it back here.

@dieppa
Copy link
Contributor

dieppa commented Jan 24, 2024

Ah, Ok.Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants