GithubHelp home page GithubHelp logo

punkch / openapi2krakend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hamzaoralk/openapi2krakend

0.0 0.0 0.0 52 KB

Conversion from OpenAPI definitions to krakend configuration.

License: MIT License

Shell 5.20% Go 89.95% Makefile 2.36% Dockerfile 2.48%

openapi2krakend's Introduction

Description

Basic conversion from OpenAPI specification to Krakend config. This is extendable with custom OpenAPI attributes and more support for both krakend and openapi configurations.

Supported custom OpenAPI extensions

Example of custom extensions can be found in the ./swagger/pet-store.json

x-timeout: At top level or at method level modifies timeout for the whole api or for a single endpoint

Usage

openapi2krakend can be run before the krakend container to generate krakend.json for krakend to consume. Services can serve their swagger definitions or even from their documentation pages one can download those swagger files and convert.

Arguments

-directory: folder where swagger files live. default is swagger folder in repository.
-encoding: backend encoding for whole endpoints. default is "json".

Usage

In make file image creation and build has been declared

To build:

make build

To dockerize

make dockerize

To run with sample environment variables

make run

Deployment to Kubernetes

In deployment/deployment.yaml file you can set environment variables to "https://service-1/api-specification,https://service-2/api-specification" then image will download all the specifications supplied and merge and convert all swagger files into a single krakend configuration file.

Environment Variables for openApi2krakend

Name Description Type Default Required
ENABLE_LOGGING Enable logging plugin for KrakenD bool false no
LOG_LEVEL Log level string WARNING no
LOG_PREFIX Log prefix for filtering string [KRAKEND] no
LOG_SYSLOG Enable syslog bool true no
LOG_STDOUT Enable stdout bool true no
ENABLE_CORS Enable CORS plugin for KrakenD bool false no
ALLOWED_ORIGINS Comma seperated allowed origins, it will be used when ENABLE_CORS is true string * no
ALLOWED_METHODS Comma seperated allowed methods, it will be used when ENABLE_CORS is true string GET,HEAD,POST,PUT,DELETE,CONNECT,OPTIONS,TRACE,PATCH no
GLOBAL_TIMEOUT Sets global timeout across all endpoints string 3000ms no
ENCODING Sets default encoding. Values are json, safejson, xml, rss, string, no-op string json no
ADDITIONAL_PATHS Comma seperated set of URLs to add every swagger for additional paths string `` no
kubectl apply -f ./deployment

Contribution

Project itself quite easy to understand and maintain, and I am changing as I need it in my stack. Please feel free to contribute and open a PR if you see fit.

openapi2krakend's People

Contributors

hamzaoralk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.