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

api_platform's openapi schema fails: Reason: Could not format because the source could not be parsed #212

Closed
sarim opened this issue Aug 19, 2021 · 3 comments · Fixed by #173

Comments

@sarim
Copy link

sarim commented Aug 19, 2021

api in question is:
https://demo.api-platform.com/docs.json?spec_version=2
or
https://demo.api-platform.com/docs.json

its ui is https://demo.api-platform.com/docs

Relevant error log

[INFO] Running build...
[WARNING] swagger_dart_code_generator:swagger_dart_code_generator on api/bookshop.json:
[WARNING] Code formatting failed.
          Please raise an issue on https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/
          Reason: Could not format because the source could not be parsed:

line 63, column 169 of .: Expected to find '}'.
   ╷
63 │ @Get(path: '/books/{id}/reviews') Future<chopper.Response<List<ReviewReviewRead>>> booksIdReviewsGet({@Path('id') required String? id, @Query('order[id]') String? order[id], @Query('order[publicationDate]') String? order[publicationDate], @Query('book') String? book, @Query('book[]') List<String>? book[], @Query('page') int? page});
   │
                                                     ^
   ╵
line 90, column 118 of .: Expected to find '}'.
   ╷
90 │ @Get(path: '/reviews') Future<chopper.Response<List<ReviewReviewRead>>> reviewsGet({@Query('order[id]') String? order[id], @Query('order[publicationDate]') String? order[publicationDate], @Query('book') String? book, @Query('book[]') List<String>? book[], @Query('page') int? page});
   │
  ^
   ╵
line 34, column 124 of .: Expected to find '}'.
   ╷
34 │ @Get(path: '/books') Future<chopper.Response<List<BookBookRead>>> booksGet({@Query('properties[]') List<String>? properties[], @Query('order[id]') String? order[id], @Query('order[title]') String? order[title], @Query('order[author]') String? order[author], @Query('order[isbn]') String? order[isbn], @Query('order[publicationDate]') String? order[publicationDate], @Query('title') String? title, @Query('author') String? author, @Query('page') int? page});
   │
        ^^
   ╵
[SEVERE] chopper_generator:chopper_generator on lib/swagger_generated_code/bookshop.swagger.dart:

This builder requires Dart inputs without syntax errors.
bookshop.swagger.dart:63:169: Expected to find '}'.
bookshop.swagger.dart:90:118: Expected to find '}'.

Try fixing the errors and re-running the build.

[INFO] 1.8s elapsed, 10/11 actions completed.
[SEVERE] json_serializable:json_serializable on lib/swagger_generated_code/bookshop.swagger.dart:

This builder requires Dart inputs without syntax errors.
However, package:hisabai/swagger_generated_code/bookshop.swagger.dart (or an existing part) contains the following errors.
bookshop.swagger.dart:34:124: Expected to find '}'.
bookshop.swagger.dart:63:169: Expected to find '}'.
bookshop.swagger.dart:90:118: Expected to find '}'.

Try fixing the errors and re-running the build.

[INFO] Running build completed, took 2.4s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 31ms

[SEVERE] Failed after 2.4s

Seems like "name": "order[id]", in json is converted to String? order[id] in dart, which for obvious reason is generating a syntax error.

@Vovanella95
Copy link
Collaborator

Hi @sarim , I will check it today

@Vovanella95
Copy link
Collaborator

Hi @sarim
Please check out latest prerelease. I've fixed generation issues and your file generated without issues.
https://pub.dev/packages/swagger_dart_code_generator/versions/2.1.0-prerelease.5

@sarim
Copy link
Author

sarim commented Aug 19, 2021

Thanks, generation now runs without errors (y)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants