api icon indicating copy to clipboard operation
api copied to clipboard

Common method accessors don't send any auth credentials

Open erunion opened this issue 2 years ago • 0 comments

const sdk = require('api')('@developers/v2.0#README_REGISTRY_UUID');

sdk.auth('MY_API_KEY');

(async () => {
  await sdk.get('/docs/MY_DOC_SLUG')
    .then(console.log)
    .catch(async err => {
      const res = await err.json()
      console.log(res)
    })
})()

The simple HTTP method accessors right now call spec.operation(path, method) but that's always going to return an empty Operation object because oas doesn't know where in the spec this path is at. Instead of doing spec.operation() it should do spec.findOperation() and if it can't find the operation fallback to an empty Operation object as it currently is.

erunion avatar Jun 22 '22 20:06 erunion