Bindoj_gen.Json_codec
This module provides functions to generate OCaml values and functions.
module Json_config = Bindoj_gen_config.Json_config
module Builtin_codecs : sig ... end
val builtin_codecs : (string * builtin_codec) list
val gen_builtin_encoders :
?attrs:Ppxlib.attributes ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.value_binding list
Returns builtin encoders of the given type declaration.
val gen_builtin_decoders :
?attrs:Ppxlib.attributes ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.value_binding list
Returns builtin decoders of the given type declaration.
val gen_json_encoder :
?self_contained:bool ->
?codec:Bindoj_typedesc.Type_desc.Coretype.codec ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.value_binding
Generates a json encoder function of the given type declaration.
val gen_json_decoder_result :
?self_contained:bool ->
?json_shape_explanation_style:
[ `inline of json_shape_explanation_resolution option | `reference ] ->
?codec:Bindoj_typedesc.Type_desc.Coretype.codec ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.value_binding
Generates a json decoder function of the given type declaration. The generated function has type ?path:jvpath -> jv -> t OfJsonResult.t
.
val gen_json_decoder_option :
?implementation_style:
[ `refer_existing_result_variant_json_decoder
| `embed_full_implementation of [ `self_contained | `non_self_contained ] ] ->
?codec:Bindoj_typedesc.Type_desc.Coretype.codec ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.value_binding
Generates a json decoder function of the given type declaration. The generated function has type jv -> t option
.
val gen_json_shape_explanation :
?json_shape_explanation_resolution:json_shape_explanation_resolution ->
?codec:Bindoj_typedesc.Type_desc.Coretype.codec ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.value_binding
Generates a value_binding of Bindoj_runtime
.json_shape_explanation.
val gen_discriminator_value_accessor :
?codec:Bindoj_typedesc.Type_desc.Coretype.codec ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.value_binding
Generates a function of the given type declaration of Bindoj_typedesc.Type_desc.type_decl_kind.Variant_decl
. The generated has type t -> string
.
val gen_json_codec :
?self_contained:bool ->
?gen_json_shape_explanation:bool ->
?discriminator_value_accessor:bool ->
?json_shape_explanation_resolution:json_shape_explanation_resolution ->
?codec:Bindoj_typedesc.Type_desc.Coretype.codec ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.structure
Generates the whole structure containing the result of gen_json_encoder
, gen_json_decoder_result
, gen_json_decoder_option
, gen_json_shape_explanation
and gen_discriminator_value_accessor
.
val gen_json_encoder_signature :
?codec:Bindoj_typedesc.Type_desc.Coretype.codec ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.value_description
val gen_json_decoder_result_signature :
?codec:Bindoj_typedesc.Type_desc.Coretype.codec ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.value_description
val gen_json_decoder_option_signature :
?codec:Bindoj_typedesc.Type_desc.Coretype.codec ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.value_description
val gen_json_shape_explanation_signature :
?codec:Bindoj_typedesc.Type_desc.Coretype.codec ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.value_description
val gen_discriminator_value_accessor_signature :
?codec:Bindoj_typedesc.Type_desc.Coretype.codec ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.value_description
val gen_json_codec_signature :
?gen_json_shape_explanation:bool ->
?discriminator_value_accessor:bool ->
?codec:Bindoj_typedesc.Type_desc.Coretype.codec ->
Bindoj_typedesc.Type_desc.type_decl ->
Ppxlib.signature
Generates the whole signature containing the result of gen_json_encoder_signature
, gen_json_decoder_result_signature
, gen_json_decoder_option_signature
, gen_json_shape_explanation_signature
and gen_discriminator_value_accessor_signature
.
val gen_json_schema :
?openapi:bool ->
Bindoj_typedesc.Type_desc.type_decl ->
Bindoj_openapi.V3.Schema_object.t
Generates json schema object.
val gen_openapi_schema :
Bindoj_typedesc.Type_desc.type_decl ->
Bindoj_openapi.V3.Schema_object.t
Generates a json schema object of OpenAPI.