Repository: apache/airflow

Issue:
Ability to provide sample conf JSON for a dag in trigger page
**Description**
In the trigger page, there is a text area to enter (optional) conf json. It would be great if a sample JSON can be provided programatically while defining DAG

**Use case / motivation**

This will improve usability of the UI that triggers a DAG



Discussion:
Thanks for opening your first issue here! Be sure to follow the issue template!

In Airflow 2.0, you can pass this as a `params` parameter. I don't know if this exists in Airflow 1.10. I also have serious concerns that this option is not documented. Would you like to add documentation?
https://github.com/apache/airflow/blob/8b95e513704b91110c47f424c4376a20560eccc4/airflow/www/views.py#L1426
I think (correct me if I'm wrong @aniketbhatnagar ) that he is asking for some in-page docs/example showing what to put in the textarea on the trigger page.
> I think (correct me if I'm wrong @aniketbhatnagar ) that he is asking for some in-page docs/example showing what to put in the textarea on the trigger page.

Yes, that is correct and customizable per DAG. We right now have to document that outside airflow.
Will it be sufficient for you if [`DAG.doc`](http://apache-airflow-docs.s3-website.eu-central-1.amazonaws.com/docs/apache-airflow/latest/concepts.html?highlight=doc_md#documentation-notes) was displayed on the trigger screen?
Yes, I think that should suffice.
Would you like to open a PR with a proposal for such a change? I am happy to help with the reviews.
@mik-laj Can I take up this issue?

Resolving patch:
diff --git a/airflow/www/views.py b/airflow/www/views.py
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -1409,16 +1409,19 @@ def trigger(self, session=None):
         if request.method == 'GET':
             # Populate conf textarea with conf requests parameter, or dag.params
             default_conf = ''
+
+            dag = current_app.dag_bag.get_dag(dag_id)
+            doc_md = wwwutils.wrapped_markdown(getattr(dag, 'doc_md', None))
+
             if request_conf:
                 default_conf = request_conf
             else:
                 try:
-                    dag = current_app.dag_bag.get_dag(dag_id)
                     default_conf = json.dumps(dag.params, indent=4)
                 except TypeError:
                     flash("Could not pre-populate conf field due to non-JSON-serializable data-types")
             return self.render_template(
-                'airflow/trigger.html', dag_id=dag_id, origin=origin, conf=default_conf
+                'airflow/trigger.html', dag_id=dag_id, origin=origin, conf=default_conf, doc_md=doc_md
             )
 
         dag_orm = session.query(models.DagModel).filter(models.DagModel.dag_id == dag_id).first()


Test patch:
diff --git a/tests/www/test_views.py b/tests/www/test_views.py
--- a/tests/www/test_views.py
+++ b/tests/www/test_views.py
@@ -2783,12 +2783,13 @@ def test_trigger_dag_params_conf(self, request_conf, expected_conf):
             2. Conf is passed as a URL parameter -> passed conf json is in textarea
         """
         test_dag_id = "example_bash_operator"
+        doc_md = "Example Bash Operator"
 
         if not request_conf:
             resp = self.client.get(f'trigger?dag_id={test_dag_id}')
         else:
             test_request_conf = json.dumps(request_conf, indent=4)
-            resp = self.client.get(f'trigger?dag_id={test_dag_id}&conf={test_request_conf}')
+            resp = self.client.get(f'trigger?dag_id={test_dag_id}&conf={test_request_conf}&doc_md={doc_md}')
 
         expected_dag_conf = json.dumps(expected_conf, indent=4).replace("\"", "&#34;")