ui

package
v2.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2023 License: MIT Imports: 5 Imported by: 0

README

// example 
engine := gin.Default()
// app
appFizz := fizz.NewFromEngine(engine)
appInfos := &openapi.Info{
   Title:       "Fruits Market",
   Description: `This is a sample Fruits market server.`,
   Version:     "1.0.0",
}
appFizz.GET("/app/openapi.json", nil, appFizz.OpenAPI(appInfos, "json"))

// h5
h5Fizz := fizz.NewFromEngine(engine)
h5Infos := &openapi.Info{
   Title:       "Fruits Market",
   Description: `This is a sample Fruits market server.`,
   Version:     "1.0.0",
}
h5Fizz.GET("/h5/openapi.json", nil, h5Fizz.OpenAPI(h5Infos, "json"))

// add a OpenApi UI with groups
ui.AddUIGroupHandler(engine, "/doc", ui.SwaggerUrl{
		Name: "app",
		Url:  "/app/openapi.json",
	}, ui.SwaggerUrl{
		Name: "H5",
		Url:  "/h5/openapi.json",
	})

And then you can get a api document with ui like follows

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUIGroupHandler added in v2.0.4

func AddUIGroupHandler(ginEngine gin.IRoutes, path string, groups ...SwaggerUrl)

AddUIGroupHandler adds handler that serves html for Swagger UI

func AddUIHandler

func AddUIHandler(ginEngine gin.IRoutes, path string, openApiJsonPath string)

AddUIHandler adds handler that serves html for Swagger UI

Types

type SwaggerConfig

type SwaggerConfig struct {
	ConfigUrl              string        `json:"configUrl"`
	DisplayRequestDuration bool          `json:"displayRequestDuration"`
	Oauth2RedirectUrl      string        `json:"oauth2RedirectUrl"`
	OperationsSorter       string        `json:"operationsSorter"`
	ValidatorUrl           string        `json:"validatorUrl"`
	Urls                   *[]SwaggerUrl `json:"urls"`
}

type SwaggerUrl

type SwaggerUrl struct {
	Url  string `json:"url"`
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL