Liking cljdoc? Tell your friends :D

nl.jomco.ring-openapi-validator


openapi-validatorclj

(openapi-validator spec)
(openapi-validator spec
                   {:keys [base-path inline? ignore-additional-properties?]})

Build an OpenApiInteractionValidator from a spec

spec is a url or path to resource describing a Swagger or OpenApi specification.

Second argument is an optional map of options:

If you need to customize the validator you can create a builder using com.atlassian.oai.validator.OpenApiInteractionValidator/createFor

Build an OpenApiInteractionValidator from a spec

`spec` is a url or path to resource describing a Swagger or OpenApi
specification.

Second argument is an optional map of options:
 - `:base-path` overrides the base path in the spec.
 - `:inline? true` indicate that `spec` is the specification body
    as a string, instead of a url or path
 - `:ignore-additional-properties? true` will disable errors on
    additional properties. This can help if you use `allOf` schemas. See also
    https://bitbucket.org/atlassian/swagger-request-validator/src/master/docs/FAQ.md

If you need to customize the validator you can create a builder using
`com.atlassian.oai.validator.OpenApiInteractionValidator/createFor`
sourceraw docstring

validate-interactionclj

(validate-interaction validator request response)

Validate a request/response pair using the given validator.

If any issues are found, returns a report collection

Validate a `request`/`response` pair using the given `validator`.

If any issues are found, returns a report collection
sourceraw docstring

validate-requestclj

(validate-request validator request)

Validate a request using the given validator.

If any issues are found, returns a report collection

Validate a `request` using the given `validator`.

If any issues are found, returns a report collection
sourceraw docstring

validate-responseclj

(validate-response validator method path response)

Validate a response using the given validator.

  • method is a ring-spec method: :get :head :post etc...
  • path is the request path excluding parameters

If any issues are found, returns a report collection

Validate a `response` using the given `validator`.

- `method` is a ring-spec method: `:get` `:head` `:post` etc...
- `path` is the request path excluding parameters

If any issues are found, returns a report collection
sourceraw docstring

wrap-request-validatorclj

(wrap-request-validator f validator)

Middleware validating requests against an OOAPI spec.

  • f is the handler to wrap
  • validator should be an OpenApiInteractionValidator - see openapi-validator.

Each incoming request is validated using validate-request. When errors are found, the a 400 Bad Request response is returned with the error collection as the response body. When the request is valid according to the validator, it is passed along to the original handler.

(-> my-api-handler
    (wrap-request-validator (openapi-validator "path/to/spec.json"))
    (wrap-json-response))

Since the error response body is just clojure map, you need some other middleware like ring.middleware.json to turn it into full ring response.

Middleware validating requests against an OOAPI spec.

  - `f` is the handler to wrap
  - `validator` should be an `OpenApiInteractionValidator` - see
    [[openapi-validator]].

Each incoming request is validated using [[validate-request]]. When
errors are found, the a 400 Bad Request response is returned with the
error collection as the response body. When the request is valid
according to the validator, it is passed along to the original
handler.

    (-> my-api-handler
        (wrap-request-validator (openapi-validator "path/to/spec.json"))
        (wrap-json-response))

Since the error response body is just clojure map, you need some other
middleware like `ring.middleware.json` to turn it into full ring
response.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close