new module:ExpressMiddleware(configRaw)
Express router integrator
Parameters:
Name | Type | Description |
---|---|---|
configRaw | ConfigOptions |
Members
(static) this.config :ExpressMiddlewareParsedConfig
Parsed configuration
Type:
- ExpressMiddlewareParsedConfig
(protected) endpoints :Map.<string, function()>
operation controllers, being built internally
Type:
- Map.<string, function()>
router :Express.Router
Express.Router object to be attached to the express api server
Type:
- Express.
Router
Methods
setupMiddleware() → {Express.Router}
Setup router (returns the router to attach to the express app)
Returns:
- Type:
- Express.
Router
Type Definitions
ConfigOptions
Options used when creating the `ExpressMiddleware`.
Type:
Properties- object
Name | Type | Description |
---|---|---|
definition | object | | The OpenAPI 3.0 definition location (location string for file type of json/yaml) or structure (json/yaml) |
controllers | Map.<String, function()> | The controllers location or structure |
securitySchemes | Map.<String, function()> | The security schemes validation functions |
enforceResponseValidation | boolean | Flag for failing invalid responses (that don't match the endpoint's responseScheme) |
new ExpressMiddleware({
definition: './openapi-sample-v3.yaml',
controllers: {
greetingGet: (req, res, next) => { res.send({ ok: true }) }
},
securitySchemes: {
basicAuth: (authHeaderValue) => {},
},
enforceResponseValidation: false
})
ExpressMiddlewareParsedConfig
Type:
Properties- object
Name | Type | Description |
---|---|---|
definition | object | openapi json definition |
controllers | Map.<string, function()> | controller functions (operationId as key, and controller function as function) |
securitySchemes | Object | openapi securitySchemes |
enforceResponseValidation | boolean | flag for failing invalid responses (that don't match the endpoint's responseScheme) |