def get_schema_for_action_parameters(action_db, runnertype_db=None):
    """
    Dynamically construct JSON schema for the provided action from the parameters metadata.

    Note: This schema is used to validate parameters which are passed to the action.
    """
    if not runnertype_db:
        from st2common.util.action_db import get_runnertype_by_name

        runnertype_db = get_runnertype_by_name(action_db.runner_type["name"])

    # Note: We need to perform a deep merge because user can only specify a single parameter
    # attribute when overriding it in an action metadata.
    parameters_schema = {}
    deep_update(parameters_schema, runnertype_db.runner_parameters)
    deep_update(parameters_schema, action_db.parameters)

    # Perform validation, make sure user is not providing parameters which can't
    # be overriden
    runner_parameter_names = list(runnertype_db.runner_parameters.keys())

    for name, schema in six.iteritems(action_db.parameters):
        if name not in runner_parameter_names:
            continue

        for attribute, value in six.iteritems(schema):
            runner_param_value = runnertype_db.runner_parameters[name].get(attribute)
            validate_runner_parameter_attribute_override(
                action_ref=action_db.ref,
                param_name=name,
                attr_name=attribute,
                runner_param_attr_value=runner_param_value,
                action_param_attr_value=value,
            )

    schema = get_schema_for_resource_parameters(parameters_schema=parameters_schema)

    if parameters_schema:
        schema["title"] = action_db.name
        if action_db.description:
            schema["description"] = action_db.description

    return schema

    Dynamically construct JSON schema for the provided action from the parameters metadata.

    Note: This schema is used to validate parameters which are passed to the action.
    
st2common/st2common/util/schema/__init__.py