diff --git a/swagger_parser/analysis_options.yaml b/swagger_parser/analysis_options.yaml index 0cc82158..0fcc5d58 100644 --- a/swagger_parser/analysis_options.yaml +++ b/swagger_parser/analysis_options.yaml @@ -1,7 +1,6 @@ include: package:carapacik_lints/core.yaml analyzer: exclude: - - 'test/e2e/tests/**' linter: rules: always_use_package_imports: false diff --git a/swagger_parser/build.yaml b/swagger_parser/build.yaml new file mode 100644 index 00000000..6175af3f --- /dev/null +++ b/swagger_parser/build.yaml @@ -0,0 +1,22 @@ +global_options: + freezed: + runs_before: + - json_serializable + json_serializable: + runs_before: + - retrofit_generator + dart_mappable_builder: + runs_before: + - retrofit_generator + options: + renameMethods: + toJson: toJsonString + toMap: toJson + +targets: + $default: + sources: + include: + - $package$ + - lib/** + - test/** \ No newline at end of file diff --git a/swagger_parser/pubspec.yaml b/swagger_parser/pubspec.yaml index c3bf1560..36e67efb 100644 --- a/swagger_parser/pubspec.yaml +++ b/swagger_parser/pubspec.yaml @@ -19,5 +19,14 @@ dependencies: yaml: ^3.1.2 dev_dependencies: + dart_mappable: + dart_mappable_builder: + json_annotation: + json_serializable: + freezed_annotation: + freezed: + retrofit: + retrofit_generator: + build_runner: carapacik_lints: ^1.8.1 test: ^1.25.2 diff --git a/swagger_parser/test/e2e/e2e_test.dart b/swagger_parser/test/e2e/e2e_test.dart index ea0a7475..bb714bda 100644 --- a/swagger_parser/test/e2e/e2e_test.dart +++ b/swagger_parser/test/e2e/e2e_test.dart @@ -4,150 +4,153 @@ import 'package:test/test.dart'; import 'e2e_util.dart'; void main() { - group('E2E', () { - test('enum_member_names', () async { - await e2eTest( - 'enum_member_names', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - enumsParentPrefix: false, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('enum_types_list', () async { - await e2eTest( - 'enum_types_list', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - enumsParentPrefix: false, - ), - schemaFileName: 'openapi.yaml', - ); - }); - test('multipart_request_properties', () async { - await e2eTest( - 'multipart_request_properties', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.json', - ); - }); - - test('multipart_request_with_ref', () async { - await e2eTest( - 'multipart_request_with_ref', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - // https://github.com/Carapacik/swagger_parser/issues/223 - test('corrector', () async { - await e2eTest( - 'corrector', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - replacementRules: [ - ReplacementRule(pattern: RegExp('V1'), replacement: ''), - ReplacementRule(pattern: RegExp(r'$'), replacement: 'DTO'), - ], - ), - schemaFileName: 'openapi.yaml', - ); - }); - - // https://github.com/Carapacik/swagger_parser/issues/224 - // https://github.com/Carapacik/swagger_parser/issues/214 - test('request_unnamed_types', () async { - await e2eTest( - 'request_unnamed_types', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.json', - ); - }); - - test('nullable_types', () async { - await e2eTest( - 'nullable_types', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - generateValidator: true, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }, skip: true); - - test('nullable_types.2.0', () async { - await e2eTest( - 'nullable_types.2.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - useXNullable: true, - ), - schemaFileName: 'swagger.yaml', - ); - }); - - test('no_required_params', () async { - await e2eTest( - 'no_required_params', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - }); + // group('E2E', () { + // test('enum_member_names', () async { + // await e2eTest( + // 'enum_member_names', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // enumsParentPrefix: false, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('enum_types_list', () async { + // await e2eTest( + // 'enum_types_list', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // enumsParentPrefix: false, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // test('multipart_request_properties', () async { + // await e2eTest( + // 'multipart_request_properties', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.json', + // ); + // }); + // + // test('multipart_request_with_ref', () async { + // await e2eTest( + // 'multipart_request_with_ref', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // // https://github.com/Carapacik/swagger_parser/issues/223 + // test('corrector', () async { + // await e2eTest( + // 'corrector', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // replacementRules: [ + // ReplacementRule(pattern: RegExp('V1'), replacement: ''), + // ReplacementRule(pattern: RegExp(r'$'), replacement: 'DTO'), + // ], + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // // https://github.com/Carapacik/swagger_parser/issues/224 + // // https://github.com/Carapacik/swagger_parser/issues/214 + // test('request_unnamed_types', () async { + // await e2eTest( + // 'request_unnamed_types', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.json', + // ); + // }); + // + // test('nullable_types', () async { + // await e2eTest( + // 'nullable_types', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // generateValidator: true, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }, skip: true); + // + // test('nullable_types.2.0', () async { + // await e2eTest( + // 'nullable_types.2.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // useXNullable: true, + // ), + // schemaFileName: 'swagger.yaml', + // ); + // }); + // + // test('no_required_params', () async { + // await e2eTest( + // 'no_required_params', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // }); group('basic', () { test('additional_properties_class.2.0', () async { await e2eTest( 'basic/additional_properties_class.2.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - useXNullable: true, - ), + (outputDirectory, schemaPath) => + SWPConfig( + outputDirectory: outputDirectory, + schemaPath: schemaPath, + jsonSerializer: JsonSerializer.freezed, + putClientsInFolder: true, + useXNullable: true, + useFreezed3: true, + ), schemaFileName: 'additional_properties_class.2.0.json', ); }); + test('additional_properties_class.3.0', () async { await e2eTest( 'basic/additional_properties_class.3.0', @@ -156,641 +159,644 @@ void main() { schemaPath: schemaPath, jsonSerializer: JsonSerializer.freezed, putClientsInFolder: true, + useFreezed3: true, ), schemaFileName: 'additional_properties_class.3.0.json', ); }); - test('all_of.3.0', () async { - await e2eTest( - 'basic/all_of.3.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'all_of.3.0.json', - ); - }); - - test('basic_requests.2.0', () async { - await e2eTest( - 'basic/basic_requests.2.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - useXNullable: true, - ), - schemaFileName: 'basic_requests.2.0.json', - ); - }); - - test('basic_requests.3.0', () async { - await e2eTest( - 'basic/basic_requests.3.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'basic_requests.3.0.json', - ); - }); - - test('basic_types_class.2.0', () async { - await e2eTest( - 'basic/basic_types_class.2.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - useXNullable: true, - ), - schemaFileName: 'basic_types_class.2.0.json', - ); - }); - - test('basic_types_class.3.0', () async { - await e2eTest( - 'basic/basic_types_class.3.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'basic_types_class.3.0.json', - ); - }); - - test('discriminated_one_of.3.0', () async { - await e2eTest( - 'basic/discriminated_one_of.3.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'discriminated_one_of.3.0.json', - ); - }); - - test('fallback_union', () async { - await e2eTest( - 'basic/fallback_union', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - fallbackUnion: 'unknown', - ), - schemaFileName: 'fallback_union.json', - ); - }); - - test('discriminated_one_of.3.0_mappable', () async { - await e2eTest( - 'basic/discriminated_one_of.3.0_mappable', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.dartMappable, - enumsToJson: true, - putClientsInFolder: true, - ), - schemaFileName: 'discriminated_one_of.3.0.json', - ); - }); - - test('empty_class.2.0', () async { - await e2eTest( - 'basic/empty_class.2.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - useXNullable: true, - ), - schemaFileName: 'empty_class.2.0.json', - ); - }); - - test('empty_class.3.0', () async { - await e2eTest( - 'basic/empty_class.3.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'empty_class.3.0.json', - ); - }); - - test('query_parameters', () async { - await e2eTest( - 'basic/query_parameters', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('enum_class', () async { - await e2eTest( - 'basic/enum_class', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'enum_class.json', - ); - }); - - test('of_like_class.3.1', () async { - await e2eTest( - 'basic/of_like_class.3.1', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'of_like_class.3.1.json', - ); - }); - - test('file_download', () async { - await e2eTest( - 'basic/file_download', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('reference_types_class.2.0', () async { - await e2eTest( - 'basic/reference_types_class.2.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - useXNullable: true, - ), - schemaFileName: 'reference_types_class.2.0.json', - ); - }); - - test('reference_types_class.3.0', () async { - await e2eTest( - 'basic/reference_types_class.3.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'reference_types_class.3.0.json', - ); - }); - - test('replacement_rules.2.0', () async { - await e2eTest( - 'basic/replacement_rules.2.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - putClientsInFolder: true, - useXNullable: true, - replacementRules: [ - ReplacementRule(pattern: RegExp('List'), replacement: 'Lizt'), - ReplacementRule(pattern: RegExp(r'$'), replacement: 'DTO'), - ], - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('replacement_rules.3.1', () async { - await e2eTest( - 'basic/replacement_rules.3.1', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - replacementRules: [ - ReplacementRule(pattern: RegExp('V1'), replacement: ''), - ReplacementRule(pattern: RegExp(r'$'), replacement: 'DTO'), - ], - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('tags', () async { - await e2eTest( - 'basic/tags', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('empty_tags', () async { - await e2eTest( - 'basic/empty_tags', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - fallbackClient: 'test', - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('excluded_tags', () async { - await e2eTest( - 'basic/excluded_tags', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - excludeTags: ['exclude'], - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('included_tags', () async { - await e2eTest( - 'basic/included_tags', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - includeTags: ['include'], - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('included_and_excluded_tags', () async { - await e2eTest( - 'basic/included_and_excluded_tags', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - includeTags: ['include'], - excludeTags: ['exclude'], - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('included_tags_with_schemas', () async { - await e2eTest( - 'basic/included_tags_with_schemas', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - includeTags: ['include'], - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('excluded_tags_with_schemas', () async { - await e2eTest( - 'basic/excluded_tags_with_schemas', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - excludeTags: ['exclude'], - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('circular_deps_with_tags', () async { - await e2eTest( - 'basic/circular_deps_with_tags', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - includeTags: ['include'], - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('include_exclude_tags_with_schemas', () async { - await e2eTest( - 'basic/include_exclude_tags_with_schemas', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - includeTags: ['include'], - excludeTags: ['exclude'], - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('use_freezed3.3.0', () async { - await e2eTest( - 'basic/use_freezed3.3.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - useFreezed3: true, - ), - schemaFileName: 'use_freezed3.3.0.json', - ); - }); - - test('deprecated', () async { - await e2eTest( - 'basic/deprecated', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - useFreezed3: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('wrapping_collections.2.0', () async { - await e2eTest( - 'basic/wrapping_collections.2.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - useXNullable: true, - ), - schemaFileName: 'wrapping_collections.2.0.json', - ); - }); - - test('wrapping_collections.3.0', () async { - await e2eTest( - 'basic/wrapping_collections.3.0', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'wrapping_collections.3.0.json', - ); - }); - - // https://github.com/Carapacik/swagger_parser/issues/353 - test('tag_with_alphanumeric', () async { - await e2eTest( - 'tag_with_alphanumeric', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.json', - ); - }); - - test('tag_edge_cases', () async { - await e2eTest( - 'tag_edge_cases', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - }); - - group('casing', () { - test('camelCase', () async { - await e2eTest( - 'casing/camelCase', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('kebab-case', () async { - await e2eTest( - 'casing/kebab-case', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('PascalCase', () async { - await e2eTest( - 'casing/PascalCase', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('SCREAMING_SNAKE_CASE', () async { - await e2eTest( - 'casing/SCREAMING_SNAKE_CASE', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('SCREAMING-KEBAB-CASE', () async { - await e2eTest( - 'casing/SCREAMING-KEBAB-CASE', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('snake_case', () async { - await e2eTest( - 'casing/snake_case', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('Train-Case', () async { - await e2eTest( - 'casing/Train-Case', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - }); - - group('xof', () { - test('discriminated_any_of_complete_mapping', () async { - await e2eTest( - 'xof/discriminated_any_of_complete_mapping', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('non_discriminated_one_of_deferred', () async { - await e2eTest( - 'xof/non_discriminated_one_of_deferred', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('non_discriminated_any_of_deferred', () async { - await e2eTest( - 'xof/non_discriminated_any_of_deferred', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('union_inline_and_refs_any_of_deferred', () async { - await e2eTest( - 'xof/union_inline_and_refs_any_of_deferred', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('union_inline_and_refs_one_of_deferred', () async { - await e2eTest( - 'xof/union_inline_and_refs_one_of_deferred', - (outputDirectory, schemaPath) => SWPConfig( - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - putClientsInFolder: true, - ), - schemaFileName: 'openapi.yaml', - ); - }); - - test('merged_outputs', () async { - await e2eTest( - 'basic/merged_outputs', - (outputDirectory, schemaPath) => SWPConfig( - name: 'merged_outputs', - outputDirectory: outputDirectory, - schemaPath: schemaPath, - jsonSerializer: JsonSerializer.freezed, - useXNullable: true, - mergeOutputs: true, - ), - schemaFileName: 'merged_outputs.json', - ); - }); }); + // + // test('all_of.3.0', () async { + // await e2eTest( + // 'basic/all_of.3.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'all_of.3.0.json', + // ); + // }); + // + // test('basic_requests.2.0', () async { + // await e2eTest( + // 'basic/basic_requests.2.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // useXNullable: true, + // ), + // schemaFileName: 'basic_requests.2.0.json', + // ); + // }); + // + // test('basic_requests.3.0', () async { + // await e2eTest( + // 'basic/basic_requests.3.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'basic_requests.3.0.json', + // ); + // }); + // + // test('basic_types_class.2.0', () async { + // await e2eTest( + // 'basic/basic_types_class.2.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // useXNullable: true, + // ), + // schemaFileName: 'basic_types_class.2.0.json', + // ); + // }); + // + // test('basic_types_class.3.0', () async { + // await e2eTest( + // 'basic/basic_types_class.3.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'basic_types_class.3.0.json', + // ); + // }); + // + // test('discriminated_one_of.3.0', () async { + // await e2eTest( + // 'basic/discriminated_one_of.3.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'discriminated_one_of.3.0.json', + // ); + // }); + // + // test('fallback_union', () async { + // await e2eTest( + // 'basic/fallback_union', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // fallbackUnion: 'unknown', + // ), + // schemaFileName: 'fallback_union.json', + // ); + // }); + // + // test('discriminated_one_of.3.0_mappable', () async { + // await e2eTest( + // 'basic/discriminated_one_of.3.0_mappable', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.dartMappable, + // enumsToJson: true, + // putClientsInFolder: true, + // ), + // schemaFileName: 'discriminated_one_of.3.0.json', + // ); + // }); + // + // test('empty_class.2.0', () async { + // await e2eTest( + // 'basic/empty_class.2.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // useXNullable: true, + // ), + // schemaFileName: 'empty_class.2.0.json', + // ); + // }); + // + // test('empty_class.3.0', () async { + // await e2eTest( + // 'basic/empty_class.3.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'empty_class.3.0.json', + // ); + // }); + // + // test('query_parameters', () async { + // await e2eTest( + // 'basic/query_parameters', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('enum_class', () async { + // await e2eTest( + // 'basic/enum_class', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'enum_class.json', + // ); + // }); + // + // test('of_like_class.3.1', () async { + // await e2eTest( + // 'basic/of_like_class.3.1', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'of_like_class.3.1.json', + // ); + // }); + // + // test('file_download', () async { + // await e2eTest( + // 'basic/file_download', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('reference_types_class.2.0', () async { + // await e2eTest( + // 'basic/reference_types_class.2.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // useXNullable: true, + // ), + // schemaFileName: 'reference_types_class.2.0.json', + // ); + // }); + // + // test('reference_types_class.3.0', () async { + // await e2eTest( + // 'basic/reference_types_class.3.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'reference_types_class.3.0.json', + // ); + // }); + // + // test('replacement_rules.2.0', () async { + // await e2eTest( + // 'basic/replacement_rules.2.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // putClientsInFolder: true, + // useXNullable: true, + // replacementRules: [ + // ReplacementRule(pattern: RegExp('List'), replacement: 'Lizt'), + // ReplacementRule(pattern: RegExp(r'$'), replacement: 'DTO'), + // ], + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('replacement_rules.3.1', () async { + // await e2eTest( + // 'basic/replacement_rules.3.1', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // replacementRules: [ + // ReplacementRule(pattern: RegExp('V1'), replacement: ''), + // ReplacementRule(pattern: RegExp(r'$'), replacement: 'DTO'), + // ], + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('tags', () async { + // await e2eTest( + // 'basic/tags', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('empty_tags', () async { + // await e2eTest( + // 'basic/empty_tags', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // fallbackClient: 'test', + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('excluded_tags', () async { + // await e2eTest( + // 'basic/excluded_tags', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // excludeTags: ['exclude'], + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('included_tags', () async { + // await e2eTest( + // 'basic/included_tags', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // includeTags: ['include'], + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('included_and_excluded_tags', () async { + // await e2eTest( + // 'basic/included_and_excluded_tags', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // includeTags: ['include'], + // excludeTags: ['exclude'], + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('included_tags_with_schemas', () async { + // await e2eTest( + // 'basic/included_tags_with_schemas', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // includeTags: ['include'], + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('excluded_tags_with_schemas', () async { + // await e2eTest( + // 'basic/excluded_tags_with_schemas', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // excludeTags: ['exclude'], + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('circular_deps_with_tags', () async { + // await e2eTest( + // 'basic/circular_deps_with_tags', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // includeTags: ['include'], + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('include_exclude_tags_with_schemas', () async { + // await e2eTest( + // 'basic/include_exclude_tags_with_schemas', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // // includeTags: ['include'], + // // excludeTags: ['exclude'], + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('use_freezed3.3.0', () async { + // await e2eTest( + // 'basic/use_freezed3.3.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // useFreezed3: true, + // ), + // schemaFileName: 'use_freezed3.3.0.json', + // ); + // }); + // + // test('deprecated', () async { + // await e2eTest( + // 'basic/deprecated', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // useFreezed3: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('wrapping_collections.2.0', () async { + // await e2eTest( + // 'basic/wrapping_collections.2.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // useXNullable: true, + // ), + // schemaFileName: 'wrapping_collections.2.0.json', + // ); + // }); + // + // test('wrapping_collections.3.0', () async { + // await e2eTest( + // 'basic/wrapping_collections.3.0', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'wrapping_collections.3.0.json', + // ); + // }); + // + // // https://github.com/Carapacik/swagger_parser/issues/353 + // test('tag_with_alphanumeric', () async { + // await e2eTest( + // 'tag_with_alphanumeric', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.json', + // ); + // }); + // + // test('tag_edge_cases', () async { + // await e2eTest( + // 'tag_edge_cases', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // }); + // + // group('casing', () { + // test('camelCase', () async { + // await e2eTest( + // 'casing/camelCase', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('kebab-case', () async { + // await e2eTest( + // 'casing/kebab-case', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('PascalCase', () async { + // await e2eTest( + // 'casing/PascalCase', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('SCREAMING_SNAKE_CASE', () async { + // await e2eTest( + // 'casing/SCREAMING_SNAKE_CASE', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('SCREAMING-KEBAB-CASE', () async { + // await e2eTest( + // 'casing/SCREAMING-KEBAB-CASE', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('snake_case', () async { + // await e2eTest( + // 'casing/snake_case', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('Train-Case', () async { + // await e2eTest( + // 'casing/Train-Case', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // }); + // + // group('xof', () { + // test('discriminated_any_of_complete_mapping', () async { + // await e2eTest( + // 'xof/discriminated_any_of_complete_mapping', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('non_discriminated_one_of_deferred', () async { + // await e2eTest( + // 'xof/non_discriminated_one_of_deferred', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('non_discriminated_any_of_deferred', () async { + // await e2eTest( + // 'xof/non_discriminated_any_of_deferred', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('union_inline_and_refs_any_of_deferred', () async { + // await e2eTest( + // 'xof/union_inline_and_refs_any_of_deferred', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('union_inline_and_refs_one_of_deferred', () async { + // await e2eTest( + // 'xof/union_inline_and_refs_one_of_deferred', + // (outputDirectory, schemaPath) => SWPConfig( + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // putClientsInFolder: true, + // ), + // schemaFileName: 'openapi.yaml', + // ); + // }); + // + // test('merged_outputs', () async { + // await e2eTest( + // 'basic/merged_outputs', + // (outputDirectory, schemaPath) => SWPConfig( + // name: 'merged_outputs', + // outputDirectory: outputDirectory, + // schemaPath: schemaPath, + // jsonSerializer: JsonSerializer.freezed, + // useXNullable: true, + // mergeOutputs: true, + // ), + // schemaFileName: 'merged_outputs.json', + // ); + // }); +// }); } diff --git a/swagger_parser/test/e2e/e2e_util.dart b/swagger_parser/test/e2e/e2e_util.dart index a8ed8f9e..fd0eff3c 100644 --- a/swagger_parser/test/e2e/e2e_util.dart +++ b/swagger_parser/test/e2e/e2e_util.dart @@ -47,6 +47,10 @@ Future e2eTest( // Getting a list of all files from expectedFolderPath final expectedFiles = Directory(expectedFolderPath) .listSync(recursive: true, followLinks: false) + .where((e) { + // excluding generated files from third party generators + return !e.path.endsWith('.g.dart') && !e.path.endsWith('.freezed.dart'); + }) .whereType() .toList(); diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/clients/test_client.g.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/clients/test_client.g.dart new file mode 100644 index 00000000..26bee8e5 --- /dev/null +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/clients/test_client.g.dart @@ -0,0 +1,73 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'test_client.dart'; + +// ************************************************************************** +// RetrofitGenerator +// ************************************************************************** + +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations,unused_element_parameter + +class _TestClient implements TestClient { + _TestClient(this._dio, {this.baseUrl, this.errorLogger}); + + final Dio _dio; + + String? baseUrl; + + final ParseErrorLogger? errorLogger; + + @override + Future testMethod() async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + const Map? _data = null; + final _options = _setStreamType( + Options(method: 'GET', headers: _headers, extra: _extra) + .compose( + _dio.options, + '/test', + queryParameters: queryParameters, + data: _data, + ) + .copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)), + ); + final _result = await _dio.fetch>(_options); + late WrapperClass _value; + try { + _value = WrapperClass.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + RequestOptions _setStreamType(RequestOptions requestOptions) { + if (T != dynamic && + !(requestOptions.responseType == ResponseType.bytes || + requestOptions.responseType == ResponseType.stream)) { + if (T == String) { + requestOptions.responseType = ResponseType.plain; + } else { + requestOptions.responseType = ResponseType.json; + } + } + return requestOptions; + } + + String _combineBaseUrls(String dioBaseUrl, String? baseUrl) { + if (baseUrl == null || baseUrl.trim().isEmpty) { + return dioBaseUrl; + } + + final url = Uri.parse(baseUrl); + + if (url.isAbsolute) { + return url.toString(); + } + + return Uri.parse(dioBaseUrl).resolveUri(url).toString(); + } +} diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/value_class.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/value_class.dart index c0f3184b..1d5e098b 100644 --- a/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/value_class.dart +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/value_class.dart @@ -8,7 +8,7 @@ part 'value_class.freezed.dart'; part 'value_class.g.dart'; @Freezed() -class ValueClass with _$ValueClass { +abstract class ValueClass with _$ValueClass { const factory ValueClass({ /// A test property required String testProp, diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/value_class.freezed.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/value_class.freezed.dart new file mode 100644 index 00000000..edfc7b3d --- /dev/null +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/value_class.freezed.dart @@ -0,0 +1,317 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'value_class.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$ValueClass { + /// A test property + String get testProp; + + /// Create a copy of ValueClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @pragma('vm:prefer-inline') + $ValueClassCopyWith get copyWith => + _$ValueClassCopyWithImpl(this as ValueClass, _$identity); + + /// Serializes this ValueClass to a JSON map. + Map toJson(); + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is ValueClass && + (identical(other.testProp, testProp) || + other.testProp == testProp)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, testProp); + + @override + String toString() { + return 'ValueClass(testProp: $testProp)'; + } +} + +/// @nodoc +abstract mixin class $ValueClassCopyWith<$Res> { + factory $ValueClassCopyWith( + ValueClass value, $Res Function(ValueClass) _then) = + _$ValueClassCopyWithImpl; + @useResult + $Res call({String testProp}); +} + +/// @nodoc +class _$ValueClassCopyWithImpl<$Res> implements $ValueClassCopyWith<$Res> { + _$ValueClassCopyWithImpl(this._self, this._then); + + final ValueClass _self; + final $Res Function(ValueClass) _then; + + /// Create a copy of ValueClass + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? testProp = null, + }) { + return _then(_self.copyWith( + testProp: null == testProp + ? _self.testProp + : testProp // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// Adds pattern-matching-related methods to [ValueClass]. +extension ValueClassPatterns on ValueClass { + /// A variant of `map` that fallback to returning `orElse`. + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case final Subclass value: + /// return ...; + /// case _: + /// return orElse(); + /// } + /// ``` + + @optionalTypeArgs + TResult maybeMap( + TResult Function(_ValueClass value)? $default, { + required TResult orElse(), + }) { + final _that = this; + switch (_that) { + case _ValueClass() when $default != null: + return $default(_that); + case _: + return orElse(); + } + } + + /// A `switch`-like method, using callbacks. + /// + /// Callbacks receives the raw object, upcasted. + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case final Subclass value: + /// return ...; + /// case final Subclass2 value: + /// return ...; + /// } + /// ``` + + @optionalTypeArgs + TResult map( + TResult Function(_ValueClass value) $default, + ) { + final _that = this; + switch (_that) { + case _ValueClass(): + return $default(_that); + case _: + throw StateError('Unexpected subclass'); + } + } + + /// A variant of `map` that fallback to returning `null`. + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case final Subclass value: + /// return ...; + /// case _: + /// return null; + /// } + /// ``` + + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_ValueClass value)? $default, + ) { + final _that = this; + switch (_that) { + case _ValueClass() when $default != null: + return $default(_that); + case _: + return null; + } + } + + /// A variant of `when` that fallback to an `orElse` callback. + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case Subclass(:final field): + /// return ...; + /// case _: + /// return orElse(); + /// } + /// ``` + + @optionalTypeArgs + TResult maybeWhen( + TResult Function(String testProp)? $default, { + required TResult orElse(), + }) { + final _that = this; + switch (_that) { + case _ValueClass() when $default != null: + return $default(_that.testProp); + case _: + return orElse(); + } + } + + /// A `switch`-like method, using callbacks. + /// + /// As opposed to `map`, this offers destructuring. + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case Subclass(:final field): + /// return ...; + /// case Subclass2(:final field2): + /// return ...; + /// } + /// ``` + + @optionalTypeArgs + TResult when( + TResult Function(String testProp) $default, + ) { + final _that = this; + switch (_that) { + case _ValueClass(): + return $default(_that.testProp); + case _: + throw StateError('Unexpected subclass'); + } + } + + /// A variant of `when` that fallback to returning `null` + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case Subclass(:final field): + /// return ...; + /// case _: + /// return null; + /// } + /// ``` + + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function(String testProp)? $default, + ) { + final _that = this; + switch (_that) { + case _ValueClass() when $default != null: + return $default(_that.testProp); + case _: + return null; + } + } +} + +/// @nodoc +@JsonSerializable() +class _ValueClass implements ValueClass { + const _ValueClass({required this.testProp}); + factory _ValueClass.fromJson(Map json) => + _$ValueClassFromJson(json); + + /// A test property + @override + final String testProp; + + /// Create a copy of ValueClass + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + @pragma('vm:prefer-inline') + _$ValueClassCopyWith<_ValueClass> get copyWith => + __$ValueClassCopyWithImpl<_ValueClass>(this, _$identity); + + @override + Map toJson() { + return _$ValueClassToJson( + this, + ); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _ValueClass && + (identical(other.testProp, testProp) || + other.testProp == testProp)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, testProp); + + @override + String toString() { + return 'ValueClass(testProp: $testProp)'; + } +} + +/// @nodoc +abstract mixin class _$ValueClassCopyWith<$Res> + implements $ValueClassCopyWith<$Res> { + factory _$ValueClassCopyWith( + _ValueClass value, $Res Function(_ValueClass) _then) = + __$ValueClassCopyWithImpl; + @override + @useResult + $Res call({String testProp}); +} + +/// @nodoc +class __$ValueClassCopyWithImpl<$Res> implements _$ValueClassCopyWith<$Res> { + __$ValueClassCopyWithImpl(this._self, this._then); + + final _ValueClass _self; + final $Res Function(_ValueClass) _then; + + /// Create a copy of ValueClass + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $Res call({ + Object? testProp = null, + }) { + return _then(_ValueClass( + testProp: null == testProp + ? _self.testProp + : testProp // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +// dart format on diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/value_class.g.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/value_class.g.dart new file mode 100644 index 00000000..e729ab33 --- /dev/null +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/value_class.g.dart @@ -0,0 +1,16 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'value_class.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_ValueClass _$ValueClassFromJson(Map json) => _ValueClass( + testProp: json['testProp'] as String, + ); + +Map _$ValueClassToJson(_ValueClass instance) => + { + 'testProp': instance.testProp, + }; diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/wrapper_class.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/wrapper_class.dart index 39e69c06..3e88a5a0 100644 --- a/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/wrapper_class.dart +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/wrapper_class.dart @@ -10,7 +10,7 @@ part 'wrapper_class.freezed.dart'; part 'wrapper_class.g.dart'; @Freezed() -class WrapperClass with _$WrapperClass { +abstract class WrapperClass with _$WrapperClass { const factory WrapperClass({ required Map map, }) = _WrapperClass; diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/wrapper_class.freezed.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/wrapper_class.freezed.dart new file mode 100644 index 00000000..52ced987 --- /dev/null +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/wrapper_class.freezed.dart @@ -0,0 +1,323 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'wrapper_class.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$WrapperClass { + Map get map; + + /// Create a copy of WrapperClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @pragma('vm:prefer-inline') + $WrapperClassCopyWith get copyWith => + _$WrapperClassCopyWithImpl( + this as WrapperClass, _$identity); + + /// Serializes this WrapperClass to a JSON map. + Map toJson(); + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is WrapperClass && + const DeepCollectionEquality().equals(other.map, map)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(map)); + + @override + String toString() { + return 'WrapperClass(map: $map)'; + } +} + +/// @nodoc +abstract mixin class $WrapperClassCopyWith<$Res> { + factory $WrapperClassCopyWith( + WrapperClass value, $Res Function(WrapperClass) _then) = + _$WrapperClassCopyWithImpl; + @useResult + $Res call({Map map}); +} + +/// @nodoc +class _$WrapperClassCopyWithImpl<$Res> implements $WrapperClassCopyWith<$Res> { + _$WrapperClassCopyWithImpl(this._self, this._then); + + final WrapperClass _self; + final $Res Function(WrapperClass) _then; + + /// Create a copy of WrapperClass + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? map = null, + }) { + return _then(_self.copyWith( + map: null == map + ? _self.map + : map // ignore: cast_nullable_to_non_nullable + as Map, + )); + } +} + +/// Adds pattern-matching-related methods to [WrapperClass]. +extension WrapperClassPatterns on WrapperClass { + /// A variant of `map` that fallback to returning `orElse`. + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case final Subclass value: + /// return ...; + /// case _: + /// return orElse(); + /// } + /// ``` + + @optionalTypeArgs + TResult maybeMap( + TResult Function(_WrapperClass value)? $default, { + required TResult orElse(), + }) { + final _that = this; + switch (_that) { + case _WrapperClass() when $default != null: + return $default(_that); + case _: + return orElse(); + } + } + + /// A `switch`-like method, using callbacks. + /// + /// Callbacks receives the raw object, upcasted. + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case final Subclass value: + /// return ...; + /// case final Subclass2 value: + /// return ...; + /// } + /// ``` + + @optionalTypeArgs + TResult map( + TResult Function(_WrapperClass value) $default, + ) { + final _that = this; + switch (_that) { + case _WrapperClass(): + return $default(_that); + case _: + throw StateError('Unexpected subclass'); + } + } + + /// A variant of `map` that fallback to returning `null`. + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case final Subclass value: + /// return ...; + /// case _: + /// return null; + /// } + /// ``` + + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_WrapperClass value)? $default, + ) { + final _that = this; + switch (_that) { + case _WrapperClass() when $default != null: + return $default(_that); + case _: + return null; + } + } + + /// A variant of `when` that fallback to an `orElse` callback. + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case Subclass(:final field): + /// return ...; + /// case _: + /// return orElse(); + /// } + /// ``` + + @optionalTypeArgs + TResult maybeWhen( + TResult Function(Map map)? $default, { + required TResult orElse(), + }) { + final _that = this; + switch (_that) { + case _WrapperClass() when $default != null: + return $default(_that.map); + case _: + return orElse(); + } + } + + /// A `switch`-like method, using callbacks. + /// + /// As opposed to `map`, this offers destructuring. + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case Subclass(:final field): + /// return ...; + /// case Subclass2(:final field2): + /// return ...; + /// } + /// ``` + + @optionalTypeArgs + TResult when( + TResult Function(Map map) $default, + ) { + final _that = this; + switch (_that) { + case _WrapperClass(): + return $default(_that.map); + case _: + throw StateError('Unexpected subclass'); + } + } + + /// A variant of `when` that fallback to returning `null` + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case Subclass(:final field): + /// return ...; + /// case _: + /// return null; + /// } + /// ``` + + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function(Map map)? $default, + ) { + final _that = this; + switch (_that) { + case _WrapperClass() when $default != null: + return $default(_that.map); + case _: + return null; + } + } +} + +/// @nodoc +@JsonSerializable() +class _WrapperClass implements WrapperClass { + const _WrapperClass({required final Map map}) + : _map = map; + factory _WrapperClass.fromJson(Map json) => + _$WrapperClassFromJson(json); + + final Map _map; + @override + Map get map { + if (_map is EqualUnmodifiableMapView) return _map; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_map); + } + + /// Create a copy of WrapperClass + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + @pragma('vm:prefer-inline') + _$WrapperClassCopyWith<_WrapperClass> get copyWith => + __$WrapperClassCopyWithImpl<_WrapperClass>(this, _$identity); + + @override + Map toJson() { + return _$WrapperClassToJson( + this, + ); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _WrapperClass && + const DeepCollectionEquality().equals(other._map, _map)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_map)); + + @override + String toString() { + return 'WrapperClass(map: $map)'; + } +} + +/// @nodoc +abstract mixin class _$WrapperClassCopyWith<$Res> + implements $WrapperClassCopyWith<$Res> { + factory _$WrapperClassCopyWith( + _WrapperClass value, $Res Function(_WrapperClass) _then) = + __$WrapperClassCopyWithImpl; + @override + @useResult + $Res call({Map map}); +} + +/// @nodoc +class __$WrapperClassCopyWithImpl<$Res> + implements _$WrapperClassCopyWith<$Res> { + __$WrapperClassCopyWithImpl(this._self, this._then); + + final _WrapperClass _self; + final $Res Function(_WrapperClass) _then; + + /// Create a copy of WrapperClass + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $Res call({ + Object? map = null, + }) { + return _then(_WrapperClass( + map: null == map + ? _self._map + : map // ignore: cast_nullable_to_non_nullable + as Map, + )); + } +} + +// dart format on diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/wrapper_class.g.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/wrapper_class.g.dart new file mode 100644 index 00000000..7f922a98 --- /dev/null +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.2.0/expected_files/models/wrapper_class.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'wrapper_class.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_WrapperClass _$WrapperClassFromJson(Map json) => + _WrapperClass( + map: (json['map'] as Map).map( + (k, e) => MapEntry(k, ValueClass.fromJson(e as Map)), + ), + ); + +Map _$WrapperClassToJson(_WrapperClass instance) => + { + 'map': instance.map, + }; diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example.dart index 09c9bfc0..d779d4ce 100644 --- a/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example.dart +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example.dart @@ -8,7 +8,7 @@ part 'example.freezed.dart'; part 'example.g.dart'; @Freezed() -class Example with _$Example { +abstract class Example with _$Example { const factory Example({ /// data required Map data, diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example.freezed.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example.freezed.dart new file mode 100644 index 00000000..5f5a3590 --- /dev/null +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example.freezed.dart @@ -0,0 +1,321 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'example.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$Example { + /// data + Map get data; + + /// Create a copy of Example + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @pragma('vm:prefer-inline') + $ExampleCopyWith get copyWith => + _$ExampleCopyWithImpl(this as Example, _$identity); + + /// Serializes this Example to a JSON map. + Map toJson(); + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is Example && + const DeepCollectionEquality().equals(other.data, data)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(data)); + + @override + String toString() { + return 'Example(data: $data)'; + } +} + +/// @nodoc +abstract mixin class $ExampleCopyWith<$Res> { + factory $ExampleCopyWith(Example value, $Res Function(Example) _then) = + _$ExampleCopyWithImpl; + @useResult + $Res call({Map data}); +} + +/// @nodoc +class _$ExampleCopyWithImpl<$Res> implements $ExampleCopyWith<$Res> { + _$ExampleCopyWithImpl(this._self, this._then); + + final Example _self; + final $Res Function(Example) _then; + + /// Create a copy of Example + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + }) { + return _then(_self.copyWith( + data: null == data + ? _self.data + : data // ignore: cast_nullable_to_non_nullable + as Map, + )); + } +} + +/// Adds pattern-matching-related methods to [Example]. +extension ExamplePatterns on Example { + /// A variant of `map` that fallback to returning `orElse`. + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case final Subclass value: + /// return ...; + /// case _: + /// return orElse(); + /// } + /// ``` + + @optionalTypeArgs + TResult maybeMap( + TResult Function(_Example value)? $default, { + required TResult orElse(), + }) { + final _that = this; + switch (_that) { + case _Example() when $default != null: + return $default(_that); + case _: + return orElse(); + } + } + + /// A `switch`-like method, using callbacks. + /// + /// Callbacks receives the raw object, upcasted. + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case final Subclass value: + /// return ...; + /// case final Subclass2 value: + /// return ...; + /// } + /// ``` + + @optionalTypeArgs + TResult map( + TResult Function(_Example value) $default, + ) { + final _that = this; + switch (_that) { + case _Example(): + return $default(_that); + case _: + throw StateError('Unexpected subclass'); + } + } + + /// A variant of `map` that fallback to returning `null`. + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case final Subclass value: + /// return ...; + /// case _: + /// return null; + /// } + /// ``` + + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_Example value)? $default, + ) { + final _that = this; + switch (_that) { + case _Example() when $default != null: + return $default(_that); + case _: + return null; + } + } + + /// A variant of `when` that fallback to an `orElse` callback. + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case Subclass(:final field): + /// return ...; + /// case _: + /// return orElse(); + /// } + /// ``` + + @optionalTypeArgs + TResult maybeWhen( + TResult Function(Map data)? $default, { + required TResult orElse(), + }) { + final _that = this; + switch (_that) { + case _Example() when $default != null: + return $default(_that.data); + case _: + return orElse(); + } + } + + /// A `switch`-like method, using callbacks. + /// + /// As opposed to `map`, this offers destructuring. + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case Subclass(:final field): + /// return ...; + /// case Subclass2(:final field2): + /// return ...; + /// } + /// ``` + + @optionalTypeArgs + TResult when( + TResult Function(Map data) $default, + ) { + final _that = this; + switch (_that) { + case _Example(): + return $default(_that.data); + case _: + throw StateError('Unexpected subclass'); + } + } + + /// A variant of `when` that fallback to returning `null` + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case Subclass(:final field): + /// return ...; + /// case _: + /// return null; + /// } + /// ``` + + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function(Map data)? $default, + ) { + final _that = this; + switch (_that) { + case _Example() when $default != null: + return $default(_that.data); + case _: + return null; + } + } +} + +/// @nodoc +@JsonSerializable() +class _Example implements Example { + const _Example({required final Map data}) : _data = data; + factory _Example.fromJson(Map json) => + _$ExampleFromJson(json); + + /// data + final Map _data; + + /// data + @override + Map get data { + if (_data is EqualUnmodifiableMapView) return _data; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_data); + } + + /// Create a copy of Example + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + @pragma('vm:prefer-inline') + _$ExampleCopyWith<_Example> get copyWith => + __$ExampleCopyWithImpl<_Example>(this, _$identity); + + @override + Map toJson() { + return _$ExampleToJson( + this, + ); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _Example && + const DeepCollectionEquality().equals(other._data, _data)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_data)); + + @override + String toString() { + return 'Example(data: $data)'; + } +} + +/// @nodoc +abstract mixin class _$ExampleCopyWith<$Res> implements $ExampleCopyWith<$Res> { + factory _$ExampleCopyWith(_Example value, $Res Function(_Example) _then) = + __$ExampleCopyWithImpl; + @override + @useResult + $Res call({Map data}); +} + +/// @nodoc +class __$ExampleCopyWithImpl<$Res> implements _$ExampleCopyWith<$Res> { + __$ExampleCopyWithImpl(this._self, this._then); + + final _Example _self; + final $Res Function(_Example) _then; + + /// Create a copy of Example + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $Res call({ + Object? data = null, + }) { + return _then(_Example( + data: null == data + ? _self._data + : data // ignore: cast_nullable_to_non_nullable + as Map, + )); + } +} + +// dart format on diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example.g.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example.g.dart new file mode 100644 index 00000000..907f0999 --- /dev/null +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'example.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_Example _$ExampleFromJson(Map json) => _Example( + data: json['data'] as Map, + ); + +Map _$ExampleToJson(_Example instance) => { + 'data': instance.data, + }; diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example_parsable.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example_parsable.dart index cc482611..8aa4ee9b 100644 --- a/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example_parsable.dart +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example_parsable.dart @@ -10,7 +10,7 @@ part 'example_parsable.freezed.dart'; part 'example_parsable.g.dart'; @Freezed() -class ExampleParsable with _$ExampleParsable { +abstract class ExampleParsable with _$ExampleParsable { const factory ExampleParsable({ /// data required Map data, diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example_parsable.freezed.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example_parsable.freezed.dart new file mode 100644 index 00000000..93b051a5 --- /dev/null +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example_parsable.freezed.dart @@ -0,0 +1,328 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'example_parsable.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$ExampleParsable { + /// data + Map get data; + + /// Create a copy of ExampleParsable + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @pragma('vm:prefer-inline') + $ExampleParsableCopyWith get copyWith => + _$ExampleParsableCopyWithImpl( + this as ExampleParsable, _$identity); + + /// Serializes this ExampleParsable to a JSON map. + Map toJson(); + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is ExampleParsable && + const DeepCollectionEquality().equals(other.data, data)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(data)); + + @override + String toString() { + return 'ExampleParsable(data: $data)'; + } +} + +/// @nodoc +abstract mixin class $ExampleParsableCopyWith<$Res> { + factory $ExampleParsableCopyWith( + ExampleParsable value, $Res Function(ExampleParsable) _then) = + _$ExampleParsableCopyWithImpl; + @useResult + $Res call({Map data}); +} + +/// @nodoc +class _$ExampleParsableCopyWithImpl<$Res> + implements $ExampleParsableCopyWith<$Res> { + _$ExampleParsableCopyWithImpl(this._self, this._then); + + final ExampleParsable _self; + final $Res Function(ExampleParsable) _then; + + /// Create a copy of ExampleParsable + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + }) { + return _then(_self.copyWith( + data: null == data + ? _self.data + : data // ignore: cast_nullable_to_non_nullable + as Map, + )); + } +} + +/// Adds pattern-matching-related methods to [ExampleParsable]. +extension ExampleParsablePatterns on ExampleParsable { + /// A variant of `map` that fallback to returning `orElse`. + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case final Subclass value: + /// return ...; + /// case _: + /// return orElse(); + /// } + /// ``` + + @optionalTypeArgs + TResult maybeMap( + TResult Function(_ExampleParsable value)? $default, { + required TResult orElse(), + }) { + final _that = this; + switch (_that) { + case _ExampleParsable() when $default != null: + return $default(_that); + case _: + return orElse(); + } + } + + /// A `switch`-like method, using callbacks. + /// + /// Callbacks receives the raw object, upcasted. + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case final Subclass value: + /// return ...; + /// case final Subclass2 value: + /// return ...; + /// } + /// ``` + + @optionalTypeArgs + TResult map( + TResult Function(_ExampleParsable value) $default, + ) { + final _that = this; + switch (_that) { + case _ExampleParsable(): + return $default(_that); + case _: + throw StateError('Unexpected subclass'); + } + } + + /// A variant of `map` that fallback to returning `null`. + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case final Subclass value: + /// return ...; + /// case _: + /// return null; + /// } + /// ``` + + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_ExampleParsable value)? $default, + ) { + final _that = this; + switch (_that) { + case _ExampleParsable() when $default != null: + return $default(_that); + case _: + return null; + } + } + + /// A variant of `when` that fallback to an `orElse` callback. + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case Subclass(:final field): + /// return ...; + /// case _: + /// return orElse(); + /// } + /// ``` + + @optionalTypeArgs + TResult maybeWhen( + TResult Function(Map data)? $default, { + required TResult orElse(), + }) { + final _that = this; + switch (_that) { + case _ExampleParsable() when $default != null: + return $default(_that.data); + case _: + return orElse(); + } + } + + /// A `switch`-like method, using callbacks. + /// + /// As opposed to `map`, this offers destructuring. + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case Subclass(:final field): + /// return ...; + /// case Subclass2(:final field2): + /// return ...; + /// } + /// ``` + + @optionalTypeArgs + TResult when( + TResult Function(Map data) $default, + ) { + final _that = this; + switch (_that) { + case _ExampleParsable(): + return $default(_that.data); + case _: + throw StateError('Unexpected subclass'); + } + } + + /// A variant of `when` that fallback to returning `null` + /// + /// It is equivalent to doing: + /// ```dart + /// switch (sealedClass) { + /// case Subclass(:final field): + /// return ...; + /// case _: + /// return null; + /// } + /// ``` + + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function(Map data)? $default, + ) { + final _that = this; + switch (_that) { + case _ExampleParsable() when $default != null: + return $default(_that.data); + case _: + return null; + } + } +} + +/// @nodoc +@JsonSerializable() +class _ExampleParsable implements ExampleParsable { + const _ExampleParsable({required final Map data}) + : _data = data; + factory _ExampleParsable.fromJson(Map json) => + _$ExampleParsableFromJson(json); + + /// data + final Map _data; + + /// data + @override + Map get data { + if (_data is EqualUnmodifiableMapView) return _data; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_data); + } + + /// Create a copy of ExampleParsable + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + @pragma('vm:prefer-inline') + _$ExampleParsableCopyWith<_ExampleParsable> get copyWith => + __$ExampleParsableCopyWithImpl<_ExampleParsable>(this, _$identity); + + @override + Map toJson() { + return _$ExampleParsableToJson( + this, + ); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _ExampleParsable && + const DeepCollectionEquality().equals(other._data, _data)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_data)); + + @override + String toString() { + return 'ExampleParsable(data: $data)'; + } +} + +/// @nodoc +abstract mixin class _$ExampleParsableCopyWith<$Res> + implements $ExampleParsableCopyWith<$Res> { + factory _$ExampleParsableCopyWith( + _ExampleParsable value, $Res Function(_ExampleParsable) _then) = + __$ExampleParsableCopyWithImpl; + @override + @useResult + $Res call({Map data}); +} + +/// @nodoc +class __$ExampleParsableCopyWithImpl<$Res> + implements _$ExampleParsableCopyWith<$Res> { + __$ExampleParsableCopyWithImpl(this._self, this._then); + + final _ExampleParsable _self; + final $Res Function(_ExampleParsable) _then; + + /// Create a copy of ExampleParsable + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $Res call({ + Object? data = null, + }) { + return _then(_ExampleParsable( + data: null == data + ? _self._data + : data // ignore: cast_nullable_to_non_nullable + as Map, + )); + } +} + +// dart format on diff --git a/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example_parsable.g.dart b/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example_parsable.g.dart new file mode 100644 index 00000000..11e626a0 --- /dev/null +++ b/swagger_parser/test/e2e/tests/basic/additional_properties_class.3.0/expected_files/models/example_parsable.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'example_parsable.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_ExampleParsable _$ExampleParsableFromJson(Map json) => + _ExampleParsable( + data: (json['data'] as Map).map( + (k, e) => MapEntry(k, Example.fromJson(e as Map)), + ), + ); + +Map _$ExampleParsableToJson(_ExampleParsable instance) => + { + 'data': instance.data, + }; diff --git a/swagger_parser/test/e2e/tests/basic/replacement_rules.3.1/openapi.yaml b/swagger_parser/test/e2e/tests/basic/replacement_rules.3.1/openapi.yaml index 31e77c9d..ae13db2a 100644 --- a/swagger_parser/test/e2e/tests/basic/replacement_rules.3.1/openapi.yaml +++ b/swagger_parser/test/e2e/tests/basic/replacement_rules.3.1/openapi.yaml @@ -1,118 +1,118 @@ -openapi: 3.1.0 -info: - title: API - version: 1.0.0 -paths: - /api/v1/: - get: - operationId: get_api_v1 - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - p1: - $ref: '#/components/schemes/ClassName1' - p2: - $ref: '#/components/schemes/Class_name_2' - p3: - $ref: '#/components/schemes/className3' - p4: - $ref: '#/components/schemes/_class_name4' - p5: - $ref: '#/components/schemes/-class-name-5' - p6: - $ref: '#/components/schemes/-class-name-56' - v1: - $ref: '#/components/schemes/V1data1[Att]' - v2: - $ref: '#/components/schemes/data{Att}V12' - v3: - $ref: '#/components/schemes/_(Att)V1_data3' - v4: - $ref: '#/components/schemes/dataV14' - p1_class: - type: object - properties: - test: - type: string - format: date-time - required: - - test - p2_enum: - type: string - enum: - - teV1st1 - - V1_test2 - - testV13 - required: - - p1 - - p3 - - p5 - - v1 - - v3 - responses: - '200': - description: dummy - content: - text/plain: - schema: - type: string - post: - operationId: post_api_v1 - requestBody: - content: - application/json: - schema: - type: object - properties: - p1_class: - type: object - properties: - test: - type: string - format: date-time - required: - - test - p2_enum: - type: string - enum: - - teV1st1 - - V1_test2 - - testV13 - required: - - p1_class - responses: - '200': - description: dummy - content: - text/plain: - schema: - type: string - -components: - schemas: - ClassName1: - type: object - Class_name_2: - type: object - className3: - type: object - _class_name4: - type: object - -class-name-5: - type: object - -class-name-56: - type: object - - V1data1[Att]: - type: object - data{Att}V12: - type: object - _(Att)V1_data3: - type: object - dataV14: - type: object - +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: + /api/v1/: + get: + operationId: get_api_v1 + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + p1: + $ref: '#/components/schemes/ClassName1' + p2: + $ref: '#/components/schemes/Class_name_2' + p3: + $ref: '#/components/schemes/className3' + p4: + $ref: '#/components/schemes/_class_name4' + p5: + $ref: '#/components/schemes/-class-name-5' + p6: + $ref: '#/components/schemes/-class-name-56' + v1: + $ref: '#/components/schemes/V1data1[Att]' + v2: + $ref: '#/components/schemes/data{Att}V12' + v3: + $ref: '#/components/schemes/_(Att)V1_data3' + v4: + $ref: '#/components/schemes/dataV14' + p1_class: + type: object + properties: + test: + type: string + format: date-time + required: + - test + p2_enum: + type: string + enum: + - teV1st1 + - V1_test2 + - testV13 + required: + - p1 + - p3 + - p5 + - v1 + - v3 + responses: + '200': + description: dummy + content: + text/plain: + schema: + type: string + post: + operationId: post_api_v1 + requestBody: + content: + application/json: + schema: + type: object + properties: + p1_class: + type: object + properties: + test: + type: string + format: date-time + required: + - test + p2_enum: + type: string + enum: + - teV1st1 + - V1_test2 + - testV13 + required: + - p1_class + responses: + '200': + description: dummy + content: + text/plain: + schema: + type: string + +components: + schemas: + ClassName1: + type: object + Class_name_2: + type: object + className3: + type: object + _class_name4: + type: object + -class-name-5: + type: object + -class-name-56: + type: object + + V1data1[Att]: + type: object + data{Att}V12: + type: object + _(Att)V1_data3: + type: object + dataV14: + type: object + \ No newline at end of file diff --git a/swagger_parser/test/e2e/tests/corrector/openapi.yaml b/swagger_parser/test/e2e/tests/corrector/openapi.yaml index 1f513735..9d25ec82 100644 --- a/swagger_parser/test/e2e/tests/corrector/openapi.yaml +++ b/swagger_parser/test/e2e/tests/corrector/openapi.yaml @@ -1,114 +1,114 @@ -openapi: 3.1.0 -info: - title: API - version: 1.0.0 -paths: - /api/v1/: - get: - operationId: get_api_v1 - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - p1: - $ref: '#/components/schemes/ClassName1' - p2: - $ref: '#/components/schemes/Class_name_2' - p3: - $ref: '#/components/schemes/className3' - p4: - $ref: '#/components/schemes/_class_name4' - p5: - $ref: '#/components/schemes/-class-name-5' - p6: - $ref: '#/components/schemes/-class-name-56' - v1: - $ref: '#/components/schemes/V1data1[Att]' - v2: - $ref: '#/components/schemes/data{Att}V12' - v3: - $ref: '#/components/schemes/_(Att)V1_data3' - v4: - $ref: '#/components/schemes/dataV14' - p1_class: - type: object - properties: - test: - type: string - format: date-time - p2_enum: - type: string - enum: - - teV1st1 - - V1_test2 - - testV13 - required: - - p1 - - p3 - - p5 - - v1 - - v3 - responses: - '200': - description: dummy - content: - text/plain: - schema: - type: string - post: - operationId: post_api_v1 - requestBody: - content: - application/json: - schema: - type: object - properties: - p1_class: - type: object - properties: - test: - type: string - format: date-time - p2_enum: - type: string - enum: - - teV1st1 - - V1_test2 - - testV13 - required: - - p1_class - responses: - '200': - description: dummy - content: - text/plain: - schema: - type: string - -components: - schemas: - ClassName1: - type: object - Class_name_2: - type: object - className3: - type: object - _class_name4: - type: object - -class-name-5: - type: object - -class-name-56: - type: object - - V1data1[Att]: - type: object - data{Att}V12: - type: object - _(Att)V1_data3: - type: object - dataV14: - type: object - +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: + /api/v1/: + get: + operationId: get_api_v1 + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + p1: + $ref: '#/components/schemes/ClassName1' + p2: + $ref: '#/components/schemes/Class_name_2' + p3: + $ref: '#/components/schemes/className3' + p4: + $ref: '#/components/schemes/_class_name4' + p5: + $ref: '#/components/schemes/-class-name-5' + p6: + $ref: '#/components/schemes/-class-name-56' + v1: + $ref: '#/components/schemes/V1data1[Att]' + v2: + $ref: '#/components/schemes/data{Att}V12' + v3: + $ref: '#/components/schemes/_(Att)V1_data3' + v4: + $ref: '#/components/schemes/dataV14' + p1_class: + type: object + properties: + test: + type: string + format: date-time + p2_enum: + type: string + enum: + - teV1st1 + - V1_test2 + - testV13 + required: + - p1 + - p3 + - p5 + - v1 + - v3 + responses: + '200': + description: dummy + content: + text/plain: + schema: + type: string + post: + operationId: post_api_v1 + requestBody: + content: + application/json: + schema: + type: object + properties: + p1_class: + type: object + properties: + test: + type: string + format: date-time + p2_enum: + type: string + enum: + - teV1st1 + - V1_test2 + - testV13 + required: + - p1_class + responses: + '200': + description: dummy + content: + text/plain: + schema: + type: string + +components: + schemas: + ClassName1: + type: object + Class_name_2: + type: object + className3: + type: object + _class_name4: + type: object + -class-name-5: + type: object + -class-name-56: + type: object + + V1data1[Att]: + type: object + data{Att}V12: + type: object + _(Att)V1_data3: + type: object + dataV14: + type: object + \ No newline at end of file diff --git a/swagger_parser/test/e2e/tests/enum_member_names/openapi.yaml b/swagger_parser/test/e2e/tests/enum_member_names/openapi.yaml index 5ff27f6b..3dfe0415 100644 --- a/swagger_parser/test/e2e/tests/enum_member_names/openapi.yaml +++ b/swagger_parser/test/e2e/tests/enum_member_names/openapi.yaml @@ -1,38 +1,38 @@ -openapi: 3.1.0 -info: - title: '' - version: 0.0.0 (v1) -paths: - /api/v1/category/: - get: - operationId: api_v1_category_list - parameters: - - in: query - name: enum_class - required: true - schema: - type: array - items: - type: string - enum: - - -index - - -name - - index - - name - - json - - yaml - - -1 - - 0 - - "1" - - '1itemOne' - - '2ItemTwo' - - '3item_three' - - '4ITEM-FOUR' - - '5иллегалчарактер' - - '6 item six' - description: 'description' - tags: - - api - responses: - '204': +openapi: 3.1.0 +info: + title: '' + version: 0.0.0 (v1) +paths: + /api/v1/category/: + get: + operationId: api_v1_category_list + parameters: + - in: query + name: enum_class + required: true + schema: + type: array + items: + type: string + enum: + - -index + - -name + - index + - name + - json + - yaml + - -1 + - 0 + - "1" + - '1itemOne' + - '2ItemTwo' + - '3item_three' + - '4ITEM-FOUR' + - '5иллегалчарактер' + - '6 item six' + description: 'description' + tags: + - api + responses: + '204': description: '' \ No newline at end of file diff --git a/swagger_parser/test/e2e/tests/enum_types_list/openapi.yaml b/swagger_parser/test/e2e/tests/enum_types_list/openapi.yaml index 8224d34e..3bd93551 100644 --- a/swagger_parser/test/e2e/tests/enum_types_list/openapi.yaml +++ b/swagger_parser/test/e2e/tests/enum_types_list/openapi.yaml @@ -1,95 +1,95 @@ -openapi: 3.1.0 -info: - title: "" - version: 0.0.0 (v1) -paths: - /api/v1/category/: - get: - operationId: api_v1_category_list - parameters: - - in: query - name: enum_class - required: true - schema: - type: array - items: - type: - - string - - null - enum: - - -index - - -name - - index - - name - - json - - yaml - - -1 - - 0 - - "1" - - "1itemOne" - - "2ItemTwo" - - "3item_three" - - "4ITEM-FOUR" - - "5иллегалчарактер" - - "6 item six" - - null - description: "description" - - in: query - name: enum_class_dynamic - required: true - schema: - type: array - items: - type: - - string - - integer - enum: - - -index - - -name - - index - - name - - json - - yaml - - -1 - - 0 - - "1" - - "1itemOne" - - "2ItemTwo" - - "3item_three" - - "4ITEM-FOUR" - - "5иллегалчарактер" - - "6 item six" - description: "description" - - in: query - name: nullable_enum_in_object - required: true - schema: - type: object - properties: - fruits: - type: - - string - - "null" - enum: - - apple - - orange - - null - - name: credentialTypes - in: query - required: false - allowReserved: true - schema: - type: array - default: [ apple ] - minItems: 1 - items: - enum: - - apple - - orange - - description: "description" - tags: - - api - responses: - "204": - description: "" +openapi: 3.1.0 +info: + title: "" + version: 0.0.0 (v1) +paths: + /api/v1/category/: + get: + operationId: api_v1_category_list + parameters: + - in: query + name: enum_class + required: true + schema: + type: array + items: + type: + - string + - null + enum: + - -index + - -name + - index + - name + - json + - yaml + - -1 + - 0 + - "1" + - "1itemOne" + - "2ItemTwo" + - "3item_three" + - "4ITEM-FOUR" + - "5иллегалчарактер" + - "6 item six" + - null + description: "description" + - in: query + name: enum_class_dynamic + required: true + schema: + type: array + items: + type: + - string + - integer + enum: + - -index + - -name + - index + - name + - json + - yaml + - -1 + - 0 + - "1" + - "1itemOne" + - "2ItemTwo" + - "3item_three" + - "4ITEM-FOUR" + - "5иллегалчарактер" + - "6 item six" + description: "description" + - in: query + name: nullable_enum_in_object + required: true + schema: + type: object + properties: + fruits: + type: + - string + - "null" + enum: + - apple + - orange + - null + - name: credentialTypes + in: query + required: false + allowReserved: true + schema: + type: array + default: [ apple ] + minItems: 1 + items: + enum: + - apple + - orange + + description: "description" + tags: + - api + responses: + "204": + description: "" diff --git a/swagger_parser/test/e2e/tests/multipart_request_properties/openapi.json b/swagger_parser/test/e2e/tests/multipart_request_properties/openapi.json index ef16c3dd..ab52e4fb 100644 --- a/swagger_parser/test/e2e/tests/multipart_request_properties/openapi.json +++ b/swagger_parser/test/e2e/tests/multipart_request_properties/openapi.json @@ -1,115 +1,115 @@ -{ - "openapi": "3.0.1", - "paths": { - "/test-multipart-required-true": { - "get": { - "summary": "Test", - "description": "Test", - "operationId": "test-multipart-required-true", - "requestBody": { - "description": "requestBody description", - "required": true, - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "properties": { - "files": { - "type": "array", - "description": "Sample List of Files", - "items": { - "type": "string", - "format": "binary" - } - }, - "address": { - "description": "Sample Address", - "type": "object", - "required": [ - "street" - ], - "properties": { - "street": { - "description": "Sample Street.", - "type": "string" - } - } - }, - "name": { - "type": "string", - "nullable": true - }, - "image": { - "description": "Sample Image", - "type": "string", - "format": "binary", - "nullable": true - } - }, - "required": [ - "files", - "name" - ] - } - } - } - }, - "responses": { - "200": { - "description": "OK" - } - } - } - }, - "/test-multipart-required-false": { - "get": { - "operationId": "test-multipart-required-false", - "requestBody": { - "required": false, - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "properties": { - "files": { - "type": "array", - "items": { - "type": "string", - "format": "binary" - } - }, - "address": { - "type": "object", - "properties": { - "street": { - "type": "string" - } - } - }, - "name": { - "type": "string", - "nullable": true - }, - "image": { - "type": "string", - "format": "binary", - "nullable": true - } - }, - "required": [ - "files", - "name" - ] - } - } - } - }, - "responses": { - "200": { - "description": "OK" - } - } - } - } - } +{ + "openapi": "3.0.1", + "paths": { + "/test-multipart-required-true": { + "get": { + "summary": "Test", + "description": "Test", + "operationId": "test-multipart-required-true", + "requestBody": { + "description": "requestBody description", + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "files": { + "type": "array", + "description": "Sample List of Files", + "items": { + "type": "string", + "format": "binary" + } + }, + "address": { + "description": "Sample Address", + "type": "object", + "required": [ + "street" + ], + "properties": { + "street": { + "description": "Sample Street.", + "type": "string" + } + } + }, + "name": { + "type": "string", + "nullable": true + }, + "image": { + "description": "Sample Image", + "type": "string", + "format": "binary", + "nullable": true + } + }, + "required": [ + "files", + "name" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/test-multipart-required-false": { + "get": { + "operationId": "test-multipart-required-false", + "requestBody": { + "required": false, + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "files": { + "type": "array", + "items": { + "type": "string", + "format": "binary" + } + }, + "address": { + "type": "object", + "properties": { + "street": { + "type": "string" + } + } + }, + "name": { + "type": "string", + "nullable": true + }, + "image": { + "type": "string", + "format": "binary", + "nullable": true + } + }, + "required": [ + "files", + "name" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK" + } + } + } + } + } } \ No newline at end of file diff --git a/swagger_parser/test/e2e/tests/multipart_request_with_ref/openapi.yaml b/swagger_parser/test/e2e/tests/multipart_request_with_ref/openapi.yaml index 8918a01c..6d04e711 100644 --- a/swagger_parser/test/e2e/tests/multipart_request_with_ref/openapi.yaml +++ b/swagger_parser/test/e2e/tests/multipart_request_with_ref/openapi.yaml @@ -1,68 +1,68 @@ -openapi: 3.1.0 -info: - title: API - version: 1.0.0 -paths: - /multipart/request/props: - post: - summary: create item - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - images: - type: array - items: - description: Binary image - format: binary - type: string - address: - type: object - properties: - street: - type: string - - required: - - images - responses: - '200': - description: dummy - content: - text/plain: - schema: - type: string - /multipart/request/ref: - post: - summary: create item - requestBody: - content: - multipart/form-data: - schema: - $ref: '#/components/schemes/Item' - responses: - '200': - description: dummy - content: - text/plain: - schema: - type: string -components: - schemas: - Item: - type: object - properties: - images: - type: array - items: - description: Binary image - format: binary - type: string - address: - type: object - properties: - street: - type: string - required: +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: + /multipart/request/props: + post: + summary: create item + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + images: + type: array + items: + description: Binary image + format: binary + type: string + address: + type: object + properties: + street: + type: string + + required: + - images + responses: + '200': + description: dummy + content: + text/plain: + schema: + type: string + /multipart/request/ref: + post: + summary: create item + requestBody: + content: + multipart/form-data: + schema: + $ref: '#/components/schemes/Item' + responses: + '200': + description: dummy + content: + text/plain: + schema: + type: string +components: + schemas: + Item: + type: object + properties: + images: + type: array + items: + description: Binary image + format: binary + type: string + address: + type: object + properties: + street: + type: string + required: - images \ No newline at end of file diff --git a/swagger_parser/test/e2e/tests/no_required_params/openapi.yaml b/swagger_parser/test/e2e/tests/no_required_params/openapi.yaml index 4ae231cf..4f861436 100644 --- a/swagger_parser/test/e2e/tests/no_required_params/openapi.yaml +++ b/swagger_parser/test/e2e/tests/no_required_params/openapi.yaml @@ -1,42 +1,42 @@ -openapi: 3.1.0 -info: - title: '' - version: 0.0.0 (v1) -paths: - /api/v1/category/: - get: - operationId: api_v1_category_list - parameters: - - in: query - name: option - schema: - $ref: '#/components/schemas/Option' - tags: - - api - responses: - '204': - description: '' -components: - schemas: - Option: - type: object - properties: - required_id: - type: integer - required_name: - type: string - required_nullable_id: - type: integer - nullable: true - required_nullable_name: - type: string - nullable: true - optional_id: - type: integer - optional_name: - type: string - required: - - required_id - - required_name - - required_nullable_id - - required_nullable_name +openapi: 3.1.0 +info: + title: '' + version: 0.0.0 (v1) +paths: + /api/v1/category/: + get: + operationId: api_v1_category_list + parameters: + - in: query + name: option + schema: + $ref: '#/components/schemas/Option' + tags: + - api + responses: + '204': + description: '' +components: + schemas: + Option: + type: object + properties: + required_id: + type: integer + required_name: + type: string + required_nullable_id: + type: integer + nullable: true + required_nullable_name: + type: string + nullable: true + optional_id: + type: integer + optional_name: + type: string + required: + - required_id + - required_name + - required_nullable_id + - required_nullable_name diff --git a/swagger_parser/test/e2e/tests/nullable_types/openapi.yaml b/swagger_parser/test/e2e/tests/nullable_types/openapi.yaml index 34aba33d..105f5b41 100644 --- a/swagger_parser/test/e2e/tests/nullable_types/openapi.yaml +++ b/swagger_parser/test/e2e/tests/nullable_types/openapi.yaml @@ -1,318 +1,318 @@ -openapi: 3.1.0 -info: - title: "" - version: 0.0.0 (v1) -paths: - /api/v1/category/: - get: - operationId: api_v1_category_list - parameters: - - in: query - name: enum_class - required: true - schema: - type: - - array - - null - items: - type: object - required: - - p1 - - p2_null_all - properties: - p1: - nullable: true - type: string - p2_null: - type: - - array - - null - items: - type: string - p2_null_all: - nullable: true - type: array - items: - nullable: true - type: string - nested_collections: - type: array - items: - type: - - array - - null - items: - type: object - additionalProperties: - type: array - items: - type: - - object - - null - additionalProperties: - type: integer - - in: query - name: nullable_string_list - required: true - schema: - type: array - items: - type: - - string - - null - - description: "description" - tags: - - api - responses: - "204": - description: "" - -components: - schemas: - ClassWithNullableTypes: - type: object - required: - - p1 - - p2 - - p2_null_item - - p2_null_all - - p3 - - required_null_anyOf - - p1_anyOf - - p2_anyOf - - p3_anyOf - - p1_oneOf - - p2_oneOf - - p3_oneOf - - p1_allOf - - p2_allOf - - p3_allOf - properties: - valid_int: - type: integer - maximum: 100 - minimum: 0 - valid_string: - type: string - maxLength: 100 - minLength: 0 - pattern: "^[a-zA-Z0-9]*$" - valid_array: - type: array - items: - type: string - maxItems: 100 - minItems: 0 - uniqueItems: true - p1: - type: string - p2: - type: array - items: - type: string - p2_null: - type: - - array - - null - items: - type: string - p2_null_item: - type: array - items: - type: array - items: - type: - - string - - null - p2_null_all: - type: - - array - - null - items: - type: - - string - - null - p3: - type: object - required: - - p1 - - p2 - properties: - p1: - type: string - p2: - type: array - items: - type: string - - p1_n: - nullable: true - type: string - p2_n: - nullable: true - type: array - items: - nullable: true - type: string - p3_n: - nullable: true - type: object - properties: - p1: - nullable: true - type: string - p2: - nullable: true - type: array - items: - nullable: true - type: string - - p1_list: - type: - - string - - null - p2_list: - type: - - array - - null - items: - type: - - string - - null - p3_list: - type: - - object - - null - required: - - p1 - - p2 - properties: - p1: - type: - - string - - null - p2: - type: - - array - - null - items: - type: - - string - - null - - nonNull_anyOf: - anyOf: - - type: string - - type: int - optional_null_anyOf: - anyOf: - - type: string - - type: null - required_null_anyOf: - anyOf: - - type: string - - type: null - - p1_anyOf: - anyOf: - - type: string - - type: null - p2_anyOf: - anyOf: - - type: array - items: - anyOf: - - type: string - - type: null - - type: null - - p3_anyOf: - anyOf: - - type: object - - type: null - required: - - p1 - - p2 - properties: - p1: - anyOf: - - type: string - - type: null - p2: - anyOf: - - type: array - - type: null - items: - anyOf: - - type: string - - type: null - - p1_oneOf: - oneOf: - - type: string - - type: null - p2_oneOf: - oneOf: - - type: array - items: - oneOf: - - type: string - - type: null - - type: null - - p3_oneOf: - oneOf: - - type: object - - type: null - required: - - p1 - - p2 - properties: - p1: - oneOf: - - type: string - - type: null - p2: - oneOf: - - type: array - - type: null - items: - oneOf: - - type: string - - type: null - - p1_allOf: - allOf: - - type: string - - type: null - p2_allOf: - allOf: - - type: array - items: - allOf: - - type: string - - type: null - - type: null - - p3_allOf: - allOf: - - type: object - - type: null - required: - - p1 - - p2 - properties: - p1: - allOf: - - type: string - - type: null - p2: - allOf: - - type: array - - type: null - items: - allOf: - - type: string - - type: null +openapi: 3.1.0 +info: + title: "" + version: 0.0.0 (v1) +paths: + /api/v1/category/: + get: + operationId: api_v1_category_list + parameters: + - in: query + name: enum_class + required: true + schema: + type: + - array + - null + items: + type: object + required: + - p1 + - p2_null_all + properties: + p1: + nullable: true + type: string + p2_null: + type: + - array + - null + items: + type: string + p2_null_all: + nullable: true + type: array + items: + nullable: true + type: string + nested_collections: + type: array + items: + type: + - array + - null + items: + type: object + additionalProperties: + type: array + items: + type: + - object + - null + additionalProperties: + type: integer + - in: query + name: nullable_string_list + required: true + schema: + type: array + items: + type: + - string + - null + + description: "description" + tags: + - api + responses: + "204": + description: "" + +components: + schemas: + ClassWithNullableTypes: + type: object + required: + - p1 + - p2 + - p2_null_item + - p2_null_all + - p3 + - required_null_anyOf + - p1_anyOf + - p2_anyOf + - p3_anyOf + - p1_oneOf + - p2_oneOf + - p3_oneOf + - p1_allOf + - p2_allOf + - p3_allOf + properties: + valid_int: + type: integer + maximum: 100 + minimum: 0 + valid_string: + type: string + maxLength: 100 + minLength: 0 + pattern: "^[a-zA-Z0-9]*$" + valid_array: + type: array + items: + type: string + maxItems: 100 + minItems: 0 + uniqueItems: true + p1: + type: string + p2: + type: array + items: + type: string + p2_null: + type: + - array + - null + items: + type: string + p2_null_item: + type: array + items: + type: array + items: + type: + - string + - null + p2_null_all: + type: + - array + - null + items: + type: + - string + - null + p3: + type: object + required: + - p1 + - p2 + properties: + p1: + type: string + p2: + type: array + items: + type: string + + p1_n: + nullable: true + type: string + p2_n: + nullable: true + type: array + items: + nullable: true + type: string + p3_n: + nullable: true + type: object + properties: + p1: + nullable: true + type: string + p2: + nullable: true + type: array + items: + nullable: true + type: string + + p1_list: + type: + - string + - null + p2_list: + type: + - array + - null + items: + type: + - string + - null + p3_list: + type: + - object + - null + required: + - p1 + - p2 + properties: + p1: + type: + - string + - null + p2: + type: + - array + - null + items: + type: + - string + - null + + nonNull_anyOf: + anyOf: + - type: string + - type: int + optional_null_anyOf: + anyOf: + - type: string + - type: null + required_null_anyOf: + anyOf: + - type: string + - type: null + + p1_anyOf: + anyOf: + - type: string + - type: null + p2_anyOf: + anyOf: + - type: array + items: + anyOf: + - type: string + - type: null + - type: null + + p3_anyOf: + anyOf: + - type: object + - type: null + required: + - p1 + - p2 + properties: + p1: + anyOf: + - type: string + - type: null + p2: + anyOf: + - type: array + - type: null + items: + anyOf: + - type: string + - type: null + + p1_oneOf: + oneOf: + - type: string + - type: null + p2_oneOf: + oneOf: + - type: array + items: + oneOf: + - type: string + - type: null + - type: null + + p3_oneOf: + oneOf: + - type: object + - type: null + required: + - p1 + - p2 + properties: + p1: + oneOf: + - type: string + - type: null + p2: + oneOf: + - type: array + - type: null + items: + oneOf: + - type: string + - type: null + + p1_allOf: + allOf: + - type: string + - type: null + p2_allOf: + allOf: + - type: array + items: + allOf: + - type: string + - type: null + - type: null + + p3_allOf: + allOf: + - type: object + - type: null + required: + - p1 + - p2 + properties: + p1: + allOf: + - type: string + - type: null + p2: + allOf: + - type: array + - type: null + items: + allOf: + - type: string + - type: null diff --git a/swagger_parser/test/e2e/tests/request_unnamed_types/openapi.json b/swagger_parser/test/e2e/tests/request_unnamed_types/openapi.json index 12c45e22..e934ebd5 100644 --- a/swagger_parser/test/e2e/tests/request_unnamed_types/openapi.json +++ b/swagger_parser/test/e2e/tests/request_unnamed_types/openapi.json @@ -1,141 +1,141 @@ -{ - "openapi": "3.0.1", - "paths": { - "/test1": { - "post": { - "operationId": "test", - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "list": { - "type": "array", - "items": { - "type": "object" - } - }, - "name": { - "nullable": true, - "type": "string" - }, - "lastname": { - "type": "string" - } - }, - "required": [ - "list", - "name" - ] - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "object" - } - } - } - } - } - } - } - }, - "/test2": { - "get": { - "operationId": "test", - "requestBody": { - "required": false, - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "list1": { - "type": "array", - "items": { - "type": "object", - "$ref": "#/components/schemas/Example" - } - }, - "list2": { - "type": "array", - "items": { - "type": "object", - "description": "data", - "additionalProperties": { - "$ref": "#/components/schemas/Example" - } - } - }, - "name": { - "nullable": true, - "type": "string" - }, - "lastname": { - "type": "string" - } - }, - "required": [ - "list1", - "name" - ] - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "list": { - "type": "array", - "items": { - "type": "string" - } - }, - "name": { - "nullable": true, - "type": "string" - }, - "lastname": { - "type": "string" - } - }, - "required": [ - "list", - "name" - ] - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "Example": { - "type": "object", - "description": "data", - "additionalProperties": { - "type": "object" - } - } - } - } +{ + "openapi": "3.0.1", + "paths": { + "/test1": { + "post": { + "operationId": "test", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "type": "object" + } + }, + "name": { + "nullable": true, + "type": "string" + }, + "lastname": { + "type": "string" + } + }, + "required": [ + "list", + "name" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + } + } + } + }, + "/test2": { + "get": { + "operationId": "test", + "requestBody": { + "required": false, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "list1": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/components/schemas/Example" + } + }, + "list2": { + "type": "array", + "items": { + "type": "object", + "description": "data", + "additionalProperties": { + "$ref": "#/components/schemas/Example" + } + } + }, + "name": { + "nullable": true, + "type": "string" + }, + "lastname": { + "type": "string" + } + }, + "required": [ + "list1", + "name" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "nullable": true, + "type": "string" + }, + "lastname": { + "type": "string" + } + }, + "required": [ + "list", + "name" + ] + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Example": { + "type": "object", + "description": "data", + "additionalProperties": { + "type": "object" + } + } + } + } } \ No newline at end of file