GeneratorConfig class
The configuration that the Generator uses
Constructors
-
GeneratorConfig({required String name, required String outputDirectory, ProgrammingLanguage language = ProgrammingLanguage.dart, JsonSerializer jsonSerializer = JsonSerializer.jsonSerializable, String defaultContentType = 'application/json', bool rootClient = true, bool extrasParameterByDefault = false, bool dioOptionsParameterByDefault = false, bool addOpenApiMetadata = false, String? rootClientName = 'RestClient', String? clientPostfix, bool exportFile = true, bool putClientsInFolder = false, bool enumsToJson = false, bool unknownEnumValue = true, bool markFilesAsGenerated = false, bool originalHttpResponse = false, List<
ReplacementRule> replacementRules = const [], bool generateValidator = false, bool useFreezed3 = false, bool freezedJsonSerialization = true, bool useMultipartFile = false, String? fallbackUnion, bool dartMappableConvenientWhen = true, bool useDartMappableNaming = false, bool mergeOutputs = false, bool includeIfNull = false, bool useFlutterCompute = false, bool generateUrlsConstants = false, List<FieldParser> fieldParsers = const []}) -
Creates a GeneratorConfig.
const
Properties
- addOpenApiMetadata → bool
-
DART ONLY
Add static OpenAPI metadata into extras by default when extras are enabled.
final
- clientPostfix → String?
-
Optional. Set postfix for client classes and files.
final
- dartMappableConvenientWhen → bool
-
DART ONLY
Optional. Set 'true' to generate when/maybeWhen convenience methods for dart_mappable unions.
Set 'false' to use only native Dart pattern matching.
final
- defaultContentType → String
-
DART ONLY
Default content type for all requests and responses.
final
- dioOptionsParameterByDefault → bool
-
DART ONLY
Add dio options parameter to all requests.
final
- enumsToJson → bool
-
DART ONLY
Optional. Set
trueto include toJson() in enums. If set tofalse, serialization will use .name instead.final - exportFile → bool
-
DART ONLY
Optional. Set
trueto generate export file.final - extrasParameterByDefault → bool
-
DART ONLY
Add extra parameter to all requests. Supported after retrofit 4.1.0.
final
- fallbackUnion → String?
-
DART ONLY
Optional. Set fallback constructor name to use fallbackUnion parameter when using Freezed annotation.
final
-
fieldParsers
→ List<
FieldParser> -
DART ONLY
Optional. Set field parsers.
final
- freezedJsonSerialization → bool
-
Generate Freezed JSON helpers through json_serializable.
final
- generateUrlsConstants → bool
-
DART/FLUTTER ONLY
Optional. Set
trueto generate URL constants for all endpoints.final - generateValidator → bool
-
Optional. Set
trueto generate validator function and prams for freezed.final - hashCode → int
-
The hash code for this object.
no setterinherited
- includeIfNull → bool
-
DART ONLY
Optional. Set
trueto generate includeIfNull annotations for nullable fields. If set tofalse, includeIfNull annotations will not be generated.final - jsonSerializer → JsonSerializer
-
DART ONLY
Optional. Current available serializers are: json_serializable, freezed, dart_mappable.
final
- language → ProgrammingLanguage
-
Optional. Sets the programming language.
Current available languages are: dart, kotlin.
final
- markFilesAsGenerated → bool
-
Optional. Set
falseto not put a comment at the beginning of the generated files.final - mergeOutputs → bool
-
Optional. Set to true to merge all generated code into a single file.
final
- name → String
-
Optional. Set API name for folder and export file or merged output file
If not specified, the file name is used.
final
- originalHttpResponse → bool
-
DART ONLY
Optional. Set
trueto wrap all request return types with HttpResponse.final - outputDirectory → String
-
Required. Sets output directory for generated files (Clients and DTOs).
final
- putClientsInFolder → bool
-
Optional. Set
trueto put all clients in clients folder.final -
replacementRules
→ List<
ReplacementRule> -
Optional. Set regex replacement rules for the names of the generated classes/enums.
All rules are applied in order.
final
- rootClient → bool
-
DART ONLY
Optional. Set 'true' to generate root client
with interface and all clients instances.
final
- rootClientName → String?
-
DART ONLY
Optional. Set root client name.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- unknownEnumValue → bool
-
DART ONLY
Optional. Set
trueto maintain backwards compatibility when adding new values on the backend.final - useDartMappableNaming → bool
-
DART ONLY
Optional, defaults to false. Set to true to use the standard
toMapandfromMapserialization from dart_mappable. This is a new feature introduced in Retrofit 4.9.2. Prior to this it was required to rename these methods in the build.yaml tofromJsonandtoJsonto make dart_mappable compatible with retrofit. To avoid breaking changes for existing dart_mappable implementations, this flag must be explicitely set to truefinal - useFlutterCompute → bool
-
DART/FLUTTER ONLY
Optional. Set
trueto generate Retrofit clients withParser.FlutterComputeand serialize/deserialize top-level functions for isolate-based multithreading.final - useFreezed3 → bool
-
Optional. Set
trueto use freezed v3 if jsonSerializer is freezed.final - useMultipartFile → bool
-
DART ONLY
Optional. Set
trueto use MultipartFile instead of File as argument type for file parameters.final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited