Repository navigation
Expand file tree
/
Copy pathrest_api.mustache
More file actions
96 lines (91 loc) · 3.5 KB
/
Copy pathrest_api.mustache
File metadata and controls
96 lines (91 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
%%%--------------------------------------------------------------------
%%% This file has been automatically generated from Swagger
%%% specification - DO NOT EDIT!
%%%
%%% @copyright (C) 2020 ACK CYFRONET AGH
%%% This software is released under the MIT license cited i
%%% in 'LICENSE.txt'.
%%% @end
%%%--------------------------------------------------------------------
%%% @doc REST API definitions for {{#operations}}{{classVarName}}{{/operations}}.
%%% @end
%%%--------------------------------------------------------------------
-module({{#operations}}{{classVarName}}_rest_routes{{/operations}}).
-author("Wojciech Geisler").
-include("http/rest.hrl").
%% API
-export([routes/0]).
%%%===================================================================
%%% API functions
%%%===================================================================
%%--------------------------------------------------------------------
%% @doc Returns a list of tuples consisting of a path, a handler module and
%% an initial request state.
%% @end
%%--------------------------------------------------------------------
-spec routes() ->
[{Path :: binary(), #rest_req{}}].
routes() ->
[
{{#operations}}
{{#operation}}
{{#vendorExtensions}}
{{#summary}}
%% {{{summary}}}
{{/summary}}
{<<"{{path}}">>, #rest_req{
method = '{{httpMethod}}',
{{#x-onedata-gri}}
b_gri = #b_gri{
type = {{type}},
id = {{{id}}}{{^id}}undefined{{/id}},
aspect = {{{aspect}}},
scope = {{{scope}}}{{^scope}}private{{/scope}}
},
{{/x-onedata-gri}}
{{#hasProduces}}
produces = [{{#produces}}<<"{{{mediaType}}}">>{{#hasMore}}, {{/hasMore}}{{/produces}}],
{{/hasProduces}}
{{#hasBodyParam}}
{{#bodyParam}}
{{#description}}
%% {{description}}
{{/description}}
{{! always put the rest_model invocation in brackets,
for cases when there are query params to be added inline }}
data_spec = (rest_model:{{dataType}}_model()){{#hasQueryParams}}#{ {{/hasQueryParams}}{{^hasQueryParams}},{{/hasQueryParams}}
{{/bodyParam}}
{{/hasBodyParam}}
{{#hasQueryParams}}
{{! if there is a body spec, query parameters spec is added to the map }}
{{^hasBodyParam}}
data_spec = #{
{{/hasBodyParam}}
{{#queryParams}}
{{#description}}
%% {{description}}
{{/description}}
{{#required}}
{{paramName}} => {{dataType}}{{#hasMore}},{{/hasMore}}
{{/required}}
{{^required}}
{{#defaultValue}}
{{#x-onedata-default-value}}
{{paramName}} => { {{dataType}}, {optional, {{x-onedata-default-value}} } }{{#hasMore}},{{/hasMore}}
{{/x-onedata-default-value}}
{{^x-onedata-default-value}}
{{paramName}} => { {{dataType}}, {optional, {{defaultValue}} } }{{#hasMore}},{{/hasMore}}
{{/x-onedata-default-value}}
{{/defaultValue}}
{{^defaultValue}}
{{paramName}} => { {{dataType}}, optional }{{#hasMore}},{{/hasMore}}
{{/defaultValue}}
{{/required}}
{{/queryParams}}
},
{{/hasQueryParams}}
}}{{#hasMore}},{{/hasMore}}
{{/vendorExtensions}}
{{/operation}}
{{/operations}}
].