-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1025 from nextcloud/feat/dynamite/config
feat(dynamite): introduce dynamite config to set ignore directives
- Loading branch information
Showing
12 changed files
with
320 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Provides a [Dart Build System](https://github.com/dart-lang/build) builder for generating clients from an [OpenAPI specifications](https://swagger.io/specification/). | ||
|
||
The builder generates code if it find files with an `.openapi.json` or `.openapi.yaml` extension in the lib directory. | ||
|
||
# Build configuration | ||
|
||
You can configure code generation by setting values in the `build.yaml`. | ||
|
||
```yaml | ||
targets: | ||
$default: | ||
builders: | ||
dynamite: | ||
options: | ||
# Options configure how source code is generated. | ||
# | ||
# The following are sensible default values that ignores the schemas for the coverage. | ||
analyzer_ignores: | ||
- camel_case_types | ||
- discarded_futures | ||
- public_member_api_docs | ||
- unreachable_switch_case | ||
coverage_ignores: | ||
- 'const .*\._\(\);' | ||
- 'factory .*\.fromJson\(Map<String, dynamic> json\) => _jsonSerializers\.deserializeWith\(serializer, json\)!;' | ||
- 'Map<String, dynamic> toJson\(\) => _jsonSerializers\.serializeWith\(serializer, this\)! as Map<String, dynamic>;' | ||
- 'static BuiltSet<.*> get values => _\$.*Values;' | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import 'package:build/build.dart'; | ||
import 'package:dynamite/dynamite.dart'; | ||
|
||
Builder openAPIBuilder(final BuilderOptions options) => OpenAPIBuilder(); | ||
Builder openAPIBuilder(final BuilderOptions options) => OpenAPIBuilder(options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'dynamite_config/config.dart'; |
38 changes: 38 additions & 0 deletions
38
packages/dynamite/dynamite/lib/src/models/dynamite_config/config.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:built_collection/built_collection.dart'; | ||
import 'package:built_value/built_value.dart'; | ||
import 'package:built_value/serializer.dart'; | ||
import 'package:built_value/standard_json_plugin.dart'; | ||
|
||
part 'config.g.dart'; | ||
|
||
/// The configuration used by the dynamite builder. | ||
abstract class DynamiteConfig implements Built<DynamiteConfig, DynamiteConfigBuilder> { | ||
factory DynamiteConfig([final void Function(DynamiteConfigBuilder) updates]) = _$DynamiteConfig; | ||
|
||
const DynamiteConfig._(); | ||
|
||
/// Constructs the dynamite config from a json like map. | ||
factory DynamiteConfig.fromJson(final Map<String, dynamic> json) => _serializers.deserializeWith(serializer, json)!; | ||
|
||
/// Serializes this configuration to json. | ||
Map<String, dynamic> toJson() => _serializers.serializeWith(serializer, this)! as Map<String, dynamic>; | ||
|
||
static Serializer<DynamiteConfig> get serializer => _$dynamiteConfigSerializer; | ||
|
||
static const String configPath = 'dynamite.yaml'; | ||
|
||
/// A set of lint rules to ignore for the entire generated file. | ||
@BuiltValueField(wireName: 'analyzer_ignores') | ||
BuiltSet<String>? get analyzerIgnores; | ||
|
||
/// A set of regular expressions used to exclude parts from code coverage. | ||
/// | ||
/// All matches will be wrapped in `// coverage:ignore-start` and `// coverage:ignore-end` blocks. | ||
@BuiltValueField(wireName: 'coverage_ignores') | ||
BuiltSet<String>? get coverageIgnores; | ||
} | ||
|
||
@SerializersFor([ | ||
DynamiteConfig, | ||
]) | ||
final Serializers _serializers = (_$_serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build(); |
170 changes: 170 additions & 0 deletions
170
packages/dynamite/dynamite/lib/src/models/dynamite_config/config.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.