This library implements generating server and client code from an
OpenAPI specification. The generated code generates or extracts
parameters from the path, request or request body and type-checks
parameters as well as responses.
- openapi_server(+File, +Options)
- Instantiate a REST server given the OpenAPI specification in File.
Normally, use `swipl-openapi --server=
server.pl
spec.yaml` to create
a file that uses this directive and generates documentation for the
server operations as well as a skeleton predicate.
- openapi_client(+File, +Options)
- Instantiate a REST client given the OpenAPI specification in File.
Normally use `swipl-openapi --client=
client.pl
spec.yaml` to create
a file that uses this directive and contains documentation for the
generated predicates.
- assemble_query(+Module, +Method, +Path, +HeaderParams, +QParams, +QOptional, +QOptions, -URL, -OpenOptions) is det
-
- Arguments:
-
QOptions | - is the option list of the client predicate. |
- openapi_read_reply(+Code, +ContentType, +Responses, +In, -Result) is det
- Handle the reply at the client side.
- assemble_security(+Security, +ClientModule, -HTTPOptions)
- Assemble additional HTTP options from the security description.
- openapi_dispatch(:Request) is semidet
- Generic HTTP handler to deal with OpenAPI REST requests.
- To be done
- -
- validate types
- handle errors
- different replies formats
- different reply codes
- json_schema(?URL, ?Spec)[multifile]
- Spec is one of
array(ItemType, Options)
object(Properties)
Properties is an ordered list of
- p(Name, Type, Properties)
- where Properties is a list of
required(Bool)
, nullable(Bool)
- A type as defined by oas_type/3.
url(URL)
Reference to another type.
- openapi_doc(+File, +Mode, +Options) is det
- Write documentation to the current output. Options are passed to
openapi_server/2. In addition, the following options are processed:
- file(+File)
- Dump output to File.
This predicate is used by the swipl-openapi
script to generate the
commented client or server code.
- openapi_arg(:PredicateName, ?Index, ?Name, ?Type) is nondet
- True when PredicateName's one-based Index-th argument is named
Name and has type Type.
- openapi_response(:PredicateName, Responses:list) is nondet
- True when Responses is a list of terms describing the possible
responses for PredicateName. Each Response is a term
response(Code,
As, MediaType, Type)
, where
- Code is the numeric HTTP status code or a variable for
default
- As describes how to handle the code. Currently one of
data
or error
- MediaType is the expected response type
- Type is the (JSON) schema describing a JSON result