operationId with dashes
Closed this issue ยท 5 comments
We have an Open API Spec with a setting such as:
"operationId":"get-api-token",
This generates a function such as:
const sdk = require('api')('...');
sdk.auth('...', '...');
sdk.getApiToken({grant_type: 'client_credentials'}, {
Accept: 'application/json',
'Cache-Control': 'no-cache'
})
.then(res => console.log(res))
.catch(err => console.error(err));
This works fine in the Readme.com reference documentation. If you install the api
library locally however it generates an error.
Error: Sorry,
getApiToken
does not appear to be a valid operation on this API.
Editing the code to instead use sdk['get-api-token']
works as expected:
< sdk.getApiToken({grant_type: 'client_credentials'}, {
---
> sdk['get-api-token']({grant_type: 'client_credentials'}, {
Which version of api are you seeing this on?
$ grep version node_modules/api/package.json
"version": "4.5.1",
Ok I see the problem, I fixed a bunch of issues within api
to clean up how we handle operation IDs but I shipped those to our current beta of v5 -- and then updated our snippet generation in production to use these new changes to operation IDs.
I'll backport these fixes today and push out a v4.5.2 release. Thanks and apologies for discovering this.
You've been very responsive and helpful, thanks for looking into it and getting to the bottom of it.
@j12y I've just published a v4.5.2 release with some fixes to this. Though we'll continue to show getApiToken
as being the SDK accessor in code snippets (as it functions more as a method accessor) on your ReadMe project, getApiToken
and get-api-token
will now both work as expected.