Fetching patched docs programmatically
You can programmatically get patched results by fetching the /patch endpoint with ?doc and ?patch query string parameters.
For example:
fetch(`https://openapi-patcher.vercel.app/patch?${
new URLSearchParams({
doc: "https://someapi.com/docs.json",
patch: "https://gist.githubusercontent.com/username/gist/raw/patch.json",
})
}`)
You can also send the data as a POST or PUT request with the request body consisting of the inline JSON patches.
fetch(`https://openapi-patcher.vercel.app/patch?${
new URLSearchParams({ doc: "https://someapi.com/docs.json" })
}`, {
method: 'put',
body: `[{"op": "replace", "path": "/host", "value": "patched host name" }]`
})
Source code is available here.