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: implemented initial version of schema validation #195 #196

Merged
merged 5 commits into from
Oct 25, 2022

Conversation

richardruiter
Copy link
Collaborator

@richardruiter richardruiter commented Oct 24, 2022

Description

Please include a summary of the change and which issue is fixed.

Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #195

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Test Configuration:

  • OS: OSX
  • Node version: 18.4.0
  • NPM Version: 8.12.1

Checklist:

  • My code follows the guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • This does not break any existing functionalities
  • Any dependent changes have been merged and published in downstream modules

@richardruiter
Copy link
Collaborator Author

I made changes to the HttpParser that I'm insecure about. I needed to postpone sending a status and/or body in order to validate it. Need guidance to see if I don't break anything.

@shubhendumadhukar
Copy link
Contributor

Changes look good. Some modification suggestions in HttpParser:

  • Redundant reassignments of status code

https://github.com/richardruiter/camouflage/blob/082473b24c3fd8e60ef034bae6a56a7e8ea9f717/src/parser/HttpParser.ts#L91

https://github.com/richardruiter/camouflage/blob/082473b24c3fd8e60ef034bae6a56a7e8ea9f717/src/parser/HttpParser.ts#L169

https://github.com/richardruiter/camouflage/blob/082473b24c3fd8e60ef034bae6a56a7e8ea9f717/src/parser/HttpParser.ts#L187

First two instances (Line 91 and 169 can be removed), whereas 3rd instance can be modified from response.status = codeResponse["status"] || this.res.statusCode; to response.status = codeResponse["status"];

  • Finally we should append headers to the response object, incase validations need to carried out on headers as well. We can add response.headers[headerKey] = headerValue; after following line

https://github.com/richardruiter/camouflage/blob/082473b24c3fd8e60ef034bae6a56a7e8ea9f717/src/parser/HttpParser.ts#L160

@richardruiter
Copy link
Collaborator Author

Added docs. Can we merge it?

@richardruiter richardruiter reopened this Oct 25, 2022
@shubhendumadhukar shubhendumadhukar merged commit f6f7601 into testinggospels:develop Oct 25, 2022
shubhendumadhukar added a commit that referenced this pull request 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 PR is included 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
None yet
Development

Successfully merging this pull request may close these issues.

Schema validation
2 participants