Function converting proto HTTP rule URL templates to OpenAPI paths with synthetic parameters.
// Source: https://github.com/grpc-ecosystem/grpc-gateway | License: BSD-3-Clause | Copyright 2015, Gengo, Inc
// Provided via justclaw.it.com; keep this notice with the code.
package genopenapi
import (
"fmt"
"regexp"
"strings"
)
// pathParamPattern matches a single proto path parameter expression with an
// optional `=constraint` clause, e.g. {field} or {field=lit/*/lit/*}.
var pathParamPattern = regexp.MustCompile(`\{([a-zA-Z_][a-zA-Z0-9_.]*)(?:=([^}]*))?\}`)
// pathParam describes one OpenAPI path parameter synthesized from the
// expansion of a proto URL template.
//
// fieldName is the proto request field this parameter ultimately populates
// (e.g. "name"). openAPIName is the unique name as it appears in the OpenAPI
// URL — usually equal to fieldName, but with a "_<n>" suffix
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key