Manweill / swagger-axios-codegen

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

Pascal case classnames #16

Closed lamuertepeluda closed 5 years ago

lamuertepeluda commented 5 years ago

Hi,

I solved the problem with class names (at least when using path parameter) mentioned in #13 .

The main issue is that type definitions for camelcase are wrong (or out of date, so at least currently wrong). Using a rx, as you did, is not effective.

The following is a more correct definition for camelcase. You can compare against the library docs and the "official" types definition which is completely wrong.

declare interface ICamelCaseOptions{
    pascalCase: boolean
}

declare function camelcase(args: string| string[], options?: ICamelCaseOptions): string;

But i didn't have success in including into the local definitions, so I just decided to cut the official ones out. I removed @types/camelcase and I added a tsconfig.json for handling this, which also address debugging issues (lack of sourcemaps in the generated code)

Manweill commented 5 years ago

Do you test with example npm run build:api ?

lamuertepeluda commented 5 years ago

Actually I did with my endpoint.

Now that you asked, I also tried with the example. However testing with the example is not straightforward:

cd example
yarn build:api

internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'swagger-axios-codegen'
...

I had to modify

swagger-axios-codegen/example/swagger/codegen.js

const { codegen } = require('../../dist/index')

and also run

yarn
yarn build:all

In the example directory.

Here I attach the outcome index.ts.zip

lamuertepeluda commented 5 years ago

Perhaps we should add some automated testing, e.g. with jest. like "Expect the output to be some reference file"

Manweill commented 5 years ago

Good! BTW, you can cd example && yarn && yarn link swagger-axios-codegen for test

Manweill commented 5 years ago

@lamuertepeluda I was add azure pipe