Skip to content

Commit

Permalink
Fix error in body with name in dart template
Browse files Browse the repository at this point in the history
  • Loading branch information
Carapacik committed Oct 18, 2023
1 parent a1728ee commit 2af3e70
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions swagger_parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.10.2
- Fix error in `body` with name in dart template

## 1.10.1
- Fix error with query parameter named `body` ([#108](https://github.com/Carapacik/swagger_parser/issues/108))

Expand Down
6 changes: 3 additions & 3 deletions swagger_parser/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ dependencies:
dio: ^5.3.3
freezed_annotation: ^2.4.1
json_annotation: ^4.8.1
retrofit: ^4.0.2
retrofit: ^4.0.3

dev_dependencies:
build_runner: ^2.4.6
carapacik_lints: ^1.4.2
freezed: ^2.4.3
freezed: ^2.4.5
json_serializable: ^6.7.1
retrofit_generator: ^8.0.0
retrofit_generator: ^8.0.1
swagger_parser:
path:
../
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ String _fileImport(UniversalRestClient restClient) => restClient.requests.any(
: '';

String _toParameter(UniversalRequestType parameter) =>
" @${parameter.parameterType.type}(${parameter.name != null ? "${parameter.parameterType.isPart ? 'name: ' : ''}'${parameter.name}'" : ''}) "
" @${parameter.parameterType.type}(${parameter.name != null && !parameter.parameterType.isBody ? "${parameter.parameterType.isPart ? 'name: ' : ''}'${parameter.name}'" : ''}) "
'${_required(parameter.type)}'
'${parameter.type.toSuitableType(ProgrammingLanguage.dart)} '
'${parameter.type.name!.toCamel}${_defaultValue(parameter.type)},';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ String _toClientRequest(UniversalRequest request) {
}

String _toQueryParameter(UniversalRequestType parameter) =>
' @${parameter.parameterType.type}${parameter.parameterType.isBody ? '' : '("${parameter.name}")'} '
' @${parameter.parameterType.type}${parameter.name != null && !parameter.parameterType.isBody ? '("${parameter.name}")' : ''} '
'${parameter.type.name!.toCamel}: ${parameter.type.toSuitableType(ProgrammingLanguage.kotlin)}'
'${_defaultValue(parameter.type)}';

Expand Down
2 changes: 1 addition & 1 deletion swagger_parser/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: swagger_parser
description: Package that generates REST clients and data classes from OpenApi definition file
version: 1.10.1
version: 1.10.2
repository: https://github.com/Carapacik/swagger_parser/tree/main/swagger_parser
homepage: https://omega-r.com
topics:
Expand Down

0 comments on commit 2af3e70

Please sign in to comment.