aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/api/workaround.go
blob: a3c47d78c34b53e1cb22e15294140c9a79067f0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
}