Makefileincludes tasks to generate and validate the full SDK and to onboard a new service to the SDKMakefile.<service>includes tasks for generating and validating a single service from its OpenAPI specspec/services/<service>/oas3.fetcheda directory of the latest fetched OpenAPI spec for a single servicespec/services/<service>/oas3.patcheda directory of the latest patched OpenAPI spec for a single servicespec/services/<service>/patches/*.patchpatch files to apply against the fetched OpenAPI spec for a single serviceexamples/hand crafted examples to demonstrate usageservices/<service>generated Go client for a single service
If need to change how the make tasks run the containers used in this repo, you can use the DOCKER_EXTRA_ARGS environment variable that the Make tasks will pass to the docker CLI.
For example, if you have custom CA certificates on your host machine that you want to use inside the containers, you can run the following commands before executing any make tasks:
# Make a certificate directory that is not inside any git repo
export CUSTOM_CERT_DIR="${HOME}/.certs"
export CA_FILE_NAME="ca-certificates.crt"
mkdir -p ${CUSTOM_CERT_DIR}
# Export CA certificates from system keychain into certificate directory
security export -t certs -f pemseq -k /System/Library/Keychains/SystemRootCertificates.keychain -o ${CUSTOM_CERT_DIR}/${CA_FILE_NAME}
# Append CA certificates from user keychain into CA file created above
security export -t certs -f pemseq -k /Library/Keychains/System.keychain >> $CUSTOM_CERT_DIR/${CA_FILE_NAME}
export DOCKER_EXTRA_ARGS="-v $(realpath ${CUSTOM_CERT_DIR}):/etc/ssl/certs"
# Run `make` tasks as documented belowTBD
TBD
To build the full SDK, run make generate-all.
To build the client for a single service, run make -f Makefile.<service> generate
To add support for a new Equinix service to this SDK, you first need to publish a valid, complete OpenAPI spec for that service. Once the OpenAPI spec is published:
- Run
make onboard-service - Specify a name for the service
- The name should be lower-case alphanumeric; we recommend basing the name on the API URL. For example, given a service
api.equinix.com/mysvc/v9, a good service name would bemysvcv9
- The name should be lower-case alphanumeric; we recommend basing the name on the API URL. For example, given a service
- Specify the URL to the OpenAPI spec for the service
- The OpenAPI spec must be served on a URL that is publicly available and does not require authentication
The onboarding process will create a new file Makefile.<service>, where <service> is the name you specified in (2) above.
The onboarding proces will automatically attempt to download the spec and generate the initial client. If initial generation fails, you may need to add custom templates or patch the OpenAPI spec for your service.
This repo uses openapi-generator to generate Go code. When necessary, we can provide custom templates to the generator in order to change the generated code.
When a service is onboarded, an empty templates/services/<service>/ directory is created. To modify generated code, you can put a custom template in this directory. Templates that are known to the generator can be seen here: https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/go
Before adding custom templates for a service, review the openapi-generator docs for templating.
While we aim to publish OpenAPI specs that can be used as-is for code generation, we sometimes need to make changes to a service's spec within the SDK in order to address language-specific concerns or work around an issue while waiting for a long-term fix. When necessary, you can patch the spec for a single service as follows:
- Make changes in
spec/services/<service>/oas3.patched/dir. - Create a patch file from the modified spec dir:
git diff spec/services/<service>/oas3.patched > spec/services/<service>/patches/<patchfilename> cd .. patchfilenameshould be in format:<patch_index>-<short_patch_decription_or_identifier>.patch- Run
make -f Makefile.<service> patchto reapply the changes to the fetched OpenAPI spec and confirm that the patched spec includes the expected changes - Run
make -f Makefile.<service> generateto regenerate the code using the patched spec and confirm that the code generates successfully and works as expected
The steps below may vary by service, depending on decisions made by the CODEOWNERS for that service, but by default the process for pulling in the latest OpenAPI specification for a service and regenerating the code is:
- Publish the updated OpenAPI specification (that happens outside of this repository)
- If necessary, update the
SPEC_BASE_URLandSPEC_ROOT_FILEto match the URL where the updated OpenAPI specification is published - Go to the Actions page and find the sync workflow for your service, and click the workflow name. The name will be in the format
Sync <service> API spec. - Click the gray
Run workflowbutton, check thatmainis selected in the popup, and then click the greenRun workflowbutton in the popup to run the sync workflow - The sync workflow will open a Pull Request (PR) that includes the OpenAPI specification updates as well as any code changes caused by the update.
After merging your service changes you can release a new version of this SDK that includes your updates.
This SDK uses a Semantic Release action to automatically determine the next release version based on Conventional Commit tags in commit messages. There is a push-button workflow for releasing the SDK after changes are made:
- Navigate to the Release workflow.
- Click the gray
Run workflowbutton, check thatmainis selected in the popup, and then click the greenRun workflowbutton in the popup to run the sync workflow
The release workflow will determine the next version, regenerate the code with the updated version number, and create a GitHub Release.