Grafikart / OpenApiToTS

Convert openapi.yml file to ts declaration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't convert item to NodeType when using array type without defined items

SirMishaa opened this issue · comments

commented

Hello, I'm sorry but I'm back

It looks like when we're using an array as type, it cannot convert it to NodeType :

{
  type: 'array',
  description: 'The allowed mime types for the document (image/jpeg, image/png, application/pdf)'
}
VVVV From VVVV
{
  type: 'array',
  description: 'The allowed mime types for the document (image/jpeg, image/png, application/pdf)'
}

Error: Can't convert item to NodeType
    at SchemaParser.itemToNode (file:///Users/mishaa/yago/seraphinWeb/node_modules/@grafikart/o2ts/dist/SchemaParser.js:221:19)
    at SchemaParser.itemToNode (file:///Users/mishaa/yago/seraphinWeb/node_modules/@grafikart/o2ts/dist/SchemaParser.js:201:57)
    at SchemaParser.convertToCode (file:///Users/mishaa/yago/seraphinWeb/node_modules/@grafikart/o2ts/dist/SchemaParser.js:27:57)
    at file:///Users/mishaa/yago/seraphinWeb/node_modules/@grafikart/o2ts/dist/generator.js:13:26

Caused by (working when changing array to string)

fileMimeTypes:
  type: array
  description: The allowed mime types for the document (image/jpeg, image/png, application/pdf)
exampleImages:
  type: array
  description: The example images of the document that will be show in a modal
  items:
    type: string
    example: https://example.com/example-image.png

The full OpenAPI file can be found here : https://gist.github.com/SirMishaa/7e80f67943cc8ffda5532f0506dd0db9#file-document-upload-api-yaml-L271-L279
(Basically, that's the same as before but with an additional type, you can update your test with it if needed)

Thank you !

commented

Also, you should open this project to Github donation, I'd to support the project because we're using in at work !

commented

Nvm, fixed by adding :

fileMimeTypes:
  type: array
  description: The allowed mime types for the document (image/jpeg, image/png, application/pdf)
+ items:
+   type: string
+   example: image/jpeg

I think it's not required in the specification, but that was my bad anyway