http_api_generator 1.0.0 copy "http_api_generator: ^1.0.0" to clipboard
http_api_generator: ^1.0.0 copied to clipboard

A package that help you to generate Http Restful Api by annotation.

Features #

Generate Http api info by annotation

Getting started #

Add dependency to your pubspec:

http_api_generator: latest_version

Usage #

part 'login.api.g.dart';

@RestApi()
abstract class LoginApi {
  factory LoginApi() => _LoginApi();
  
  @POST("app/login")
  HttpApi<UserEntity> login(@Body() LoginRequest request);

  @GET("app/{userId}")
  HttpApi<UserEntity?> getUser(@Path() String userId);

Then run the build_runner by 'flutter packages pub run build_runner build'.

You can get the following information from the generated HttpApi: /// @Method String method;

/// Url of @Method and @Path String url;

/// baseUrl in @HttpApi String? baseUrl;

/// @Body Object? body;

/// @Query Map<String, dynamic>? queryParams;

/// @Field Map<String, dynamic>? fields;

/// @FormUrlEncoded bool formUrlEncoded;

/// Type of response, as T Type responseType;

/// From Json FromJsonTransform

1
likes
0
pub points
48%
popularity

Publisher

unverified uploader

A package that help you to generate Http Restful Api by annotation.

License

unknown (license)

Dependencies

analyzer, build, built_collection, code_builder, dart_style, meta, source_gen

More

Packages that depend on http_api_generator