Git Tagged Stash

Devs, like Firefighters, live and die by their tools. Well, not literally. Unlike firefighters, when we made mistakes in using our tools, the spectrum of effect is rather broad. Ranging from mild inconvenience to mistakenly dropping prod db.

Most of the time, we only focus on how our tools help our work. Disregarding the amount of complexity hidden inside the tool itself. Those complexities often arise from needs to cover multiple possible workloads. With only small subset of those features is directly usable for our use case.

While this may be enough for day-to-day work, there are times when we fall into “add another tool” trap. Mostly because we need to improve our experience with existing tools, or because we think that our current tools did not cover our use case. Despite the fact that our current tool can actually handle the task just fine.

This is either due to our lack of understanding of the tool. Or simply due to lack of desire to learn said tool in-depth. While the later factor is somewhat difficult to deal with, the former can be “fixed” by doing some exploratory exercises and a lot of reading. Yes, it boils down to good-old RTFM. What a surprise!

Lanjutkan membaca Git Tagged Stash

Automate OpenApi Path Aliasing for NelmioApiDoc

When using Nelmio with serialization groups, there’s a “small” caveat. As mentioned in the documentation:

If you are using serialization contexts (e.g. Groups) each permutation will be treated as a separate Path. – source

This means that for each serialization group, the number of generated paths will grow really fast, since it provides each permutation with its own path. For example, if you have list and detail groups, you’ll have (2 custom + 1 default)! = 6 possible paths.

While it seems to be a non-issue at first, imagine when you’re building a structure to consume the API and can’t decide whether User1 and User23 can be simplified into a union type before actually inspecting the actual response. Worse still, any changes in backend code that affect either serialization group or parsing logic would remove any guarantee that the variant number still refer to the same structure. Madness!

Lanjutkan membaca Automate OpenApi Path Aliasing for NelmioApiDoc