Manweill / swagger-axios-codegen

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

Generating wrong enums #48

Closed nibytes closed 5 years ago

nibytes commented 5 years ago
  4977 |   
  4978 |   export enum WallContentType{
> 4979 |     1|2|3
       |      ^
  4980 |   }

(node:17056) UnhandledPromiseRejectionWarning: SyntaxError: ',' expected. (4979:6)

nibytes commented 5 years ago

    result = type === 'string' ?
    enumArray.map(item => `'${item}'`).join('|') :
    enumArray.join('|')

I think this happen here createDefinitionEnum, and when results of this function using like that

allEnum.forEach(item => {
      if (allImport.includes(item.name)) {
        const text = item.value
          ? enumTemplate(item.value.name, item.value.enumProps, options.enumNamePrefix)//here
          : item.content || ''
        defSource += text
      }
    })

string like 1|2|3 inserting in enum template

nibytes commented 5 years ago

@Manweill Can you check and approve PR?

nibytes commented 5 years ago

@Manweill ???

Manweill commented 5 years ago

Day off before today

nibytes commented 5 years ago

@Manweill Can you update npm version? Pls pls pls is very urgent