Did you know ... Search Documentation:
Pack openapi -- prolog/openapi.pl
PublicShow source

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.
 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)
  • object(Properties) Properties is an ordered list of
    • p(Name, Type, Required)
  • 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.