I'm using deepmap/oapi-codegen to generate a chi-server from a openapi 3.0.3 specification, most of it works just fine but I'm having an issue with UUID validation. I've defined a path parameter like this (not a complete definition):
openapi: "3.0.3"
info:
title: "Example"
description: "Sites API"
version: "0.0.3"
paths:
/sites/{siteId}:
parameters:
- in: path
name: siteId
required: true
schema:
type: string
format: uuid
The generated validator seems to recognize invalid UUIDs correctly but insists on throwing a 500 error if the UUID is invalid. Looking at the code for the validation it seems it may have something to do with an upstream issue but as I'm completely new in the go world I'm not completely sure I'm following the flow correctly.
This is the code that sets up the chi-router:
swagger, err := Openapi.GetSwagger()
if err != nil {
s.logger.Error().Msg("Error loading swagger spec.")
}
swagger.Servers = nil
router := chi.NewRouter()
router.Use(middleware.OapiRequestValidator(swagger))
Openapi.HandlerFromMux(s.api, router)
api.Server = &http.Server{
Handler: router,
Addr: fmt.Sprintf("0.0.0.0:%s", config.Port),
}
Has anyone out there seen this issue? If so, is there a fix/workaround to this? Am I forgetting something obvious in my code?