Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var GenCommand = &cobra.Command{ Use: "gen", Short: "generate swagger file, contain swagger.yaml, doc.go", Run: func(c *cobra.Command, args []string) { container := commandUtil.GetContainer(c.Root()) appService := container.MustMake(contract.AppKey).(contract.App) outputDir := filepath.Join(appService.BasePath(), "app", "http", "swagger") conf := &gen.Config{ SearchDir: "./app/http/", Excludes: "", OutputDir: outputDir, MainAPIFile: "swagger.go", PropNamingStrategy: "", ParseVendor: false, ParseDependency: false, ParseInternal: false, MarkdownFilesDir: "", GeneratedTime: false, } err := gen.New().Build(conf) if err != nil { fmt.Println(err) } }, }
envCommand show current envionment
View Source
var IndexCommand = &cobra.Command{ Use: "swagger", Short: "swagger operator", RunE: func(c *cobra.Command, args []string) error { if len(args) == 0 { c.Help() } return nil }, }
View Source
var ServeCommand = &cobra.Command{ Use: "serve", Short: "use gen serve", RunE: func(c *cobra.Command, args []string) error { container := commandUtil.GetContainer(c.Root()) appService := container.MustMake(contract.AppKey).(contract.App) r := gin.Default() hadeURL, err := url.Parse(address) if err != nil { return err } address := fmt.Sprintf("%s:%s", hadeURL.Hostname(), hadeURL.Port()) jsonFolder := filepath.Join(appService.BasePath(), "app", "http", "swagger") r.Static("/swagger_gen/", jsonFolder) swaggerGenUrl := ginSwagger.URL("/swagger_gen/swagger.json") r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, swaggerGenUrl)) fmt.Println("swagger success: http://" + address + "/swagger/index.html") fmt.Println("if you want to replace, remember use command: swagger gen") r.Run(address) return nil }, }
envCommand show current envionment
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.