MCPcopy
hub / github.com/pydantic/pydantic / bytes_schema

Method bytes_schema

pydantic/json_schema.py:779–790  ·  view source on GitHub ↗

Generates a JSON schema that matches a bytes value. Args: schema: The core schema. Returns: The generated JSON schema.

(self, schema: core_schema.BytesSchema)

Source from the content-addressed store, hash-verified

777 return json_schema
778
779 def bytes_schema(self, schema: core_schema.BytesSchema) -> JsonSchemaValue:
780 """Generates a JSON schema that matches a bytes value.
781
782 Args:
783 schema: The core schema.
784
785 Returns:
786 The generated JSON schema.
787 """
788 json_schema = {'type': 'string', 'format': 'base64url' if self._config.ser_json_bytes == 'base64' else 'binary'}
789 self.update_with_validations(json_schema, schema, self.ValidationsMapping.bytes)
790 return json_schema
791
792 def date_schema(self, schema: core_schema.DateSchema) -> JsonSchemaValue:
793 """Generates a JSON schema that matches a date value.

Callers 15

SecretBytesClass · 0.80
_path_schemaMethod · 0.80
match_typeMethod · 0.80
test_bytesFunction · 0.80
test_modelFunction · 0.80
test_dataclassFunction · 0.80
test_model_allow_extraFunction · 0.80

Calls 1

Tested by 15

test_bytesFunction · 0.64
test_modelFunction · 0.64
test_dataclassFunction · 0.64
test_model_allow_extraFunction · 0.64
test_model_wrong_warnFunction · 0.64
test_exclude_noneFunction · 0.64
test_propertyFunction · 0.64