Read JSON file (resources/oas/swagger-1.json) using Javascript Policy

I want to read swagger-1.json which is there in resources/oas folder in Javascript policy. Is there any possibility to do that?

My Intention is to write OASValidation using javascript Policy. For that I saw an example which makes use of swagger-1.js (var oas = <Swagger Spec>) which contains actual oas spec. But now as per my requirement I wanted to change swagger-1.js to swagge-1.json

Solved Solved
0 5 942
2 ACCEPTED SOLUTIONS

Not applicable

you can add the file in javascript <IncludeURL> tag inside a function.

You can call that function in the main javascript and validate it as required.

ref: https://stackoverflow.com/questions/55945687/is-there-a-way-to-retrieve-all-the-parameterseven-neste...

View solution in original post

Not applicable

you can use java callout also.

View solution in original post

5 REPLIES 5

Not applicable

you can add the file in javascript <IncludeURL> tag inside a function.

You can call that function in the main javascript and validate it as required.

ref: https://stackoverflow.com/questions/55945687/is-there-a-way-to-retrieve-all-the-parameterseven-neste...

Thanks for the response sir.

  1. I saw the link you shared, it is taking json in the request.
  2. <IncludeURL> tag is not taking .json file


But my requirement is,

.json file will be there in the resources folder. I need to read that .json and put it in javascript variable

you have to add the json file inside a javascript function and put the javascript in include tag.

Could you please provide a sample code for that

Not applicable

you can use java callout also.