SWPConfig class

Swagger Parser Config

Constructors

SWPConfig({required String outputDirectory, String? schemaPath, String? schemaUrl, String name = 'api', ProgrammingLanguage language = ProgrammingLanguage.dart, JsonSerializer jsonSerializer = JsonSerializer.jsonSerializable, bool rootClient = true, String rootClientName = 'RestClient', String? clientPostfix, bool exportFile = true, bool putClientsInFolder = false, bool enumsToJson = false, bool unknownEnumValue = true, bool markFilesAsGenerated = true, bool originalHttpResponse = false, List<ReplacementRule> replacementRules = const [], List<ReplacementRule> replacementRulesForRawSchema = const [], String defaultContentType = 'application/json', bool extrasParameterByDefault = false, bool dioOptionsParameterByDefault = false, bool addOpenApiMetadata = false, bool pathMethodName = false, bool mergeClients = false, bool enumsParentPrefix = true, List<String> skippedParameters = const <String>[], bool generateValidator = false, bool useXNullable = false, bool useFreezed3 = false, bool freezedJsonSerialization = true, bool useMultipartFile = false, String? fallbackUnion, bool dartMappableConvenientWhen = false, bool useDartMappableNaming = false, List<String> excludeTags = const <String>[], List<String> includeTags = const <String>[], List<String>? includePaths, String fallbackClient = 'fallback', bool mergeOutputs = false, bool includeIfNull = false, bool inferRequiredFromNullable = false, bool useFlutterCompute = false, bool generateUrlsConstants = false, List<FieldParser> fieldParsers = const [], bool preserveSchemaCasing = false})
Creates a SWPConfig.
const
SWPConfig.fromYaml(YamlMap yamlMap, {bool isRootConfig = false, SWPConfig? rootConfig})
Creates a SWPConfig from YamlMap.
factory
SWPConfig.fromYamlWithOverrides(YamlMap yamlMap, ArgResults? argResults, {bool isRootConfig = false, SWPConfig? rootConfig})
Creates a SWPConfig from YamlMap with CLI argResults overrides.
factory

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
enumsParentPrefix → bool
Set 'true' to set enum prefix from parent component.
final
enumsToJson → bool
DART ONLY Optional. Set true to include toJson() in enums. If set to false, serialization will use .name instead.
final
excludeTags → List<String>
DART ONLY Optional. Set excluded tags.
final
exportFile → bool
DART ONLY Optional. Set true to generate export file.
final
extrasParameterByDefault → bool
DART ONLY Add extra parameter to all requests. Supported after retrofit 4.1.0.
final
fallbackClient → String
DART ONLY Optional. Fallback client name for endpoints without tags.
final
fallbackUnion → String?
DART ONLY Optional. Set fallback consctructor 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 true to generate URL constants for all endpoints.
final
generateValidator → bool
Set true to generate validator for freezed.
final
hashCode → int
The hash code for this object.
no setterinherited
includeIfNull → bool
DART ONLY Optional. Set true to generate includeIfNull annotations for nullable fields. If set to false, includeIfNull annotations will not be generated.
final
includePaths → List<String>?
Optional. Set included paths.
final
includeTags → List<String>
DART ONLY Optional. Set included tags.
final
inferRequiredFromNullable → bool
DART ONLY Optional. When true, infer required properties from nullability. Properties without nullable: true in schema are marked as required. Only applies when schema has no explicit required array.
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 false to not put a comment at the beginning of the generated files.
final
mergeClients → bool
Set true to merge all clients in single client.
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 If not specified, the file name is used.
final
originalHttpResponse → bool
DART ONLY Optional. Set true to wrap all request return types with HttpResponse.
final
outputDirectory → String
Required. Sets output directory for generated files (Clients and DTOs).
final
pathMethodName → bool
If true, use the endpoint path for the method name. if false, use operationId.
final
preserveSchemaCasing → bool
Optional. When true, schema and enum names are projected into the target language by stripping separator characters (spaces, dashes, dots, underscores) while preserving the casing of every other character. Defaults to false — the default behaviour, which normalises every name to PascalCase and loses internal acronym and lowercase-prefix casing (e.g. XMLHttpRequest becomes XmlHttpRequest).
final
putClientsInFolder → bool
Optional. Set true to 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
replacementRulesForRawSchema → List<ReplacementRule>
Optional. Set raw regex replacement rules for the names of the raw schema objects.
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
schemaPath → String?
Sets the path directory of the OpenApi schema.
final
schemaUrl → String?
Sets the url of the OpenApi schema.
final
skippedParameters → List<String>
List of parameter names that should skip during parsing
final
unknownEnumValue → bool
DART ONLY Optional. Set true to 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 toMap and fromMap serialization 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 to fromJson and toJson to make dart_mappable compatible with retrofit. To avoid breaking changes for existing dart_mappable implementations, this flag must be explicitely set to true
final
useFlutterCompute → bool
DART/FLUTTER ONLY Optional. Set true to generate Retrofit clients with Parser.FlutterCompute and serialize/deserialize top-level functions for isolate-based multithreading.
final
useFreezed3 → bool
Set true to use Freezed 3.x code generation syntax. Set false to maintain compatibility with Freezed 2.x
final
useMultipartFile → bool
DART ONLY Optional. Set true to use MultipartFile instead of File as argument type for file parameters.
final
useXNullable → bool
Set true if Schema uses x-nullable to indicate nullable fields
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toGeneratorConfig() → GeneratorConfig
Convert SWPConfig to GeneratorConfig
toParserConfig({required String fileContent, required bool isJson}) → ParserConfig
Convert SWPConfig to ParserConfig
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited