{ 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
    • 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 /
  • Developer Portal (Drupal-based) /
avatar image
1
Question by tpearson · Oct 22, 2015 at 10:01 PM · 623 Views api proxyOpenAPI - Swagger Specjava calloutswagger-tools

How to create client libraries for my Apigee proxies from my swagger spec

We have a detailed swagger spec for our APIs at https://github.com/amadeus-travel-innovation-sandb... We'd like to use this to provide API libraries for our clients from our developer portal.

Other than the Generate Client dropdown menu at editor.swagger.io, I can't find any public services that host swagger-codegen; the project that can generate client libraries for various programming languages from a swagger spec. Does Apigee host a swagger-codegen service for clients to use?

I thought it might also be possible to run this as a Java Callout in a new API proxy running entirely on Apigee, but looking at the cookbooks, I realized this might be quite difficult to do. If such a service doesn't do this, is it possible to do it this way?

Comment
Add comment
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

Close

1 Answer

  • Sort: 
avatar image
0

Answer by tpearson · Nov 04, 2015 at 10:26 PM

OK, turns out that generator.swagger.io hosts a public service to generate client API libraries from your Swagger spec. Unfortunately, it uses POST to get the URL of the Swagger document, so it's not that easy to embed in a HTML page. Fortunately, you can build an API proxy quite easily to make it build a variety of clients for your Swagger spec.

  1. Make a new API proxy that targets https://generator.swagger.io/api/gen/clients
  2. Add an Assign Message policy to your Request Preflow that does the following
    <Set>
            <Verb>POST</Verb>
            <Headers>
                <Header name="Content-Type">application/json</Header>
            </Headers>
            <Payload>\{"swaggerUrl":"https://link.to/your-swagger-spec.yml"}</Payload>
        </Set>
  3. Add a Javascript policy to your Response Postflow that does this
    var content = context.getVariable('response.content');
    var body = JSON.parse(content);
    context.setVariable('response.header.Location', "" + body.link);
    context.setVariable('response.status.code', 303);

And you're all done. When you go to http://you.apigee.net/proxy-name-from-step-1/language it will give a redirect back to your browser to download the client library generated from your swagger spec in the language you put in the URL.

Enjoy!

Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

28 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

Related Questions

Dev Portal SmartDocs/Swagger Public access 1 Answer

swagger/openapi import failing on api proxy,swagger/openapi import failing 1 Answer

Does Apigee Edge Support Swagger Specs? 4 Answers

How to download OpenAPI Specification from Developer Portal 2 Answers

limitations of java code in a Java Callout policy in Apigee 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
© 2019 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
  • 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
  • Members
  • Badges