dlt-hub / dlt-hub/dlt-init-openapi
Outdated Imports in OpenAPI-Generated Code
- Dominant language
- Python
- Stars
- 39
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
I am new to the dlthub tool so please take this with grain of salt. I might be doing this incorrectly on my end.
When generating a pipeline using dlt-init-openapi, the generated Python code contains outdated imports that cause an ImportError.
---
### **Steps to Reproduce:**
1. Run the following command to generate an OpenAPI-based pipeline:
```bash
dlt-init-openapi hacker_news_api_swagger --no-interactive --url "https://gist.githubusercontent.com/wing328/44a6cb6c899feda4c2bd44747e9dcbc8/raw/737d3cf34daeef32280c66c5790c7de1a7b26905/hacker_news_api_swagger.json"
```
1.1 I tested with a local file as well:
```bash
dlt-init-openapi openweather_source --path
openapi_source_generator/openweather_openapi.yml```
2.This generates a directory with the source and pipeline files.
3. Inside the generated `hacker_news_api_swagger/__init__.py`, the following import is present: ```python
from rest_api import rest_api_source
from rest_api.typing import RESTAPIConfig
```
4. When running the pipeline:
```bash
python3 hacker_news_api_swagger_pipeline.py
```
It raises:
```
ImportError: cannot import name 'rest_api_source' from 'rest_api'
```
---
### Expected Behavior
The generated code should use the **correct import**:
```python
from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources, rest_api_source
```
---
Contributor guide
Assessment
This issue has not been assessed yet.