swagger_parser 1.44.1 copy "swagger_parser: ^1.44.1" to clipboard
swagger_parser: ^1.44.1 copied to clipboard

Package that generates REST clients and data classes from OpenApi definition file

1.44.1 #

  • Fixes dart_mappable enum generation for JSON Schema type lists by quoting non-numeric JSON values (#468).

1.44.0 #

  • Adds preserve_schema_casing option to preserve original casing of schema-derived identifiers, defaults to false for backwards 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, and anyOf schemas with sibling nullable: true.
  • Fixes missing imports for nested union properties in Freezed discriminated-union variants.

1.43.1 #

  • Fixes escaping $unknownin generated enumtoJson error 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 #

  • Allows standard dart_mappable serializer method naming convention.
  • Fixes default values for Enums in forms.
  • Fixes errors with corrector.

1.42.0 #

  • Adds support for streaming & SSE.
  • Fixes preserve property names and required modifiers in properties blocks.
  • Fixes API path definitions are incorrectly converted to PascalCase.

1.41.0 #

  • Adds field_parsers option for setting field parsers for JSON serializable.

1.40.0 #

  • Adds include_paths option for filtering endpoints by paths.
  • Adds generate_urls_constants option for generating URL constants for all endpoints.

1.39.1 #

  • Fixes client methods returning ModelNameUnioninstead ofModelNameSealed for oneOf types (#393).

1.39.0 #

  • Handles request body name generation case when request body is declared within request.
  • Fixes incorrect deserialization syntax for undiscriminated unions (Freezed serializer).

1.38.0 #

  • Adds replacement_rules_for_raw_schema option for raw schema objects replacement rules.

1.37.1 #

  • Fixes missing import for MultipartFile(#408).
  • Fixes refs in components.responses.

1.37.0 #

  • Adds use_flutter_compute option 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.
swagger_parser:
  use_flutter_compute: true

1.36.0 #

  • Adds add_openapi_metadata(defaultfalse) to generate OpenAPI tags, operationId, and externalDocsUrlconstants for each endpoint; whenextras_parameter_by_defaultistrue, the metadata is also prefilled into Dio extras—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 enum name values being an int returned in a toString.

1.35.1 #

  • Fixes enum names 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: true to enable it.

1.33.0 #

  • Supports correct processing of nested allOf classes.

1.32.1 #

  • Fixes CHANGELOG duplication.

1.32.0 #

  • Adds complete support for sealed classes (oneOf/anyOf) with the json_serializable serializer.
    • WARNING: Undiscriminated sealed classes use O(n) try-catch deserialization where n is the number of variants.
    • RECOMMENDED: Adds discriminator properties to your OpenAPI specification for O(1) performance.
    • Adds support for sealed classes fallback for failed decoding.
  • Adds complete support for sealed classes (oneOf/anyOf) with the dart_mappable serializer.
    • WARNING: Undiscriminated sealed classes use O(n) try-catch deserialization where n is the number of variants.
    • RECOMMENDED: Adds discriminator properties to your OpenAPI specification for O(1) performance.
    • Adds support for sealed classes fallback for failed decoding.
  • Adds dart_mappable_convenient_whenoption to control union type generation fordart_mappable serializer.
    • dart_mappable_convenient_when: truegenerates legacywhen<T>, maybeWhen<T> methods.
    • dart_mappable_convenient_when: false (default) generates sealed classes for better type safety.
  • Adds the @Deprecated()annotation to thewhen<T>andmaybeWhen<T> methods for dart_mappable; use Dart pattern matching instead.
  • Fixes duplicate unknownenum values fordart_mappable when unknown_enum_value: true is enabled.
  • Fixes nullable discriminator union handling.

1.30.1 #

  • Fixes resolve inline schemas nested within tagged operations.

1.30.0 #

  • Adds support for merging all generated code into single output file using the merge_outputs option.

1.29.0 #

Features #

  • Adds support for non-discriminated unions (oneOf/anyOf without a discriminator).
  • Filters out unused schemas when using include_tagsorexclude_tags.

Fixes #

  • Fixes the client name for untagged paths to properly fall back to the configured fallback_client instead of client.
  • Fixes the fallback_clientconfiguration to default tofallbackinstead ofdefault to avoid conflicts with the Dart default keyword 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_tags is specified.

1.28.0 #

  • Fixes documentation.
  • Fixes ensure consistent file naming 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_generator 10.0.1 or later.

1.26.3 #

  • Fixes collisions between untagged endpoints and endpoints tagged Client that caused generated clients to overwrite each other.

1.26.2 #

1.26.1 #

  • Adds a toStringoverride fordart_mappable.
  • Makes dart_mappable toJson return a string.

1.26.0 #

  • Adds support for Freezed fallbackUnion parameter.

1.25.1 #

  • Fixes broken dart_mappable enum.

1.25.0 #

  • Allows using MultipartFileinstead ofFile in multipart requests, to support usage on web.

1.24.6 #

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 $valuesDefined getter to filter out unknown values automatically.

1.24.3 #

  • Deduplicates property names for allOfschemas that mixrefandproperties, preventing naming overlaps.

1.24.2 #

1.24.1 #

  • Removes duplicate parameters in dataclass(#322).

1.24.0 #

  • Fixes detection of nullable list with non-null items vs nullable list with nullable items(#323).
  • Requires Dart 3.6 or later.

1.23.2 #

  • Fixes error with client parameters with $(#262).

1.23.1 #

  • Updates dart_mappable template.

1.23.0 #

  • Adds support for allOf composition and xOf (#239).
  • Fixes nullable handling (#251).
  • Makes list with null in items nullable.

1.22.1 #

  • Adds supports for freezed 3.

1.22.0 #

  • Adds supports oneOf polymorphic types with dart_mappable (#290).

1.21.4 #

  • Adds x-enumNames(#289).
  • Fixes errors with nullable in enums (#216).
  • Fixes duplicate class generation when using discriminator (#300).

1.21.3 #

1.21.2 #

  • Adds use_x_nullable parameter to config(#295).
  • Fixes error with config(#296).

1.21.1 #

  • Fixes config properties inheritance with multi-scheme URLs(#293).

1.21.0 #

  • Adds support for union types oneOf(#265, #286).
  • Fixes config property inheritance.

1.20.1 #

  • Fixes errors with config parsing.

1.20.0 #

  • Adds validation params to generated freezed classes.
  • Fixes errors with empty schema properties(#280).

1.19.2 #

  • Fixes replacement rules for OpenAPI v2(#266).
  • Adds x-nullable field for null definition in OpenAPI v2(#268).

1.19.1 #

  • Fixes generation with anyOf, oneOfandallOf properties(#260).

1.19.0 #

  • Adds version getter to root client:
final version = RestClient.version;
  • Adds dio_options_parameter_by_default.

1.18.3 #

  • Removes support of BigInt in Dart for int64 types.

1.18.2 #

  • Adds support for int64 types.

1.18.1 #

  • Fixes errors with nullable: false.
  • Fixes same property name conflict(#235).

1.18.0 #

  • Handles empty enum value case (#238).
  • Fixes replacement rules.
  • Adds support for nullable lists and maps.
  • Removes the required_by_default config parameter; behavior now matches required_by_default: false.
  • Requires Dart 3.4.

1.17.3 #

  • Fixes unnecessary null types with required_by_default: false.
  • Fixes generation of class parameters that are set directly from the request specification (#224).
  • Fixes changing case and applying replacement rules to class names (#223).
  • Generates maps with additionalProperties correctly (#214).

1.17.2 #

  • Adds MappableField to dart_mappable template.

1.17.1 #

  • Fixes error with nullable in multipart (#211).

1.17.0 #

1.16.4 #

  • Fixes errors with required_by_default.

1.16.3 #

  • Adds a temporary fix for #110.
  • Ignores parameters start with x- for (#185).
  • Fixes parameter type (#186.
  • Fixes handle $ref (#187) and (#183).

1.16.2 #

  • Adds new exceptions to export.
  • Fixes file name from schemeUrl.

1.16.1 #

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).
  • Refactors config and rename parameters:
    • squash_clientstomerge_clients.
    • enums_prefixtoenums_parent_prefix.
    • skipp_parameterstoskipped_parameters.
  • Removes config parameter put_in_folder.

1.15.5 #

  • Supports schema url without extension (#160).

1.15.4 #

  • Fixes docs.

1.15.3 #

  • Fixes errors with Object body in retrofit client (#110).

1.15.2 #

  • Fixes errors with enum names (#163), (#164).

1.15.1 #

  • Adds support for generation multipart request with ref (#154).

1.15.0 #

  • Adds new config parameter required_by_default.
  • Adds template for E2E tests.

1.14.2 #

  • Fixes errors with multipart (#144).

1.14.1 #

  • Removes check that would avoid generating a map when additional properties has a $ref value.

1.14.0 #

  • Fixes error with empty content type.
  • Fixes retrofit template.
  • Removes special characters from tags.
  • Adds new config parameter skip_parameters.
  • Extracts schemes from url (#150).

1.13.1 #

  • Fixes error with path-level parameters cause crash (#147).
  • Fixes dart:io import in template.

1.13.0 #

  • Adds support for dart_mappable.
  • Changes freezedschema property tojson_serializer, which can be set to freezed, dart_mappableorjson_serializable (default).
  • Fixes enum generation name that are defined inside an array.

1.12.2 #

  • Fixes enum duplicate names (#140).

1.12.1 #

  • Fixes error with ref in a case other than PascalCase (#139).

1.12.0 #

  • Adds new config parameter export_file.

1.11.3 #

  • Fixes error with annotating client methods with the first specified content type header in OpenAPI V2 schemes if the specified one is not the default.

1.11.2 #

  • Adds description of request parameters to the code docs.

1.11.1 #

  • Fixes ref component being wrongly labeled as map.
  • Fixes map components being assigned an import despite not needing one.

1.11.0 #

  • Adds unknown value to all enums to maintain backwards compatibility when adding new values on the backend.
  • Adds new config parameter unknown_enum_value (dart only) (#106).
  • Adds new config parameter default_content_type.
  • Supports String values with spaces for enums (#127).

1.10.6 #

  • Fixes map objects parsing as separate entities (#124).

1.10.5 #

  • Fixes error with parsing dictionary objects (#113).

1.10.4 #

  • Fixes error with additionalProperties (#114).

1.10.3 #

  • Adds new config parameter original_http_response (dart only) (#115).

1.10.2 #

  • Fixes error in body with name in dart template.

1.10.1 #

  • Fixes error with query parameter named body (#108).

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.2 #

  • Fixes error with required in clients (#101).

1.9.1 #

  • Handles invalid names for classes, enums, and methods.
  • Adds a name for unnamed models (#98).
  • Adds support for deprecated annotations for methods.

1.9.0 #

  • Adds display of generation statistics for each scheme and total.
  • Changes the generation command to dart run swagger_parser.
  • Fixes error with required params in unnamed classes (#98).
  • Fixes error with missing File import (#101).

1.8.0 #

  • Adds support for multiple schemas (see the example).
  • Adds support for specifying nullable types via anyOf.
  • Edits 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.
  • Renames root_interfacetoroot_client.
  • Renames squish_clientstoput_clients_in_folder.

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, and oneOf schemas.

1.6.3 #

  • Fixes error with allOfresults in the schema with typeobject (#91).

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.3 #

  • Fixes error with imports in dto component (#86).

1.5.2 #

  • Fixes grouping words for acronyms and abbreviations (#85).

1.5.1 #

  • Fixes method name generation in a language other than English (#83).

1.5.0 #

  • Requires Dart 3.0 or later.

1.4.0 #

  • Makes values nullable and optional by default when processing default values (#76).
  • Adds support for common parameters for various paths (#78).

1.3.5 #

  • Fixes default enum values in dto (#79).

1.3.4 #

  • Applies enum prefixes only to variable types.

1.3.3 #

  • Fixes error with unnamed classes uniques names (#74).

1.3.2 #

  • Fixes error with replacement rules in allOf.

1.3.1 #

  • Fixes error with allOf (#72).

1.3.0 #

  • Adds possibility to add enum prefix from parent component (#29). Change enums_prefix to true to enable this option.

1.2.4 #

  • Fixes names for negative enum values.

1.2.3 #

  • Fixes rename for enums (#69).

1.2.2 #

  • Fixes error with parse nullable item in array (#68).

1.2.1 #

  • Updates retrofit_generator dependency to 7.0.8 and added config option to generate .toJson() methods in enums (retrofit_generatorwill use.toJson() instead of .name in this case).

1.2.0 #

  • Updates retrofit_generator dependency to 7.0.7 and consequently removed unused .toJson() generated methods in enums.

1.1.0 #

  • Adds regex replacement for generated class names.
  • Fixes error with null raw parameter in OpenApi v2 (#63).

1.0.7 #

  • Fixes classes as body parameters (#61).

1.0.6 #

  • Fixes generation default enum values (#58).
  • Adds new keywords to check the name of variables.

1.0.5 #

  • Fixes generation default enum values in client (#56).

1.0.4 #

  • Fixes parsing Body in OpenApi v2 (#53).
  • Adds multiline comments (#54).
  • Fixes items name in enum generation (#55).

1.0.3 #

  • Fixes error with default value in json_serializable generation.

1.0.2 #

  • Fixes error with application/x-www-form-urlencoded (#45).

1.0.1 #

  • Fixes error with nullable in array (#43).

1.0.0+1 #

1.0.0 #

  • Requires Dart >= 2.19.
  • Adds support for description annotation.
  • Adds root_interface option to generate root interface for all Clients.
  • Refactors code related to nullable.

0.10.3 #

  • Uses refto identify a client method's return type whentype is also present.

0.10.2 #

  • defaultValue in dart class now generates in constructor.
  • Fixes error with empty client_postfix.

0.10.1 #

  • Fixes error with servers in requests (#32).
  • Uses operationId for method name(if such a field exists).

0.10.0 #

  • Fixes error with enum values not parsed in object properties.
  • Uses 2xx codes if code 200 not found.
  • nullable types are now supported.

0.9.1 #

  • Uses JsonEnum and JsonValue on generated enum.

0.9.0 #

  • Defines single-reference sibling elements as typedefs instead of generating unnecessary classes.
  • Fixes error with Null type with empty type in schema.

0.8.1 #

  • Adds DateTime to the format for processing types (#16).

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 File type.
  • Adds support for additionalProperties annotations.
  • Fixes templates.
  • Fixes error with YAML files.

0.6.4 #

  • Updates example.
  • Removes implicit_dynamic field for analyzer.

0.6.3 #

  • Fixes error with return type in rest client.

0.6.2 #

  • Updates docs.

0.6.1 #

  • Fixes error with Multipart file type in retrofit.
  • Updates dart api docs.
  • Updates web interface.

0.6.0 #

  • Adds support for yaml files.
  • BREAKING CHANGE: Renames json_pathinpubspec.yamltoschema_path.

0.5.1 #

  • Fixes problem with default value in freezed template.

0.5.0 #

  • Recognizes objects and generates them as DTOs.
  • Fixes some problems with defaultValue.
  • Fixes some problems with return type.
  • Fixes some problems with naming parameters whose names are similar to dart keywords.

0.4.1 #

  • Fixes a problem with parameters whose names are similar to dart keywords.
  • Fixes a problem with postfix in file import.

0.4.0 #

  • Adds support for default annotations.
  • Adds enum support for dart.
  • Fixes errors with Multipart.
  • Fixes errors with Kotlin types.

0.3.1 #

  • Fixes error with @ in url path.
  • Fixes the problem with number type to map double.
  • Fixes the problem with object type to map Dart Object.
  • Updates the README with instructions and steps to generate the code.

0.3.0 #

  • Adds support for required annotations.
  • Fixes error with rest client parameters type in OpenApi v2.

0.2.4 #

  • Fixes error with . and , in url path.

0.2.3 #

  • Fixes error in MultiPart with single $ref.

0.2.2 #

  • Removes swagger_parser section from pubspec.yaml.
  • Updates dependencies in example.

0.2.1 #

  • Fixes README.
  • Fixes workflow files.

0.2.0 #

0.1.0 #

  • Marks the initial release.
121
likes
160
points
34.3k
downloads

Documentation

API reference

Publisher

verified publishercarapacik.dev

Weekly Downloads

Package that generates REST clients and data classes from OpenApi definition file

Repository (GitHub)
View/report issues
Contributing

Topics

#swagger #openapi #codegen #api #rest

License

MIT (license)

Dependencies

args, collection, meta, path, yaml

More

Packages that depend on swagger_parser