Skip to content

Outdated Imports in OpenAPI-Generated Code #133

@Jay-Nehra

Description

@Jay-Nehra

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

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
  1. When running the pipeline:
    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:

from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources, rest_api_source

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions