swagger_parser
swagger_parser copied to clipboard
Error during generate schema ('List<Object?>' is not a subtype of type 'Map<String, dynamic>')
Steps to reproduce
-
Schema: look at
kaigo.json -
dart run swagger_parser && dart run build_runner build -d -
See error
Expected results
Generated Schema
Actual results
┃ ____ _ _ _ ____ ____ ____ ____ ____ ___ ____ ____ ____ ____ ____
┃ [__ | | | |__| | __ | __ |___ |__/ |__] |__| |__/ [__ |___ |__/
┃ ___] |_|_| | | |__] |__] |___ | \ ___ | | | | \ ___] |___ | \
┃
Generate...
> kaigo:
Failed to generate files.
type 'List<Object?>' is not a subtype of type 'Map<String, dynamic>' in type cast
#0 OpenApiParser.parseRestClients.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:swagger_parser/src/parser/parser/open_api_parser.dart:609:44)
#1 ContextStack.withContext (package:swagger_parser/src/parser/utils/context_stack.dart:24:20)
#2 OpenApiParser.parseRestClients.<anonymous closure>.<anonymous closure> (package:swagger_parser/src/parser/parser/open_api_parser.dart:606:23)
#3 _LinkedHashMapMixin.forEach (dart:_compact_hash:764:13)
#4 OpenApiParser.parseRestClients.<anonymous closure> (package:swagger_parser/src/parser/parser/open_api_parser.dart:604:17)
#5 _LinkedHashMapMixin.forEach (dart:_compact_hash:764:13)
#6 OpenApiParser.parseRestClients (package:swagger_parser/src/parser/parser/open_api_parser.dart:588:67)
#7 GenProcessor.generateFiles (package:swagger_parser/src/generator/generator/generator_processor.dart:33:32)
<asynchronous suspension>
#8 main (file:///Users/jayjah/.pub-cache/hosted/pub.dev/swagger_parser-1.30.0/bin/swagger_parser.dart:28:39)
<asynchronous suspension>
The generation was completed with errors.
No schemes were generated.
Your OpenApi snippet
Code sample
Code sample
[Paste your code here]
Logs
Logs
[Paste your logs here]
Dart version and used packages versions
pubspec.yaml:
dependencies:
dio: ^5.8.0+1
pretty_dio_logger: ^1.4.0
dart_jsonwebtoken: ^3.2.0
http:
retry: ^3.1.2
freezed_annotation: ^2.4.4 # for freezed
json_annotation: ^4.9.0
retrofit: ^4.6.0
dev_dependencies:
lints: ^6.0.0
test: ^1.26.2
build_runner: ^2.5.4
carapacik_lints: ^1.13.0
freezed: ^2.5.7 # for freezed
json_serializable: ^6.9.5
retrofit_generator: ^9.7.0
#chopper_generator: ^8.1.0
swagger_parser: ^1.30.0
Currently I am not sure why this is happening at all. I tried to delete all tags Keys in that schema, but that does not help at all.
Just to make sure, here's the content of the swagger_parser.yaml file:
swagger_parser:
# You must provide the file path and/or url to the OpenApi schema.
# Sets the OpenApi schema path directory for api definition.
schema_path: lib/kaigo.json
# Sets the url of the OpenApi schema.
#schema_url: https://petstore.swagger.io/v2/swagger.json
# Required. Sets output directory for generated files (Clients and DTOs).
output_directory: lib/api
# Optional. Set API name for folder and export file
# If not specified, the file name is used.
name: null
# Optional. Sets the programming language.
# Current available languages are: dart, kotlin.
language: dart
# Optional (dart only).
# Current available serializers are: json_serializable, freezed, dart_mappable.
json_serializer: freezed
# Optional. Set default content-type for all requests.
default_content_type: "application/json"
# Optional (dart only).
# Support @Extras annotation for interceptors.
# If the value is 'true', then the annotation will be added to all requests.
extras_parameter_by_default: false
# Optional (dart only).
# Support @DioOptions annotation for interceptors.
# If the value is 'true', then the annotation will be added to all requests.
dio_options_parameter_by_default: false
# Optional (dart only). Set 'true' to generate root client
# with interface and all clients instances.
root_client: true
# Optional (dart only). Set root client name.
root_client_name: RestClient
# Optional (dart only). Set 'true' to generate export file.
export_file: true
# Optional. Set to 'true' to put the all api in its folder.
put_in_folder: false
# Optional. Set 'true' to put all clients in clients folder.
put_clients_in_folder: false
# Optional. Set to 'true' to squash all clients in one client.
merge_clients: false
# Optional. Set postfix for Client class and file.
client_postfix: Client
# Optional. Set 'true' to use only the endpoint path for the method name.
# Set 'false' to use operationId
path_method_name: false
# Optional (dart only). Set 'true' to include toJson() in enums.
# If set to false, serialization will use .name instead.
enums_to_json: true
# Optional. Set 'true' to set enum prefix from parent component.
enums_parent_prefix: true
# Optional (dart only). Set 'true' to maintain backwards compatibility
# when adding new values on the backend.
unknown_enum_value: true
# Optional. Set 'false' to not put a comment at the beginning of the generated files.
mark_files_as_generated: true
# Optional (dart only). Set 'true' to wrap all request return types with HttpResponse.
original_http_response: false
This error first occurred by version 1.27.0. Before that version it worked as it should. So it has something to do with Allow to filter the generation of endpoints in a client by tags.