ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » REST API not validating incoming JSON

Post new topic  Reply to topic
 REST API not validating incoming JSON « View previous topic :: View next topic » 
Author Message
johkar
PostPosted: Tue Mar 21, 2017 11:42 am    Post subject: REST API not validating incoming JSON Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Tue Mar 21, 2017 11:55 am    Post subject: Re: REST API not validating incoming JSON Reply with quote

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
View user's profile Send private message
johkar
PostPosted: Tue Mar 21, 2017 12:05 pm    Post subject: Re: REST API not validating incoming JSON Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Tue Mar 21, 2017 12:19 pm    Post subject: Re: REST API not validating incoming JSON Reply with quote

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
View user's profile Send private message
timber
PostPosted: Tue Mar 21, 2017 1:19 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

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.
Back to top
View user's profile Send private message
johkar
PostPosted: Wed Mar 22, 2017 5:02 am    Post subject: Reply with quote

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
View user's profile Send private message
timber
PostPosted: Wed Mar 22, 2017 11:20 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

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
View user's profile Send private message
mqjeff
PostPosted: Thu Mar 23, 2017 3:37 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » REST API not validating incoming JSON
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.