mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-08 03:54:18 +00:00
Add codegen placeholders
This commit is contained in:
parent
433253a27b
commit
0477fd5030
@ -9,6 +9,7 @@ import (
|
|||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/textproto"
|
"net/textproto"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -267,6 +268,8 @@ func handleOpObj(entryWithSource *EntryWithSource, pathObj *openapi.PathObj) (*o
|
|||||||
|
|
||||||
setSampleID(&opObj.Extensions, entryWithSource.Id)
|
setSampleID(&opObj.Extensions, entryWithSource.Id)
|
||||||
|
|
||||||
|
setCodegenPlaceholders(opObj)
|
||||||
|
|
||||||
return opObj, nil
|
return opObj, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,3 +743,20 @@ func getOpObj(pathObj *openapi.PathObj, method string, createIfNone bool) (*open
|
|||||||
|
|
||||||
return *op, isMissing, nil
|
return *op, isMissing, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setCodegenPlaceholders(obj *openapi.Operation) {
|
||||||
|
langsStr := os.Getenv("MIZU_CODEGEN_PLACEHOLDERS")
|
||||||
|
if langsStr != "" {
|
||||||
|
placeholders := make([]map[string]string, 0)
|
||||||
|
for _, lang := range strings.Split(langsStr, ",") {
|
||||||
|
item := make(map[string]string)
|
||||||
|
item["lang"] = lang
|
||||||
|
item["source"] = ""
|
||||||
|
placeholders = append(placeholders, item)
|
||||||
|
}
|
||||||
|
err := obj.SetExtension("x-codeSamples", placeholders)
|
||||||
|
if err != nil {
|
||||||
|
logger.Log.Warningf("Failed to set codegen extension: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user