Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error encored during generating TypeError: type.toLocaleLowerCase is not a function #58

Closed
hackermanmx opened this issue Jun 20, 2018 · 4 comments
Labels
bug Some problem (breaking)

Comments

@hackermanmx
Copy link

hackermanmx commented Jun 20, 2018

Steps:

After installing api-client-generator ran api-client-generator -s ./api.yaml -o ./apidocs.

Assumptions:
YAML is valid.
No errors during installation.

Angular CLI: 6.0.7
Node: 10.2.1
OS: darwin x64
Angular: 6.0.3
  • angular-devkit/architect 0.6.8
  • angular-devkit/build-angular 0.6.8
  • angular-devkit/build-optimizer 0.6.8
  • angular-devkit/core 0.6.8
  • angular-devkit/schematics 0.6.7 (cli-only)
  • angular/cli 6.0.7
  • ngtools/webpack 6.0.8
  • schematics/angular 0.6.7 (cli-only)
  • schematics/update 0.6.7 (cli-only)
  • rxjs 6.2.1
  • typescript 2.7.2
  • webpack 4.8.3

Stack trace shown:

Error encored during generating TypeError: type.toLocaleLowerCase is not a function
at Object.toTypescriptType (/usr/local/lib/node_modules/api-client-generator/dist/helper.js:46:21)
at /usr/local/lib/node_modules/api-client-generator/dist/parser.js:109:39
at Array.map ()
at parseInterfaceProperties (/usr/local/lib/node_modules/api-client-generator/dist/parser.js:106:39)
at defineInterface (/usr/local/lib/node_modules/api-client-generator/dist/parser.js:161:22)
at defineEnumOrInterface (/usr/local/lib/node_modules/api-client-generator/dist/parser.js:75:11)
at /usr/local/lib/node_modules/api-client-generator/dist/parser.js:62:16
at Array.map ()
at parseDefinitions (/usr/local/lib/node_modules/api-client-generator/dist/parser.js:60:10)
at createMustacheViewModel (/usr/local/lib/node_modules/api-client-generator/dist/parser.js:18:22)

Any input is more than welcomed.

Cheers.

@vmasek vmasek added the bug Some problem (breaking) label Jun 21, 2018
@vmasek
Copy link
Member

vmasek commented Jun 21, 2018

@DeeNeon Thanks for the report. It seems like it tried to lowercase something else than string. Would it be possible to provide at least anonymized swagger file? it would really help me find the problem

@hackermanmx
Copy link
Author

Thank you @vmasek for the follow up.
Here's the sample I'm trying to use, I hope this gets a lead!
sample.txt

@vmasek
Copy link
Member

vmasek commented Jun 21, 2018

Problem is that given swagger seems invalid, if you try to validate it in https://editor.swagger.io/ you get multiple errors, where some are Schema "type" key must be a string which is the cause of the error in our case.

If we look at the docs, there is schamaObject spec which is telling us
type - Value MUST be a string. Multiple types via an array are not supported.

that means model like base-ml

base-ml:
    title: base-ml
    type: object
    properties:
      model_id:
        type:
          - 'null'
          - string
        default: null
      is_fraud:
        type:
          - boolean
          - 'null'
        default: null
      score:
        type:
          - integer
          - 'null'
        default: null
        minimum: 0
        maximum: 100

is invalid due to the types being arrays instead of just string value

I'll try to look at why it doesn't tell this when validating or if validation even happens properly.

@hackermanmx
Copy link
Author

Thanks @vmasek I'll check, I actually exported it from Stoplight, and indeed it's invalid... sigh.
Cheers!

@vmasek vmasek closed this as completed in 59c3c1b Jun 22, 2018
vmasek added a commit that referenced this issue Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Some problem (breaking)
Projects
None yet
Development

No branches or pull requests

2 participants