icerockdev / moko-network

Network components with codegeneration of rest api for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev
Apache License 2.0
151 stars 29 forks source link

Syntax errors in generated source files #1

Closed darizhap closed 4 years ago

darizhap commented 4 years ago

Hello! I'm trying to use your moko-network-generator plugin to automatically generate a multi-platform ktor client. If I use the swagger.json from your example in the sample folder, then everything works fine. But if we take another example of the API, then compilation errors may occur when building the client. E. g. if you take a swagger file from petstore.swagger.io, then syntax errors are detected in the generated source files. For example:

  1. There is no import directive for the serializer() extension function, resulting in error "Unresolved reference: serializer".
  2. In some cases, instead of angle brackets containing a type parameter, the generator uses their codes. Instead of List<User> we have List&lt;User&gt;
  3. Instead of grave accent the generator uses its unicode hex character code &#x60
  4. Also in some cases we have errors like this: "Suspend function 'request' should be called only from a coroutine or another suspend function".
  5. Also, when serializing lists, instead of User.serializer().list generator writes List<User>.serializer().

Of course, there is still an option to edit those generated source files and build projects manually. But this is not as convenient as if the entire generation and building procedure would be performed automatically.

Alex009 commented 4 years ago

hello! thx for report, i was able to reproduce the problem using https://petstore.swagger.io/v2/swagger.json. The next two weeks are very busy, most likely I can fix the problem no earlier than the beginning of December.

darizhap commented 4 years ago

Thank you for quick response. If you need help with this issue, write here a brief instruction on where to look and what to fix.

Alex009 commented 4 years ago

@darizhap I apologize for the long wait, we release now version 0.2.0 with fix this issue from @ATchernov. Please check on your side, if all ok - i close issue