The project is in a healthy, maintained state
Import endpoints from OpenAPI spec to KrakenD endpoint configuration. Supports OpenAPI v3.0
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 1.2
 Project Readme

KrakenD OpenAPI Importer

Import endpoints from OpenAPI spec to KrakenD endpoint configuration. Supports OpenAPI v3.0 and up.

Ruby Gem Version

Installation

Execute

gem install krakend-openapi-importer

Usage

Import OpenAPI spec from SPEC file. Writes KrakenD config to output.json

krakend-openapi-importer import SPEC -c CONFIG
Options:
-c, [--config=CONFIG]  # Path to importer.yaml config

Configuration

Example config

---
format: "json" # can be 'json' or 'yaml', optional, defaults to 'json'
pretty: false # make JSON pretty, optional, defaults to false
output: "output.json" # output file name, optional, defaults to 'output.json'
default_roles: ["guest"] # fall back roles for auth validator plugin when operation 'x-jwt-roles` are not specified, optional
defaults:
  base:
    name: Example application
  endpoint:
    output_encoding: "no-op" # act like a no-op proxy
    input_headers: ["*"]
    input_query_strings: ["*"]
  backend:
    - encoding: "no-op"
      host: [ "https://example.org" ]
  plugins:
    auth_validator:
      alg: "RS256"
      jwk_url: "https://KEYCLOAK_URL/auth/realms/master/protocol/openid-connect/certs"
      cache: false
      operation_debug: true
      roles_key: "realm_access.roles"
      roles_key_is_nested: true
      scopes_key: scopes # only needed when defining scopes in OpenAPI spec

Auth Validator plugin configuration

  • You can specify custom roles for each OpenAPI operation using the x-jwt-roles operation extension. If no x-jwt-roles are provided for an operation, the plugin will fall back to the default roles defined in the default_roles configuration.
  • Importer supports openIdConnect and oauth2 security schemes defined using Security Requirement Objects.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/denblackstache/krakend-openapi-importer.

License

The gem is available as open source under the terms of the MIT License.