1.1.7 • Published 3 years ago

openapi-validator-utils v1.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

npm Build Known Vulnerabilities Maintainability Test Coverage License: MIT

openapi-validator-utils

This library expose some methods to validate request, parameters, headers and response based on your OpenAPI Json definition.

Methods

validate(openApiDef, options) -> {ValidationMethods}

You can checkout more info about this method in our Docs link.

Parameters

NameTypeDescription
openApiDefobjectOpenAPI definition
optionsobjectOptions to extend the errorHandler, strictValidation or Ajv configuration

Returns: validator methods

ValidatorMethods object

These are the object keys the validate method returns.

{
  validateRequest,
  validateQueryParam,
  validatePathParam,
  validateHeaderParam,
  validateResponse,
}
NameTypeDescription
validateRequestfunctionMethod to validate an endpoint's request
validateQueryParamfunctionMethod to validate an endpoint's query parameter
validatePathParamfunctionMethod to validate an endpoint's path parameter
validateHeaderParamfunctionMethod to validate an endpoint's header parameter
validateResponsefunctionMethod to validate an endpoint's response
validateRequiredValuesfunctionMethod to required parameters
isRequestRequiredfunctionMethod to validate if requestBody is necessary

validateRequest

validateRequest(payload, endpoint, method, contentType)
NameTypeDescription
payloadobjectPayload we want to validate
endpointstringOpenApi endpoint we want to validate
methodstringOpenApi method we want to validate
contentTypestringContent api of the request we want to validate. Optional

validateQueryParam

validateQueryParam(payload, endpoint, method, contentType)
NameTypeDescription
payloadobjectPayload we want to validate
endpointstringOpenApi endpoint we want to validate
methodstringOpenApi method we want to validate
contentTypestringContent api of the request we want to validate. Optional

validatePathParam

validatePathParam(payload, endpoint, method, contentType)
NameTypeDescription
payloadobjectPayload we want to validate
endpointstringOpenApi endpoint we want to validate
methodstringOpenApi method we want to validate
contentTypestringContent api of the request we want to validate. Optional

validateHeaderParam

validateHeaderParam(payload, endpoint, method, contentType)
NameTypeDescription
payloadobjectPayload we want to validate
endpointstringOpenApi endpoint we want to validate
methodstringOpenApi method we want to validate
contentTypestringContent api of the request we want to validate. Optional

validateResponse

validateResponse(payload, endpoint, method, status, contentType)
NameTypeDescription
payloadobjectPayload we want to validate
endpointstringOpenApi endpoint we want to validate
methodstringOpenApi method we want to validate
statusstringOpenApi status we want to validate
contentTypestringContent api of the request we want to validate. Optional

validateRequiredValues

validateRequiredValues(values, endpoint, method)
NameTypeDescription
valuesobjectValues we want to check if they are required
endpointstringOpenApi endpoint we want to validate
methodstringOpenApi method we want to validate

isRequestRequired

isRequestRequired(endpoint, method, contentType)
NameTypeDescription
endpointstringOpenApi endpoint we want to validate
methodstringOpenApi method we want to validate
contentTypestringContent api of the request we want to validate. Optional
1.1.7

3 years ago

1.1.6

3 years ago

1.1.0

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago