Hi there,
First off, thank you for making and sharing Massimo, it’s very elegant.
I’m using it to play with Hetzner’s OpenAPI spec:
npx massimo-cli https://docs.hetzner.cloud/cloud.spec.json --name hetzner
Based on the Client Options example in the readme, I initially wrote the following code:
import hetzner from 'hetzner'
const api = await hetzner({
url: 'https://api.hetzner.cloud/v1/',
headers: {
Authorization: 'Bearer <actual token not shown but was entered correctly>'
}
})
const result = await api.listDatacenters()
console.log(result)
This didn’t work (returns “token required” error).
Looking into the generated code, buildOpenAPIClient() is not passed a headers object from objects; only a getHeaders function.
The following, thus, works:
import hetzner from 'hetzner'
const api = await hetzner({
url: 'https://api.hetzner.cloud/v1/',
getHeaders: () => {
return {
Authorization: 'Bearer <actual token not shown but was entered correctly>'
}
}
})
const result = await api.listDatacenters()
console.log(result)
Unless I’m missing something, the Client Options section in the readme should be updated to reflect this.