When generating API clients from an OpenAPI specification that contains multi-line descriptions with \n characters, swagger_to_dart generates invalid Dart code that cannot be formatted by dart_style.
Environment
swagger_to_dart: 4.1.0 and 4.2.0
dart_style: 3.0.0+
Dart SDK: 3.10.4
Problem
The generator embeds OpenAPI descriptions into @Extras() annotations using raw strings (r'...'). However, it does not properly handle \n characters in these descriptions, resulting in literal newlines within raw strings, which is invalid Dart syntax.
Example
OpenAPI specification:
{
"description": "HTTP proxy endpoint.\n\nArgs:\n request: The original request from client.\n\nReturns:\n The response from target server."
}
Error
Could not format because the source could not be parsed:
Unterminated string literal.
Expected Behavior
The generator should either:
- Use regular strings (not raw strings) and properly escape the content
- Replace \n with \n in raw strings
- Use triple-quoted strings for multi-line content
When generating API clients from an OpenAPI specification that contains multi-line descriptions with
\ncharacters, swagger_to_dart generates invalid Dart code that cannot be formatted by dart_style.Environment
swagger_to_dart: 4.1.0 and 4.2.0
dart_style: 3.0.0+
Dart SDK: 3.10.4
Problem
The generator embeds OpenAPI descriptions into @Extras() annotations using raw strings (r'...'). However, it does not properly handle \n characters in these descriptions, resulting in literal newlines within raw strings, which is invalid Dart syntax.
Example
OpenAPI specification:
Error
Expected Behavior
The generator should either: