Skip to content

ReferenceV3 resolves incorrect value for schema names that start with Http #2234

@captainsafia

Description

@captainsafia

In ASP.NET Core, there are two types named HttpValidationProblemDetails and HttpProblemDetails that developers can use to return the responses that comply with the ProblemDetails RFC.

The type names are used as the schema IDs in the default implementation of our OpenAPI generation.

This presents an issue with the current logic of the ReferenceV3 property which has a special case around IDs that start with HTTP.

public string ReferenceV3
{
get
{
if (IsExternal)
{
return GetExternalReferenceV3();
}
if (!Type.HasValue)
{
throw new ArgumentNullException(nameof(Type));
}
if (Type == ReferenceType.Tag)
{
return Id;
}
if (Type == ReferenceType.SecurityScheme)
{
return Id;
}
if (Id.StartsWith("http", StringComparison.OrdinalIgnoreCase))
{
return Id;
}
return "#/components/" + Type.Value.GetDisplayName() + "/" + Id;
}
}

The end result being that schema references for these types do not get generated correctly.

Image

We should switch to a more resilient URL check for this case to avoid mishandling schema IDs that are intentionally beginning with Http.

cc: @mikekistler the distinguished bug finder

Metadata

Metadata

Assignees

Labels

WIPpriority:p1High priority but not blocking. Causes major but not critical loss of functionality SLA <=7daystype:bugA broken experiencetype:regressionA bug from previous release

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions