oaspec/codegen/server_request_decode
Types
pub type BodyFieldKind {
BodyFieldUnknown
BodyFieldString
BodyFieldInt
BodyFieldFloat
BodyFieldBool
BodyFieldStringArray
BodyFieldIntArray
BodyFieldFloatArray
BodyFieldBoolArray
}
Constructors
-
BodyFieldUnknown -
BodyFieldString -
BodyFieldInt -
BodyFieldFloat -
BodyFieldBool -
BodyFieldStringArray -
BodyFieldIntArray -
BodyFieldFloatArray -
BodyFieldBoolArray
Values
pub fn body_field_kind(
schema_ref: schema.SchemaRef,
ctx: context.Context,
) -> BodyFieldKind
pub fn body_field_kind_needs_float(kind: BodyFieldKind) -> Bool
pub fn body_field_kind_needs_int(kind: BodyFieldKind) -> Bool
pub fn cookie_optional_expr(
key: String,
param: spec.Parameter(spec.Resolved),
) -> String
Generate expression for an optional cookie parameter.
pub fn cookie_required_expr(
bound_var: String,
param: spec.Parameter(spec.Resolved),
) -> String
Generate expression for a required cookie parameter.
bound_var is the raw cookie String the router has already pulled out
via case cookie_lookup(...) { Ok(<var>) ->. As with the header helper
the router pre-binds <bound_var>_parsed for numeric scalar types.
pub fn deep_object_has_additional_properties(
param: spec.Parameter(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn deep_object_has_untyped_additional_properties(
param: spec.Parameter(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn deep_object_optional_expr(
key: String,
param: spec.Parameter(spec.Resolved),
op_id: String,
ctx: context.Context,
) -> String
pub fn deep_object_param_has_optional_fields(
param: spec.Parameter(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn deep_object_param_needs_float(
param: spec.Parameter(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn deep_object_param_needs_int(
param: spec.Parameter(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn deep_object_param_needs_string(
param: spec.Parameter(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn deep_object_required_expr(
key: String,
param: spec.Parameter(spec.Resolved),
op_id: String,
ctx: context.Context,
) -> String
pub fn enum_match_result_expr(
bound_var: String,
type_name: String,
values: List(String),
) -> String
Render the inline Gleam expression that converts a raw query-string
<bound_var> into Result(types.<TypeName><Variant>, Nil). Used by
the required-enum query path (server.gleam opens a case on this
expression; the Ok arm binds <bound_var>_parsed).
pub fn form_urlencoded_body_has_nested_object(
rb: spec.RequestBody(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn form_urlencoded_body_has_optional_fields(
rb: spec.RequestBody(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn form_urlencoded_body_needs_float(
rb: spec.RequestBody(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn form_urlencoded_body_needs_int(
rb: spec.RequestBody(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn form_urlencoded_body_needs_string(
rb: spec.RequestBody(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn generate_body_decode_expr(
rb: spec.RequestBody(spec.Resolved),
op_id: String,
ctx: context.Context,
) -> String
Generate the body decode expression for a request body.
pub fn header_optional_expr(
key: String,
param: spec.Parameter(spec.Resolved),
) -> String
Generate expression for an optional header parameter.
pub fn header_required_expr(
bound_var: String,
param: spec.Parameter(spec.Resolved),
) -> String
Generate expression for a required header parameter.
bound_var is the raw header String the router has already pulled
out of the headers dict in an enclosing case dict.get(...) { Ok(<var>) ->.
The router additionally opens a numeric parse case for int/float scalar
params, binding <bound_var>_parsed on success.
pub fn is_deep_object_param(
param: spec.Parameter(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn multipart_body_has_optional_fields(
rb: spec.RequestBody(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn multipart_body_needs_float(
rb: spec.RequestBody(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn multipart_body_needs_int(
rb: spec.RequestBody(spec.Resolved),
ctx: context.Context,
) -> Bool
pub fn operation_uses_form_urlencoded_body(
operation: spec.Operation(spec.Resolved),
) -> Bool
pub fn operation_uses_multipart_body(
operation: spec.Operation(spec.Resolved),
) -> Bool
pub fn param_needs_result_unwrap(
param: spec.Parameter(spec.Resolved),
) -> Bool
Return true when the parse expression returns a Result that the router must unwrap (int/float parsing). Bool and string params are always safe.
pub fn param_parse_expr(
var_name: String,
param: spec.Parameter(spec.Resolved),
) -> String
Generate parse expression for a path parameter (already bound as String). Returns a safe expression that does not crash on invalid input. For types that need parsing (int, float), returns the raw parse call so the router can wrap it in a case expression for error handling.
pub fn query_optional_expr(
key: String,
param: spec.Parameter(spec.Resolved),
ctx: context.Context,
) -> String
Generate expression for an optional query parameter.
pub fn query_required_expr(
bound_var: String,
param: spec.Parameter(spec.Resolved),
ctx: context.Context,
) -> String
Generate expression for a required query parameter.
bound_var is the name of a variable that the router has already bound
in an enclosing case expression. For scalar params (string/bool/int/float)
this is the raw String value pulled out of the query dict. For array
params with explode=true this is the List(String) from the dict; with
explode=false it is the single raw String that still needs splitting.
The router opens a case dict.get(query, key) { Ok([raw, ..]) -> ...
(or Ok(raw_list) -> ... for explode-true arrays) before asking this
helper for the value expression, so the lookup never let asserts.
For numeric scalar/array parameters the router additionally opens a
case int.parse(...) / float.parse(...) (or list.try_map(..., int.parse))
case, binding <bound_var>_parsed (or <bound_var>_parsed_list) on
success — that’s the variable name the helper returns here.
pub fn query_schema_needs_float(
schema_ref: option.Option(schema.SchemaRef),
) -> Bool
pub fn query_schema_needs_int(
schema_ref: option.Option(schema.SchemaRef),
) -> Bool
pub fn query_schema_needs_string(
schema_ref: option.Option(schema.SchemaRef),
) -> Bool
pub fn request_body_uses_form_urlencoded(
rb: spec.RequestBody(spec.Resolved),
) -> Bool
pub fn request_body_uses_multipart(
rb: spec.RequestBody(spec.Resolved),
) -> Bool
pub fn schema_ref_body_field_kind(
schema_ref: option.Option(schema.SchemaRef),
ctx: context.Context,
) -> BodyFieldKind
pub fn schema_ref_string_enum(
schema_ref: schema.SchemaRef,
ctx: context.Context,
) -> option.Option(#(String, List(String)))
If schema_ref is a $ref to a string enum schema, return the
generated Gleam type name and the list of enum values (in spec
order). Used by query parameter codegen to emit a string→variant
match for $ref-based enum query parameters (issue #305).