shlogg · Early preview
Philip Perry @artisanphil

Go Huma API Versioned Documentation Setup

We can have separate documentation for each version in Go Huma by setting the docs path like this: `config.DocsPath = "/{version}/docs"`. Middleware can get the version from the path and load the description used in the docs.

We want to have a separate documentation for each version in Go Huma, e.g. /v1/docs, /v2/docs, etc.
This can be done by setting the docs path like this:

config.DocsPath = "/{version}/docs"

    
    

    
    




We can use middleware to get the version from the path in the request and load the description used in the docs depending on the version:

config := huma.DefaultConfig("API V"+versionNumberString, versionNumberString+".0.0")
                overviewFilePath := filepath.Join("/app/docs", fmt.Sprintf("v%s", versionNumberString), "overview.md")
                overview, err := ioutil....