You have an API with a Swagger UI page and you need to export swagger to JSON, meaning the swagger.json file, for a client generator, an API gateway or a teammate. You do not need Postman or any extra tool: the document is just a URL served by your app, or a file you can have the build write for you. Which URL depends on the stack. On a new .NET 9 or .NET 10 project it is /openapi/v1.json, on Swashbuckle it is /swagger/v1/swagger.json, and if you are not sure, the browser Network tab shows it.

Find the swagger.json URL in Swagger UI
Swagger UI is only a viewer. It loads a JSON or YAML document from a URL, and that same URL is what you export. Many Swagger UI pages show the link under the page title. If yours does not:
- Open the Swagger UI page, then open the browser developer tools (F12) and choose the Network tab.
- Refresh the page and filter by Fetch/XHR or search for
swagger,openapiorapi-docs. - Click the request that returns the document. Its URL is the one to save, and the Response tab shows the content.
If the page itself shows an error instead, read Failed to load API definition: undefined /swagger/v1/swagger.json. I did not test the browser steps in this guide, because they depend on your own site.
| Stack | Default document URL |
|---|---|
| .NET 9 and .NET 10 built-in OpenAPI | /openapi/v1.json (YAML needs an extra mapping, see below) |
| Swashbuckle.AspNetCore | /swagger/v1/swagger.json and /swagger/v1/swagger.yaml |
| Node.js with swagger-jsdoc | no default: you serve it, for example /openapi.json |
| Spring Boot with springdoc | /v3/api-docs and /v3/api-docs.yaml |
Export OpenAPI JSON and YAML in .NET 9 and .NET 10
New Web API templates use the built-in Microsoft.AspNetCore.OpenApi package, not Swashbuckle. It generates the document but ships no UI, which is why there is no /swagger page in a new project.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.MapOpenApi(); // /openapi/v1.json
app.MapOpenApi("/openapi/{documentName}.yaml"); // /openapi/v1.yaml
}
app.Run();
What I got when I ran this on .NET 10.0.401 with Microsoft.AspNetCore.OpenApi 10.0.12:
GET /openapi/v1.jsonreturned 200 and the document started with"openapi": "3.1.1".GET /openapi/v1.yamlreturned 404 until I added the secondMapOpenApiline. YAML is not on by default, so map the route with a.yamlsuffix as the Generate OpenAPI documents (Microsoft Learn) describes. After that it returned 200 andopenapi: '3.1.1'.- With the environment set to Production and the mapping inside the Development check,
/openapi/v1.jsonreturned 404. If you see a 404 outside development, this is the usual reason.
Get OpenAPI 3.0 instead of 3.1
.NET 10 generates OpenAPI 3.1 by default. If a downstream tool only reads 3.0, set the version explicitly:
builder.Services.AddOpenApi(options =>
{
options.OpenApiVersion = Microsoft.OpenApi.OpenApiSpecVersion.OpenApi3_0;
});
I checked this: the document then started with "openapi": "3.0.4".
Write the file during the build (CI friendly)
You can also have the build write the document, with no running server. Add the package Microsoft.Extensions.ApiDescription.Server and these properties:
<PropertyGroup>
<OpenApiGenerateDocuments>true</OpenApiGenerateDocuments>
<OpenApiDocumentsDirectory>./</OpenApiDocumentsDirectory>
</PropertyGroup>
After dotnet build the file appeared next to the project, named after the project (oa.json in my test, with package version 10.0.0). Build-time YAML is not supported according to the Microsoft docs, so in CI either keep the JSON or fetch the YAML from a running instance.
Swashbuckle: URL and the swagger CLI
With Swashbuckle, UseSwagger() serves both formats. On a running app, /swagger/v1/swagger.json and /swagger/v1/swagger.yaml both returned 200 in my test with Swashbuckle.AspNetCore 10.1.7. To write the files without starting the app, use the CLI tool:
dotnet new tool-manifest
dotnet tool install Swashbuckle.AspNetCore.Cli --version 10.1.7
dotnet build
dotnet swagger tofile --output swagger.json bin/Debug/net10.0/MyApi.dll v1
dotnet swagger tofile --yaml --output swagger.yaml bin/Debug/net10.0/MyApi.dll v1
Both commands succeeded and produced OpenAPI 3.0.4 files. One thing I noticed: without a SwaggerDoc definition the info.title was the assembly name with version and culture text, so set a real title in AddSwaggerGen. See Swashbuckle.AspNetCore on GitHub for the CLI options. Not sure whether to stay on Swashbuckle? Read NSwag vs Swashbuckle.
Node.js and Express
In Node there is no default route, so serve the specification yourself next to the UI. This ran on Node 26 with express 5.3.0, swagger-jsdoc 6.3.0 and swagger-ui-express 5.0.1:
const express = require("express");
const swaggerJsdoc = require("swagger-jsdoc");
const swaggerUi = require("swagger-ui-express");
const specs = swaggerJsdoc({
definition: { openapi: "3.0.0", info: { title: "Demo API", version: "1.0.0" } },
apis: ["./app.js"],
});
const app = express();
app.get("/openapi.json", (req, res) => res.json(specs)); // the raw document
app.use("/docs", swaggerUi.serve, swaggerUi.setup(specs)); // the UI
app.listen(3000);
/openapi.json returned 200 with the generated document and /docs/ returned the UI. More setup steps are in adding Swagger OpenAPI to Node.js and Express.
Spring Boot
With springdoc-openapi the JSON is at /v3/api-docs and the YAML at /v3/api-docs.yaml, as listed in the springdoc-openapi documentation. I did not run a Spring project for this guide.
Save the file and fix common errors
Any client that can fetch a URL works. In the browser use Save As on the document URL, or use curl:
curl -o openapi.json http://localhost:5000/openapi/v1.json
# with a bearer token when the docs endpoint is protected
curl -H "Authorization: Bearer $TOKEN" -o openapi.json https://api.example.com/openapi/v1.json
I ran the first form against local apps and it saved the file. In PowerShell the equivalent is Invoke-WebRequest -Uri <url> -OutFile openapi.json; I could not run PowerShell here, so that line is untested.
- 404 in staging or production: the mapping sits inside an
IsDevelopment()check. Decide whether the document should be public before you move it. See enabling OpenAPI per environment. - 401 or 403: the docs endpoint is protected. Send the same token or cookie as for any other call.
- YAML returns 404 on .NET 10: add the
.yamlmapping shown above. - A tool rejects the file: it may only support OpenAPI 3.0. Set
OpenApiVersionor see converting Swagger 2.0 to OpenAPI 3.1.
What was tested and what was not
- Run on .NET SDK 10.0.401: built-in OpenAPI JSON and YAML URLs, the 404 outside development, OpenAPI 3.0 and 3.1 output, the build-time export, Swashbuckle URLs and CLI, curl downloads. Node 26 with Express, swagger-jsdoc and swagger-ui-express.
- Not tested: Spring Boot (URLs are from the springdoc documentation), PowerShell, and the browser Network tab steps.
Summary
- Swagger UI only displays a document; the document URL is what you export.
- Built-in .NET 9 and 10:
/openapi/v1.json. Swashbuckle:/swagger/v1/swagger.json. Spring:/v3/api-docs. - YAML on the built-in generator needs its own
MapOpenApiroute with a.yamlsuffix. - For CI, use the build-time export or
dotnet swagger tofileinstead of starting the app.
Found this useful?
Bookmark this page and share it with your team. Get new .NET, cloud and database tutorials in your inbox.
Export swagger.json FAQ
What is the default swagger.json URL in ASP.NET Core?
With Swashbuckle it is /swagger/v1/swagger.json. With the built-in OpenAPI support in .NET 9 and later it is /openapi/v1.json. The v1 part is the document name, so a custom name changes the URL.
Why is there no swagger.json in my .NET 10 project?
New templates use Microsoft.AspNetCore.OpenApi, which serves /openapi/v1.json and includes no Swagger UI. Add Swagger UI, Scalar or Swashbuckle if you want a page or the old path.
How do I export the OpenAPI document as YAML?
On the built-in generator, map a second route with app.MapOpenApi("/openapi/{documentName}.yaml") and request that URL. With Swashbuckle, request /swagger/v1/swagger.yaml or run dotnet swagger tofile --yaml.
Did you find your swagger.json? Tell us in the comments which stack you used.
