On Sat, Sep 15, 2018 at 3:49 PM Hasunie Adikari <[email protected]> wrote:
> I have implemented the JSON schema validator [1][2] for APIM 2.6 and > planned to release it as an update. We have provided a per API > level option to enable the schema validator at the API design phase. We > keep an RXT field to determine if the JSON schema validation is enabled > or not for a particular API. Please find the documentation [3] of JSON schema > validator for APIM 2.6. > Please note that we were unable to merge this PR and it will not available with 2.6.0 GA release. Like mentioned it comes as update. > > We have also evaluated the validator mediator to check the feasibility of > fulfilling this requirement. IMO it is extremely hard to implement a > perfect validator which validates all the resource paths against the > schemas which are defined in the swagger definition. Thus, we have > developed our own implementation using a class mediator. > > @Shalika > As I have understood from the mail, you have come up with two possible > solutions to validate the request/response messages. When it comes to the > third-party library option, I have experienced some limitations with the > Everit library. However, it was the best viable option among other > libraries such as swagger inflector, Atlassian JSON schema validator, and the > java json tool schema validator. Please find the documentation for the > library evaluation [4] we did. > > Your second option might be a good initiative for the future adoptions. If > we can create our own implementation, it will produce a well defined and > flexible validator rather than doing unnecessary coding in order to avoid > third-party library limitations. > +1. In future even if ballerina core changes syntax will remain unchanged. So its good to start ballerina based development at this stage rather relying on external library. Thanks, sanjeewa. > > [1] [Architecture] [APIM] Json Schema Validation > [2] Invitation: Design Review - Json Schema Validation > [3] > https://docs.google.com/document/d/14AYpwVtRMpe2-KbFILRqRzFA-_Gt7nlHZCCCPzs0jw0/edit?usp=sharing > [4] > https://docs.google.com/document/d/1rYBXD3j_ql06ayN2G-Z_W1liJRTOIknuCrTZqSEUyho/edit?usp=sharing > > Regards, > Hasunie > > > On Fri, Sep 14, 2018 at 10:42 PM, Firzhan Naqash <[email protected]> wrote: > >> Hi Shalika, >> >> This particular validation functionality has been partially implemented >> (Without UI support) across various customer implementations. >> >> However, before implementing this feature, we should be able to consider >> having options to use JSON schema validation options at the resource level >> or on a global level. >> >> I have already done a custom handler implementation for JSON validation >> by using the json*-schema-validator *library which is being used with >> the EI's Validator mediator. AFAIK Lahiru implemented a comprehensive JSON >> schema validation library. >> >> Regards, >> Firzhan >> >> >> email: [email protected] >> mobile: (+94) 77 9785674 <%28%2B94%29%2071%205247551>*| >> blog: http://firzhanblogger.blogspot.com/ >> <http://firzhanblogger.blogspot.com/> <http://suhothayan.blogspot.com/>* >> *twitter: https://twitter.com/firzhan007 >> <https://twitter.com/firzhan007> | linked-in: >> **https://www.linkedin.com/in/firzhan >> <https://www.linkedin.com/in/firzhan>* >> >> >> On Fri, Sep 14, 2018 at 9:49 AM Hasunie Adikari <[email protected]> wrote: >> >>> Hi Shalika, >>> >>> Could you please elaborate more on how are we planning to store the >>> swagger definition in the API Gateway runtime? >>> >>> Regards, >>> Hasunie >>> >>> On Fri, Sep 14, 2018 at 3:33 PM, Shalki Wenushika <[email protected]> >>> wrote: >>> >>>> Hi All, >>>> >>>> Problem >>>> >>>> >>>> - >>>> >>>> Current microgateway version does not have an approach to validate >>>> requests/responses. >>>> - >>>> >>>> Validating request/response based on a predefined API schema is >>>> helpful to ensure whether the user have sent the request >>>> according to the schema and also to ensure whether the back-end have >>>> sent >>>> the correct response to the request. >>>> >>>> Solution >>>> >>>> >>>> - >>>> >>>> Store the swagger definition within gateway runtime. >>>> - >>>> >>>> When a user sends a request to the microgateway, validate the >>>> request using the swagger file. >>>> - >>>> >>>> If valid, send the request to the back-end or otherwise send an >>>> error message to the user. >>>> - >>>> >>>> And when the back-end sends response to the request, validate the >>>> response using the swagger file. >>>> - >>>> >>>> If valid, send the response to the user or otherwise send an error >>>> message. >>>> >>>> >>>> Implementation >>>> >>>> >>>> - >>>> >>>> Two solutions exist for this problem. >>>> >>>> 01. First solution is to validate request/response using everit JSON >>>> schema validator. >>>> >>>> 02. Implement a request/response validator in Ballerina. >>>> >>>> For that swagger-model-validator for Node.js can be convert in to >>>> Ballerina. >>>> >>>> >>>> >>>> Fig 1: Validating a request >>>> >>>> Fig 2: Validating >>>> a response >>>> >>>> >>>> Thank you! >>>> >>>> -- >>>> >>>> *Shalki Wenushika* >>>> *Software engineering Intern* >>>> WSO2 (University of Moratuwa) >>>> *mobile *: *+94 716792399* | *email *: >>>> <http://c.content.wso2.com/signatures/wso2-signature-general.png> >>>> [email protected] >>>> >>>> >>>> >>>> >>> >>> >>> -- >>> *Hasunie Adikari* >>> Senior Software Engineer >>> WSO2 Inc.; http://wso2.com >>> lean.enterprise.middleware >>> blog http://hasuniea.blogspot.com | https://medium.com/@Hasunie/ >>> Mobile:+94713095876 >>> >>> _______________________________________________ >>> Architecture mailing list >>> [email protected] >>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture >>> >> >> _______________________________________________ >> Architecture mailing list >> [email protected] >> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture >> >> > > > -- > *Hasunie Adikari* > Senior Software Engineer > WSO2 Inc.; http://wso2.com > lean.enterprise.middleware > blog http://hasuniea.blogspot.com | https://medium.com/@Hasunie/ > Mobile:+94713095876 > > _______________________________________________ > Architecture mailing list > [email protected] > https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture > -- *Sanjeewa Malalgoda* Software Architect | Associate Director, Engineering WSO2 Inc. (m) +94 712933253 | (e) [email protected] GET INTEGRATION AGILE <https://wso2.com/signature> Integration Agility for Digitally Driven Business
_______________________________________________ Architecture mailing list [email protected] https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
