{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
0
Question by vishnuvardhan kolli · Jan 20, 2020 at 06:11 PM · 217 Views node.jsapi designOpenAPI - Swagger Specswaggerswagger file

How to fetch data from existing swagger file using nodejs

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

Comment
Add comment Show 2
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Dino-at-Google ♦♦   · Jan 21, 2020 at 11:36 PM 0
Link

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?

avatar image vishnuvardhan kolli Dino-at-Google ♦♦ · Jan 23, 2020 at 10:54 AM 0
Link

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.

swagger.txt (2.2 kB)

Close

1 Answer

  • Sort: 
avatar image
0

Answer by Cleison Melo · Jan 23, 2020 at 02:27 PM

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

Comment
Add comment Show 4 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image vishnuvardhan kolli · Jan 23, 2020 at 03:54 PM 0
Link

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));


avatar image vishnuvardhan kolli vishnuvardhan kolli · Jan 24, 2020 at 03:54 PM 0
Link

Hi @Dino-at-Google please help me on this senario it will be helpfull for my development.

avatar image Girish Gajria vishnuvardhan kolli · Jan 26, 2020 at 10:10 AM 1
Link

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

avatar image vishnuvardhan kolli Girish Gajria · Jan 28, 2020 at 07:00 AM 0
Link

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.

Follow this Question

Answers Answers and Comments

116 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Adding transformation in the Apigee Edge through Node sometimes slows down the speed of loading 1 Answer

Fetch the endpoint along with definitions from the swagger file using JavaScript 1 Answer

Open API 3 for Apigee On premise 4.19.06 1 Answer

is it possible to add native(!) node.js modules in apigee Edge? 1 Answer

NodeJs app runs fine locally - but dumps when deployed to Edge 2 Answers

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges