def default_schema(self, schema: core_schema.WithDefaultSchema) -> JsonSchemaValue:
        """Generates a JSON schema that matches a schema with a default value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        """
        json_schema = self.generate_inner(schema['schema'])

        default = self.get_default_value(schema)
        if default is NoDefault:
            return json_schema

        # we reflect the application of custom plain, no-info serializers to defaults for
        # JSON Schemas viewed in serialization mode:
        # TODO: improvements along with https://github.com/pydantic/pydantic/issues/8208
        if self.mode == 'serialization':
            # `_get_ser_schema_for_default_value()` is used to unpack potentially nested validator schemas:
            ser_schema = _get_ser_schema_for_default_value(schema['schema'])
            if (
                ser_schema is not None
                and (ser_func := ser_schema.get('function'))
                and not (default is None and ser_schema.get('when_used') in ('unless-none', 'json-unless-none'))
            ):
                try:
                    default = ser_func(default)  # type: ignore
                except Exception:
                    # It might be that the provided default needs to be validated (read: parsed) first
                    # (assuming `validate_default` is enabled). However, we can't perform
                    # such validation during JSON Schema generation so we don't support
                    # this pattern for now.
                    # (One example is when using `foo: ByteSize = '1MB'`, which validates and
                    # serializes as an int. In this case, `ser_func` is `int` and `int('1MB')` fails).
                    self.emit_warning(
                        'non-serializable-default',
                        f'Unable to serialize value {default!r} with the plain serializer; excluding default from JSON schema',
                    )
                    return json_schema

        try:
            encoded_default = self.encode_default(default)
        except pydantic_core.PydanticSerializationError:
            self.emit_warning(
                'non-serializable-default',
                f'Default value {default} is not JSON serializable; excluding default from JSON schema',
            )
            # Return the inner schema, as though there was no default
            return json_schema

        json_schema['default'] = encoded_default
        return json_schema
Generates a JSON schema that matches a schema with a default value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        
pydantic/json_schema.py