IPFS pinning services API codgen project aims to provide a way for pinning services to generate their own SDKs in 30+ languages & frameowrks easily using openapi-generator-cli
tools.
Generate OpenApi client SDKs from IPFS Pinning Service OpenAPI Specification.
We can add support for new language SDKs by following these steps:
- Find the generator name for the language here
- Add a configuration file under
config/{generatorName}.yml
(most or all generators require at leastpackageName
) - Find available configuration options by viewing the page for the generator here
- Add the desired configuration values
- Create a separate git repository for the new SDK
- Add a new entry to the matrix in
.github/workflows/generate.yml
:{ repo: "{repoName}", openapi_generator: "{generatorName}" }
. The next time the workflow is ran a PR will be created in the new repo with the generated SDK - Optionally add language templates by creating a directory
templates/{generatorName}
and placing the.moustache
files in here (see Adding custom templates) - Optionally add a new npm command to
package.json
(see existing scripts) for generation and update thegen:all
npm script
OpenApi geneartor uses mustache
as its templating engine.
As an example lets use a custom python
template:
- Create a directory with the name of the generator under the
templates
directory (i.e./templates/python
) - Find the default template that we are updating in the
openapi-generator
codebase, lets useREADME.mustache
for our example - Create
./templates/python/README.mustache
- Copy+paste the default template from the
openapi-generator
codebase in the./templates/python/README.mustache
file - Make any changes to our custom template, we can add new configuration values using
{{configValue}}
and then setting the value in the language configuration file./config/python.yml
like soconfigValue: Hello
- Run generation
npm run gen:py
, our template changes will be observable in the produced file:out/python/README.md
Install dependencies:
docker
, make sure your docker daemon is running before generatingnodejs
&npm
Now perform the following:
- the location of the openapi spec is locked to ipfs pinning service OpenAPI spec repo at: https://raw.githubusercontent.com/ipfs/pinning-services-api-spec/master/ipfs-pinning-service.yaml (so it will always pull the latest version and generate the latest SDKs when you run)
npm run build
npm run gen:all
to generate all language SDKs ORnpm run gen:py
to generate the python SDK for example
All generated SDKs can be viewed and tested in /out folder under their respective languages. Test files templates are generated so are the documentation of the SDKs.