DEV Community


Posted on

Building SDKs for your SAAS

Building SDKs for your SAAS

I recently build a service, docxmerge, which does a merge from a Microsoft Word and JSON document and converts it to PDF.

The API is very simple, but in order to make easy for developers to integrate it in their applications, I chose to create a library for at least four languages, NodeJS, Dotnet, Java, and Python.

Yeah, it looks like we got a bit of work. This task can be either too easy or too embarrassing. But I had a benefit, which was to use Swagger for the API definition, so basically, I could generate all the boilerplate code and just do a class in every language and publish it to the corresponding registry.

With Swagger, all is based on the JSON generated in the backend in this case the next one:

Having that JSON, the swagger codegen is able to generate the code to interact with your api in a typed way and with no effort at all. I generate that code with docker which is much cleaner:

docker run --rm --network=host -v ${PWD}/src/swagger:/local swaggerapi/swagger-codegen-cli:v2.3.1 generate -i ${SWAGGER_URL} -l typescript-node -o /local --additional-properties supportsES6=true

As a said, Swagger was the biggest advantage, as it was effort free and I didn't have to worry about paths, query strings, multipart requests, etc. And lucky me, I was able to generate it from C# annotations using this Swashbucle library , so didn't have to write that mega JSON ;)

I will do one post per language explaining how I built each library from the swagger-codegen to the publish.

This is the repository where I'm working:

It's still in progress, and I'm still missing the Java one to be deployed because of the verification, but it works.

Top comments (0)