NewAPI creates a new API from the router.
(name string, opts ...APIOpts)
| 21 | |
| 22 | // NewAPI creates a new API from the router. |
| 23 | func 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 | |
| 38 | var defaultKnownTypes = map[reflect.Type]openapi3.Schema{ |
| 39 | reflect.TypeOf(time.Time{}): *openapi3.NewDateTimeSchema(), |