swagger_generator_flutter/lib/templates/api/api_class.mustache

40 lines
700 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{{>common/file_header}}
{{>common/imports}}
{{#parts}}
part '{{.}}';
{{/parts}}
{{{extraCode}}}
{{#docLines}}
/// {{.}}
{{/docLines}}
{{#hasRestApi}}
@RestApi(
{{#baseUrl}}baseUrl: '{{.}}',
{{/baseUrl}}parser: Parser.JsonSerializable,
)
{{/hasRestApi}}
abstract class {{className}} {
{{#hasRetrofit}}
/// 创建 API 服务实例
/// [dio] Dio 实例,可以预配置拦截器、超时等
/// [baseUrl] 可选的基础 URL会覆盖注解中的 baseUrl
factory {{className}}(
Dio dio, {
String? baseUrl,
}) = _{{className}};
{{/hasRetrofit}}
{{^hasRetrofit}}
final Dio _dio;
{{className}}(this._dio);
{{/hasRetrofit}}
{{#methods}}
{{>api/api_method}}
{{/methods}}
}