WingCode opened a new issue #17172:
URL: https://github.com/apache/airflow/issues/17172


   **Apache Airflow version**:  2.1.2
   
   **Environment**: OpenApi-generator 5.2.1-SNAPSHOT
   
   **What happened**:
   Call any APIs from the java code generated using 
https://airflow.apache.org/docs/apache-airflow/stable/_specs/v1.yaml fails with 
an API exception: UNAUTHORISED
   
   **What you expected to happen**:
   The API to succeed & return with a collection of DAGs
   
   
   On closer inspection of the request sent, the request auth parameters is not 
present. In the generated java code,
   DagApi.class
   ```
    public okhttp3.Call getDagCall(String dagId, final ApiCallback _callback) 
throws ApiException{
    ...
   String[] localVarAuthNames = new String[] {   };
   }
   ```
   The variable localVarAuthNames is initialised with empty parameters.
   
   **How to reproduce it**:
   Get the jar from 
https://github.com/OpenAPITools/openapi-generator#13---download-jar
   Generate the java client using
   `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar 
generate -i ./v1.yaml -g java \
    -o ./java-airflow-client`
   
   Create a java test containing the code
   ```
   import ApiClient;
   import DagAPI;
   
   ApiClient apiClient = new ApiClient();
   apiClient.setUsername("WingCode"); // Change this to your setup
   apiClient.setPassword("MyNotSoSecretPassword"); // Change this to your setup
   apiClient.setBasePath("http://localhost:8080/api/v1";); // Change this to 
your setup
   DagApi dagApi = new DagApi(apiClient);
       
   DAGCollection a = dagApi.getDags(1, null, null, null);
   ```
   The API call should fail throwing an exception: UNAUTHORISED
   
   


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