KrakenD OpenAPI Importer
Import endpoints from OpenAPI spec to KrakenD endpoint configuration. Supports OpenAPI v3.0 and up.
- In case you have a different version of OpenAPI you can use https://github.com/LucyBot-Inc/api-spec-converter to convert to the v3.0.
- Supported Ruby versions: 2.7 and up
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 CONFIGOptions:
-c, [--config=CONFIG] # Path to importer.yaml configConfiguration
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 specAuth Validator plugin configuration
- You can specify custom roles for each OpenAPI operation using the
x-jwt-rolesoperation extension. If nox-jwt-rolesare provided for an operation, the plugin will fall back to the default roles defined in thedefault_rolesconfiguration. - Importer supports
openIdConnectandoauth2security 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.