pierrejeambrun commented on code in PR #46042:
URL: https://github.com/apache/airflow/pull/46042#discussion_r1933930174


##########
airflow/api_fastapi/core_api/openapi/v1-generated.yaml:
##########
@@ -4457,6 +4457,74 @@ paths:
             application/json:
               schema:
                 $ref: '#/components/schemas/HTTPValidationError'
+    post:
+      tags:
+      - XCom
+      summary: Create Xcom Entry
+      description: Create an XCom entry.
+      operationId: create_xcom_entry
+      parameters:
+      - name: dag_id
+        in: path
+        required: true
+        schema:
+          type: string
+          title: Dag Id
+      - name: task_id
+        in: path
+        required: true
+        schema:
+          type: string
+          title: Task Id
+      - name: dag_run_id
+        in: path
+        required: true
+        schema:
+          type: string
+          title: Dag Run Id
+      requestBody:
+        required: true
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/XComCreateRequest'
+      responses:
+        '201':
+          description: Successful Response
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/XComCreateResponse'
+        '401':
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/HTTPExceptionResponse'
+          description: Unauthorized
+        '403':
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/HTTPExceptionResponse'
+          description: Forbidden
+        '400':
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/HTTPExceptionResponse'
+          description: Bad Request
+        '404':

Review Comment:
   For now, If a resource or related resource is missing when we try to `POST`  
(Or any other method) something, we return a 404.
   
   I think it's fine to keep it like this for now (and we should for 
consistency). If we want to change that behavior, we can but I believe it 
should be a separate PR and discussion.



##########
airflow/api_fastapi/core_api/datamodels/xcom.py:
##########
@@ -57,3 +57,28 @@ class XComCollection(BaseModel):
 
     xcom_entries: list[XComResponse]
     total_entries: int
+
+
+class XComCreateRequest(BaseModel):
+    """Request body for creating an XCom entry."""
+
+    key: str
+    value: Any
+    map_index: int = -1
+
+
+class XComCreateResponse(BaseModel):
+    """Serializer for a xcom create response."""
+
+    key: str
+    dag_run_id: int
+    timestamp: datetime
+    map_index: int
+    task_id: str
+    dag_id: str
+    run_id: str
+    value: str | None
+
+    @field_validator("value", mode="before")
+    def value_to_string(cls, v):
+        return str(v) if v is not None else None

Review Comment:
   This can be extracted into a common validator and not duplicated from  
`XComResponseString`.



-- 
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