Skip to content

Commit 1da30d2

Browse files
committed
update the quick example
1 parent 42067f0 commit 1da30d2

File tree

1 file changed

+32
-33
lines changed

1 file changed

+32
-33
lines changed

README.md

+32-33
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1-
# dlt-init-openapi
2-
`dlt-init-openapi` generates [`dlt`](https://dlthub.com/docs) pipelines from OpenAPI 3.x documents/specs using the [`dlt` `rest_api` `verified source`](https://dlthub.com/docs/dlt-ecosystem/verified-sources/rest_api). If you do not know `dlt` or our `verified sources`, please read:
1+
# dlt openapi source generator (dlt-init-openapi)
2+
`dlt-init-openapi` generates [`dlt`](https://dlthub.com/docs) data pipelines from OpenAPI 3.x specs using the [`dlt` `rest_api` `verified source`](https://dlthub.com/docs/dlt-ecosystem/verified-sources/rest_api) to extract data from any rest API. If you do not know `dlt` or our `verified sources`, please read:
33

44
* [Getting started](https://dlthub.com/docs/getting-started) to learn the `dlt` basics
55
* [dlt rest_api](https://dlthub.com/docs/dlt-ecosystem/verified-sources/rest_api) to learn how our `rest_api` source works
66

7-
> This generator does not support OpenAPI 2.x FKA Swagger. If you need to use an older document, try upgrading it to
8-
version 3 first with one of many available converters.
9-
10-
11-
## Prior work
12-
This project started as a fork of [openapi-python-client](https://github.com/openapi-generators/openapi-python-client). Pretty much all parts are heavily changed or completely replaced, but some lines of code still exist and we like to acknowledge the many good ideas we got from the original project :)
13-
14-
15-
## Support
16-
If you need support for this tool, [join our slack community](https://dlthub.com/community) and ask for help on the technical help channel. We're usually around to help you out or discuss features :)
17-
187

198
## Features
20-
The dlt-init-openapi generates code from an OpenAPI spec that you can use to extract data from a `rest_api` into any [`destination`](https://dlthub.com/docs/dlt-ecosystem/destinations/) (e.g. Postgres, BigQuery, Redshift...) `dlt` supports.
9+
The dlt-init-openapi generates code from an OpenAPI spec that you can use to extract data from a `rest_api` into any [`destination`](https://dlthub.com/docs/dlt-ecosystem/destinations/) (e.g. Postgres, BigQuery, Redshift...) `dlt` supports. dlt-init-openapi additional executes a set of heuristics to discover information that is not explicetely defined in OpenAPI specs.
2110

2211
Features include
2312

@@ -27,32 +16,26 @@ Features include
2716
* **Payload JSON path [data selector](https://dlthub.com/docs/dlt-ecosystem/verified-sources/rest_api#data-selection) discovery** for results nested in the returned json
2817
* **[Authentication](https://dlthub.com/docs/dlt-ecosystem/verified-sources/rest_api#authentication)** discovery for an API
2918

30-
## Setup
31-
32-
You will need Python 3.9 or higher installed, as well as pip.
3319

34-
```console
35-
# 1. install this tool locally
36-
$ pip install dlt-init-openapi
20+
## Support
21+
If you need support for this tool or `dlt`, please [join our slack community](https://dlthub.com/community) and ask for help on the technical help channel. We're usually around to help you out or discuss features :)
3722

38-
# 2. Show the version of the installed package to verify it worked
39-
$ dlt-init-openapi --version
40-
```
23+
## A quick example
4124

42-
## Basic Usage
25+
You will need Python 3.9 or higher installed, as well as pip. You can run `pip install dlt-init-openapi` to install the current version.
4326

44-
Let's create an example pipeline from the [PokeAPI spec](https://raw.githubusercontent.com/cliffano/pokeapi-clients/ec9a2707ef2a85f41b747d8df013e272ef650ec5/specification/pokeapi.yml). You can point to any other OpenAPI Spec instead if you like.
27+
We will create a simple example pipeline from a [PokeAPI spec](https://pokeapi.co/) in our repo. You can point to any other OpenAPI Spec instead if you like.
4528

4629
```console
4730
# 1.a. Run the generator with an url:
48-
$ dlt-init-openapi pokemon --url https://raw.githubusercontent.com/cliffano/pokeapi-clients/ec9a2707ef2a85f41b747d8df013e272ef650ec5/specification/pokeapi.yml
31+
$ dlt-init-openapi pokemon --url https://raw.githubusercontent.com/dlt-hub/dlt-init-openapi/devel/tests/cases/e2e_specs/pokeapi.yml --global-limit 2
4932

5033
# 1.b. If you have a local file, you can use the --path flag:
5134
$ dlt-init-openapi pokemon --path ./my_specs/pokeapi.yml
5235

53-
# 2. You can now pick the endpoints you need from the popup
36+
# 2. You can now pick both of the endpoints from the popup
5437

55-
# 3. After selecting your pokemon endpoints and hitting Enter, your pipeline will be rendered
38+
# 3. After selecting your pokemon endpoints and hitting Enter, your pipeline will be rendered.
5639

5740
# 4. If you have any kind of authentication on your pipeline (this example has not), open the `.dlt/secrets.toml` and provide the credentials. You can find further settings in the `.dlt/config.toml`.
5841

@@ -68,19 +51,32 @@ $ pip install pandas streamlit
6851
$ dlt pipeline pokemon_pipeline show
6952

7053
# 8. You can go to our docs at https://dlthub.com/docs to learn how modify the generated pipeline to load to many destinations, place schema contracts on your pipeline and many other things.
54+
55+
# NOTE: we used the `--global-limit 2` cli flag to limit the requests to the pokekom API for this example. This way the Pokemon collection endpoint only get's queried twice, resulting in 2 x 20 Pokemon details being rendered
7156
```
7257

7358
## What will be created?
59+
7460
When you run the `init` command above, the following files will be generated:
7561

76-
* `./pokemon-pipeline` - a folder containing the full project.
77-
* `./pokemon-pipeline/pipeline.py` - a file which you can execute to run your pipeline.
78-
* `./pokemon-pipeline/pokemon/__init__.py` - a file that contains the generated code to connect to the PokeApi, you can inspect this file and manually change it to your liking or to fix incorrectly generated results.
79-
* `./pokemon-pipeline/.dlt` - a folder with the `config.toml`. You can add your `secrets.toml` with credentials here.
80-
* `./pokemon-pipeline/rest_api` - a folder that contains the rest_api source from our verified sources.
62+
```text
63+
pokemon_pipeline/
64+
├── .dlt/
65+
│ ├── config.toml # dlt config, learn more at dlthub.com/docs
66+
│ └── secrets.toml # your secrets, only needed for APIs with auth
67+
├── pokemon/
68+
│ └── __init__.py # your rest_api dictionary, learn more below
69+
├── rest_api/
70+
│ └── ... # rest_api copied from our verified sources repo
71+
├── .gitingore
72+
├── pokemon_pipeline.py # your pipeline file that you can execute
73+
├── README.md # a list of your endpoints with some additional info
74+
└── requirements.txt # the pip requirements for your pipeline
8175
8276
> If you re-generate your pipeline, you will be prompted to continue if this folder exists. If you select yes, all generated files will be overwritten. All other files you may have created will remain in this folder.
8377
78+
## A closer look
79+
8480
## CLI commands
8581
8682
```console
@@ -141,6 +137,9 @@ $ dlt-init-openapi pokemon --url ... --config config.yml
141137
## Telemetry
142138
We track your usage of this tool similar to how we track other commands in the dlt core library. Read more about this and how to disable it here: https://dlthub.com/docs/reference/telemetry.
143139

140+
## Prior work
141+
This project started as a fork of [openapi-python-client](https://github.com/openapi-generators/openapi-python-client). Pretty much all parts are heavily changed or completely replaced, but some lines of code still exist and we like to acknowledge the many good ideas we got from the original project :)
142+
144143
## Implementation notes
145144
* OAuth Authentication currently is not natively supported, you can supply your own
146145
* Per endpoint authentication currently is not supported by the generator, only the first globally set securityScheme will be applied. You can add your own per endpoint if you need to.

0 commit comments

Comments
 (0)