MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / NewIrisPetServer

Function NewIrisPetServer

examples/petstore-expanded/iris/petstore.go:19–39  ·  view source on GitHub ↗
(petStore *api.PetStore, port int)

Source from the content-addressed store, hash-verified

17)
18
19func NewIrisPetServer(petStore *api.PetStore, port int) *iris.Application {
20 swagger, err := api.GetSpec()
21 if err != nil {
22 fmt.Fprintf(os.Stderr, "Error loading swagger spec\n: %s", err)
23 os.Exit(1)
24 }
25
26 // Clear out the servers array in the swagger spec, that skips validating
27 // that server names match. We don't know how this thing will be run.
28 swagger.Servers = nil
29
30 i := iris.Default()
31
32 // Use our validation middleware to check all requests against the
33 // OpenAPI schema.
34 i.Use(middleware.OapiRequestValidator(swagger))
35
36 api.RegisterHandlers(i, petStore)
37
38 return i
39}
40
41func main() {
42 port := flag.Int("port", 8080, "Port for test HTTP server")

Callers 2

mainFunction · 0.85
TestPetStoreFunction · 0.85

Calls 2

GetSpecFunction · 0.92
RegisterHandlersFunction · 0.92

Tested by 1

TestPetStoreFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…