Rfc6570VariableMapper.TryBuildRfc6570Variables method (1 of 2)

Backwards-compatible overload that discards detailed error information.

public static bool TryBuildRfc6570Variables(HttpContext context, string openApiPathTemplate, 
    out Dictionary<string, object?> variables)
parameter description
context The HTTP context containing route values from ASP.NET Core routing.
openApiPathTemplate The OpenAPI 3.2 RFC 6570 path template.
variables When true, contains variable assignments.

Return Value

True on success; otherwise false.

See Also


Rfc6570VariableMapper.TryBuildRfc6570Variables method (2 of 2)

Attempts to build RFC 6570 variable assignments from an ASP.NET Core HTTP context.

public static bool TryBuildRfc6570Variables(HttpContext context, string openApiPathTemplate, 
    out Dictionary<string, object> variables, out string? error)
parameter description
context The HTTP context containing route values from ASP.NET Core routing.
openApiPathTemplate The OpenAPI 3.2 RFC 6570 path template (e.g., “/files/{+path}” or “/users/{id}”).
variables When this method returns true, contains a dictionary of variable names to their values. Variable names are extracted from the OpenAPI path template, and values are taken from ASP.NET route values.
error When this method returns false, contains a human-readable error message.

Return Value

True if variable assignments were successfully built; false if the context or template is invalid.

Remarks

This helper only prepares variable values. Actual URI template expansion (percent-encoding rules) is performed by an RFC 6570 expander.

  • Simple variables: {id}
  • Reserved expansion: {+path} (multi-segment)
  • Explode modifier: {path*} (multi-segment)

The OpenAPI template determines whether a variable is multi-segment ({+var} / {var*}). This method does not parse the ASP.NET route template to infer expansion semantics.

var template = "/users/{id}";
if (Rfc6570VariableMapper.TryBuildRfc6570Variables(context, template, out var vars, out var error))
{
    // vars contains: { "id" = "123" }
}

See Also