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?
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.
<Set> <Verb>POST</Verb> <Headers> <Header name="Content-Type">application/json</Header> </Headers> <Payload>\{"swaggerUrl":"https://link.to/your-swagger-spec.yml"}</Payload> </Set>
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!
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