oaspec/codegen/schema_utils

Values

pub fn constant_property_value(
  prop_ref: schema.SchemaRef,
  prop_name: String,
  required: List(String),
) -> option.Option(String)

Issue #309: detect a property that is fully determined by the schema — an inline string-enum with exactly one allowed value that the parent schema lists as required. Such a property is a constant marker on the wire (e.g. a kind: type: string, enum: [text] discriminator on a oneOf variant): the only legal value is known at codegen time, so the generated record drops the field, the encoder emits the constant, and the decoder validates it.

Returns Some(value) for an elidable constant property; None otherwise (including $refs, multi-value enums, optional properties, and non-string schemas — those keep their current record-field shape).

pub fn filter_read_only_properties(
  schema_obj: schema.SchemaObject,
  ctx: context.Context,
) -> schema.SchemaObject

Filter readOnly properties from an ObjectSchema for request body context. Returns a new schema with readOnly properties removed.

pub fn filter_write_only_properties(
  schema_obj: schema.SchemaObject,
  ctx: context.Context,
) -> schema.SchemaObject

Filter writeOnly properties from an ObjectSchema for response body context. Returns a new schema with writeOnly properties removed.

pub fn schema_has_additional_properties(
  schema_ref: schema.SchemaRef,
  ctx: context.Context,
) -> Bool

Check if a schema has typed or untyped additionalProperties that would need Dict.

pub fn schema_has_optional_fields(
  schema_ref: schema.SchemaRef,
  ctx: context.Context,
) -> Bool

Check if a schema has any optional or nullable fields that would need Option.

pub fn schema_has_untyped_additional_properties(
  schema_ref: schema.SchemaRef,
  ctx: context.Context,
) -> Bool

Check if a schema has untyped additionalProperties (needs Dynamic import).

pub fn schema_ref_is_nullable(
  ref: schema.SchemaRef,
  ctx: context.Context,
) -> Bool

Check if a SchemaRef is nullable, resolving $ref if needed.

pub fn schema_ref_is_read_only(
  ref: schema.SchemaRef,
  ctx: context.Context,
) -> Bool

Check if a SchemaRef has readOnly metadata, resolving $ref if needed.

pub fn schema_ref_is_write_only(
  ref: schema.SchemaRef,
  ctx: context.Context,
) -> Bool

Check if a SchemaRef has writeOnly metadata, resolving $ref if needed.

Search Document