All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dart-jaguar.api.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
import 'package:jaguar_retrofit/annotations/annotations.dart';
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
import 'package:jaguar_serializer/jaguar_serializer.dart';
import 'package:jaguar_mimetype/jaguar_mimetype.dart';
import 'dart:async';

{{#operations}}
{{#modelImports}}import 'package:{{pubName}}/model/{{.}}{{#protoFormat}}.pb{{/protoFormat}}.dart';
{{/modelImports}}
{{#fullImports}}import '{{.}}';
{{/fullImports}}

part '{{classFilename}}.jretro.dart';

@GenApiClient()
class {{classname}} extends ApiClient with _${{classname}}Client {
    final Route base;
    final Map converters;
    final Duration timeout;

    {{classname}}({this.base, this.converters, this.timeout = const Duration(minutes: 2)});

    {{#operation}}
    /// {{summary}}
    ///
    /// {{notes}}
    @{{httpMethod}}Req(path: "{{path}}"{{#hasAuthMethods}}, metadata: {"auth": [{{#authMethods}} {"type": "{{type}}", "name": "{{name}}"{{#isApiKey}}, "keyName": "{{keyParamName}}", "where": "{{#isKeyInQuery}}query{{/isKeyInQuery}}{{#isKeyInHeader}}header{{/isKeyInHeader}}"{{/isApiKey}} }{{^-last}}, {{/-last}}{{/authMethods}}]}{{/hasAuthMethods}})
    Future<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{nickname}}(
    {{#pathParams}}
            @PathParam("{{baseName}}") {{dataType}} {{paramName}}{{^-last}}, {{/-last}}
    {{/pathParams}}
    {{#headerParams}}
        {{#-first}}{{#hasPathParams}},{{/hasPathParams}}{{/-first}}
            @Header("{{baseName}}") {{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}
    {{/headerParams}}
    {{#queryParams}}
        {{#-first}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/-first}}
            @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}
    {{/queryParams}}
    {{#vendorExtensions}}
        {{#formParams}}
            {{#-first}}{{#hasQueryParams}},{{/hasQueryParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/-first}}
            {{#x-is-json}}@AsJson() {{/x-is-json}}{{#x-is-form}}@AsFormField() {{/x-is-form}}{{#x-is-multipart}}@AsMultipartField() {{/x-is-multipart}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}
        {{/formParams}}
        {{#bodyParam}}
            {{#hasFormParams}},{{/hasFormParams}}{{^hasFormParams}}{{#hasQueryParams}},{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}
            {{^x-is-proto}}{{^x-is-json}}{{^x-is-form}}{{^x-is-multipart}}@AsBody(){{/x-is-multipart}}{{/x-is-form}}{{/x-is-json}}{{/x-is-proto}} {{#x-is-proto}}@Serialized(MimeTypes.binary) {{/x-is-proto}}{{#x-is-json}}@AsJson() {{/x-is-json}}{{#x-is-form}}@AsForm() {{/x-is-form}}{{#x-is-multipart}}@AsMultipart() {{/x-is-multipart}}{{{dataType}}} {{paramName}}
        {{/bodyParam}}
    {{/vendorExtensions}}
        ) {
        return super.{{nickname}}(
    {{#pathParams}}
        {{paramName}}{{^-last}}, {{/-last}}
    {{/pathParams}}
    {{#headerParams}}
        {{#-first}}{{#hasPathParams}},{{/hasPathParams}}{{/-first}}
        {{paramName}}{{^-last}}, {{/-last}}
    {{/headerParams}}
    {{#queryParams}}
        {{#-first}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/-first}}
        {{paramName}}{{^-last}}, {{/-last}}
    {{/queryParams}}

    {{#formParams}}
        {{#-first}}{{#hasQueryParams}},{{/hasQueryParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/-first}}
        {{paramName}}{{^-last}}, {{/-last}}
    {{/formParams}}
    {{#bodyParam}}
        {{#hasFormParams}},{{/hasFormParams}}{{^hasFormParams}}{{#hasQueryParams}},{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}
        {{paramName}}
    {{/bodyParam}}
        ).timeout(timeout);
    }

  {{/operation}}

}
{{/operations}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy