1
0
mirror of synced 2026-01-02 21:02:43 -05:00
Files
airbyte/airbyte-cdk/python/bin/generate-component-manifest-files.sh
Alexandre Girard 0a91a98370 Add descriptions and examples to component schema (#25117)
* Reference docs for backoff strategies

* Docs for most authentication mechansims

* Docs for CheckStream

* MinMaxDatetime

* DeclarativeStream

* DefaultErrorHandler

* CompositeErrorHandler

* update

* Update token expiry date description

* DPath extractor

* Add interpolation_context

* HttpResponseFilter

* RecordFilter

* RecordSelector

* DefaultPaginator

* CursorPagination

* OffsetIncrement

* Page Increment

* PrimaryKey

* HttpRequester

* request option and request path

* Schemas

* Spec

* Add field

* remove fields

* no auth and no pagination

* Delete deprecated comment

* Missing description

* Json Decoder

* OAuthConfigSpecification

* reorder

* add titles, examples, and descriptions for partition routers and datetime based cursor

* updates

* Update

* fix indentation

* Automated Commit - Formatting Changes

* Update as per feedback

* html tag

* generate models

* Update name

* do not use title as class name

* Update

* Add stream_interval and stream_partition to interpolation_context

* Automated Commit - Formatting Changes

* fix path

* format

---------

Co-authored-by: brianjlai <brian.lai@airbyte.io>
Co-authored-by: girarda <girarda@users.noreply.github.com>
2023-04-21 10:58:23 -07:00

40 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
[ -z "$ROOT_DIR" ] && exit 1
YAML_DIR=airbyte-cdk/python/airbyte_cdk/sources/declarative
OUTPUT_DIR=airbyte-cdk/python/airbyte_cdk/sources/declarative/models
function main() {
rm -rf "$ROOT_DIR/$OUTPUT_DIR"/*.py
echo "# generated by generate-component-manifest-files" > "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
for f in "$ROOT_DIR/$YAML_DIR"/*.yaml; do
filename_wo_ext=$(basename "$f" | cut -d . -f 1)
echo "from .$filename_wo_ext import *" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
docker run --user "$(id -u):$(id -g)" -v "$ROOT_DIR":/airbyte airbyte/code-generator:dev \
--input "/airbyte/$YAML_DIR/$filename_wo_ext.yaml" \
--output "/airbyte/$OUTPUT_DIR/$filename_wo_ext.py" \
--disable-timestamp \
--enum-field-as-literal one
# There is a limitation of Pydantic where a model's private fields starting with an underscore are inaccessible.
# The Pydantic model generator replaces special characters like $ with the underscore which results in all
# component's $parameters field resulting in _parameters. We have been unable to find a workaround in the
# model generator or while reading the field. There is no estimated timeline on the fix even though it is
# widely debated here:
# https://github.com/pydantic/pydantic/issues/288.
#
# Our low effort way to address this is to perform additional post-processing to rename _parameters to parameters.
# We can revisit this if there is movement on a fix.
temp_file=$(mktemp)
sed 's/ _parameters:/ parameters:/g' "$ROOT_DIR/$OUTPUT_DIR/$filename_wo_ext.py" > "${temp_file}"
mv "${temp_file}" "$ROOT_DIR/$OUTPUT_DIR/$filename_wo_ext.py"
done
}
main "$@"