uranusjr commented on code in PR #36630:
URL: https://github.com/apache/airflow/pull/36630#discussion_r1451981136


##########
airflow/api_connexion/endpoints/dag_run_endpoint.py:
##########
@@ -319,11 +320,34 @@ def post_dag_run(*, dag_id: str, session: Session = 
NEW_SESSION) -> APIResponse:
     if not dagrun_instance:
         try:
             dag = get_airflow_app().dag_bag.get_dag(dag_id)
+
+            data_interval_start_exists = post_body.get("data_interval_start") 
is not None
+            data_interval_end_exists = post_body.get("data_interval_end") is 
not None
+
+            if (
+                data_interval_start_exists
+                and not data_interval_end_exists
+                or data_interval_end_exists
+                and not data_interval_start_exists
+            ):
+                raise BadRequest(
+                    detail="Both 'data_interval_start' and 'data_interval_end' 
must be specified, you cannot specify only one",
+                )

Review Comment:
   The OpenAPI schema is a derivative of JSON schema. There’s a compatibility 
table somewhere on the OpenAPI website. If it supports the syntax, it goes into 
`openapi/v1.yaml`, which is used in the API client (e.g. web front end).
   
   But to validate at the back end, you need to change the Marshmallow 
declaration (in `schemas/dag_run_schema.py`). This should be a bit easier (in 
the sense of figuring out compatibility and whatnot). A [schema-level 
validation 
function](https://marshmallow.readthedocs.io/en/latest/extending.html#schema-level-validation)
 should work for this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to