From 4d061bf197a29403b758479db132435668673828 Mon Sep 17 00:00:00 2001 From: Alex Kataev Date: Sun, 13 Nov 2022 17:06:14 +0500 Subject: [PATCH] add update script --- README.md | 37 +++++++++++++++++++++++++++++++++++++ swagger-ui-dist.sh | 15 +++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 swagger-ui-dist.sh diff --git a/README.md b/README.md index 44ffa95..e0bab7a 100644 --- a/README.md +++ b/README.md @@ -1 +1,38 @@ # swagfs + +## Swagger-UI + +Update dist files in `files/dist/*` + +```bash +./swagger-ui-dist.sh 4.15.5 +``` + +## Example + +Use `echo` + +```golang +package main + +import ( + "log" + + "github.com/a-kataev/swagfs" + "github.com/labstack/echo/v4" +) + +func main() { + e := echo.New() + + cfg := &swagfs.Config{} + cfg.AddURL("https://petstore.swagger.io/v2/swagger.json", "petstore") + cfg.SetLayout("StandaloneLayout") + + e.StaticFS("/*", swagfs.FS(cfg)) + + if err := e.Start("127.0.0.1:8080"); err != nil { + log.Fatal(err) + } +} +``` diff --git a/swagger-ui-dist.sh b/swagger-ui-dist.sh new file mode 100755 index 0000000..8324dc5 --- /dev/null +++ b/swagger-ui-dist.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +version=${1:-4.15.5} + +set -x + +curl -Ls -o swagger-ui.zip "https://github.com/swagger-api/swagger-ui/archive/refs/tags/v${version}.zip" + +unzip -o swagger-ui.zip "swagger-ui-${version}/dist/*.*" -d tmp + +rm "tmp/swagger-ui-${version}/dist/swagger-initializer.js" + +cp -rf "tmp/swagger-ui-${version}/dist" files/ + +rm -rf tmp swagger-ui.zip