Describe the bug
When generating the machine-readable JSON in a dev environment on a Mac I can see the full JSON including the paths with the descriptions etc:
Output of http://localhost:3000/api/v2/openapi (openapi.ts file contains the code from README.md Usage #3 Step 1)
{
"openapi": "3.0.0",
"info": {
"title": "Techmap's Daily International Job Postings Export API",
"version": "2.0.1-beta"
},
"paths": {
...
"/api/v2/meta/jobs/statistics": {
"get": {
"tags": [
"Metadata Operations"
],
"summary": "Get statistics for searchable fields such as workPlace, industry, timezone etc.",
"description": "Returns a list of statistics for the given query parameter in the `/api/v2/jobs/search` endpoint.The returned JSON is described below and mainly consist of a list of statistics with counts and percentages for a given field.<br /><h3>Notes</h3><ul><li>This endpoint is only be available for MEGA subscription plans.</li><br /><li>The results are capped at 100 values and are calculated from job postings within the last month (i.e., current date minus 1 month).</li></ul><br /><h2>Search Query Parameters</h2><h3>General Parameters</h3><ul><li>`field`: A field name used in the search endpoint `/api/v2/jobs/search` as a parameter.</li></ul><br /><br /><h2>Usage Examples</h2><p>Statistics on the workPlace field:<br />`/api/v2/meta/jobs/statistics?field=workPlace`</p><p>Statistics on the industry field:<br />`/api/v2/meta/jobs/statistics?field=industry`</p>",
"parameters": [
{
"field": null,
"in": "query",
"name": "field",
"required": true,
"schema": {
"type": "string",
"example": "workPlace"
},
"description": "A field name used in the search endpoint `/api/v2/jobs/search` as a parameter."
}
],
"responses": {
"200": {
"description": "OK - indicating success and a correct query execution with results.<h4>Response Schema</h4>The API response provides a list of distinct field values for one field with a count of documents they are used in. Each distinct value object in the `result` array contains the following fields:<ul><li> `totalCount` (integer): The total number of jobs within the time range.<li> `docsWithValue` (integer): The number of documents with any value for that field within the time range.<li> `coverage` (double): The percentage of jobs in the time range that have any value.<li> `valueCount` (integer): The total number of values in the time range.<li> `aggregation` (object): The aggregation query we constructed and used to retrieve the distinct values.<li> `values` (array): A list of up to 100 distinct values with their data. Each distinct value object in the `result` array contains the following fields:<ul><li> `key` (string): The value found in the job documents.<li> `doc_count` (integer): The number of documents the value was found in.<li> `percentage_relative` (integer): The percentage of documents with the value relative to all documents with any value (docs_with_field).<li> `percentage_absolute` (integer): The percentage of documents with the value relative to all documents (total_doc_count).</ul></ul>"
},
"401": {
"description": "Unauthorized request to API! (e.g., not trying to access API via RapidAPI)"
},
"403": {
"description": "Forbidden request to API! (e.g., supscription plan to low)"
},
"404": {
"description": "Not Found - due to an non-existant or invalid query parameter format (e.g., 'dateCreated')"
},
"405": {
"description": "Method Not Allowed - due to unsupported HTTP Method (e.g., PUT, CONNECT, HEAD, etc.)"
},
"500": {
"description": "Internal Server Error - used for general problems (i.e., a catch-all with more info in return value)"
},
"503": {
"description": "Service Unavailable due to problems with our backend (e.g., the connection to our Database is interrupted)"
}
}
}
}
},
"components": {
},
"tags": [
]
}
However, in Production after deploying with Vercel they are not shown:
Output of https://example.com/api/v2/openapi
{
"openapi": "3.0.0",
"info": {
"title": "Techmap's Daily International Job Postings Export API",
"version": "2.0.1-beta"
},
"paths": {
},
"components": {
},
"tags": [
]
}
Relevant Dependencies:
"next-swagger-doc": "^0.4.0",
"openapi-types": "^12.1.3",
"swagger-parser": "^10.0.3",
"swagger-ui-react": "^5.10.5"
Btw. the generated OpenAPI docs work both in dev and production - only the generated json does not work.
I assume the problem is a different path to the API in the dev or prod environment of the nextjs application due to the deployment via Vercel. When I change pages/api/v2/
to api/v2/
in dev I get the same incomplete JSON.
I've tried to use /pages/api/v2/
and app/api/v2/
but that did not help in Production.
Any Ideas how to fix this or is this a bug?
Reproduction
Deploy to Vercel and check JSON in production
System Info
on Dev:
System:
OS: macOS 14.2
CPU: (12) arm64 Apple M2 Max
Memory: 703.17 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.8.1 - /opt/homebrew/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 10.1.0 - /opt/homebrew/bin/npm
Browsers:
Chrome: 120.0.6099.129
Edge: 120.0.2210.91
Safari: 17.2
Used Package Manager
yarn
Validations