Automagically updating oapi-codegen JSON Schema version bumps with Renovate

Featured image for sharing metadata for article

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!

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.

#blogumentation #renovate #oapi-codegen.

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.