Unable to render this definition
The provided definition does not specify a valid version field.
Please indicate a valid Swagger or OpenAPI version field. Supported version fields are swagger: "2.0" and those that match openapi: 3.x.y (for example, openapi: 3.1.0).



Sangeetha SRank #212 · 11.4K reputationPosted Jul 24, 2025, 9:25 AM EDT
It looks like you're working with a Swagger or OpenAPI specification file, and you're encountering an error related to the version field.
To fix this, ensure your specification includes one of the following valid version fields at the top of the file:
For Swagger 2.0
swagger: "2.0"
For OpenAPI 3.x.y (e.g., 3.0.0, 3.1.0):
Ajay BansodeRank #7,443 · 241 reputationPosted Jul 24, 2025, 12:54 PM EDT
Check that the Package is installed in your project
Swashbuckle.AspNetCoreis use to dependent for Swagger and openApi.Make sure your project refer this package.
After starting your application and swagger
Ctrl + Shift + R is used to refresh the swagger.
Cynthia SathuragiriRank #937 · 2.2K reputationPosted Jul 25, 2025, 12:56 AM EDT
Your API spec must include one of these fields at the root level:
swagger: "2.0" or openapi: "3.0.0" or "3.1.0"
If you’re using Swashbuckle in .NET, check your
Startup.csorProgram.csconfiguration:services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
});
confirm the top line has
openapi: "3.0.1"orswagger: "2.0".