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

Fix incompatibility with the latest json schema v4 updates before updating jsen #86

Open
TysonAndre opened this issue Mar 12, 2020 · 1 comment

Comments

@TysonAndre
Copy link
Contributor

Related to https://github.com/bugventure/jsen/issues/52

This will be a breaking change, and require changes to monocle-api and the applications using it.

diff --git a/lib/RequestRouter.js b/lib/RequestRouter.js
index e981568..822bcf4 100644
--- a/lib/RequestRouter.js
+++ b/lib/RequestRouter.js
@@ -209,6 +209,10 @@ function cleanParamKey(key) {
 
 function castParam(key, value, type) {
     var hasTypeError = false;
+    if (!type || !type.indexOf) {
+        // Type is not string or array?
+        return value;
+    }
 
     if (type.indexOf('boolean') !== -1) {
         switch(value) {
diff --git a/test/lib/Router_test.js b/test/lib/Router_test.js
index 9bae87f..7468d34 100644
--- a/test/lib/Router_test.js
+++ b/test/lib/Router_test.js
@@ -805,7 +805,7 @@ describe('API Router', function() {
                     this.meeSchema = {
                         type: 'object',
                         properties: {
-                            floatParam: {type: 'float'}
+                            floatParam: {type: 'number'}
                         }
                     };
 
@@ -1712,7 +1712,7 @@ describe('API Router', function() {
                             }
                         },
                         param4: {type: 'integer'},
-                        param5: {type: 'date-time'}
+                        param5: {format: 'date-time'}
                     }
                 };
                 this.postObjSpy = sinon.spy(function(request, connection) {
@TysonAndre
Copy link
Contributor Author

Noticed while working on #85

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

No branches or pull requests

1 participant