Automagically updating oapi-codegen JSON Schema version bumps with Renovate

A number of releases ago, I introduced a JSON Schema for oapi-codegen's configuration file format, to aid with editor-driven autocomplete.

It's best if you pin this, so you're not trying to use features that don't yet exist, like so:

# yaml-language-server: $schema=https://raw.githubusercontent.com/oapi-codegen/oapi-codegen/v2.6.0/configuration-schema.json
package: api
# ...

But if so, how do you update that? Do you need to do it manually after each release?

Y'all will be unsurprised to know that you can do this in a straightforward means, using Renovate.

Using the following renovate.json with a Custom Manager:

{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "customManagers": [
    {
      "customType": "regex",
      "managerFilePatterns": [
        "**/config.yaml"
      ],
      "matchStrings": [
        "# yaml-language-server: \\$schema=https://raw.githubusercontent.com/oapi-codegen/oapi-codegen/(?<currentValue>[^/]+)/configuration-schema.json"
      ],
      "depNameTemplate": "github.com/oapi-codegen/oapi-codegen/v2",
      "datasourceTemplate": "go"
    }
  ]
}

This will now detect the version accordingly, and new version bumps to oapi-codegen will also bump in the configuration file - test it out!

Alternatively, you can use our pre-built preset:

{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": [
    "github>oapi-codegen/renovate-config:user"
  ]
}

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

This blog post is 100% human-written, and has nothing derived from LLMs (be it code, editorial support or prose).

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.