diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-28 16:19:52 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-28 17:12:12 +0900 |
| commit | 0dd94cbea6e857896c46d17493725f97369d99f9 (patch) | |
| tree | 8d324c16eecfb3fb510488c9339e9c4c4a0692ce /backend/api/workaround.go | |
| parent | d24c19963f8d0d17d6db93b418cc9d644693c868 (diff) | |
| download | phperkaigi-2025-albatross-0dd94cbea6e857896c46d17493725f97369d99f9.tar.gz phperkaigi-2025-albatross-0dd94cbea6e857896c46d17493725f97369d99f9.tar.zst phperkaigi-2025-albatross-0dd94cbea6e857896c46d17493725f97369d99f9.zip | |
refactor: remove /api/ prefix from openapi.yaml
Diffstat (limited to 'backend/api/workaround.go')
| -rw-r--r-- | backend/api/workaround.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/backend/api/workaround.go b/backend/api/workaround.go new file mode 100644 index 0000000..a3c47d7 --- /dev/null +++ b/backend/api/workaround.go @@ -0,0 +1,22 @@ +package api + +import ( + "github.com/getkin/kin-openapi/openapi3" +) + +// Work-around for this issue: +// https://stackoverflow.com/questions/70087465/echo-groups-not-working-with-openapi-generated-code-using-oapi-codegen +func GetSwaggerWithPrefix(prefix string) (*openapi3.T, error) { + spec, err := GetSwagger() + if err != nil { + return nil, err + } + + var prefixedPaths openapi3.Paths = openapi3.Paths{} + for key, value := range spec.Paths.Map() { + prefixedPaths.Set(prefix+key, value) + } + + spec.Paths = &prefixedPaths + return spec, nil +} |
