Anyone has integrated Swagger UI with Kraken D? In the community version there is no such option available

1.8k views Asked by At

As the krakend.json is not of the type which swagger understands.Following error occurs:

Error: Document must be valid OpenAPI 3.0.0 definition

Is there any alternate way to generate documentation for krakenD

1

There are 1 answers

0
Milan Jaros On

Generating both KrakenD configuration and OpenAPI documentation is possible, but...

  • You should precisely define your use case:
    • Do you want to generate krakend.json config from OpenAPI just as no-op proxy? (see an example script)
    • Are you willing to adopt another (custom) format? (see openapi2krakend)
    • Do you want to generate OpenAPI documentation from KrakenD config? If so, do you need just a list of endpoints or do you want also to have defined descriptions, examples and types (!) in one file?
  • You should (at least try to) write the script to generate the configuration by yourself to suit your needs.
  • Consider a usage of KrakenD Studio that has the OpenAPI generator plugin.

It can look like a good idea, but the devil is in the details and you should analyse your requirements because these two files have totally different purposes. I can only suggest you write such a transformation script (as I did) which should be like "5 minutes of work" and then go to the deep.


Edit: We have selected a subset of KrakendD features and implemented our own configuration generator (from OAS). We use tags with a custom route-to/ prefix for metadata, a definition could look like this:

  /coupons/{id}:
    get:
      tags:
        - Coupons
        - route-to/path=/coupons/{id}/detail
        - route-to/backend=GET|http://coupons.content
        - route-to/flags=jwt_validation