MCPcopy Create free account
hub / github.com/a-h/rest / NewAPI

Function NewAPI

api.go:23–36  ·  view source on GitHub ↗

NewAPI creates a new API from the router.

(name string, opts ...APIOpts)

Source from the content-addressed store, hash-verified

21
22// NewAPI creates a new API from the router.
23func NewAPI(name string, opts ...APIOpts) *API {
24 api := &API{
25 Name: name,
26 KnownTypes: defaultKnownTypes,
27 Routes: make(map[Pattern]MethodToRoute),
28 // map of model name to schema.
29 models: make(map[string]*openapi3.Schema),
30 comments: make(map[string]map[string]string),
31 }
32 for _, o := range opts {
33 o(api)
34 }
35 return api
36}
37
38var defaultKnownTypes = map[reflect.Type]openapi3.Schema{
39 reflect.TypeOf(time.Time{}): *openapi3.NewDateTimeSchema(),

Callers 5

TestMergeFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
TestSchemaFunction · 0.85

Calls 1

oFunction · 0.50

Tested by 2

TestMergeFunction · 0.74
TestSchemaFunction · 0.68