jaguar_http_cli 0.0.2+1

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

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

Alternatively, your editor might support pub 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

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
10 / 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]
55

Platforms

Detected platforms: other

Primary library: package:jaguar_http_cli/jaguar_http_cli.dart with components: io, build, mirrors.

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.

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.0+1
build ^0.11.0 0.11.2 0.12.0+1
build_runner >=0.6.0 <0.7.0 0.6.0+1 0.7.9
code_builder ^1.0.0 1.0.4 3.0.1
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.4+3
Transitive dependencies
args 1.3.0
async 2.0.3
barback 0.15.2+14
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.5
convert 2.0.1
crypto 2.0.2+1
csslib 0.14.1
dart_style 1.0.9+1
front_end 0.1.0-alpha.4.1 0.1.0-alpha.8
func 1.0.0
glob 1.1.5
html 0.13.2+2
http_parser 3.1.1
intl 0.15.2
isolate 1.1.0
kernel 0.3.0-alpha.1.1 0.3.0-alpha.5
matcher 0.12.1+4
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.1
stream_channel 1.6.3
stream_transform 0.0.10
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-dev1
test ^0.12.0