What are Client API Stubs?
API stubs are a set of source code files with type definitions and methods prototypes, but without implementation of these methods. Some developers find it easier to use these stubs rather than programming HTTP requests.
PaperCut provide an OpenAPI specification of the AOP APIs and you can use a code generator tool to create your own API stubs. There are a variety of tools that can consume OpenAPI V3, and this example is provided to help if you have not done this before.
Basic Process
- Download the OpenAPI YAML file (there is a download button on the API ref page)
- Run the your chosen code generator, making sure use the correct programming language for your client development. For example
npx @openapitools/openapi-generator-cli generate -g python -o client_stubs -i public-bundle.yaml
In this example we are using the OpenAPI Generator (to be technically accurate we are using the NPM wrapper for the OpenAPI Generator). Other tools are available.
OpenAPI Generator tips
-
OpenAPI Generator can generate code for a wide collection of languages. Run
npx @openapitools/openapi-generator-cli list
to review -
OpenAPI Generator has a large number of options to tune the output. Try running
npx @openapitools/openapi-generator-cli help generate
or consult the docs -
Running OpenAPI Generator via
npx
every time can be slow. You can install the wrapper locally or use a Docker image to save time.