jaguar_http_cli 0.0.2+1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 70

jaguar_http_cli

An Http Api generator inspired by Retrofit for Dart

Install

pub global activate jaguar_http_cli

Usage

A simple usage example:

pubspec.yaml

jaguar_http:
  - example/example.dart

example.yaml

library example;

part 'example.g.dart';

/// definition
@JaguarHttp(name: "Api")
abstract class ApiDefinition extends JaguarInterceptors {
  @Get("/users/:id")
  Future<JaguarResponse<User>> getUserById(@Param() String id);

  @Post("/users")
  Future<JaguarResponse<User>> postUser(@Body() User user);

  @Put("/users/:uid")
  Future<JaguarResponse<User>> updateUser(@Param(name: "uid") String userId, @Body() User user);

  @Delete("/users/:id")
  Future<JaguarResponse> deleteUser(@Param() String id);
}

run

jaguar_http build

use it

final api = new Api(new IOClient(), "http://localhost:9000", serializers: repo);

Features and bugs

Please file feature requests and bugs at the issue tracker.

Changelog

0.0.2+1

  • Remove unneccesary code

0.0.2

  • Initial version, created by Stagehand

example/example.dart

library jaguar_http.example;

import 'dart:async';
import 'package:http/http.dart';
import 'package:jaguar_http/jaguar_http.dart';
import 'package:jaguar_serializer/jaguar_serializer.dart';
import 'models/user.dart';

part 'example.g.dart';

/// definition
@JaguarHttp(name: "Api")
abstract class ApiDefinition {
  @Get("/users/:id")
  Future<JaguarResponse<User>> getUserById(@Param() String id);

  @Post("/users")
  Future<JaguarResponse<User>> postUser(@Body() User user);

  @Put("/users/:uid")
  Future<JaguarResponse<User>> updateUser(
      @Param("uid") String userId, @Body() User user);

  @Delete("/users/:id")
  Future<JaguarResponse> deleteUser(@Param() String id);

  @Get("/users")
  Future<JaguarResponse<List<User>>> search(
      {@QueryParam("n") String name, @QueryParam("e") String email});
}

JsonRepo repo = new JsonRepo()..add(new UserSerializer());

void main() {
  ApiDefinition api = new Api(
      client: new IOClient(),
      baseUrl: "http://localhost:9000",
      serializers: repo)
    ..requestInterceptors.add((JaguarRequest req) {
      req.headers["Authorization"] = "TOKEN";
      return req;
    });

  api.getUserById("userId").then((JaguarResponse res) {
    print(res);
  }, onError: (e) {
    print(e);
  });
}

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  jaguar_http_cli: "^0.0.2+1"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:jaguar_http_cli/jaguar_http_cli.dart';
        
Version Uploaded Documentation Archive
0.0.2+1 Jan 7, 2018 Go to the documentation of jaguar_http_cli 0.0.2+1 Download jaguar_http_cli 0.0.2+1 archive
0.0.2 Jan 7, 2018 Go to the documentation of jaguar_http_cli 0.0.2 Download jaguar_http_cli 0.0.2 archive

Analysis

We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
40 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
70
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:jaguar_http_cli/jaguar_http_cli.dart.

Suggestions

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Strong-mode analysis of lib/src/generator/generator.dart gave the following hint:

    line: 13 col: 7
    The top level variable '_log' isn't used.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
analyzer ^0.30.0 0.30.0+4 0.31.1
build ^0.11.0 0.11.2 0.12.2
build_runner >=0.6.0 <0.7.0 0.6.0+1 0.8.3
code_builder ^1.0.0 1.0.4 3.0.3
http ^0.11.0 0.11.3+16
jaguar_generator_config >=0.0.1 <0.1.0 0.0.1
jaguar_http >=0.0.2 <0.1.0 0.0.2+1
logging ^0.11.0 0.11.3+1
source_gen >=0.7.0 <0.8.0 0.7.5+1 0.8.1
Transitive dependencies
args 1.4.2
async 2.0.6
barback 0.15.2+15
build_barback 0.4.0+2 0.5.0+3
charcode 1.1.1
cli_util 0.1.2+1
code_transformers 0.5.1+4
collection 1.14.9
convert 2.0.1
crypto 2.0.2+1
csslib 0.14.1
dart_style 1.0.9+1 1.0.10
front_end 0.1.0-alpha.4.1 0.1.0-alpha.11
func 1.0.0
glob 1.1.5
html 0.13.3
http_parser 3.1.1
intl 0.15.6
isolate 1.1.0 2.0.0
kernel 0.3.0-alpha.1.1 0.3.0-alpha.11
matcher 0.12.2
meta 1.1.2
mime 0.9.6
package_config 1.0.3
path 1.5.1
plugin 0.2.0+2
pool 1.3.4
quiver_iterables 1.0.1
shelf 0.7.2
source_maps 0.10.4
source_span 1.4.0
stack_trace 1.9.2
stream_channel 1.6.5
stream_transform 0.0.11
string_scanner 1.0.2
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+7
yaml 2.1.13
yamlicious 0.0.5
Dev dependencies
jaguar_serializer ^0.5.0 0.5.1 1.0.0-dev6
test ^0.12.0