swagger_parser 2.1.1
swagger_parser: ^2.1.1 copied to clipboard
Generate Dart models and HTTP clients from Swagger and OpenAPI. Supports Retrofit, Dio, and package:http.
Changelog #
2.1.1 #
- Uses Freezed for all data model classes when selected, including value wrappers,
oneOfvariants,anyOfmodels, tuples, unknown values, and typed HTTP results. Fixes value equality for primitive union variants (#488). - Updates the minimum
swagger_parser_coreversion to 1.0.2. - Adds pub.dev topics, documentation links, and the project icon.
2.1.0 #
2.0.1 #
- Fixes single-reference
allOfproperties with descriptions generating duplicate models and losing enum types (#479). - Fixes negative numeric enum names losing their sign (#480).
- Fixes duplicate enum values generating distinct members for the same JSON value (#481).
- Defaults
infer_missing_requiredtofalse. Set it totrueto infer required non-nullable fields without defaults whenrequiredis absent (#482). - Fixes
first_successdecoding declared bodyless success responses as payloads. Buffered return types become nullable when a bodyless success is declared. Handlenullafter regenerating affected clients (#483). - Adds regression tests, generated-file e2e cases, runnable examples, and public API documentation.
2.0.0 #
- Rebuilds parsing in
swagger_parser_corefor Swagger 2.0 and OpenAPI 3.0–3.2. - Adds plain Dart JSON codecs alongside
json_serializable, Freezed, anddart_mappable. - Adds standalone Dio and
package:httpclients alongside Retrofit + Dio. - Adds typed status results, JSON Lines, and streaming downloads. Retains SSE.
- Adds request/response models, custom type codecs, and optional DTO validation.
- Rebuilds Pages with JSON/YAML file input, config editing, templates, and ZIP output.
- BREAKING CHANGES:
- Requires Dart ^3.13.0. Update the Dart SDK before upgrading.
- Replaces v1 configuration. Migrate settings with the configuration reference.
- Moves custom templates and helper files to
swagger_parser_templates. Use its package and CLI for custom output. - Removes Kotlin generation. Use a generator with a Kotlin backend for Kotlin output.
- Removes single-file output. Import the generated API entry point to access models and clients.
- Removes DTO output without serialization. Use custom templates for that output.
1.46.0 #
- Adds
freezed_nullable_presence(defaultfalse) to generate a<name>Presentflag for each optional nullable property of Freezed models, sotoJsoncan tell an omitted key from an explicitnull, for example to clear a field in a PATCH request body (#477).
1.45.1 #
- Fixes OpenAPI 3 schemas without a
requiredarray generating every property asrequiredwhen any property usesallOf(#460).
1.45.0 #
- Adds
freezed_json_serialization(defaulttrue) to generate Freezed models without.g.dartandfromJsonwhen JSON serialization is not needed. Existing JSON-enabled generation remains the default (#473). - Documents Freezed 4 and current code generation dependency versions.
1.44.3 #
- Fixes
infer_required_from_nullabletreating OpenAPI 3.1 type lists containing"null"as non-nullable, which generated them asrequired T?(#472).
1.44.1 #
- Fixes
dart_mappableenum generation for JSON Schema type lists by quoting non-numeric JSON values (#468).
1.44.0 #
- Adds
preserve_schema_casingoption to preserve original casing of schema-derived identifiers, defaults tofalsefor backward compatibility, which normalises to PascalCase. - Fixes crash when a
multipart/form-datarequest body references a schema withoutproperties. - Fixes nullable handling for single-element
allOf,oneOf, andanyOfschemas with siblingnullable: true. - Fixes missing imports for nested union properties in Freezed discriminated-union variants.
1.43.1 #
- Fixes escaping
$unknownin generated enumtoJsonerror messages. - Fixes generated code when using
json_serializable. - Fixes default enum values for
dart_mappable. - Adds README section about Server-Sent Events.
1.43.0 #
- Supports standard
dart_mappableserializer method names. - Fixes default enum values in forms.
- Fixes name correction errors.
1.42.0 #
- Adds support for streaming and SSE.
- Preserves property names and
requiredmodifiers inpropertiesblocks. - Fixes API paths incorrectly converted to PascalCase.
1.41.0 #
- Adds
field_parsersoption for field parsers injson_serializable.
1.40.0 #
- Adds
include_pathsoption for filtering endpoints by paths. - Adds
generate_urls_constantsoption for generating URL constants for all endpoints.
1.39.1 #
- Fixes client methods returning
ModelNameUnioninstead ofModelNameSealedforoneOftypes (#393).
1.39.0 #
- Handles names for request bodies declared inline.
- Fixes deserialization syntax for Freezed unions without a discriminator.
1.38.0 #
- Adds
replacement_rules_for_raw_schemaoption for raw schema objects replacement rules.
1.37.0 #
- Adds
use_flutter_computeoption for Flutter isolate-based multithreading support.- Generates
@RestApi(parser: Parser.FlutterCompute)annotation in Retrofit clients. - Generates top-level serialization functions in each DTO model file following Retrofit's naming convention.
- Works with all serializers:
freezed,json_serializable,dart_mappable.
- Generates
swagger_parser:
use_flutter_compute: true
1.36.0 #
- Adds
add_openapi_metadata(defaultfalse) to generate OpenAPItags,operationId, andexternalDocsUrlconstants for each endpoint; whenextras_parameter_by_defaultistrue, the metadata is also prefilled into Dioextras—handy for interceptors and logging without overwriting user-supplied extras. - Uses fully-qualified default extras values (e.g.
BannerApi.findAllBannersOpenapiExtras) so generated implementations can access the static metadata constants.
swagger_parser:
extras_parameter_by_default: true
add_openapi_metadata: true
abstract class PetsClient {
static const Map<String, dynamic> listPetsOpenapiExtras =
<String, dynamic>{
'openapi': <String, dynamic>{
'tags': <String>['pets'],
'operationId': 'listPets',
'externalDocsUrl': 'https://docs.example.com/pets',
},
};
@GET('/pets')
Future<void> listPets({
// defaults to the OpenAPI metadata; merge with your own extras if needed
@Extras() Map<String, dynamic>? extras =
PetsClient.listPetsOpenapiExtras,
@DioOptions() RequestOptions? options,
});
}
# https://openapi.sepc/pets/listPets
1.35.2 #
- Fixes
toStringreturning anintfor enum names.
1.35.1 #
- Fixes enum name generation.
1.35.0 #
- Adds
infer_required_from_nullable.
infer_required_from_nullable: true
Schema without required array:
- id: type: integer → required int id
- name: type: string → required String name
- desc: type: string, nullable: true → String? desc
- Fixes nullable array item types generation.
1.34.0 #
- Adds
includeIfNullhandling, disabled by default; setinclude_if_null: trueto enable it.
1.33.0 #
- Handles nested
allOfclasses.
1.32.1 #
- Fixes duplicate changelog entries.
1.32.0 #
- Adds sealed classes for
oneOfandanyOfwithjson_serializableanddart_mappable. Uses O(n) try-catch decoding without a discriminator, where n is the number of variants. Use a discriminator for O(1) dispatch. Supports fallback variants when decoding fails. - Adds
dart_mappable_convenient_whenfordart_mappableunions. Generateswhen<T>andmaybeWhen<T>whentrue. Generates sealed classes whenfalse(the default). - Deprecates
when<T>andmaybeWhen<T>with@Deprecated()fordart_mappable. Use Dart pattern matching instead. - Fixes duplicate
unknownenum values withdart_mappableandunknown_enum_value: true. - Fixes nullable discriminator union handling.
1.30.1 #
- Fixes resolution of inline schemas in tagged operations.
1.30.0 #
- Adds support for merging all generated code into single output file using the
merge_outputsoption.
1.29.0 #
-
Adds support for non-discriminated unions (
oneOf/anyOfwithout a discriminator). -
Filters out unused schemas when using
include_tagsorexclude_tags. -
Fixes the client name for untagged paths to properly fall back to the configured
fallback_clientinstead ofclient. -
Fixes the
fallback_clientconfiguration to default tofallbackinstead ofdefaultto avoid conflicts with the Dartdefaultkeyword in the generated code. -
Fixes OpenAPI spec parsing to correctly preserve casing for
SCREAMING_SNAKE_CASE. -
Fixes filtering so paths without tags are filtered out when
include_tagsis specified.
1.28.0 #
- Fixes documentation.
- Fixes file names for tags with alphanumeric suffixes.
1.27.0 #
- Allows filtering generated client endpoints by tags.
- Adds a fallback client for endpoints without tags (#271).
1.26.4 #
- Allows single
MultipartFilearguments in multipart requests; requiresretrofit_generator10.0.1 or later.
1.26.3 #
- Fixes collisions between untagged endpoints and endpoints tagged
Clientthat caused generated clients to overwrite each other.
1.26.2 #
- Aligns default value handling for parameters according to the OpenAPI specification: https://swagger.io/docs/specification/v3_0/describing-parameters/#default-parameter-values.
1.26.1 #
- Adds a
toStringoverride fordart_mappable. - BREAKING CHANGE: Makes
dart_mappabletoJsonreturn a string. Use the returned JSON string instead of a map.
1.26.0 #
- Adds support for the Freezed
fallbackUnionparameter.
1.25.1 #
- Fixes
dart_mappableenum generation.
1.25.0 #
- Allows using
MultipartFileinstead ofFilein multipart requests, to support usage on web.
1.24.6 #
- Handles binary responses, such as file downloads, based on retrofit.dart#503.
1.24.5 #
- Adds an enum
toString()override that provides a JSON value to third-party consumers such as Retrofit.
1.24.4 #
- Adds the
$valuesDefinedgetter to filter out unknown values automatically.
1.24.3 #
- Deduplicates property names for
allOfschemas that mixrefandproperties, preventing naming overlaps.
1.24.2 #
- Fixes
typedefimports when generatingjson_serializableclasses; see google/json_serializable#1124.
1.24.0 #
- Fixes detection of nullable list with non-null items vs nullable list with nullable items (#323).
- BREAKING CHANGE: Requires Dart 3.6 or later. Update the Dart SDK before upgrading.
1.23.1 #
- Updates the
dart_mappabletemplate.
1.23.0 #
1.22.1 #
- Adds support for Freezed 3.
1.21.4 #
1.20.1 #
- Fixes errors with config parsing.
1.20.0 #
- Adds validation parameters to generated Freezed classes.
- Fixes errors with empty schema properties (#280).
1.19.2 #
1.19.0 #
- Adds a version getter to the root client.
final version = RestClient.version;
- Adds
dio_options_parameter_by_default.
1.18.3 #
- BREAKING CHANGE: Maps
int64tointinstead ofBigInt. Update callers to useint.
1.18.2 #
- Adds support for
int64types.
1.18.0 #
- Handles empty enum value case (#238).
- Fixes replacement rules.
- Adds support for nullable lists and maps.
- BREAKING CHANGES:
- Removes
required_by_default. Remove it from config; behavior matchesfalse. - Requires Dart 3.4. Update the Dart SDK before upgrading.
- Removes
1.17.3 #
1.17.2 #
- Adds
MappableFieldto thedart_mappabletemplate.
1.17.0 #
- Adds new config parameter
extras_parameter_by_defaultfrom retrofit 4.1.0 for (#208). - Fixes errors (#190), (#192) and (#195).
1.16.4 #
- Fixes errors with
required_by_default.
1.16.3 #
1.16.2 #
- Exports new exceptions.
- Fixes file names derived from
schemeUrl.
1.16.1 #
- Fixes the web interface.
1.16.0 #
- Adds a wrapping collections variable that replaces
arrayDepthandmapType; it stores and resolves all collections wrapping a type in their order of appearance (#128). - Fixes error with
required_by_default(#168). - BREAKING CHANGES:
- Renames config keys. Replace
squash_clientswithmerge_clients,enums_prefixwithenums_parent_prefix, andskipp_parameterswithskipped_parameters. - Removes
put_in_folder. Remove this key from config.
- Renames config keys. Replace
1.15.4 #
- Fixes documentation.
1.15.0 #
- Adds new config parameter
required_by_default. - Adds a template for end-to-end tests.
1.14.1 #
- Removes check that would avoid generating a map when additional properties has a
$refvalue.
1.14.0 #
- Fixes error with empty content type.
- Fixes the Retrofit template.
- Removes special characters from tags.
- Adds new config parameter
skip_parameters. - Extracts schemas from URLs (#150).
1.13.0 #
- Adds support for dart_mappable.
- BREAKING CHANGE: Replaces the
freezedconfig key withjson_serializer. Setjson_serializertofreezed,dart_mappable, orjson_serializable(the default). - Fixes names for enums defined inside arrays.
1.12.0 #
- Adds new config parameter
export_file.
1.11.3 #
- Fixes client annotations for non-default content types in Swagger 2.0 schemas.
1.11.2 #
- Adds description of request parameters to the code docs.
1.11.1 #
- Fixes referenced components incorrectly classified as maps.
- Removes unused imports for map components.
1.11.0 #
1.10.2 #
- Fixes named
bodyparameters in the Dart template.
1.10.0 #
- Adds support for generating schemas by URL (see the example).
- Adds new config parameter
schema_url. - Adds new config parameter
schema_from_url_to_file. - Adds new config parameter
prefer_schema_source.
1.9.1 #
- Handles invalid names for classes, enums, and methods.
- Adds a name for unnamed models (#98).
- Adds support for
deprecatedannotations for methods.
1.9.0 #
1.8.0 #
- Adds support for multiple schemas (see the example).
- Adds support for nullable types through
anyOf. - Updates the root client template.
- Adds new config parameter
root_client_name. - Adds new config parameter
name. - Adds new config parameter
put_in_folder. - Adds new config parameter
squash_clients. - BREAKING CHANGES:
- Renames
root_interfacetoroot_client. Update this key in config. - Renames
squish_clientstoput_clients_in_folder. Update this key in config.
- Renames
1.7.0 #
- Adds new config parameter
mark_files_as_generated. - Adds support for default values for ref enum types.
- Adds type support for single-element
allOf,anyOf, andoneOfschemas.
1.6.2 #
- Fixes grouping words for abbreviations when special characters are present.
- Fixes replacement type for enum classes.
- Preserves casing in replacements.
1.6.1 #
- Adds summary of the methods to the code docs.
- Fixes indents for multiline code docs.
- Adds support for root client code docs.
1.6.0 #
- Adds new config parameter
path_method_name.
1.5.0 #
- BREAKING CHANGE: Requires Dart 3.0 or later. Update the Dart SDK before upgrading.
1.4.0 #
1.3.4 #
- Applies enum prefixes only to variable types.
1.3.2 #
- Fixes replacement rules in
allOf.
1.3.0 #
- Adds possibility to add enum prefix from parent component
(#29). Change
enums_prefixto true to enable this option.
1.2.4 #
- Fixes names for negative enum values.
1.2.1 #
- Updates
retrofit_generatordependency to 7.0.8 and adds a config option to generate.toJson()methods in enums (retrofit_generatorwill use.toJson()instead of.namein this case).
1.2.0 #
- Updates
retrofit_generatordependency to 7.0.7 and removes unused.toJson()generated methods in enums.
1.1.0 #
- Adds regex replacement for generated class names.
- Fixes null raw parameters in Swagger 2.0 (#63).
1.0.6 #
- Fixes generation of default enum values (#58).
- Adds new keywords to check the name of variables.
1.0.4 #
1.0.3 #
- Fixes error with default value in
json_serializablegeneration.
1.0.0+1 #
- Adds
root_interfaceoption to web interface. - Adds topics.
1.0.0 #
- BREAKING CHANGE: Requires Dart 2.19 or later. Update the Dart SDK before upgrading.
- Adds support for
descriptionannotation. - Adds
root_interfaceto generate a root interface for all clients. - Refactors code related to
nullable.
0.10.3 #
- Uses
refto identify a client method's return type whentypeis also present.
0.10.2 #
- Generates
defaultValuein the Dart class constructor. - Fixes error with empty
client_postfix.
0.10.1 #
- Fixes error with
serversin requests (#32). - Uses
operationIdfor method names when the field exists.
0.10.0 #
- Fixes error with
enumvalues not parsed in object properties. - Uses other 2xx codes when a 200 response is absent.
- Adds support for
nullabletypes.
0.9.1 #
- Uses
JsonEnumandJsonValueon generated enum.
0.9.0 #
- Defines single-reference sibling elements as typedefs instead of generating unnecessary classes.
- Fixes error with
Nulltype with empty type in schema.
0.8.0 #
- Adds support for Dio 5.
- Downgrades the lower bound of dependencies to support Flutter 3.0.
- Completes templates for Kotlin.
0.7.0 #
- Fixes error with import for
Filetype. - Adds support for
additionalPropertiesannotations. - Fixes templates.
- Fixes error with YAML files.
0.6.4 #
- Updates example.
- Removes
implicit_dynamicfield for analyzer.
0.6.3 #
- Fixes error with return type in rest client.
0.6.2 #
- Updates documentation.
0.6.1 #
- Fixes multipart file types in Retrofit.
- Updates Dart API documentation.
- Updates web interface.
0.6.0 #
- Adds support for
yamlfiles. - BREAKING CHANGE: Renames
json_pathtoschema_path. Update this key inpubspec.yaml.
0.5.1 #
- Fixes default values in the Freezed template.
0.5.0 #
- Recognizes objects and generates them as DTOs.
- Fixes
defaultValuehandling. - Fixes return types.
- Fixes parameter names that conflict with Dart keywords.
0.4.1 #
- Fixes parameter names that conflict with Dart keywords.
- Fixes file suffixes in imports.
0.4.0 #
- Adds support for
defaultannotations. - Adds enum support for Dart.
- Fixes multipart handling.
- Fixes errors with Kotlin types.
0.3.1 #
- Fixes error with
@in URL paths. - Maps
numbertodouble. - Maps
objectto DartObject. - Updates the README with instructions and steps to generate the code.
0.3.0 #
- Adds support for
requiredannotations. - Fixes REST client parameter types in Swagger 2.0.
0.2.4 #
- Fixes error with
.and,in URL paths.
0.2.3 #
- Fixes multipart requests with a single
$ref.
0.2.2 #
- Removes the
swagger_parsersection from the packagepubspec.yaml. - Updates dependencies in example.
0.2.1 #
- Fixes README.
- Fixes workflow files.
0.2.0 #
- Fixes errors with generation of data classes containing
allOf. - Fixes errors with templates.
- Adds the web interface.
- Adds generator tests.
0.1.0 #
- Marks the initial release.