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

Function main

examples/petstore-expanded/echo/petstore.go:19–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17)
18
19func main() {
20 port := flag.String("port", "8080", "Port for test HTTP server")
21 flag.Parse()
22
23 swagger, err := api.GetSpec()
24 if err != nil {
25 fmt.Fprintf(os.Stderr, "Error loading swagger spec\n: %s", err)
26 os.Exit(1)
27 }
28
29 // Clear out the servers array in the swagger spec, that skips validating
30 // that server names match. We don't know how this thing will be run.
31 swagger.Servers = nil
32
33 // Create an instance of our handler which satisfies the generated interface
34 petStore := api.NewPetStore()
35
36 // This is how you set up a basic Echo router
37 e := echo.New()
38 // Use our validation middleware to check all requests against the
39 // OpenAPI schema.
40 e.Use(middleware.OapiRequestValidator(swagger))
41
42 // We now register our petStore above as the handler for the interface
43 api.RegisterHandlers(e, petStore)
44
45 // And we serve HTTP until the world ends.
46 e.Logger.Fatal(e.Start(net.JoinHostPort("0.0.0.0", *port)))
47}

Callers

nothing calls this directly

Calls 4

GetSpecFunction · 0.92
NewPetStoreFunction · 0.92
RegisterHandlersFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected