Skip to content

VuedaExpandableFieldsSerializerMixin

Overview

Serializer mixin that builds structured metadata about expandable fields for the /info/ meta-API and OpenAPI schema. Automatically omits available_actions from nested expand representations.

_get_expanded_field_names

Signature

_get_expanded_field_names(self, expand_fields, omit_fields, sparse_fields, next_level_omits)

Parameters

NameTypeRequiredDescription
selfyes
expand_fieldslist[str]yes
omit_fieldslist[str]yes
sparse_fieldslist[str]yes
next_level_omitsdict[str, list[str]]yes

Returns

list[str]

Source

server/vueda/core/serializers/__init__.py:301

_reduce_field_model_info_for_schema

Reduce model_fields/model_expands-shaped metadata (as produced by generate_expand_model_info/ ModelInfoSerializer.get_model_fields_data and corrected by get_expand_model_info/ get_field_model_info) to what an OpenAPI schema needs: a label, the DRF field type (renamed from type_serializer to type), whether the value is required, and its choices. Drops the database/model type detail (type_db/type_model), the many/read_only flags, the hidden flag, help text, and constraint bookkeeping (max_value, min_value, max_length, min_length, max_digits, decimal_places, pk) that /info/ also reports but the schema does not need.

Handles three shapes: a flat model_fields-style dict keyed by field name (from get_schema_fields); a list of model_expands-style descriptors with nested per-field metadata under the FIELDS_PARAM key (a related-model-backed expand); and a list of descriptors with no nested fields (a SerializerMethodField-backed expand with no related model), whose own type metadata sits directly on the descriptor instead of under FIELDS_PARAM. The reduction applies to the descriptor itself as well as to any nested fields, so a descriptor's own many/read_only/type keys are reduced too.

Signature

_reduce_field_model_info_for_schema(original_expands_data)

Parameters

NameTypeRequiredDescription
original_expands_datayes

Source

server/vueda/core/serializers/__init__.py:501

generate_expand_model_info

Build the base list of expand descriptors for the /info/ meta-API from Meta.expandable_fields. This is the internal generation step; serializers that need to customize the final expand metadata should override get_expand_model_info instead.

Signature

generate_expand_model_info(self)

Parameters

NameTypeRequiredDescription
selfyes

Returns

<class 'list'>

Source

server/vueda/core/serializers/__init__.py:316

get_expand_model_info

Customization hook for the model_expands metadata the /info/ meta-API returns for this serializer. Receives the generated list of expand descriptors and must return a list in the same shape; override to add or adjust entries, such as the real type of a SerializerMethodField. The default implementation returns expands unchanged.

Signature

get_expand_model_info(self, expands)

Parameters

NameTypeRequiredDescription
selfyes
expandsyes

Source

server/vueda/core/serializers/__init__.py:404

get_field_display_choices

Return display-only label mappings for serializer fields.

field_display_choices should be keyed by serializer field name. Each value may be either a mapping of {stored_value: label}, an iterable of (stored_value, label) pairs, or an iterable of objects with value and label keys. These labels affect read-only display metadata only; they do not change validation choices or editable widgets.

Signature

get_field_display_choices(self)

Parameters

NameTypeRequiredDescription
selfyes

Source

server/vueda/core/serializers/__init__.py:425

get_field_model_info

Customization hook for the model_fields metadata the /info/ meta-API returns for this serializer. Receives the generated field metadata dict (keyed by field name) and must return a dict in the same shape; override to correct or add entries, such as the real type of a SerializerMethodField. The default implementation applies field_display_choices.

Signature

get_field_model_info(self, fields)

Parameters

NameTypeRequiredDescription
selfyes
fieldsyes

Source

server/vueda/core/serializers/__init__.py:413

get_schema_expandable_fields

Build the expand query parameter's documented values for the OpenAPI schema, reusing the same generation (generate_expand_model_info) and customization hook (get_expand_model_info) the /info/ meta-API uses for model_expands, then reducing the result to what the schema needs.

Signature

get_schema_expandable_fields(self)

Parameters

NameTypeRequiredDescription
selfyes

Source

server/vueda/core/serializers/__init__.py:561

get_schema_fields

Build this serializer's own field metadata for OpenAPI schema purposes, mirroring how model_fields is generated for the /info/ meta-API: inspect the serializer's own fields with ModelInfoSerializer.get_model_fields_data, then run the result through get_field_model_info so a serializer that already corrects a SerializerMethodField's metadata for /info/ gets the same correction reflected in its schema, then reduce to the keys the schema needs. Returns an empty dict when this serializer has no Meta.model to inspect.

Passes self.context along so get_model_fields_data re-instantiates this same serializer class with the view already in context (rather than bare) -- this is describing this serializer's own fields, not another serializer's, so reusing self's context here is always correct.

Signature

get_schema_fields(self)

Parameters

NameTypeRequiredDescription
selfyes

Source

server/vueda/core/serializers/__init__.py:571

get_schema_operation_parameters

Signature

get_schema_operation_parameters(self, operation_id, parameters)

Parameters

NameTypeRequiredDescription
selfyes
operation_idyes
parametersyes

Source

server/vueda/core/serializers/__init__.py:453

serialize_display_choices

Return model-info display_choices entries from a display-choice declaration.

Signature

serialize_display_choices(choices)

Parameters

NameTypeRequiredDescription
choicesyes

Source

server/vueda/core/serializers/__init__.py:436

dict {#dict}

dictionary for instance variables

weakref {#weakref}

list of weak references to the object

field_display_choices

Source

server/vueda/core/serializers/__init__.py:292

Documents matching: server v3.0.0a1.post1client v3.0.0-alpha.2