module:ExpressMiddleware

new module:ExpressMiddleware(configRaw)

Express router integrator
Parameters:
NameTypeDescription
configRawConfigOptions

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:
  • object
Properties
NameTypeDescription
definitionobject | stringThe OpenAPI 3.0 definition location (location string for file type of json/yaml) or structure (json/yaml)
controllersMap.<String, function()>The controllers location or structure
securitySchemesMap.<String, function()>The security schemes validation functions
enforceResponseValidationbooleanFlag for failing invalid responses (that don't match the endpoint's responseScheme)
Example
new ExpressMiddleware({
  definition: './openapi-sample-v3.yaml',
  controllers: {
    greetingGet: (req, res, next) => { res.send({ ok: true }) }
  },
  securitySchemes: {
    basicAuth: (authHeaderValue) => {},
  },
  enforceResponseValidation: false
})

ExpressMiddlewareParsedConfig

Type:
  • object
Properties
NameTypeDescription
definitionobjectopenapi json definition
controllersMap.<string, function()>controller functions (operationId as key, and controller function as function)
securitySchemesObjectopenapi securitySchemes
enforceResponseValidationbooleanflag for failing invalid responses (that don't match the endpoint's responseScheme)