How to Export Swagger.Json- OpenAPI without tools

Today in this article, we will see How to Export Swagger.Json without tools using existing available API endpoint URLs
Updated October 2026: built-in .NET 9/10 OpenAPI paths, build-time export and Swashbuckle CLI fixes, and an FAQ.
What is Swagger.JSON
Swagger is the entire schema definition of your API. Swagger JSON contains the entire schema with details on the endpoint, request, and response object supported by your API.
Swagger or OpenAPI describes the standards and specifications for the RESTFul API description. These specifications are an attempt to create a universal and language agnostic description for describing the REST API and its capability.
If you are already following recent OpenAPI V3.0 specifications which are guidelines and specifications around how the API documentation should be then you will inbuilt capability on generating the API documentation by using the Swagger UI feature.
This swagger UI feature is supported in all types of languages including .NET, Java, Python, etc.
Example using.NET Core
The below example demonstrates the ASP.NET Core API example.

The above swagger document will be available in the path swagger/v1/swagger.JSON.

Export swagger.json in .NET 9 and .NET 10 (built-in OpenAPI)
Since .NET 9, the default Web API templates use ASP.NET Core’s built-in OpenAPI generator, so the document lives at /openapi/v1.json, not /swagger/v1/swagger.json. That’s why many readers can’t find a swagger.json in a new project.
Calling AddOpenApi() registers the generator, and MapOpenApi() serves the result at /openapi/{documentName}.json. Both come from the Microsoft.AspNetCore.OpenApi package. The default document name is v1.
In plain English: The generator is like a printer that produces your API’s manual on request. It doesn’t display the manual for you. You still need a separate viewer to read it comfortably.
Why is there no /swagger page in a new project?
ASP.NET Core generates the OpenAPI document and ships no UI. New templates therefore have no /swagger page. If you want an interactive page, add Swagger UI or Scalar yourself. You don’t need either one just to export the file.
Why do I get a 404 in staging or production?
The template maps the OpenAPI endpoint only when the environment is Development. A 404 elsewhere usually means a missing environment check, not a broken API. Move the mapping outside the Development block if you want the document exposed, and think about whether you really want it public.
How do you save the file without Postman?
Any tool that can fetch a URL will do. Pick one of these:
- Browser: open the document URL, then use Save As.
- curl: run
curl -o openapi.jsonfollowed by the URL. - PowerShell: run
Invoke-WebRequestwith the URL and the-OutFileparameter.
How do you get YAML or a specific OpenAPI version?
JSON is the default. To get YAML at runtime, map the endpoint with a .yaml or .yml suffix and request that path.
The spec version also changed between releases. .NET 10 defaults to OpenAPI 3.1, while .NET 9 produced 3.0. If a downstream tool only understands 3.0, set the version explicitly in the options you pass to AddOpenApi() instead of relying on the default.
What changes with custom document names or protected endpoints?
A custom document name replaces the {documentName} part of the URL. If you register a document called v2 or internal, you’d request /openapi/v2.json or /openapi/internal.json. Versioned APIs usually give you one document per version.
If the docs endpoint sits behind authentication, your export request needs the same credentials as any other call. Add the token or cookie to the curl or PowerShell request, or you’ll get a 401 or 403 instead of the file.
If using Javascript or Python or other languages
If you are using any Javascript or Python or other languages, please make sure you enable Swagger UI with the route details.
Example 1 – Node Js and Express
const specs = swaggerJsondoc(options);
app.use("/docs", swaggerUi.serve);
app.get(
"/docs",
swaggerUi.setup(specs, {
explorer: true
})
);
For more details visit the below article,
Example 2–
var SwaggerUIBundle = require('swagger-ui-dist').SwaggerUIBundle
const ui = SwaggerUIBundle({
url: "https://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
]
})
Alternate Approach – Works in any language
If Swagger UI does not have a link to the API definition as above then please follow the below steps,
- Open the browser Dev tools-> Click on the Network. – Inspect -> Shift+Ctrl+I,
- Next refresh the page.
- Search for the API definition file like
swagger.json,swagger.yaml,api-docsetc. in the requests.
- Filter by All or XHR as needed.
In the example below under the response tab, you are set to get the Swagger.Json file.

Do you have any comments or ideas or any better suggestions to share?
Please sound off your comments below.
Happy Coding !!
Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published (2026) best practices and guidelines for software design and development.
Frequently asked questions
What is the default URL of swagger.json in ASP.NET Core?
With Swashbuckle, it’s /swagger/v1/swagger.json. With the built-in OpenAPI support in .NET 9 and later (AddOpenApi and MapOpenApi), it’s /openapi/v1.json. The v1 part is the document name, so a custom name or API versioning changes the URL. The endpoint is often mapped only in Development, so a 404 in other environments is usually an environment check in Program.cs.
Why is there no swagger.json in my .NET 9 or .NET 10 project?
New templates use the built-in Microsoft.AspNetCore.OpenApi generator instead of Swashbuckle. It serves the document at /openapi/v1.json and includes no UI, so there is no /swagger page. Add Swagger UI or Scalar separately if you want a browsable UI. If you’d rather keep the old paths, install Swashbuckle.AspNetCore 10.0.0 or later.
How do I export the OpenAPI document as YAML instead of JSON?
With the built-in .NET generator, map the endpoint with a .yaml or .yml suffix and request that URL from the running app. JSON is the default output. Build-time YAML output isn’t supported yet, so in CI you either export JSON or fetch the YAML from a running instance.
Why does ‘dotnet swagger tofile’ fail on .NET 10?
Older Swashbuckle CLI versions could throw a TypeLoadException for Microsoft.OpenApi.Models.OpenApiDocument. The .NET 10 stack moved to Microsoft.OpenApi v2, which broke the v1 object model those versions relied on. Use Swashbuckle.AspNetCore 10.0.0 or later and check the latest release notes, since the CLI has changed since the early reports. Another option is to switch to the built-in generator with Microsoft.Extensions.ApiDescription.Server, which writes the document during the build.
Further reading
- How to Export Swagger.Json without tools – TheCodeBuzz (TheCodeBuzz)
- Generate OpenAPI documents (Microsoft Learn)
- Microsoft.AspNetCore.OpenApi 10.0.13 – NuGet Gallery (NuGet / Microsoft)