Liking cljdoc? Tell your friends :D

s-exp.legba.openapi-schema

Loading, $ref resolution and validation of OpenAPI 3.1 schemas and of values against their sub-schemas

Loading, $ref resolution and validation of OpenAPI 3.1 schemas and of
values against their sub-schemas
raw docstring

get-schemaclj

(get-schema schema-registry schema-uri json-pointer)

Returns json-schema from schema-registry at schema-uri/json-pointer

Returns json-schema from schema-registry at `schema-uri`/`json-pointer`
raw docstring

merge-path-parametersclj

(merge-path-parameters operation path-parameters)

Adds path item level path-parameters to operation parameters. Operation level parameters override path item level ones with the same name and location

Adds path item level `path-parameters` to `operation` parameters. Operation
level parameters override path item level ones with the same name and
location
raw docstring

path-itemclj

(path-item openapi-schema path)

Returns the Path Item Object of path in openapi-schema, following a local $ref

Returns the Path Item Object of `path` in `openapi-schema`, following a local
$ref
raw docstring

read-schemaclj

(read-schema schema-uri
             &
             {:as _opts :keys [validate-schema] :or {validate-schema true}})

Loads JSON or YAML schema from schema-uri and returns map (of :openapi-schema, :schema-uri, :schema-registry and :schemas, a cache of resolved schemas) that contains all the necessary information to perform validate! calls later (minus a JSON pointer).

Loads JSON or YAML schema from `schema-uri` and returns
map (of :openapi-schema, :schema-uri, :schema-registry and :schemas, a cache
of resolved schemas) that contains all the
necessary information to perform `validate!` calls later (minus a JSON
pointer).
raw docstring

read-schema-strclj

(read-schema-str s
                 &
                 {:as _opts
                  :keys [schema-uri format validate-schema]
                  :or {validate-schema true}})

Loads a JSON or YAML OpenAPI schema from a raw string s.

An optional :schema-uri can be provided to anchor $ref resolution; if omitted a random urn:legba:<uuid> URI is generated. YAML strings are detected by the :yaml format option (:format :yaml), otherwise JSON is assumed.

Returns the same map as read-schema: {:openapi-schema … :schema-uri … :schema-registry …}.

Loads a JSON or YAML OpenAPI schema from a raw string `s`.

An optional `:schema-uri` can be provided to anchor `$ref` resolution; if
omitted a random `urn:legba:<uuid>` URI is generated. YAML strings are
detected by the `:yaml` format option (`:format :yaml`), otherwise JSON is
assumed.

Returns the same map as `read-schema`: `{:openapi-schema … :schema-uri …
:schema-registry …}`.
raw docstring

resolve-operation-refsclj

(resolve-operation-refs openapi-schema sub-schema)

Resolves the Reference Objects of an operation sub-schema: parameters, requestBody, responses and response headers

Resolves the Reference Objects of an operation `sub-schema`: parameters,
requestBody, responses and response headers
raw docstring

resolve-refclj

(resolve-ref openapi-schema node)

Follows local $refs (#/...) from node to the referenced node within openapi-schema. Returns node as is when it is not a Reference Object. Throws on non local, unresolvable or circular references.

Follows local `$ref`s (`#/...`) from `node` to the referenced node within
`openapi-schema`. Returns `node` as is when it is not a Reference Object.
Throws on non local, unresolvable or circular references.
raw docstring

schema->routes-schemaclj

(schema->routes-schema {:as _schema :keys [openapi-schema]})

schema-registry-configclj

Default reusable SchemaRegistryConfig instance.

This configures the validator to:

  • Enable JSON Schema reference preloading and caching
  • Enable format assertions (per the JSON Schema spec)
  • Use JSON_PATH for error paths in validation results

This config can be reused for schema load/validation for performance and consistency.

Default reusable `SchemaRegistryConfig` instance.

This configures the validator to:
- Enable JSON Schema reference preloading and caching
- Enable format assertions (per the JSON Schema spec)
- Use `JSON_PATH` for error paths in validation results

This config can be reused for schema load/validation for performance and consistency.
raw docstring

validateclj

(validate schema sub-schema val & {:as opts})

Validates a val against schema

Validates a `val` against `schema`
raw docstring

validate-schema!clj

(validate-schema! schema-registry schema-uri)

Validates a user-provided JSON schema against the OpenAPI 3.1 base schema.

Parameters:

  • schema-registry: An instance of SchemaRegistry containing preloaded schemas.
  • schema-uri: URI identifying the schema to validate (String).

Throws:

  • ex-incorrect! if the provided schema does not conform to the OpenAPI specification.
  • The exception contains a map of validation errors in :errors.

This function uses the OpenAPI 3.1 base schema loaded from the local classpath to validate the user schema and reports any problems found in a structured way.

Validates a user-provided JSON schema against the OpenAPI 3.1 base schema.

Parameters:
- schema-registry: An instance of SchemaRegistry containing preloaded schemas.
- schema-uri: URI identifying the schema to validate (String).

Throws:
- ex-incorrect! if the provided schema does not conform to the OpenAPI specification.
- The exception contains a map of validation errors in :errors.

This function uses the OpenAPI 3.1 base schema loaded from the local classpath
to validate the user schema and reports any problems found in a structured way.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close