dryvPacks

@dryv/flutter-api-bridgev0.1.0

A Dart/Flutter package over flutter_api_bridge with typed features, endpoints and models.

Flutter API BridgeClientsUnitPublished 7 days ago2 downloads

dryv pack add @dryv/flutter-api-bridge
895 BRaw ↗
jinja
{#- "yes" when the operation's path has parameters. -#}
{%- macro has_params(http) -%}
{%- for binding in http.inputs -%}{%- if binding.is.path -%}yes{%- endif -%}{%- endfor -%}
{%- endmacro -%}
/// Typed route registry for the {{ group.name.title }} group. Static paths are getters;
/// parameterised paths are methods that interpolate their segments.
class {{ file.symbol }} {
  const {{ file.symbol }}();
{%- for operation in operations %}
{%- set http = operation.facets.http %}

  /// {{ http.method }} {{ http.path.local }}
{%- if has_params(http) %}
  String {{ operation.name.camel }}({ {% for binding in http.inputs %}{% if binding.is.path %}required String {{ binding.name }}, {% endif %}{% endfor %}}) =>
      '{{ http.path.local | replace('{', '$') | replace('}', '') }}';
{%- else %}
  String get {{ operation.name.camel }} => '{{ http.path.local }}';
{%- endif %}
{%- endfor %}
}