REST API: simplify json response by removing result wrapper (BC) (#22299)
This commit is contained in:
parent
db824ad42d
commit
d541dfa4fa
28 changed files with 423 additions and 293 deletions
28
cmd/openapi/openapi.go
Normal file
28
cmd/openapi/openapi.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
)
|
||||
|
||||
func main() {
|
||||
doc, err := openapi3.NewLoader().LoadFromFile(os.Args[1])
|
||||
if err != nil {
|
||||
log.Fatal("failed to load OpenAPI spec:", err)
|
||||
}
|
||||
|
||||
// omit servers
|
||||
doc.Servers = nil
|
||||
|
||||
b, err := json.MarshalIndent(doc, "", " ")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(os.Args[2], b, 0o644); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue