11010cy opened a new issue #40:
URL: https://github.com/apache/airflow-client-python/issues/40


   **[description]**
   file: 
[airflow/airflow/api_connexion/openapi/v1.yaml](https://github.com/apache/airflow/blob/main/airflow/api_connexion/openapi/v1.yaml)
   
   As seen in the file above, the following usages are used in many places:
   
   ```
   # line 2661
   dag_run_timeout:
                 nullable: true
                 $ref: '#/components/schemas/TimeDelta'
   
   # line 2498
   sla_miss:
             $ref: '#/components/schemas/SLAMiss'
             nullable: true
   
   ```
   
   Obviously the expectation is to be able to make a variable nullable while 
using $ref. 
   
   But the generated code is not as expected.
   
https://github.com/apache/airflow-client-python/blob/master/airflow_client/client/model/dag_detail.py
   ```
   # line 132
   @cached_property
       def openapi_types():
           """
           This must be a method because a model may have properties that are
           of type self, this must run after the class is loaded
   
           Returns
               openapi_types (dict): The key is attribute name
                   and the value is attribute type.
           """
           lazy_import()
           return {
              ...
               'dag_run_timeout': (TimeDelta,),  # noqa: E501
              ...
           }
   ```
   
   **[expected]**
   ```
   return {
              ...
               'dag_run_timeout': (TimeDelta, none_type, ),  # noqa: E501
              ...
           }
   ```
   
   **[Suggest a fix]**
   
   Per the openapi spec, properties adjacent to refs are ignored:
   
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#reference-object
   This object cannot be extended with additional properties and any properties 
added SHALL be ignored. except for summary and description.
   
   The right schema could be:
   
   ```
   dag_run_timeout:
    oneOf:
     - type: null
     - $ref: '#/components/schemas/TimeDelta'
   ```
   
   The generated code will be like:
   ```
   return {
              ...
                'dag_run_timeout': (bool, date, datetime, dict, float, int, 
list, str, none_type,),  # noqa: E501
              ...
           }
   ```
   
   Of course, some bugs due to nullable can be fixed, but the readability of 
the generated model will be worse. I am still working on that.
   
   **[related]**
   #20 
   #27 


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