OCaml let namevalue_of_req x = y
and let namevalue_to_req y = x
printer of Request Body object serialization functions.
Each OpenAPI Request Body Object can have many content types like "application/x-www-form-urlencoded"
that have specialized rules for how to serialize it.
Confer Describing Request Body and OpenAPI Request Body Object.
This version does not support Encoding objects. Instead, the assumption is that all object
fields are encoded as deepObject
and explode = true
, and all other fields are encoded as form
.
ctype argument
The content type of the request body like "application/x-www-form-urlencoded"
.
OpenAPI allows multiple content types for a request body, so a client can generate code that picks only one (probably the "application/json"
if present) while a server must accept all of them and route based on the "Content-Type"
request header.
One of:
`FormUrlEncoded
is"application/x-www-form-urlencoded"
. Each name and value will be URL encoded per RFC 1866 (also Percent encoding). That means newline normalizaiton, replacing spaces with"+"
s, and doing URL encoding for the query component of the URL, and separating name-values with"&"
and names from values with"="
. So"+&="
are reserved by definition, and all the query component reserved characters are also reserved. ForUri
the percent encoding matches the`Query_key
component. This version does not support Encoding objects. Instead, the assumption is that allobject
fields are encoded asdeepObject
andexplode = true
, and all other fields are encoded asform
(withexplode = true
forarray
fields). Confer: Support for x-www-form-urlencoded Request Bodies`Json
is"application/json"
style argument
A subset of the OpenAPI style
property relevant to request bodies.
Confer OpenAPI Specification Style Examples.
One of:
`Form
`DeepObject
`Simple
- unused since don't support Encoding objects in application/x-www-form-urlencoded yet`Label
- unused since don't support Encoding objects in application/x-www-form-urlencoded yet`SpaceDelimited
- unused since don't support Encoding objects in application/x-www-form-urlencoded yet`PipeDelimited
- unused since don't support Encoding objects in application/x-www-form-urlencoded yet
explode argument
The OpenAPI explode
property.
Confer OpenAPI Specification Style Examples.
val serializername :
(module OaDocument.STANDARD) ->
[< `PrimitiveType of string | `TypeAlias of string ] ->
string
include DkCoder_Std.SCRIPT
__init context
is the entry point for running a script module. The DkCoder compiler will inject this function at the top and bottom of the script module. The top __init
does nothing, while the bottom __init
calls the prior __init
.
That means:
- calling the
__init
function guarantees that the script module is initialized; that is, all of the script module's side-effects (ex.let () = Format.printf "Hello world@."
) are executed before the__init
returns to the caller. - you can override the
__init
function by simply defining the__init
idempotently. That will shadow the top__init
and when the bottom__init
is executed your__init
will be called instead of the do-nothing top__init
.
Future versions of DkCoder will call __init
in dependency order for all `You
script modules. Your __init
function may be called several times.
__repl context
is the entry point for debugging a script module in a REPL. The DkCoder compiler will inject this function at the top and bottom of the script module. The top __repl
does nothing, while the bottom __repl
calls the prior __repl
.
That means:
- you can override the
__repl
function by simply defining the__repl
idempotently. That will shadow the top__repl
and when the bottom__repl
is executed your__repl
will be called instead of the do-nothing top__repl
.
The run-time module information for the script module.