Can't generate Strava api response models
Hi, I'm trying to generate ts-axios client for the strava api but can't generate the response models correctly. All response types are just 'any' or 'any[]'. I'm using the script below to generate client.
generateApi({
name: `strava.ts`,
url: "https://developers.strava.com/swagger/swagger.json",
output: path.resolve(process.cwd(), "clients"),
httpClientType: 'axios',
})
I also realized that the Strava uses http links for schema definitions. Is this can be cause of the problem?
"responses": {
"200": {
"description": "Profile information for the authenticated athlete.",
"schema": {
"$ref": "https://developers.strava.com/swagger/athlete.json#/DetailedAthlete"
},
Thanks
When I update the source code as follows I can generate the response types now. As I see currently the lib doesn't support the external refs.
1-) swagger.js --> line 65 --> I added resolve: true option to 'swagger2openapi' lib config to resolve external refs.
converter.convertObj( swaggerSchema, { warnOnly: true, refSiblings: "preserve", resolve: true, rbname: "requestBodyName", },
2-) After that there was an error due to a url issue in 'oas-resolver' package. At the execution of index.js -> resolveExternal function options.source was returning undefined and the pointer value was equal to the actual url so I made the changes below to try a fix. I am not sure why options.source is undefined but the solution works...
I changed below lines
function resolveExternal(root, pointer, options, callback) { debugger; var u = url.parse(options.source); var base = options.source || pointer.split('\\').join('/').split('/');
to
function resolveExternal(root, pointer, options, callback) { debugger; var u = url.parse(options.source || pointer); var base = (options.source || pointer).split('\\').join('/').split('/');
Hey, thanks for this - it still works!