Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ void main() {
typeMappings: {'Pet': 'ExamplePet'},
generatorName: Generator.dio,
runSourceGenOnOutput: true,
skipIfSpecIsUnchanged: false,
outputDirectory: 'api/petstore_api',
)
class MyApp extends StatelessWidget {
Expand Down
20 changes: 10 additions & 10 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -319,26 +319,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
sha256: "8dcda04c3fc16c14f48a7bb586d4be1f0d1572731b6d81d51772ef47c02081e0"
url: "https://pub.dev"
source: hosted
version: "10.0.9"
version: "11.0.1"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
url: "https://pub.dev"
source: hosted
version: "3.0.9"
version: "3.0.10"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "3.0.2"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -560,10 +560,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
url: "https://pub.dev"
source: hosted
version: "0.7.4"
version: "0.7.6"
timing:
dependency: transitive
description:
Expand All @@ -584,10 +584,10 @@ packages:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev"
source: hosted
version: "2.1.4"
version: "2.2.0"
vm_service:
dependency: transitive
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import 'dart:io';
import 'package:crypto/crypto.dart';
import 'package:meta/meta.dart';

const skipSpecDepMessage =
'This will be removed in next major release. This generator will always run'
'if changes are detected on local spec file. see https://github.com/gibahjoe/openapi-generator-dart#deprecation--breaking-change-notice - Use `forceAlwaysRun` '
'to always run the generator regardless of spec changes.';

class Openapi {
/// Additional properties to pass to the compiler (CSV)
Expand Down Expand Up @@ -149,22 +145,10 @@ class Openapi {
/// Note: Setting this to `true` can lead to merge conflicts in team environments,
/// as each developer may end up modifying the annotated file.
///
/// This setting is different from [skipIfSpecIsUnchanged], which only regenerates
/// the client SDK if it detects changes in the OpenAPI specification.
///
/// Defaults to [false].
final bool forceAlwaysRun;

/// Skips execution if the OpenAPI specification file is different from a cached copy.
///
/// For remote specifications, the file will be downloaded and cached locally.
/// The cache is then compared to the remote file to detect any changes.
///
/// If set to false, a cached copy of the OpenAPI specification file is not kept.
///
/// Defaults to [false].
@Deprecated(skipSpecDepMessage)
final bool skipIfSpecIsUnchanged;

const Openapi({
this.additionalProperties,
Expand All @@ -188,7 +172,6 @@ class Openapi {
this.projectPubspecPath,
this.debugLogging = false,
this.forceAlwaysRun = false,
@Deprecated(skipSpecDepMessage) this.skipIfSpecIsUnchanged = true,
});

@override
Expand Down Expand Up @@ -250,7 +233,6 @@ class Openapi {
}
buffer.writeln(' debugLogging: $debugLogging,');
buffer.writeln(' forceAlwaysRun: $forceAlwaysRun,');
buffer.writeln(' skipIfSpecIsUnchanged: $skipIfSpecIsUnchanged,');
buffer.write(')');
return buffer.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ void main() {
expect(props.debugLogging, isFalse);
expect(props.nameMappings, isNull);
expect(props.enumNameMappings, isNull);
expect(props.skipIfSpecIsUnchanged, isTrue);
});
group('NextGen', () {
test('Sets cachePath', () {
Expand Down Expand Up @@ -391,14 +390,6 @@ void main() {
expect(openapi.toString(), contains('forceAlwaysRun: true'));
});

test('should include skipIfSpecIsUnchanged when set', () {
final openapi = Openapi(
skipIfSpecIsUnchanged: true,
inputSpec: InputSpec(path: 'example_path'),
generatorName: Generator.dart,
);
expect(openapi.toString(), contains('skipIfSpecIsUnchanged: true'));
});
});

group('InputSpec.toString', () {
Expand Down
7 changes: 1 addition & 6 deletions openapi-generator/lib/src/models/generator_arguments.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ class GeneratorArguments {
/// The default location is: .dart_tool/openapi-generator-cache.json
final String cachePath;

/// Informs the generator to disable the cache.
@Deprecated(skipSpecDepMessage)
final bool skipIfSpecIsUnchanged;

final bool isDebug;

Expand Down Expand Up @@ -137,9 +134,7 @@ class GeneratorArguments {
'${Directory.current.path}${Platform.pathSeparator}pubspec.yaml'),
isDebug = annotations.readPropertyOrDefault('debugLogging', false),
inputSpec =
annotations.readPropertyOrDefault('inputSpec', InputSpec.json()),
skipIfSpecIsUnchanged =
annotations.readPropertyOrDefault('skipIfSpecIsUnchanged', false);
annotations.readPropertyOrDefault('inputSpec', InputSpec.json());

/// The stringified name of the [Generator].
String get generatorName => generator == Generator.dart
Expand Down
52 changes: 2 additions & 50 deletions openapi-generator/lib/src/openapi_generator_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,7 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
}
}

if (!builderCanReadSpec) {
if (args.skipIfSpecIsUnchanged && !await hasDiff(args: args)) {
logOutputMessage(
log: log,
communication: OutputMessage(
message: 'No diff between versions, not running generator.',
),
);
return '';
}
}
// Skip spec check removed - deprecated functionality

await runOpenApiJar(arguments: args);
await fetchDependencies(baseCommand: baseCommand, args: args);
Expand All @@ -242,45 +232,7 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
),
),
);
if (!builderCanReadSpec) {
if (!args.skipIfSpecIsUnchanged) {
logOutputMessage(
log: log,
communication: OutputMessage(
message:
'Skip spec cache because [skipIfSpecIsUnchanged] is set to false',
),
);
return '';
} else {
if (!args.hasLocalCache) {
logOutputMessage(
log: log,
communication: OutputMessage(
message: 'No local cache found. Creating one.',
level: Level.CONFIG,
),
);
} else {
logOutputMessage(
log: log,
communication: OutputMessage(
message: 'Local cache found. Overwriting existing one.',
level: Level.CONFIG,
),
);
}
await cacheSpec(
outputLocation: args.cachePath,
spec: await loadSpec(specConfig: args.inputSpec));
logOutputMessage(
log: log,
communication: OutputMessage(
message: 'Successfully cached spec changes.',
),
);
}
}
// Cache handling removed - deprecated functionality
} catch (e, st) {
logOutputMessage(
log: log,
Expand Down
2 changes: 0 additions & 2 deletions openapi-generator/test/github_issues_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ void main() {
typeMappings: {'Pet': 'ExamplePet'},
generatorName: Generator.dio,
runSourceGenOnOutput: true,
skipIfSpecIsUnchanged: false,
cleanSubOutputDirectory: [
'./test/specs/issue/$issueNumber/output'
],
Expand Down Expand Up @@ -377,7 +376,6 @@ void main() {
generatorName: Generator.dio,
runSourceGenOnOutput: true,
typeMappings: {'Pet': 'ExamplePet', 'Test': 'ExampleTest'},
skipIfSpecIsUnchanged: false,
cleanSubOutputDirectory: [
'./test/specs/issue/$issueNumber/output'
],
Expand Down