Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 03 2017 20:53
    tejainece opened #101
  • Jun 03 2017 20:52
    tejainece closed #100
  • Jun 03 2017 20:41
    tejainece synchronize #100
  • Jun 03 2017 20:15
    tejainece opened #100
  • Jun 03 2017 19:46

    tejainece on master

    Merge pull request #25 from Jag… Jaguar 0.5.x primary changes Big step towards 0.5.0 and 1 more (compare)

  • Jun 03 2017 19:46
    tejainece closed #99
  • Jun 03 2017 18:18
    tejainece opened #99
  • Mar 09 2017 18:38
    tejainece closed #98
  • Mar 09 2017 18:38
    tejainece commented #98
  • Mar 04 2017 08:39
    tejainece opened #98
  • Mar 03 2017 15:43
    tejainece closed #95
  • Mar 03 2017 15:43
    tejainece commented #95
  • Feb 28 2017 17:00
    lejard-h assigned #97
  • Feb 28 2017 17:00
    lejard-h assigned #96
  • Feb 28 2017 17:00
    lejard-h opened #97
  • Feb 28 2017 17:00
    lejard-h opened #96
  • Feb 28 2017 16:58
    lejard-h closed #90
  • Feb 28 2017 16:58
    lejard-h commented #90
  • Feb 27 2017 21:39

    Kleak on master

    Version bump Merge pull request #24 from Jag… Added glob route matching witho… and 2 more (compare)

  • Feb 27 2017 21:39
    Kleak closed #92
Jaumard
@jaumard
that the most up to date ^^
Rob Halff
@rhalff
oh ok, my fault :)
Jaumard
@jaumard
from what I’ve understand the swagger generator is kind of no more update and abandoned ^^
And I don’t want to keep updated two generators that does the same ^^
openapi generator is generating without compilation errors ;)
Rob Halff
@rhalff
ok thanks, will try that one also, just to see what has changed.
I didn't keep up with swagger vs openapi.
Rob Halff
@rhalff
The open api generator indeed generates correctly and is much improved, sorry for the confusion. A real time saver for flutter projects this is.
Jaumard
@jaumard
no problem ! glad it work :)
Ravi Teja Gudapati
@tejainece
Nice!
Rob Halff
@rhalff
Is there a generator for the validator? https://github.com/Jaguar-dart/jaguar_validate
The description hints there is: A simple, source generated Validator framework
Otherwise I'll try to write one myself.
Rob Halff
@rhalff
Something like this:
// order.validator.dart

const nameValidator = Validate.string
  .isNotNull()
  .isNotEmpty(trim: true)
  .startsWithAlpha()
  .hasLengthLessThan(10);

@GenValidator(
  fields: {
    'productName': nameValidator,
    ,
  }
)
class OrderValidator extends Validator<Order>
    with _$OrderValidator {}

// order.validator.jval.dart
abstract class _$OrderValidator implements Validator<Order> {
  final _validators = {
    'productName': nameValidator,
  };

  Validator<ProductAttribute> __productAttributeValidator;
  Validator<ProductAttribute> get _productAttributeValidator =>
      __productAttributeValidator ??= ProductAttributeValidator();
  @override
  List<dynamic> validate(Order model) {
    if (model == null) return null;
    ObjectErrors errors = new ObjectErrors();
    errors.add(validateField(
        'attributes',
        codeIterable(
            model.attributes,
            (val) =>
                _productAttributeValidator.validate(val as ProductAttribute))));
    errors.add(validateField<String>('productName', model.productName));
    errors.add(validateField<int>('quantity', model.quantity));
    errors.add(validateField<double>('unitCost', model.unitCost));
    errors.add(validateField<double>('subtotal', model.subtotal));
    return errors;
  }

  @override
  List<dynamic> validateField<T>(String fieldName, T value) {
    const validator = validators[fieldName];

    if (validator != null) {
      return validator.validate(value);
    }
  }
}

// Usage:
final orderValidator = OrderValidator();

orderValidator.validate(Order order);

orderValidator.validateField('productName', value);
Perhaps it's not worth a generator though, not sure :-)
Ravi Teja Gudapati
@tejainece
Yes
I think it is easier to the validations right away
The package is slightly outdated.
Contributions are welcome!
Rob Halff
@rhalff
@tejainece yeah I've noticed, the pubspec of validate still contains sdk: ">=1.8.0 <2.0.0" which is hopefully not necessary. And the test dependency is outdated.
Ravi Teja Gudapati
@tejainece
Yes
It is probably very easy to update it to Dart 2.x
lewcianci
@lewcianci
Hi everyone :) trying to use this package on my flutter app because it looks great but am having some issues getting started...
The getting started guide says to do this after setting up the beans so the codegen can run: pub run build_runner build
i've found that i have to prefix that command with 'flutter' (so flutter pub run build_runner build) to get it to work...
but no code is generated...

this is the log of the command running
C:\code\MapManFlutter>flutter pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 467ms

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 119ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 996ms

[INFO] Running build...
[INFO] Running build completed, took 17ms

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 63ms

[INFO] Succeeded after 93ms with 0 outputs (0 actions)

lewcianci
@lewcianci
i worked it out
i was missing the 'part' statement up the top of my model that has the bean information in it
escamoteur
@escamoteur
Hi, I ran into trouble with jaguar_serializer
for two classses it throws exeptions although serializers do exists for the types
[SEVERE] JaguarCliException: Cannot handle TrackState in SampleJsonSerializer!
[SEVERE] #0      AnnotationParser._expandTypeInfo (package:jaguar_serializer_cli/src/instantiater/instantiater.dart:441:5)
#1      AnnotationParser.parse (package:jaguar_serializer_cli/src/instantiater/instantiater.dart:94:20)
#2      JaguarSerializerGenerator.generateForAnnotatedElement (package:jaguar_serializer_cli/src/generator.dart:34:65)
#3      GeneratorForAnnotation.generate (package:source_gen/src/generator_for_annotation.dart:47:30)
<asynchronous suspension>
#4      _generate (package:source_gen/src/builder.dart:280:35)
<asynchronous suspension>
#5      _Builder._generateForLibrary (package:source_gen/src/builder.dart:73:15)
<asynchronous suspension>
#6      _Builder.build (package:source_gen/src/builder.dart:67:11)
<asynchronous suspension>
#7      runBuilder.buildForInput (package:build/src/generate/run_builder.dart:45:21)
escamoteur
@escamoteur
ah ok it seems that the serializer can only handle direct imports of used types. importing a file that exports all types does not wotk
Ravi Teja Gudapati
@tejainece

ah ok it seems that the serializer can only handle direct imports of used types. importing a file that exports all types does not wotk

This should work. Can you please provide a simple reproducable repo. So I can fix this.

Jaumard
@jaumard

Is there an example somewhere on how to do a custom serializer ? Basically I want to manage a string enum like this:

class TxType {
  /// The underlying value of this enum member.
  final String value;

  const TxType._internal(this.value);

  static const TxType inject_ = const TxType._internal("inject");
  static const TxType transfer_ = const TxType._internal("transfer");
  static const TxType burn_ = const TxType._internal("burn");
  static const TxType delete_ = const TxType._internal("delete");
}

But I need to serialize/deserialize it correctly as from the backend it will be a simple String. Any ideas ?

Rob Halff
@rhalff
@jaumard here is an example:
class _StripBearerProcessor implements FieldProcessor<String, String> {
  const _StripBearerProcessor();
  @override
  String serialize(String value) => 'Bearer $value';

  @override
  String deserialize(String value) {
    return value.substring(7);
  }
}

@GenSerializer(
  fields: {
    'accessToken': Field(
      processor: _StripBearerProcessor(),
    ),
  },
)
class CustomerResponseSerializer extends Serializer<CustomerResponse>
    with _$CustomerResponseSerializer {}
Rob Halff
@rhalff
Examples seem to specify it as const EnDecode(processor: _StripBearerProcessor) instead of Field(processor: ...) though, not sure which one is more correct: https://github.com/Jaguar-dart/jaguar_serializer/wiki/Basics
Jaumard
@jaumard
Thanks @rhalff ! I’ve updated the openapi generator with that to handle enums OpenAPITools/openapi-generator#3654 :)
Jaumard
@jaumard
Anyone is able to do multipart request with jaguar_retrofit or resty ? Look like it’s broken Jaguar-dart/client#62
Jaumard
@jaumard
So to fix that I had to update my dependencies, but now I have a problem with jaguar_serializer_cli lol it tells me JaguarCliException: Cannot handle Uint8List in UserUpdateSerializer! I’ve bumped from 2.2.5 to 2.2.8 and there is nothing in the changelog.
Rob Halff
@rhalff
@jaumard I'm only looking at the code but probably it is because Uint8List is not detected as a built-in type?
But that wouldn't explain why it suddenly breaks, perhaps Uint8List was recently introduced somewhere within your own code?
Jaumard
@jaumard
No my code didn’t change between the two version it was always Uint8List, maybe something change in analyzer arround this and like you say it’s not a built in type… Only a guess ^^
Rob Halff
@rhalff
ah yes it's from the typed_data package.
Jaumard
@jaumard
I don’t think it’s buildIn method the problem, I suppose it’s isList that doesn’t recognize Uint8List as a List<int>
Rob Halff
@rhalff
what should it be serialized as though? In build_value there is a suggestion for base64 encoded in case of serializing to json: google/built_value.dart#194
you could solve that with a processor perhaps?
Jaumard
@jaumard
Uint8List is just a List<int> from what I understood :)