Skip to content

IPFS pinning services api codgen project aims to provide a way for pinning services to generate their own SDKs easily by using github actions.

License

Notifications You must be signed in to change notification settings

JenksyGuo/pinning-services-api-codegen

Repository files navigation

IPFS Pinning Service API OpenAPI Code Generation Project

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.

Latest generated SDKs

Screen Shot 2021-12-10 at 11 12 50 pm

Adding new language targets

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 least packageName)
  • 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 the gen:all npm script

Adding custom templates

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 use README.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 so configValue: Hello
  • Run generation npm run gen:py, our template changes will be observable in the produced file: out/python/README.md

Running locally

Install dependencies:

  • docker, make sure your docker daemon is running before generating
  • nodejs & npm

Now perform the following:

Generated SDKs & Documentation

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.

About

IPFS pinning services api codgen project aims to provide a way for pinning services to generate their own SDKs easily by using github actions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published