Image for post
Image for post

Exposing API DevPortals using Go-Swagger

Recently we had the Brazil's Central Banking publishing the regulation about OpenBanking. By October 2021, the expected 4 adoption milestones/phases must be ready. Lot's of good things ahead! One of the greatest tools that we added as part of our implementation framework to solve some challenges on this is actually Go-Swagger. In this post, I will show how to expose an astonishing API DevPortals using that tool

Installing Go-Swagger

Exposing a DevPortal from existing Swagger/OAS

We used a Open API Spec file from a Bank from Mexico for that example.

If you type in the command line just the command swagger, you will see several options, in order to expose de DevPortal you can basically to use the following command (same folder where you saved the api.json file) :

The default API Docs will be exposed via this URL: http://localhost:62482/docs, see the following images:

Image for post
Image for post
DevPortal using ReDoc UI

Using Redoc and incrementing some extra properties, you can add your log, more information and etc. For the Golang ecosystem, I do recommend using Hugo as an offline/static CMS if you have to go further in the Documentation and Developer Experience.

If for some reason, you prefer the standard Swagger-UI, you can just use this command: swagger serve api.json — flavor=swagger , we use the parameter flavor to identity the API Doc renderer. For more configurations execute this command: swagger serve — help

Image for post
Image for post


Another great aspect of investing in great API's contracts is to use tools like 42Crunch, which acts as an API Firewall(Scanning, Auditing, etc) helping you to discover breaches and potential critical security issues when you are exposing APIs.

Written by

Just a dad, husband, and an Old-School Brazilian Jiu-Jitsu Black-belt. Skalena Founder, former WSO2, MuleSoft, Oracle, RedHat, Sun, Borland

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store