Thank you for reaching out to Microsoft Q & A forum.
Here are some steps to resolve the 404 issue with /openapi/v1.json:
1.Ensure OpenAPI is properly registered Replace builder.Services.AddOpenApi("internal"); with:
builder.Services.AddOpenApi();
This ensures the OpenAPI services are correctly set up.
2.Correct the OpenAPI endpoint mapping Make sure app.MapOpenApi(); is placed before app.UseRouting(); to ensure it is properly registered.
3.Enable Swagger middleware If you are using Swashbuckle, make sure app.UseSwagger(); is not commented out, and verify the Swagger UI mapping:
app.UseSwaggerUI(c => c.SwaggerEndpoint("/openapi/v1.json", "Client API"));
Ensure the endpoint name matches the OpenAPI document name.
4.Check project configuration In your .csproj file, confirm that OpenAPI document generation is enabled:
<OpenApiGenerateDocuments>true</OpenApiGenerateDocuments>
This allows OpenAPI documents to be generated at build time.
5.Enable logging for debugging To capture potential errors, add:
builder.Logging.AddDebug();
builder.Logging.AddConsole();
This can help identify if there are any underlying issues.
After making these changes, rebuild and test the /openapi/v1.json endpoint again.
Please feel free to contact us if you have any additional questions.
If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.