dlt-hub / verified-sources

Contribute to dlt verified sources 🔥
https://dlthub.com/docs/walkthroughs/add-a-verified-source
Apache License 2.0
48 stars 38 forks source link

reset_api: allow JSONPath in field value in ResolveParamConfig #471

Closed burnash closed 1 month ago

burnash commented 1 month ago

This pull request adds ability to use JSONPath in path parameter resolve configuration:

Example:

Suppose you have parent resource data item like:

{
    "number": 42,
    "nested_data": {
       "some_nested_identifier": 24,
       ...
    }
}

Before this PR you could only refer the number field, like so:

{
    "resources": [
        ...
        {
            "name": "issue_comments",
            "endpoint": {
                "path": "issues/{issue_number}/comments",
                "params": {
                    "issue_number": {
                        "type": "resolve",
                        "resource": "issues",
                        "field": "number",
                    }
                },
            },
        },
    ],
}

With this PR you can also refer nested_data.some_nested_identifier field by using JSONPath:

{
    "resources": [
        ...
        {
            "name": "issue_comments",
            "endpoint": {
                "path": "issues/{issue_number}/comments",
                "params": {
                    "issue_number": {
                        "type": "resolve",
                        "resource": "issues",
                        "field": "nested_data.some_nested_identifier",
                    }
                },
            },
        },
    ],
}
burnash commented 1 month ago

Thanks @rudolfix, I think passing compiled jsonpath should be covered already per se, it's just the typing needs to be updated, isn't it?