I have sample Swagger doc inside the spec file i have 100 different endpoints i need to fetch one end point need some suggestions please help me on this.
@Siddharth Barahalikar @Dino @Dino-at-Google @Sai Saran Vaidyanathan
i need to fetch one end point
I don't know how to answer this question. Maybe you could elaborate a little more on your requirements here ? Maybe give an example?
swagger.txtThanks for replying @Dino-at-Google
Please find the attached swagger doc I want to fetch path (/basicauth) using javascript in the attached swagger.
Hi, if I understood you correctly, you want read the content from body response, right? If yes, you can search for any string using search function, https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/String/search, it will give you an answer like true/false. If you want just check if exist or not the endpoint, it should works for you.
Cleison Melo
Thanks for your suggestion @Cleison Melo
In the above case, I need to fetch one of the endpoint data like below I can describe.
var res={ //Total swagger file here i keep } var paths=res.paths./basicauth; document.write(JSON.stringify(paths));
Hi @Dino-at-Google please help me on this senario it will be helpfull for my development.
Hello,
You can use the same as below:
var res={ //Total swagger file here i keep } var paths=res.paths["/basicauth"]; //since this contains a slash, better to use [] notation context.setVariable("response.content", JSON.stringify(paths))
response.content is a special Apigee variable, that you can set to send any custom response
context.setVariable(var, value) is a special function within the JavaScript policy, to set the value of any writable flow variable.
Regards,
Girish
Thanks for your reply @Girish Gajria, The above scenario when I was giving
//Inside the spec file and inside the "paths" i have "/basicauth/api" When i use var paths=res.paths["/basicauth/api"];//In the oucome i am getting only [baicauth] How can i resolve that issue. //Sample code "paths": { "/basicauth/api": { "post": { ///////// } } } //Outcome { "paths":{ "post":{ "tags":["basicauth"], "description":"Get access token.\n", ///////////// //////////// } } } //Need to print "/basicauth/api" also get as outcome.
Could you please help me with this scenario.
Regards,
Vishnu.