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

Schema validation #195

Closed
richardruiter opened this issue Oct 24, 2022 Discussed in #194 · 4 comments · Fixed by #196
Closed

Schema validation #195

richardruiter opened this issue Oct 24, 2022 Discussed in #194 · 4 comments · Fixed by #196

Comments

@richardruiter
Copy link
Collaborator

Discussed in #194

Originally posted by richardruiter October 23, 2022
Hi, we are implementing Contract Testing and have a need for validating the mocks we create against OpenApi and XML-RPC schemas from the backend teams. This makes sure we don't make false assumptions when using a mock server.

We already have a homegrown mockserver with this principle baked in, but we need more functionality and camouflage covers it.
First I was thinking to create middleware that can be shared with multiple teams and created a successful PoC with middleware.js

However then the idea arose to make schema validation part of camouflage server.

loglevel: info
protocols:
  http:
    enable: true
    mocks_dir: "./mocks"
    port: 8080
validation:
  schemas:
    - https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json
    - https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/example2.json

In the case of OpenApi It would parse the schemas with @apidevtools/swagger-parser, validate the request with openapi-request-validator and response with `openapi-response-validator.

richardruiter added a commit to richardruiter/camouflage that referenced this issue Oct 24, 2022
richardruiter added a commit to richardruiter/camouflage that referenced this issue Oct 25, 2022
richardruiter added a commit to richardruiter/camouflage that referenced this issue Oct 25, 2022
richardruiter added a commit to richardruiter/camouflage that referenced this issue Oct 25, 2022
shubhendumadhukar pushed a commit that referenced this issue Oct 25, 2022
* feat: implemented initial version of schema validation #195

* chore: tweaks after review #195

* doc: added a validation section in the docs #195

* doc: added a validation section in the docs #195
Camouflage Issue Tracker automation moved this from To do to Closed Oct 25, 2022
shubhendumadhukar added a commit that referenced this issue Oct 25, 2022
* fix: move @types/js-yaml to dev deps

* fix: upgrade convert-csv-to-json

* deps: bump express to 4.18.1

* deps: bump fs-extra to latest

* deps: bump logform

* deps: bump moment

* deps: bump node-cron

* deps: bump pg

* fix: pass grpc metadata to helpers. Closes #189

* fix: generic parsing of express requests to string

* feat: implemented initial version of schema validation. Closes #195 (#196)

* feat: implemented initial version of schema validation #195

* chore: tweaks after review #195

* doc: added a validation section in the docs #195

* doc: added a validation section in the docs #195

* fix/ignore lint errors

Co-authored-by: Richard Ruiter <richard@inorm.nl>
@github-actions
Copy link

🎉 This issue has been resolved in version 0.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@richardruiter
Copy link
Collaborator Author

Will you also update the documentation? @shubhendumadhukar

@shubhendumadhukar
Copy link
Contributor

Oh my bad. I forgot that wasn't automated :) On it.

@github-actions
Copy link

🎉 This issue has been resolved in version 0.13.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants