Author |
Message
|
johkar |
Posted: Tue Mar 21, 2017 11:42 am Post subject: REST API not validating incoming JSON |
|
|
Novice
Joined: 27 Jan 2015 Posts: 16
|
IIB 10
10.0.0.6
I'm working on a REST API and I created my yaml file in http://editor.swagger.io/#!/ and it validates.
* There are no errors in the workspace after the Swagger file was imported
* All the JSON elements I marked as required in Swagger show required in the msgflow and the model looks goods.
* When I send a valid message the service works fine
* When I send a message without a required field it does not flag it as a validation error...continues down the good path.
I can't figure out why it won't validate and I'm a little confused on debugging this type of behind the scenes flow the REST API uses. There are no properties on the flow itself in the traditional sense.
I could just go back to HTTP nodes but I'd like to have the Swagger file available to consumers and have the native validation.
Any pointers on what I should try? This is my first attempt using REST API in IIB10. Thanks. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Mar 21, 2017 11:55 am Post subject: Re: REST API not validating incoming JSON |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
johkar wrote: |
Any pointers on what I should try? |
Is the node set to both complete parsing and validation for Content & Value? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
johkar |
Posted: Tue Mar 21, 2017 12:05 pm Post subject: Re: REST API not validating incoming JSON |
|
|
Novice
Joined: 27 Jan 2015 Posts: 16
|
Vitor wrote: |
johkar wrote: |
Any pointers on what I should try? |
Is the node set to both complete parsing and validation for Content & Value? |
The flow for REST APIs in IIB10 is dynamically generated so there is nothing to set that I can see. If you open up the flow with the standard editor you get a UI that shows the service and you can edit the service from it also.
If I open the flow in the default editor it is simply using standard HTTP nodes so maybe it isn't capable of validating for JSON??? That's too bad if that is the case. I was wondering why IBM didn't supply a RESTInput node on the palette that had Swagger support. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Mar 21, 2017 12:19 pm Post subject: Re: REST API not validating incoming JSON |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
johkar wrote: |
If I open the flow in the default editor it is simply using standard HTTP nodes so maybe it isn't capable of validating for JSON??? |
I can't imagine why it wouldn't be able to - it can validate other (XML, DFDL, etc.) message models so it would be an odd thing if it couldn't do that.
I'd recommend a PMR, or wait for a passing IBMer. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
timber |
Posted: Tue Mar 21, 2017 1:19 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
|
Back to top |
|
 |
johkar |
Posted: Wed Mar 22, 2017 5:02 am Post subject: |
|
|
Novice
Joined: 27 Jan 2015 Posts: 16
|
timber wrote: |
https://www.ibm.com/support/knowledgecenter/en/SSMKHH_10.0.0/com.ibm.etools.mft.doc/bc28400_.htm
In general, you cannot validate JSON. There is a thing called JSON schema, but it is not properly standardised, and is missing a lot of fairly basic features that XML schema has had for years. I suspect that's why IBM is not offering it as a feature - it would be a great PMR generator.
I'm not speaking on IBM's behalf, btw. Just speculating. |
Thanks, it appears you are right. All the key pieces are in the Swagger so hopefully it will get some traction. |
|
Back to top |
|
 |
timber |
Posted: Wed Mar 22, 2017 11:20 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
All the key pieces are in the Swagger so hopefully it will get some traction. |
All except a properly-functioning standards body for the JSON schema specification. I wouldn't hold your breath while waiting if I were you. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Mar 23, 2017 3:37 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I have found Swagger generally only good for generating a set of docs on an API, not making it possible to validate messages.
It's a subset of YAML, though - so any tools you have that can generate java code from YAML could be used to validate a JSON message *after* it's arrived off of an input node.
If you could generate something more like VisualBasic than Javo, you might have an easier time converting that to ESQL, should that be a preferences. Or just use a .NET node. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
|