Selective Generation with Swagger Codegen

Swagger Codegen is a tool for generating server stubs and client SDKs for any API defined with an OpenAPI specification. This is particularly useful when you are following a spec-first API development approach.

When generating the stub code for the backend powering the API, it may not always be desirable to generate stubs for every endpoint in the same module. This will depend on the number of endpoints in your API definition, and your approach to the contents of deployed services (Microservices or otherwise). There does not appear to be a documented way to only generate stubs for some API paths using this tool. There does however appear to be an undocumented one.

» Continue reading

Git Commit Hooks for Branch Naming Using Pre-commit

In many organisations there are conventions on how Git branches should be named. As with all aspects of code quality, it is better to be able to identify these issues before they are pushed into version control.

There is not a hook that we can specifically use at the point that a branch is created, so the best we can do is ensure that commits are not made to the newly created branch.

» Continue reading

Running HomeBridge on Docker without Host Network Mode - Additional Accessories

This is just a quick post to announce that a new version of the generate_service.sh script is now available.

Instead of putting the source for this into this post, I’ve now committed it to a Github repository here: generate_service.sh. This version adds support for generating additional service files for accessories defined under a platform in Homebridge.

I have been testing this out with a Samsung Tizen based TV, but this has exposed another issue with Wake-on-Lan packets not being able to be routed from a Docker network without using host mode. I’m still investigating options to solve this, which will be another post (or defeat, time will tell).

Managing Git Hooks in Maven Projects

Git hooks are a fantastic first step for identifying issues before code is pushed to a repository. However, the configuration files which control these client-side hooks cannot be committed to the repository and need to be configured on each client once the repository has been checked out.

In the NPM world, Husky is a tool which is used to maintain commit hooks through the package.json file, and integrates with the NPM build lifecycle to keep the contents of the local “.git/hooks” folder up to date. With this, I have been using commitlint for ensuring commit messages conform to a standard format, as well as ensuring code has had linting checks ran against it.

I had a look for a similar solution for Maven, but could not immediately find one. I wanted to find a solution that could be integrated with the Maven lifecycle, like Husky does for NPM.

» Continue reading