Hierarchy

  • PathMiddleware

Constructors

Properties

operations: Map<string, ValidateFunction<unknown>>
validate: boolean
validatorQueue: string[]
instance: PathMiddleware

Methods

  • Parameters

    • operationId: string
    • __namedParameters: { exclude: boolean; operationObject?: { callbacks?: { [callback: string]: ReferenceObject | CallbackObject }; deprecated?: boolean; description?: string; externalDocs?: ExternalDocumentationObject; operationId?: string; parameters?: (ReferenceObject | ParameterObject)[]; requestBody?: ReferenceObject | RequestBodyObject; responses: ResponsesObject; security?: SecurityRequirementObject[]; servers?: ServerObject[]; summary?: string; tags?: string[] }; validate: boolean }
      • exclude: boolean
      • Optional operationObject?: { callbacks?: { [callback: string]: ReferenceObject | CallbackObject }; deprecated?: boolean; description?: string; externalDocs?: ExternalDocumentationObject; operationId?: string; parameters?: (ReferenceObject | ParameterObject)[]; requestBody?: ReferenceObject | RequestBodyObject; responses: ResponsesObject; security?: SecurityRequirementObject[]; servers?: ServerObject[]; summary?: string; tags?: string[] }
        • Optional callbacks?: { [callback: string]: ReferenceObject | CallbackObject }
          • [callback: string]: ReferenceObject | CallbackObject
        • Optional deprecated?: boolean
        • Optional description?: string
        • Optional externalDocs?: ExternalDocumentationObject
        • Optional operationId?: string
        • Optional parameters?: (ReferenceObject | ParameterObject)[]
        • Optional requestBody?: ReferenceObject | RequestBodyObject
        • responses: ResponsesObject
        • Optional security?: SecurityRequirementObject[]
        • Optional servers?: ServerObject[]
        • Optional summary?: string
        • Optional tags?: string[]
      • validate: boolean

    Returns RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

  • Initializes the validation feature for the path middlewares. Must be placed right before starting Express app.

    Throws

    • If no path middleware have been created (attached to at least one route)
    • If open api document or ajv instances is missing
    • If an operationId is not unique
    • If an operation object on the OpenApiv3 document was not found with one of the operationIds

    Parameters

    • openApiDoc: Document<{}>

      Document that is used to validate routes. OperationId's must match pathMiddleware operationIds

    • ajv: Ajv

      Ajv client instance - user configured, provided and defined.

    Returns void

  • Creates a path middleware that attaches to a route, providing meta-data for the express parser to pick up.

    Returns

    An Express middleware object to attach to a route

    Throws

    • If operationId is not unique per express app,
    • If validation is selected and no OpenApi document is provided.

    Parameters

    • operationId: string

      Required unique Express App wide id representing this specific operation in the open api schema.

    • param: { exclude?: boolean; operationObject?: { callbacks?: { [callback: string]: ReferenceObject | CallbackObject }; deprecated?: boolean; description?: string; externalDocs?: ExternalDocumentationObject; operationId?: string; parameters?: (ReferenceObject | ParameterObject)[]; requestBody?: ReferenceObject | RequestBodyObject; responses: ResponsesObject; security?: SecurityRequirementObject[]; servers?: ServerObject[]; summary?: string; tags?: string[] }; validate?: boolean }

      Object to hold optional parameters

      • Optional exclude?: boolean

        Indicates if this route should be marked for exclusion when generating OpenApi documents.

      • Optional operationObject?: { callbacks?: { [callback: string]: ReferenceObject | CallbackObject }; deprecated?: boolean; description?: string; externalDocs?: ExternalDocumentationObject; operationId?: string; parameters?: (ReferenceObject | ParameterObject)[]; requestBody?: ReferenceObject | RequestBodyObject; responses: ResponsesObject; security?: SecurityRequirementObject[]; servers?: ServerObject[]; summary?: string; tags?: string[] }

        The Open Api operation object for this route.

        • Optional callbacks?: { [callback: string]: ReferenceObject | CallbackObject }
          • [callback: string]: ReferenceObject | CallbackObject
        • Optional deprecated?: boolean
        • Optional description?: string
        • Optional externalDocs?: ExternalDocumentationObject
        • Optional operationId?: string
        • Optional parameters?: (ReferenceObject | ParameterObject)[]
        • Optional requestBody?: ReferenceObject | RequestBodyObject
        • responses: ResponsesObject
        • Optional security?: SecurityRequirementObject[]
        • Optional servers?: ServerObject[]
        • Optional summary?: string
        • Optional tags?: string[]
      • Optional validate?: boolean

        Overrides global validation option for this route.

    Returns RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

Generated using TypeDoc