This directory contains configuration to generate OpenAPI client together with custom templates for part of generated code. Layout:
- configs - configuration files
- custom_templates - custom_templates directory used for client
Client is created using OpenAPI generator. Python language was marked as STABLE recently by PR.
OpenAPI client generation is orchestrated by script scripts/generate_client.sh. Script either creates a new client
if no such exists or updates existing client code.
Use prepared make targets from repository root:
make api-client
Predefined targets use http://localhost:3000 URL to fetch OpenAPI schema. If you need to connect to the GoodData
services running in docker-compose, you can use the gooddata-python-sdk_default network. The docker-compose.yaml
in the repository root starts all required GoodData microservices for testing and development.
When you need to point generator to different schema source, use generate_client.sh script directly.
Below is the example for gooddata-scan-client and schema on URL https://my-gd-cn, execute it from
the repository root:
./scripts/generate_client.sh gooddata-scan-client -u 'https://my-gd-cn'When the schema source is available only in docker on the localhost use parameter -n to specify docker network
name:
./scripts/generate_client.sh gooddata-scan-client -u 'https://my-gd-cn' -n 'my-gd-cn-network-name'It is possible to generate default openapi generator templates. Execute the following from the repository root
docker run --rm \
-v "$(pwd):/local" \
-u $(id -u ${USER}):$(id -g ${USER}) \
openapitools/openapi-generator-cli:v6.0.1 author template \
-g python --library urllib3 \
-o /local/.openapi-generator/templatesTemplates can be used as the base for customizations. See templating documentation for the details.
If new file needs to be added refer to customization documentation.
List of options available for python generator is here.
There are also options common to all generators. Execute docker cli with help to list them.
docker run --rm \
-u $(id -u ${USER}):$(id -g ${USER}) \
openapitools/openapi-generator-cli help generateCode used to generate python client code is here
- Find out the last used generator version and the last used OpenAPI version
- Dump default templates and compare them with custom templates
- Update custom templates based on a new updates from generated templates
- Generate new clients using new version of generator and the last used version of OpenAPI
Metadata OpenApi specification is missing response schema or the following resources:
- /api/config
- /api/options/availableDrivers
This inconsistency will be addressed by future GD.CN version.
It unfortunately causes NullPointerException in openapitools/openapi-generator-cli:v5.3.1 and later.
Do the following to generate the file:
- store OpenApi schema to localhost to repository root
- add missing response schemata
- generate metadata client using
./scripts/generate_client.sh gooddata-metadata-client -f "/local/<name_of_openapi_json_file>.json"
- /api/options
{ "schema": { "type": "object", "description": "A hashmap of all available datasource drivers", "properties": { "options": { "type": "object", "properties": { "description": { "type": "string" }, "links": { "type": "object", "properties": { "availableDrivers": { "type": "string" } } } } } } } } - /api/options/availableDrivers
{ "schema": { "type": "object", "description": "A hashmap of all available datasource drivers", "additionalProperties": { "type": "string" } } }