Liking cljdoc? Tell your friends :D

martian.openapi


base-urlclj/s

(base-url url server-url json)

Returns the API root URL derived from the spec URL, an optional server override, and the parsed JSON spec.

Resolution order for OpenAPI (3.x) specs:

  1. If server-url is provided and non-blank, it is used as-is when absolute (e.g. "https://example.com"), or resolved against url when relative (e.g. "/v3" → "http://host/v3").

  2. Otherwise, servers[0].url from the spec is used, applying the same absolute-vs-relative logic.

  3. If neither is present (no :servers key in the spec), the base is derived from the directory of url via RFC 3986 resolution:

    • absolute url → origin only, e.g. "http://localhost:8888"
    • relative url → parent path, e.g. "/api/spec.json" → "/api"
    • top-level relative url (e.g. "/spec.json") → "" (empty string), which is correct because OpenAPI paths begin with "/", so api-root + path remains a valid relative URL.

For Swagger (2.x) specs, the base is always reconstructed as scheme://host[:port] + basePath from the parsed url.

The return value never has a trailing slash.

Returns the API root URL derived from the spec URL, an optional
server override, and the parsed JSON spec.

Resolution order for OpenAPI (3.x) specs:

1. If `server-url` is provided and non-blank, it is used as-is when
   absolute (e.g. "https://example.com"), or resolved against `url`
   when relative (e.g. "/v3" → "http://host/v3").

2. Otherwise, `servers[0].url` from the spec is used, applying the
   same absolute-vs-relative logic.

3. If neither is present (no `:servers` key in the spec), the base is
   derived from the directory of `url` via RFC 3986 resolution:
   - absolute `url`  → origin only, e.g. "http://localhost:8888"
   - relative `url`  → parent path, e.g. "/api/spec.json" → "/api"
   - top-level relative `url` (e.g. "/spec.json") → "" (empty string),
     which is correct because OpenAPI paths begin with "/", so
     api-root + path remains a valid relative URL.

For Swagger (2.x) specs, the base is always reconstructed as
scheme://host[:port] + basePath from the parsed `url`.

The return value never has a trailing slash.
sourceraw docstring

generate-route-nameclj/s

(generate-route-name url-pattern method)
source

openapi->handlersclj/s

(openapi->handlers openapi-json content-types)
(openapi->handlers openapi-json
                   {:keys [encodes decodes] :as _content-types}
                   route-name-sources)
source

openapi-schema?clj/s

(openapi-schema? json)
source

produce-route-nameclj/s

(produce-route-name route-name-sources url-pattern method definition)
source

tokenise-pathclj/s

(tokenise-path url-pattern)
source

unique-route-name?clj/s

(unique-route-name? route-name route-names)
source

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