swagger-api / swagger-api/swagger-codegen
[Dart] - Flutter issue with generic classes
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I am using a standard aspnet boilerplate (AspNet Core 2.1). I'm trying to generate flutter code however I run into issues with generic types.
One of the C# functions is declared as following:
Task<ListResultDto<PermissionDto>> GetAllPermissions();
Full Gist with Declarations:
https://gist.github.com/antonio-mikulic/7a0c5e50e01bf9e3e0c1d5c7ef535e2f
And this is part of genenerated code:
class ListResultDto[PermissionDto] {
List<PermissionDto> items = [];
ListResultDto[PermissionDto]();
}
class PermissionDto {
String name = null;
String displayName = null;
String description = null;
int id = null;
PermissionDto();
static List<PermissionDto> listFromJson(List<dynamic> json) {
return json == null ? new List<PermissionDto>() : json.map((value) => new PermissionDto.fromJson(value)).toList();
}
}
-
Error: Occurs on PermissionDto class: "The name 'PermissionDto' is already defined.dart(duplicate_definition)".
-
Error: PermissionDto(); Invalid constructor name.dart(invalid_constructor_name)
Errors 1 and 2 go away after class ListResultDto[PermissionDto] {} is changed into ListResultDtoPermissionDto. -
Error: Occurs on class ListResultDto[PermissionDto] {}. No other errors in this file.
Expected to find ';'.dart(expected_token)
Variables must be declared using the keywords 'const', 'final', 'var' or a type name.dart(missing_const_final_var_or_type)
dynamic PermissionDto
swagger.api
Swagger-codegen version
2.4.1-SNAPSHOT
Command line used for generation
set executable=..\..\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i http://localhost:21021/swagger/v1/swagger.json -l dart -o swagger -DbrowserClient=false -DdateLibrary=joda -DhideGenerationTimestamp=true
java %JAVA_OPTS% -jar %executable% %ags%
Steps to reproduce
Generate code from empty aspnet boilerplate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the swagger-codegen CLI Dart generation entry point and reproduce the issue with the provided ASP.NET Swagger URL or gist declarations. Inspect the generated ListResultDto[PermissionDto] and PermissionDto output, then verify that generated Dart parses without duplicate-definition, invalid-constructor-name, or expected-token errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100