Table of contents
- Quick summary
- What an agent does with the file
- Who should skip this
- Choose a version
- Path one: write the file by hand
- Path two: let your framework write it
- FastAPI
- Next.js
- Express or Hono
- Astro
- WordPress
- How the scan grades E2 by platform
- Advertise it so agents do not guess
- Verify it parses
- With AIScan
- By hand
- What 864 sites serve on 19 November 2026
- What the 88 documents contain
- The catalog route: 99 catalogs, 21 point at something else
- What the stored scans say
- When the file is there and agents still fail
- Maintenance
- Next step
Updated on 22 November 2026: tested setup steps for FastAPI, Next.js, Express or Hono, Astro and WordPress, and how the scan grades E2 by platform.
Serve an OpenAPI 3.1 JSON file at /openapi.json with a JSON content type, put your real API host in servers, and link the file from an API catalog. On 19 November 2026 we fetched that path on 864 scanned sites: 88 serve a document that parses, and 98 answer 200 with no document behind it, nearly always the home page. The steps below take about ten minutes, and the script further down tells the two cases apart.
An agent that wants to call your API has to know what it can ask for. An OpenAPI file answers that in one fetch: every path, every parameter, every response shape, in JSON a program can read. Publishing it takes about ten minutes if you already have the file, and the check that grades it (E2) is a pass or a miss with no partial credit for a file that exists but does not parse. This guide covers where to serve it, which version to write, how to advertise it, and how to prove it parses.
Quick summary
Short answer: serve an OpenAPI 3.1 JSON document at /openapi.json with a JSON content type, list your real API host in servers, and add a service-desc link so agents do not have to guess the path.
| If you want to... | Do this | Check | Time |
|---|---|---|---|
| Pass the check fastest | Put openapi.json at the site root | check:E2 | 10 minutes |
| Have your framework write the file | Turn on the built-in export (FastAPI does by default) | check:E2 | 5 minutes |
| Find your stack's steps | Jump to FastAPI, Next.js, Hono, Astro or WordPress | check:E2 | 1 minute |
| Know if E2 counts against you | Read how the scan grades E2 by platform | check:E2 | 2 minutes |
| Make the file discoverable | Add a Link header and an API catalog entry | check:P1, check:D3 | 10 minutes |
| Confirm it works | Run the script below, or scan the site | check:E2 | 2 minutes |
| See how common it is | Read what 864 sites serve | check:E2 | 3 minutes |
According to the OpenAPI Specification 3.1.2 (re-read 19 November 2026), it is RECOMMENDED that the entry document be named openapi.json or openapi.yaml. That is the whole reason /openapi.json is the path every scanner tries first, and in our 19 November fetch 81 of the 88 real documents sat at exactly that path.
What an agent does with the file
Think of the file as the menu a restaurant hands over before anyone orders. Without it, an agent reads your human-facing docs, guesses a parameter name, gets a 400 and tries again. With it, the agent reads the menu once and sends a correct request first time.
The spec sets a low bar for what counts as a document. In its own words, an OpenAPI description must contain at least one of paths, components or webhooks. A file with only openapi and info is valid JSON and useless, and the script in this guide marks it FAIL. A file with real paths is what an agent can act on.
AIScan's E2 check (the capability checks reference, re-read on 19 November 2026) looks for /openapi.json, /openapi.yaml, /api/openapi.json, /.well-known/openapi.json, /swagger.json, or a service-desc link in your RFC 9727 API catalog. E2 has a weight of 3 and is marked recommended. On some platforms the report calls a missing file an optional improvement rather than a failure; which ones is in how the scan grades E2 by platform.
Who should skip this
If your site has no endpoints a stranger could call, there is nothing to describe. A brochure site, a blog, a store whose only API is the platform's own: skip E2 and spend the time on llms.txt and server-rendered HTML. A WordPress site already exposes /wp-json/, which is WordPress's own route index, not an OpenAPI file. If you only run a blog on WordPress, the useful files for you are llms.txt, robots rules and schema, and ThinkRank handles all three from one plugin and migrates from Rank Math, Yoast, AIOSEO and SEOPress. If you run a Shopify store, StoreSEO generates llms.txt from live products and collections. Neither of those publishes an OpenAPI file for an API you wrote yourself, which is what this guide is about.
Publish the file when you run your own API: a SaaS product, a headless backend, a public data endpoint, a booking or quote service.
Choose a version
Write 3.1. The spec site at spec.openapis.org lists 3.1.2 and 3.2.1 as the newest published versions (fetched 19 November 2026; in October the 3.2 line stopped at 3.2.0), and the spec says tooling that supports OAS 3.1 should be compatible with all 3.1.x patch versions. AIScan's own reference file uses 3.1.0 and its docs describe the target as OpenAPI 3.1. The sites we fetched agree: 79 of the 88 real documents declare a 3.1.x version, 9 declare 3.0.x, and none declares 3.2 or Swagger 2.
Two version traps:
- A
swaggerkey at the top instead ofopenapimarks an older Swagger 2.x file. AIScan still looks for/swagger.json, but new files should useopenapi. - The
openapifield is the spec version.info.versionis your API's own version. Mixing them up is the most common first-draft mistake.
Path one: write the file by hand
Use this when you have a handful of endpoints and no framework that exports a spec.
- Create a file named
openapi.json. - Start with the three required top-level pieces:
openapi,info(withtitleandversion) andpaths. - Add a
serversarray with your real, absolute API URL. The spec says that whenserversis missing, the default is a single server with aurlof/, which is relative to wherever the file was fetched and tells an agent nothing about a separate API host. - Describe each operation with a
summary, its parameters and at least one response. - Serve the file from the site root as a static file with the content type
application/json.
A minimal file that passes the check:
{
"openapi": "3.1.0",
"info": { "title": "Example Quote API", "version": "1.0.0" },
"servers": [{ "url": "https://api.example.com" }],
"paths": {
"/quotes": {
"get": {
"summary": "List quotes",
"parameters": [
{ "name": "limit", "in": "query", "schema": { "type": "integer" } }
],
"responses": { "200": { "description": "A list of quotes" } }
}
}
}
}
Where the static file goes depends on your stack:
| Stack | Where the file goes | Note |
|---|---|---|
| Next.js | public/openapi.json | Served from / with application/json (tested on 16.4.6, 22 November 2026); see Next.js |
| Plain nginx or Apache | The web root, next to index.html | Confirm the content type with curl -I |
| WordPress with an API of your own | The site root, over SFTP or your host's file manager | A file at the root is served as is; do not put it in a theme folder |
| Cloudflare Pages or Netlify | The publish directory root | Check that a catch-all rewrite does not swallow it |
Path two: let your framework write it
If your API is built with a framework that already generates a spec, publishing is a setting, not a writing job.
- Find the framework's export or docs-URL setting.
- Confirm it produces OpenAPI 3.x, not Swagger 2.
- Make the URL one of the paths E2 tries, or add a redirect from
/openapi.json. - Re-export on every release so the file never describes last quarter's API.
Pick your stack from the list below. On 22 November 2026 we built each one in a local lab (not deployed), fetched the file with curl, and ran it through openapi-spec-validator 0.9.0. The table is what came back.
| Stack, version tested | Where the file appeared | Content type served | Validator |
|---|---|---|---|
| FastAPI 0.165.0 on uvicorn 0.54.0 | /openapi.json with no setup | application/json | valid, 3.1.0 |
Next.js 16.4.6, file in public/ | /openapi.json | application/json; charset=UTF-8 | valid (same file) |
| Next.js 16.4.6, route handler | /api/openapi.json | whatever you set (application/openapi+json in our test) | valid |
Hono 4.13.20 with @hono/zod-openapi 1.6.3 | /openapi.json via app.doc31() | application/json | valid, 3.1.0 |
| Astro 7.4.13, static build | dist/openapi.json | application/json from the file server | valid |
Astro 7.4.13 with @astrojs/node 11.1.14 | prerendered endpoint | application/json; charset=utf-8, set by the file extension | valid |
Source: AIScan lab, 22 November 2026, one test app per row, localhost only.
FastAPI
- Create the app with a title, a version and your public API host:
from fastapi import FastAPI
app = FastAPI(
title="Example Quote API",
version="1.0.0",
servers=[{"url": "https://api.example.com"}],
)
- Declare return types on your routes (
-> list[Quote]). FastAPI turns the Pydantic models intocomponents.schemas, which is what lets an agent read the response shape. - Run the app and fetch
/openapi.json. In our lab it answered 200 withapplication/jsonand declared3.1.0, with no extra code. - If you move it with
openapi_url="/api/v1/openapi.json", the old path returns 404. We tested that too. E2 does not try/api/v1/, so add aservice-desclink (next section) or a redirect from/openapi.json. - Keep
openapi_urlset. According to the FastAPI metadata docs,openapi_url=Noneturns off the schema and the/docspages that read it.
Next.js
Next.js has no built-in OpenAPI generator. You either ship a file or serve one from a route handler.
- A static file. Put
openapi.jsoninpublic/. The Next.js public folder docs say files there are served from the base URL. On 16.4.6next startsent it withapplication/json; charset=UTF-8andCache-Control: public, max-age=0. - A route handler, when you build the spec in code. A folder named
openapi.jsonworks as a route segment:
// app/api/openapi.json/route.ts
import spec from "../../../openapi.json";
export const dynamic = "force-static";
export function GET() {
return Response.json(spec, {
headers: { "Content-Type": "application/openapi+json" },
});
}
The build listed it as static (○ /api/openapi.json) and it answered with the content type we set.
3. If you generate the spec from Zod schemas or JSDoc comments, run the generator at build time and write the result to public/openapi.json. That keeps the file static and cacheable.
4. Add the Link header in next.config.mjs with headers(), source: "/". Our test homepage then sent Link: </openapi.json>; rel="service-desc"; type="application/json".
5. Check that a nonsense path still 404s. Ours did (/nothing.json → 404). A catch-all [...slug] page can turn it into a soft 200.
One trap we hit: the project's package.json had "type": "commonjs" (what npm init -y writes), and the build failed on the JSON import with "Specified module format (CommonJs) is not matching". Removing that line fixed it.
Express or Hono
- Hono. Define routes with
createRoutefrom@hono/zod-openapiand serve the document withapp.doc31("/openapi.json", { openapi: "3.1.0", info, servers }). In our lab the Zod schema becamecomponents.schemas.Quoteand the file validated. The Hono Zod OpenAPI guide covers the route syntax. - Express. Express does not write a spec on its own. The common route is
swagger-jsdoc, which reads JSDoc comments, plus one route that returns its output withres.json(spec). We did not run Express today, so check that package's own README for the current option names. - Either way, serve the document from the public API host, not only from an internal port behind a proxy.
Astro
- Create
src/pages/openapi.json.tsand return the spec fromGETwithexport const prerender = true. The Astro endpoints guide explains static and server endpoints. - On a static build the file lands in
dist/openapi.json, and the host picks the content type from the extension. Python's file server sentapplication/json. - On a server build (
@astrojs/node), a prerendered endpoint is served as a static file. We setContent-Type: application/openapi+jsonin the response, and the server still sentapplication/json; charset=utf-8, because the header is dropped when the file is written. That is fine for E2. If you need the exact media type, setprerender = false: our server endpoint then sentapplication/openapi+json. - A prerendered
openapi.yamlcame back astext/yaml; charset=utf-8. Prefer the JSON file.
WordPress
- Know what
/wp-json/is. In WordPress 7.1.5,WP_REST_Server::get_index()returns the site name, URL,namespaces,authenticationandroutes. That is WordPress's own route index, not an OpenAPI document, and it has noopenapikey, so E2 does not count it. - WordPress also sends
Link: <…/wp-json/>; rel="https://api.w.org/"on every page (rest_output_link_headerinwp-includes/rest-api.php). That relation is notservice-desc, and it does not describe your API. - If you only run a blog or a store on WordPress, stop here. In our scan data WordPress sites get E2 as
info, which costs no points. - If you built a plugin with its own REST routes that strangers should call, write an OpenAPI file for those routes (Path one) and upload it to the site root. Do not point
service-descat/wp-json/; our 19 November fetch found three catalogs doing that.
How the scan grades E2 by platform
Whether a missing file is a fail or a free pass depends on the platform the scanner detects, not on whether your site has an API. We counted the latest site scan per host on 22 November 2026 (871 hosts, rubric 2026.08.2, aiscan.site left out).
| Detected platform | Pass | Fail | Info (optional) |
|---|---|---|---|
| Next.js | 51 | 167 | 0 |
| Astro | 25 | 27 | 0 |
| Shopify | 2 | 13 | 0 |
| Lovable | 6 | 7 | 0 |
| SvelteKit, Nuxt, Vue, Bolt, Angular | 9 | 13 | 0 |
| WordPress | 10 | 0 | 205 |
| Framer, Wix, Ghost, HubSpot, Squarespace | 0 | 0 | 13 |
| Not detected | 20 | 0 | 303 |
Source: AIScan scan database, 871 hosts, read 22 November 2026. Every fail carries the same evidence line, "no /openapi.json, /api/openapi.json or swagger document found" (227 hosts).
So a marketing site on Next.js with no API fails E2, and the same site on WordPress does not. If that is you, E2 costs 3 points and nothing in this guide fixes it short of publishing an API. We have reported the platform rule to the scanner team. On Shopify, the 13 fails are stores whose only API is Shopify's own; you can ignore them.
Clients do guess these paths. Our own crawler log for aiscan.site (13 September to 15 November 2026) shows 17 requests for /api/openapi.json from 11 bot names and 16 for /swagger.json from 10, all 404, because our file lives at /openapi.json. Most of those senders are scanners using AI user agents, so read it as "tools try these paths", not as demand from any one AI company.
Advertise it so agents do not guess
A file at a guessable path passes E2. A file that is linked is found by agents that do not know your conventions. Add two pointers.
A Link header. The service-desc relation comes from RFC 8631. On nginx:
add_header Link '</openapi.json>; rel="service-desc"; type="application/json"' always;
I have not run that nginx line in this session (no nginx in the sandbox), so confirm it with curl -I after you reload.
An API catalog entry. RFC 9727 defines /.well-known/api-catalog. Add your spec as a service-desc entry. Our walkthrough, publish an API catalog agents can find, covers the full file, so this guide stays on the OpenAPI document itself.
AIScan's own setup shows the pattern. Fetched again on 19 November 2026, aiscan.site/openapi.json returns 200 with application/json, declares 3.1.0, lists two paths and names https://aiscan.site as its server. The catalog at /.well-known/api-catalog returns application/linkset+json and lists that file first under service-desc. Two honest gaps, both unchanged since October. The Link header on the homepage has a service-desc entry that points at /api/scan (the SSE stream), not at the OpenAPI file, so an agent reading only headers would miss the spec and need the catalog. And the catalog lists four more service-desc entries after the OpenAPI file that are API endpoints, not descriptions. The section on what 864 sites serve shows how common that second habit is. The header side of this is covered in Link headers for agent discovery.
Verify it parses
With AIScan
Run npx aiscan-cli yoursite.com, or paste the URL at aiscan.site. It is free and needs no account. Read these rows:
| Row | What it tells you |
|---|---|
| check:E2 | A machine-readable API description was found |
| check:P1 | An API catalog exists and lists it |
| check:D3 | Discovery links are present in response headers |
AIScan cannot judge whether your spec is accurate. It can find a file and confirm it is there. It will not notice that your spec describes an endpoint you removed in March. That part is a review job, and it is yours.
One more limit, found while updating this guide on 19 November 2026: on the /swagger.json path, E2 currently accepts a 200 that is a web page. A scan we ran that day passed E2 on a store whose /swagger.json is its HTML shell. We have filed it as a scanner bug. Until it is fixed, a pass whose evidence line ends in (text/html) is not a pass, and the script below is the stricter test.
By hand
If you would rather check by hand, run this script. It tries the four JSON paths E2 uses and refuses to count a soft 200 (an HTML page returned with status 200) as a pass. It does not parse YAML, so check an openapi.yaml by eye.
#!/usr/bin/env python3
import json, sys, urllib.request, urllib.error
PATHS = ["/openapi.json", "/api/openapi.json", "/.well-known/openapi.json", "/swagger.json"]
UA = "Mozilla/5.0 (compatible; openapi-check/1.0)"
def fetch(url):
req = urllib.request.Request(url, headers={"User-Agent": UA})
try:
with urllib.request.urlopen(req, timeout=15) as r:
return r.status, r.headers.get("content-type", ""), r.read(20_000_000)
except urllib.error.HTTPError as e:
return e.code, e.headers.get("content-type", ""), b""
def main(site):
base = "https://" + site.removeprefix("https://").strip("/")
problems, found = [], False
for p in PATHS:
status, ctype, body = fetch(base + p)
if status != 200:
print(f"- {p}: {status}")
continue
try:
doc = json.loads(body)
except ValueError:
problems.append(f"{p}: 200 but not JSON ({ctype or 'no type'}), a soft 200")
continue
version = doc.get("openapi") or doc.get("swagger")
if not version:
problems.append(f"{p}: JSON without an openapi or swagger key")
elif not any(k in doc for k in ("paths", "components", "webhooks")):
problems.append(f"{p}: version {version} but no paths, components or webhooks")
elif "json" not in ctype:
problems.append(f"{p}: parses, but content-type is {ctype!r}")
else:
print(f"PASS {p}: {version}, {len(doc.get('paths', {}))} paths, {ctype}")
found = True
for m in problems:
print("FAIL", m)
return 0 if found and not problems else 1
if __name__ == "__main__":
sys.exit(main(sys.argv[1]))
Save it as check_openapi.py and run python3 check_openapi.py yoursite.com. A pass prints the version and the path count and exits 0.
I ran it on 12 October 2026 against aiscan.site (PASS on /openapi.json: 3.1.0, 2 paths; the other three paths returned 404) and against a local test server built to fail. That server returned an HTML shell with status 200 for every unknown path, a {"hello":1} file at /openapi.json, and an openapi file with no paths at /swagger.json. The script reported all four as FAIL and exited 1. The soft 200 is the trap worth remembering: a status check alone calls an HTML page a pass.
I ran it again on 19 November 2026. aiscan.site still passes with the same line. The read limit in the script went from 5 MB to 20 MB that day, because one site in the corpus serves a valid 12.4 MB /openapi.json with 356 paths, and the October version of the script cut the body short and reported it as "200 but not JSON". With the larger limit it prints PASS /openapi.json: 3.0.3, 356 paths. If your own reader caps the download, a large spec fails the same way.
Success thresholds, in order of strictness:
/openapi.jsonreturns 200 and a JSON content type.- The body parses and has
openapiand at least one ofpaths,components,webhooks. - A path that should not exist returns 404, not 200. Try
/definitely-not-here.json.
If check 3 fails, your server answers everything with 200 and every other check in this guide is unreliable until you fix it.
What 864 sites serve on 19 November 2026
We run AIScan on whatever sites people submit, so the scan database is a convenience sample, not a random draw from the web. It leans towards small SaaS products, agencies, stores and developer sites. On 19 November 2026 we took the latest site-level scan for every host in it (864 hosts, rubric 2026.08.2, our own site left out) and fetched seven URLs on each with the script's user agent: the five paths E2 tries, /.well-known/api-catalog, and a nonsense .json path to catch servers that answer everything with 200. Redirects were followed, the timeout was 15 seconds, and there were no retries. 829 hosts answered at least one request and 35 answered none.
A "real document" below means the body parses, has an openapi or swagger key, and has at least one of paths, components or webhooks. That is the same test the script in this guide applies.
| Path | Real document | 200 with a web page | 404 |
|---|---|---|---|
/openapi.json | 81 | 76 | 605 |
/api/openapi.json | 6 | 60 | 686 |
/openapi.yaml | 5 | 80 | 662 |
/.well-known/openapi.json | 2 | 62 | 691 |
/swagger.json | 0 | 79 | 683 |
| Any of the five | 88 hosts | 98 hosts with a 200 and no document |
Source: AIScan live fetch, 864 hosts, 19 November 2026. The remaining responses per path are 403, 5xx, 429, 402 or no answer.
Three things stand out.
More sites fake the file than have it. 88 hosts (10.2% of 864) serve a real document. 98 hosts return 200 on at least one of the five paths with no document behind it, and 75 of those 98 also return 200 for the nonsense path. They are single-page apps and catch-all routes that send the home page for any URL. A checker that reads only the status code would report 186 sites with an API description and be wrong about more than half.
/swagger.json is dead as a location. Not one host serves a real document there. Every 200 on that path was a web page.
Seven of the 88 are not at /openapi.json. Six use /api/openapi.json or /.well-known/openapi.json, and one publishes only YAML. An agent that tries the one obvious path finds 81.
What the 88 documents contain
| Property | Count | Note |
|---|---|---|
| Version 3.1.0 | 77 | 3.1.1 and 3.1.2: one each |
| Version 3.0.x | 9 | 3.0.3 on seven, 3.0.0 on two |
| Swagger 2.x or OpenAPI 3.2 | 0 | |
Served as application/json | 60 | |
Served as application/openapi+json | 16 | |
Served as application/vnd.oai.openapi+json | 11 | |
servers names the site's own host | 68 | of the 87 JSON documents |
servers names another public host | 16 | an api. subdomain on eight |
servers missing | 2 | the default / applies |
servers is http://localhost:3001 | 1 | a development value shipped to production |
paths present but empty | 4 | |
| One or two paths | 22 | 9 with one, 13 with two |
| Three to nine paths | 41 | |
| Ten or more paths | 20 | 6 of them have 50 or more |
Source: the same fetch. The path counts cover the 87 JSON documents. The median is 5 paths and the largest file has 356 paths in 12.4 MB.
Most of these are small, honest files: a median of five paths and five kilobytes. The mistakes this guide warns about do show up, though rarely. Three documents would send an agent to the wrong place (two with no servers, one pointing at localhost), and four declare paths with nothing in it.
By detected platform, Astro sites had a real document most often (18 of 52, 34.6%), then Next.js (41 of 214, 19.2%). WordPress sites almost never did (5 of 212, 2.4%), which fits the "who should skip this" advice above. AIScan's platform detector returned no platform for 322 hosts, and 10 of those have a document.
The catalog route: 99 catalogs, 21 point at something else
113 hosts serve a linkset at /.well-known/api-catalog, and 99 of those list at least one service-desc entry. We followed all 127 service-desc links.
What the service-desc link returned | Links |
|---|---|
| A real OpenAPI document | 85 |
| JSON that is not OpenAPI (mostly MCP server cards) | 21 |
Plain text or Markdown (llms.txt, llms-full.txt, index.md) | 10 |
| A web page | 5 |
| 404, 405 or no answer | 6 |
Source: AIScan live fetch of 127 links on 99 hosts, 19 November 2026.
On 78 of the 99 hosts at least one link leads to a real document. On 21 hosts none does: the catalog's service-desc points at an MCP server card (12 links), at llms.txt (7), at /wp-json/ (3) or at a similar file. According to RFC 8631 section 4.2 (re-read 19 November 2026), the target of a service-desc link is expected to provide a service description that is "primarily intended for machine consumption", and service-doc is the relation for people. A text file written for language models fits neither well, and an agent that expects OpenAPI from service-desc will fail to parse it.
The catalog does earn its place for one group: 9 hosts have a real document that is reachable only through the catalog, at paths such as /api/v1/openapi.json that no scanner guesses. Counting those, 97 of 864 hosts (11.2%) publish an OpenAPI document an agent can find by either route. In the other direction, 18 of the 88 hosts with a file at a guessable path have no catalog entry for it.
What the stored scans say
The same 864 hosts carry a stored E2 result from their latest scan, taken between 25 August and 19 November 2026.
| Stored E2 result | Hosts |
|---|---|
| Pass, file found at a path | 88 |
Pass, API catalog advertises a service-desc | 34 |
| Fail (site looks like an app) | 224 |
| Info, optional (site looks like a content site) | 518 |
Source: AIScan scan database, latest site-level scan per host, 864 hosts, read 19 November 2026.
Checked against today's fetch, 78 of the 88 stored path passes still serve a real document at the stored path. Eight now return a web page (seven of them were recorded as /swagger.json → 200 (text/html), the scanner limit described above), and two returned an error or no answer. Of the 34 catalog passes, 11 lead to a real OpenAPI document today. The stored figures overstate real adoption a little, and the live fetch is the number to quote: 88 by path, 97 with the catalog.
When the file is there and agents still fail
Three failures show up after the file is live. Each has a first thing to try.
| Symptom | Likely cause | First fix |
|---|---|---|
| The scan reports no API description although the URL opens in your browser | The path returns HTML with status 200, or the type is text/html | Run the script above and read the FAIL line |
| The file parses but an agent calls the wrong host | servers is missing, so the default / applies | Add the absolute API URL to servers |
| The file is found on one path and 404s on the other three | Normal; E2 needs one hit, not four | Leave it, or add the link header so the path is explicit |
The scan passes E2 with evidence ending in (text/html) | A soft 200 on /swagger.json was counted | Treat it as a miss, publish a real file, and fix the catch-all route |
| A reader reports "not JSON" on a file that opens fine | The file is larger than the reader's download limit | Split the spec, or confirm with the script (20 MB limit) |
If the nonsense-path test returns 200, start with fixing soft 404s for AI agents, which has the per-platform fix.
A related question is whether an agent can finish a job once it has found your API. That is a separate test, covered in how to test whether an AI agent can complete a task on your site, and it is worth running once the spec is live. The spec tells an agent what exists, and the test tells you whether the calls work. The wider set of well-known files is mapped in our well-known files corpus, with figures fetched from the live sites it measured.
Maintenance
- Regenerate the file in your release pipeline. A stale spec is worse than none, because an agent trusts it.
- Re-run the script after any change to caching, redirects or a CDN rule. A rule that rewrites unknown paths to the home page will turn your 404s into soft 200s.
- Keep the file public. If it contains internal-only routes, remove them before you serve it.
Next step
Scan your site at aiscan.site and read check:E2 and check:P1 in the Capabilities group. Then browse the other fixes in the AIScan guides, starting with the capability checks reference.
Frequently asked questions
Where should I publish my OpenAPI file?
At /openapi.json on the site root. The OpenAPI Specification recommends naming the entry document openapi.json or openapi.yaml, and AIScan's E2 check tries /openapi.json first, then /openapi.yaml, /api/openapi.json, /.well-known/openapi.json and /swagger.json. Of 88 real documents we found on 19 November 2026, 81 were at /openapi.json and none at /swagger.json.
Should I use OpenAPI 3.1 or Swagger 2.0?
Use 3.1. The spec site lists 3.1.2 and 3.2.1 as the newest published versions (19 November 2026). In our fetch of 864 sites that day, 79 of 88 real documents declared 3.1.x, 9 declared 3.0.x and none used Swagger 2. A top-level swagger key marks an older 2.x file; a new file should start with an openapi key.
Does my site need an OpenAPI file at all?
Only if you run an API that others can call. A blog or brochure site has nothing to describe, and AIScan reports E2 as an optional improvement on sites it detects as pure content sites.
My OpenAPI URL opens in the browser but the scan says no API description was found. Why?
The most common cause is a soft 200: the path returns an HTML page with status 200, or a JSON body without an openapi key. Run the check_openapi.py script in this guide and read the FAIL line. It names the path and the reason.
The scan finds my file but an agent sends requests to the wrong host. What is wrong?
The servers array is probably missing. The spec says the default is a single server with a url of /, which is relative to where the file was fetched. Add your absolute API URL, for example https://api.example.com.
My framework serves the spec at /api/v1/openapi.json and E2 shows nothing. What do I do?
Move the URL to /openapi.json, or add a redirect, or advertise the real path with a Link header using rel="service-desc" and an entry in /.well-known/api-catalog. FastAPI, for one, serves /openapi.json by default and changes with the openapi_url parameter.
Is a file with only openapi and info valid?
It is valid JSON, but the spec says an OpenAPI description must contain at least one of paths, components or webhooks. The script in this guide marks a file without any of them as FAIL.
How do I stop the spec going stale?
Generate it in your release pipeline instead of editing it by hand, and re-run the check after any caching, redirect or CDN change. A stale spec misleads an agent more than a missing one.
How many sites publish an OpenAPI file?
In our scan corpus, about one in ten. On 19 November 2026 we fetched five common paths on 864 scanned sites: 88 (10.2%) served a document that parses as OpenAPI, and 9 more exposed one only through an API catalog link, 97 in all. Another 98 sites returned status 200 on one of those paths with no document, almost always the home page.
The scan passes E2 but the evidence says /swagger.json returned text/html. Is that a real pass?
No. That is a soft 200: your server sent a web page for a path that does not exist. As of 19 November 2026 the E2 check accepts it on the /swagger.json path, which we have filed as a scanner bug. Publish a real file at /openapi.json and make unknown paths return 404.
Does FastAPI publish an OpenAPI file automatically?
Yes. In our 22 November 2026 lab, FastAPI 0.165.0 served /openapi.json with application/json and openapi 3.1.0 with no extra code, and the file passed openapi-spec-validator. Pass servers=[{"url": "https://api.example.com"}] so agents call the right host.
My Next.js build fails with "Specified module format (CommonJs) is not matching" when I import openapi.json. How do I fix it?
Your package.json probably has "type": "commonjs", which npm init -y writes. Remove that line and build again. In our Next.js 16.4.6 test the route handler then built as a static route and served the file.
I set Content-Type: application/openapi+json in my Astro endpoint but the site sends application/json. Why?
The endpoint is prerendered, so Astro writes it to a file and the server picks the type from the .json extension. We saw that with Astro 7.4.13 and @astrojs/node 11.1.14. application/json is fine for E2. Set prerender = false if you need the exact media type.
My Next.js marketing site has no API and E2 fails. Is that a bug?
It is how the scanner grades today: on 22 November 2026, every Next.js, Astro, Shopify and Lovable host without a file got fail, while WordPress and undetected sites got info. If you have no API, the fail costs 3 points and is safe to ignore. We have reported the rule to the scanner team.
Is WordPress's /wp-json/ an OpenAPI file?
No. In WordPress 7.1.5, /wp-json/ returns WordPress's own index of namespaces and routes, with no openapi key, so E2 does not count it. Do not point a service-desc link at it. Write an OpenAPI file only for REST routes you built yourself.

About the author
M Asif Rahman
Entrepreneur, curious about AI
I have been building companies for a long time, and lately most of my curiosity goes to AI. AIScan is a small personal project I built on a flight from Dubai to Narita. I use it to understand how ready the web is for AI agents, and I share what the scans teach me.
Related guides
API Catalog (RFC 9727): Next.js, Astro, Netlify, Vercel, WordPress
Updated on 16 November 2026: perstack steps for Next.js, Astro, Netlify, Cloudflare Pages, Vercel, nginx, Apache and WordPress, each tested or sourced, plus a reprobe of every site AIScan credits for…
AI readiness setup guide by platform (2026)
Verified 17, 18, 20 and 22 October 2026. Updated on 22 October 2026. An AIready site needs six things: a robots.txt that names AI crawlers D1, B2, a sitemap D2, a declared feed E5, an llms.txt C2,…
Link Headers for AI Agent Discovery: Next.js, Astro, Vercel, Netlify, Cloudflare, WordPress
Updated on 26 November 2026: a new section for Shopify, Webflow, Framer and Wix, where the builder's CDN sends the header and you add head tags instead, measured on 889 sites. Updated on 15 November…
