Import Swagger (Open API) document to create API in Kong

We do contract first API creation starting with creating the API spec using the swagger editor, it would be great if we could import that directly into Kong to create the API and also then display all our APIs in a catalogue as a central repository of all active API’s in our environment. It would also be great if Kong could use the Examples specification from swagger to automatically implement simple api mocks, this would allow clients to start coding against the api while it is still being developed.

Thank you
Gregg

7 Likes

Hi,

This has indeed been suggested many many times over the past few years. See:

https://github.com/Kong/kong/search?q=swagger&type=Issues&utf8=✓

We do not have anything in particular to announce at this time regarding OpenAPI support regarding Kong CE. Pull requests welcome!

Yes I added a comment to one of those and was asked by someone from Kong to put the feature request here. So I hope that means they are starting to think about it again.

+1 to this feature request, i’m gonna go +1 it in github now too.

1 Like

I am shocked , that this feature isnt available - very basic. :frowning:

Hi @thibaultcha, is this feature on your roadmap? It could be a nice use case for plugin development ;).

I agree to this comment. AWS API gateway has this feature since a couple of years now. We are being forced to develop something in-house to meet this gap. It would be good for Kong to put this on roadmap.

Hi Everyone,

Could someone please let us know if import swagger (i.e. (Open API) document to create API in Kong) is available in Kong CE.

if it is available, please help in providing the documentation for the same Or if there is any plugin available, please let us know.

Regards,
Pradeep

1 Like

I would like to recommend that my company use Kong CE if it can somehow support definition of APIs through OpenAPI. Is there a way?

Hi, there’s a way with 3 steps.

  1. Create a function: openapi2kong
    This should map the data from an openapi spec file to Kong services configurations. Then, just use Kong API to load your new services.
  2. Publish your package at npm and come back here
  3. Wait Kong open source that Gelato module. We will use your package meanwhile and maybe forever

For reference; this is available as a commandline utility in Kong Enterprise 0.36-x. Can be invoked as openapi2kong from the commandline.

1 Like

Thanks @Tieske for the reference

Another update: Also available as a feature in Kong Studio (version 1.2) that will most likely replace “openapi2kong” cli.

1 Like

Is Kong Studio part of the enterprise edition?

Hi @Ahmed_Samir. Yes, Kong Studio is part of Enterprise. Kong Studio is Insomnia Designer, which is OSS, plus the Kong integration plugins that generate Kong config from Spec files and deploys Specs to the Kong Dev Portal along with technical support.

Maybe this might help? https://www.npmjs.com/package/openapi-2-kong

Is openapi-2-kong open source project? I cannot find it on github and there’s no license information on npmjs for this package. It looks it’s something internally used by Insomnia?

@morningspace : If you download the NPM package and inspect the files, you will find an MIT license:

$ npm pack openapi-2-kong
$ tar xzf openapi-2-kong-2.2.24.tgz
$ cat package/LICENSE
MIT License

Copyright (c) Insomnia REST Client

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

The original source code (JavaScript/Flow) is located in Insomnia repository: https://github.com/Kong/insomnia/tree/develop/packages/openapi-2-kong

I have forked the openapi-2-kong package and rewritten it in TypeScript here: https://github.com/mikaello/openapi-2-kong

I created a PR to Insomnia project to possibly improve the lack of metadata information: https://github.com/Kong/insomnia/pull/2802

That’s cool. Thanks @Michael_Johansen.