github.com/djarvur/go-swagger@v0.18.0/examples/tutorials/todo-list/dynamic-1/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  )
    10  
    11  func init() {
    12  	loads.AddLoader(fmts.YAMLMatcher, fmts.YAMLDoc)
    13  }
    14  
    15  func main() {
    16  	if len(os.Args) == 1 {
    17  		log.Fatalln("this command requires the swagger spec as argument")
    18  	}
    19  	log.Printf("loading %q as contract for the server", os.Args[1])
    20  
    21  	specDoc, err := loads.Spec(os.Args[1])
    22  	if err != nil {
    23  		log.Fatalln(err)
    24  	}
    25  
    26  	log.Println("Would be serving:", specDoc.Spec().Info.Title)
    27  }