agilord / owl Goto Github PK
View Code? Open in Web Editor NEWDart source code generator for JSON serialization, HTTP APIs and SQL CRUD.
Dart source code generator for JSON serialization, HTTP APIs and SQL CRUD.
is there any documentation or sample project using this package?
I'm willing to contribute to bringing this feature around, just let me know if I have the green light.
See, I'm using owl
to build an OpenAPI specification library, but the specification declares several fields that can best be expressed as Dart Maps. Example:
Map<String, SecurityScheme> securityDefinitions;
I've wound up using @Transient()
or @JsonField(native: true)
and writing manual code in a fromMap
factory constructor or the toJson
method. This is very tedious, and can indeed be automated. Something like:
// parse(map)
object.securityDefinitions = map['securityDefinitions']?.keys?.fold(
{},
(out, k) =>
out..[k.toString()] = SecuritySchemeMapper.parse(map['securityDefinitions'][k]));
// map(object)
return (new _owl_json.MapBuilder(ordered: false)
..put('securityDefinitions', securityDefinitions.keys.fold(
{},
(out, k) =>
out..[k] = SecuritySchemeMapper.map(securityDefinitions[k]))))
.toMap();
For conveniency's sake, it might be a good idea to switch to using package:code_builder
. This would also make it possible to generate something for this field:
Map<String, Map<String, Operation>> paths;
If you feel like this would be a good addition to owl
, please let me know, and I will get right to it.
I'm using this library indirectly with spotify-dart in a Flutter app that is AOT compiled with Dart v2.0.0-dev.67.0, but compilation fails because of Dart 2's strict types due to the dynamic
type parameter generated in json_generator.dart:81
.
i.e. (map['${field.keyName}'] as List<dynamic>)?.map(${field.parserFn})?.toList()
Flutter compiler error:
compiler message: file:///Users/chancesnow/bin/flutter/.pub-cache/git/spotify-dart-55bff18594c7337681570999f994bdf8cf42b0ba/lib/spotify_io.json.g.dart:129:59: Error: The argument type '(dart.core::Map<dart.core::String, dynamic>) → spotify::Image' can't be assigned to the parameter type '(dynamic) → dynamic'.
compiler message: Try changing the type of the parameter, or casting the argument to '(dynamic) → dynamic'.
compiler message: (map['images'] as List<dynamic>)?.map(ImageMapper.parse)?.toList();
I've tried changing List<dynamic>
to List<Map<String, dynamic>>
in my fork of Owl to no avail:
Unable to spawn isolate: file:///Users/chancesnow/.pub-cache/hosted/pub.dartlang.org/async-1.13.3/lib/src/typed/stream.dart:56:10: Error: The return type of the method 'TypeSafeStream::firstWhere' is dart.async::Future<dynamic>, which does not match the return type of the overridden method (dart.async::Future<#lib1::TypeSafeStream::T>).
Change to a subtype of dart.async::Future<#lib1::TypeSafeStream::T>.
Future firstWhere(bool test(T element), {Object defaultValue()}) =>
^
file:///Users/chancesnow/.pub-cache/hosted/pub.dartlang.org/async-1.13.3/lib/src/typed/stream.dart:56:10: Error: The method 'TypeSafeStream::firstWhere' doesn't have the named parameter 'orElse' of overriden method 'Stream::firstWhere'.
Future firstWhere(bool test(T element), {Object defaultValue()}) =>
^
file:///Users/chancesnow/.pub-cache/hosted/pub.dartlang.org/async-1.13.3/lib/src/typed/stream.dart:59:10: Error: The return type of the method 'TypeSafeStream::lastWhere' is dart.async::Future<dynamic>, which does not match the return type of the overridden method (dart.async::Future<#lib1::TypeSafeStream::T>).
Change to a subtype of dart.async::Future<#lib1::TypeSafeStream::T>.
Future lastWhere(bool test(T element), {Object defaultValue()}) =>
^
file:///Users/chancesnow/.pub-cache/hosted/pub.dartlang.org/async-1.13.3/lib/src/typed/stream.dart:59:10: Error: The method 'TypeSafeStream::lastWhere' doesn't have the named parameter 'orElse' of overriden method 'Stream::lastWhere'.
Future lastWhere(bool test(T element), {Object defaultValue()}) =>
^
file:///Users/chancesnow/.pub-cache/hosted/pub.dartlang.org/async-1.13.3/lib/src/typed/stream.dart:62:13: Error: The method 'TypeSafeStream::singleWhere' has fewer named arguments than those of overridden method 'Stream::singleWhere'.
Future<T> singleWhere(bool test(T element)) async =>
^
file:///Users/chancesnow/.pub-cache/hosted/pub.dartlang.org/build_runner-0.7.13+1/lib/src/performance_tracking/performance_tracking_resolvers.dart:11:7: Error: The non-abstract class 'PerformanceTrackingResolvers' is missing implementations for these members:
'reset'.
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class PerformanceTrackingResolvers implements Resolvers {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
file:///Users/chancesnow/.pub-cache/hosted/pub.dartlang.org/async-1.13.3/lib/src/restartable_timer.dart:11:7: Error: The non-abstract class 'RestartableTimer' is missing implementations for these members:
'tick'.
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class RestartableTimer implements Timer {
^^^^^^^^^^^^^^^^
file:///Users/chancesnow/.pub-cache/hosted/pub.dartlang.org/async-1.13.3/lib/src/result/capture_transformer.dart:15:7: Error: The non-abstract class 'CaptureStreamTransformer' is missing implementations for these members:
'cast'.
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class CaptureStreamTransformer<T> implements StreamTransformer<T, Result<T>> {
^^^^^^^^^^^^^^^^^^^^^^^^
file:///Users/chancesnow/.pub-cache/hosted/pub.dartlang.org/async-1.13.3/lib/src/result/release_transformer.dart:12:7: Error: The non-abstract class 'ReleaseStreamTransformer' is missing implementations for these members:
'cast'.
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class ReleaseStreamTransformer<T> implements StreamTransformer<Result<T>, T> {
^^^^^^^^^^^^^^^^^^^^^^^^
file:///Users/chancesnow/.pub-cache/hosted/pub.dartlang.org/async-1.13.3/lib/src/single_subscription_transformer.dart:16:7: Error: The non-abstract class 'SingleSubscriptionTransformer' is missing implementations for these members:
'cast'.
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
I've tried upgrading analyzer
, build_runner
, and source_gen
to their latest versions for the owl_codegen
package to no avail. (Same errors as above.)
I'm not sure what else to try. Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.