github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/tutorials/todo-list/dynamic-setup-invalid/main.go (about) 1 package main 2 3 import ( 4 "log" 5 "os" 6 7 "github.com/go-openapi/loads" 8 "github.com/go-openapi/loads/fmts" 9 "github.com/go-openapi/runtime/middleware/untyped" 10 ) 11 12 func init() { 13 loads.AddLoader(fmts.YAMLMatcher, fmts.YAMLDoc) 14 } 15 16 func main() { 17 if len(os.Args) == 1 { 18 log.Fatalln("this command requires the swagger spec as argument") 19 } 20 log.Printf("loading %q as contract for the server", os.Args[1]) 21 22 specDoc, err := loads.Spec(os.Args[1]) 23 if err != nil { 24 log.Fatalln(err) 25 } 26 27 api := untyped.NewAPI(specDoc) 28 29 // validate the API descriptor, to ensure we don't have any unhandled operations 30 if err := api.Validate(); err != nil { 31 log.Fatalln(err) 32 } 33 log.Println("serving:", specDoc.Spec().Info.Title) 34 35 }