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

feat: match objects support JSON Schema #402

Open
AndersDJohnson opened this issue Jul 13, 2019 · 0 comments
Open

feat: match objects support JSON Schema #402

AndersDJohnson opened this issue Jul 13, 2019 · 0 comments
Assignees

Comments

@AndersDJohnson
Copy link
Member

Match objects could support optionally using a JSON Schema compatible structure to validate some objects or nested objects. This would enable a declarative alternative to functions, which don't work in static files like JSON, e.g., for record groups in config (#401).

We could use a $schema meta property to indicate dropping into a JSON Schema. We would want to provide a way to override the $ prefix on $schema to support handling any namespace conflicts.

For example, the below would require the query params firstName, lastName, and ensure one called favoriteColor matches one of the values in the specified enumeration. We could mix with existing features, as in this example, where someParam must also be present with a value of "someValue".

mockyeah.get({
  query: {
    someParam: "someValue",
    $schema: {
      favoriteColor: {
        type: "array",
        items: {
          type: "string",
          enum: ["red", "blue", "yellow"]
        }
      },
      required: ["firstName", "lastName"]
    }
  }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant