Configuring host, scheme and base path with SwashBuckle

Configuring host, scheme and base path with SwashBuckle

Swagger 2.0 supports specifying both host, scheme and base path directly in the swagger document. By default SwashBuckle does not set any values for these properties in the swagger document.

The following snippet will dynamically add the properties taken from the request to the swagger document:

app.UseSwagger(c =>
{
    c.PreSerializeFilters.Add((swaggerDoc, httpReq) => {
        swaggerDoc.Host = httpReq.Host.Value;
        swaggerDoc.Schemes = new List<string>() { httpReq.Scheme };
        swaggerDoc.BasePath = httpReq.PathBase;
    });
});

 

Cannot find project info for ‘project’. This can indicate a missing project reference.

While trying out migrating a few old projects to ASP.NET Core 1.1, I stumbled upon this error when trying to the build the project.

For some reason VS does not inform about which specific references are missing. Imagine the following scenario:

Library A -> Library B

Library C -> Library A

If Library A expose any types from Library B, then C would require a direct reference to B. However, if A does not expose any of B’s types, then C can reference A without a direct reference to B.

So, VS 2017 will give you ‘Cannot find project info for (…)’ error when you don’t have the necessary direct references. Unlike previously, it will not inform which dependencies are required.

Edit: Seems the error occurs for several different issues. See more on this github issue.