WardrikRest. OpenAPI
(wardrik_rest v0.1.0-rc.1)
Copy Markdown
Reads OpenAPI 3.0 and 3.1 documents, in JSON or YAML.
{:ok, suggestions} =
WardrikRest.API.load(
{WardrikRest.OpenAPI, path: "priv/apis/catalog-suggestion.openapi.yaml"},
name: "meta_catalog",
base_url: "https://ads-api.facebook.com/v27.0/marketing-api",
auth: %{"OAuthToken__Authorization" => {:credential, "meta"}}
)Options
:url- where the document is.:req_optionsare merged into its request.:path- a file holding it.:document- the document itself, decoded.
How it reads
- Each operation is named by its
operationId, any character but a letter, a digit or_made_, or by its method and path where it has none. - Its path, query and header parameters become arguments; cookie parameters are left out.
- A JSON body's fields become arguments beside them, and a field named like a parameter is
left out. A body that isn't an object of fields is one argument,
body. Anapplication/x-www-form-urlencodedbody is sent form-encoded. An operation whose body is only some other type, as a file upload, is left out. - Its security, or the document's, gives its schemes:
httpbearer,oauth2andopenIdConnectas a bearer token, andapiKeyin a header or the query, each by its name incomponents/securitySchemes. An alternative needing any other scheme, as HTTP basic, is left out, and an operation with none left can't be offered. components/schemasbecome the spec's types. SeeWardrikRest.OpenAPI.Schema.- Its
serversare never read: the API's:base_urlsays where it's reached, with any path a server has, as/v1.