Manweill / swagger-axios-codegen

swagger client to use axios and typescript
MIT License
306 stars 83 forks source link

OperationId to camelcase and include #164

Closed Luifr closed 2 years ago

Luifr commented 2 years ago

I was trying to use include to filter out the requests to be generated, but it wasnt working, i was getting an empty class

Looking through the source code (/src/requestCodegen/index.ts) I found out that the methodName variable (operationId) is transformed to camelCase. For the include filter (param of codegen method) to work i have to get the operationId from the swagger.json and also transform to camelCase and it doesnt make sense

I was trying this way, following the swagger.json:

codegen({
    methodNameMode: 'operationId',
    outputDir: './.generated',
    fileName: 'file.ts',
    include: [{
        Availability: ['AvailabilityUnit-groupsGet', 'AvailabilityUnitsGet'],
    }],
    remoteUrl: 'https://api.apaleo.com/swagger/availability-v1/swagger.json',
  })

But only this worked:

codegen({
    methodNameMode: 'operationId',
    outputDir: './.generated',
    fileName: 'file.ts',
    include: [{
        Availability: ['availabilityUnitGroupsGet', 'availabilityUnitsGet'],
    }],
    remoteUrl: 'https://api.apaleo.com/swagger/availability-v1/swagger.json',
  })
Manweill commented 2 years ago

yes,it use generated methodName to filter. it should support methodNameMode=path