decidim-api 0.26.5 → 0.27.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/decidim/api/documentation_controller.rb +21 -0
- data/app/packs/entrypoints/decidim_api_docs.js +1 -26
- data/app/packs/entrypoints/decidim_api_docs.scss +1318 -0
- data/app/views/decidim/api/documentation/graphql_docs_template.html.erb +7 -0
- data/app/views/decidim/api/documentation/show.html.erb +2 -11
- data/app/views/decidim/api/graphiql/show.html.erb +3 -1
- data/app/views/layouts/decidim/api/documentation.html.erb +1 -4
- data/config/routes.rb +1 -0
- data/lib/decidim/api/schema.rb +3 -3
- data/lib/decidim/api/test/component_context.rb +2 -2
- data/lib/decidim/api/version.rb +1 -1
- data/lib/decidim/api.rb +17 -0
- data/lib/tasks/decidim_api_docs.rake +34 -0
- metadata +23 -28
- data/app/helpers/decidim/api/application_helper.rb +0 -24
- data/app/packs/stylesheets/decidim/api/docs.scss +0 -61
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
<div class="intro">
|
1
|
+
<div class="content">
|
3
2
|
<div class="version">Decidim <%= Decidim.version %></div>
|
4
3
|
|
5
4
|
<h1><%= current_organization.name %> API documentation</h1>
|
@@ -8,12 +7,4 @@
|
|
8
7
|
<% end %>
|
9
8
|
</div>
|
10
9
|
|
11
|
-
|
12
|
-
<%= render_doc("usage") %>
|
13
|
-
</div>
|
14
|
-
|
15
|
-
<div id="documentation"></div>
|
16
|
-
|
17
|
-
<script>
|
18
|
-
window.renderDocumentation("<%= root_path %>");
|
19
|
-
</script>
|
10
|
+
<%= static_api_docs_content %>
|
@@ -3,13 +3,14 @@
|
|
3
3
|
<head>
|
4
4
|
<title><%= Decidim::GraphiQL::Rails.config.title || "Decidim API" %></title>
|
5
5
|
<%= stylesheet_pack_tag("decidim_api_graphiql") %>
|
6
|
-
<%= javascript_pack_tag("decidim_api_graphiql", defer: false) %>
|
7
6
|
</head>
|
8
7
|
<body>
|
9
8
|
<div id="graphiql-container">
|
10
9
|
Loading...
|
11
10
|
</div>
|
12
11
|
|
12
|
+
<%= javascript_pack_tag "decidim_api_graphiql", defer: false %>
|
13
|
+
|
13
14
|
<%
|
14
15
|
js_configs = {
|
15
16
|
graphql_endpoint: graphql_endpoint_path,
|
@@ -17,6 +18,7 @@
|
|
17
18
|
request_headers: JSON.pretty_generate(Decidim::GraphiQL::Rails.config.resolve_headers(self))
|
18
19
|
}
|
19
20
|
%>
|
21
|
+
|
20
22
|
<script>
|
21
23
|
window.Decidim.config.set(<%== js_configs.to_json %>);
|
22
24
|
</script>
|
@@ -1,10 +1,7 @@
|
|
1
1
|
<html>
|
2
2
|
<head>
|
3
3
|
<title><%= current_organization.name %> - API Documentation</title>
|
4
|
-
<%=
|
5
|
-
<%= stylesheet_pack_tag "decidim_api_docs" %>
|
6
|
-
<style>
|
7
|
-
</style>
|
4
|
+
<%= stylesheet_pack_tag("decidim_api_docs") %>
|
8
5
|
</head>
|
9
6
|
<body>
|
10
7
|
<%= yield %>
|
data/config/routes.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
Decidim::Api::Engine.routes.draw do
|
4
4
|
get "/graphiql", to: "graphiql#show", graphql_path: "/api", as: :graphiql
|
5
5
|
get "/docs", to: "documentation#show", as: :documentation
|
6
|
+
get "/docs/*path", to: "documentation#show"
|
6
7
|
get "/", to: redirect("/api/docs")
|
7
8
|
post "/" => "queries#create", as: :root
|
8
9
|
end
|
data/lib/decidim/api/schema.rb
CHANGED
@@ -7,9 +7,9 @@ module Decidim
|
|
7
7
|
mutation(MutationType)
|
8
8
|
query(QueryType)
|
9
9
|
|
10
|
-
default_max_page_size
|
11
|
-
max_depth
|
12
|
-
max_complexity
|
10
|
+
default_max_page_size Decidim::Api.schema_max_per_page
|
11
|
+
max_depth Decidim::Api.schema_max_depth
|
12
|
+
max_complexity Decidim::Api.schema_max_complexity
|
13
13
|
|
14
14
|
orphan_types(Api.orphan_types)
|
15
15
|
end
|
@@ -12,8 +12,8 @@ shared_context "with a graphql decidim component" do
|
|
12
12
|
let(:participatory_process) { create :participatory_process, organization: current_organization }
|
13
13
|
let(:category) { create(:category, participatory_space: participatory_process) }
|
14
14
|
|
15
|
-
let(:component_type) {}
|
16
|
-
let(:component_fragment) {}
|
15
|
+
let(:component_type) { nil }
|
16
|
+
let(:component_fragment) { nil }
|
17
17
|
|
18
18
|
let(:participatory_process_query) do
|
19
19
|
%(
|
data/lib/decidim/api/version.rb
CHANGED
data/lib/decidim/api.rb
CHANGED
@@ -7,6 +7,23 @@ module Decidim
|
|
7
7
|
# This module holds all business logic related to exposing a Public API for
|
8
8
|
# decidim.
|
9
9
|
module Api
|
10
|
+
include ActiveSupport::Configurable
|
11
|
+
|
12
|
+
# defines the schema max_per_page to configure GraphQL pagination
|
13
|
+
config_accessor :schema_max_per_page do
|
14
|
+
50
|
15
|
+
end
|
16
|
+
|
17
|
+
# defines the schema max_complexity to configure GraphQL query complexity
|
18
|
+
config_accessor :schema_max_complexity do
|
19
|
+
5000
|
20
|
+
end
|
21
|
+
|
22
|
+
# defines the schema max_depth to configure GraphQL query max_depth
|
23
|
+
config_accessor :schema_max_depth do
|
24
|
+
15
|
25
|
+
end
|
26
|
+
|
10
27
|
# This declares all the types an interface or union can resolve to. This needs
|
11
28
|
# to be done in order to be able to have them found. This is a shortcoming of
|
12
29
|
# graphql-ruby and the way it deals with loading types, in combination with
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "graphql-docs"
|
4
|
+
|
5
|
+
namespace :decidim_api do
|
6
|
+
desc "Generates the API docs files"
|
7
|
+
task generate_docs: :environment do
|
8
|
+
output_dir = clear_previous_docs
|
9
|
+
|
10
|
+
GraphQLDocs.build(
|
11
|
+
schema: Decidim::Api::Schema,
|
12
|
+
output_dir: output_dir,
|
13
|
+
base_url: "/api/docs",
|
14
|
+
landing_pages: {
|
15
|
+
index: File.expand_path("../../docs/usage.md", __dir__)
|
16
|
+
},
|
17
|
+
templates: {
|
18
|
+
default: File.expand_path("../../app/views/decidim/api/documentation/graphql_docs_template.html.erb", __dir__)
|
19
|
+
}
|
20
|
+
)
|
21
|
+
|
22
|
+
clear_cache_folder
|
23
|
+
end
|
24
|
+
|
25
|
+
def clear_previous_docs
|
26
|
+
output_dir = Rails.application.root.join("app", "views", "static", "api", "docs")
|
27
|
+
FileUtils.rm_rf(output_dir)
|
28
|
+
output_dir
|
29
|
+
end
|
30
|
+
|
31
|
+
def clear_cache_folder
|
32
|
+
FileUtils.rm_rf(Rails.application.root.join(".sass-cache"))
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.27.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-06-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: graphql
|
@@ -33,95 +33,89 @@ dependencies:
|
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '1.13'
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: graphql-docs
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 2.1.0
|
42
42
|
type: :runtime
|
43
43
|
prerelease: false
|
44
44
|
version_requirements: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 2.1.0
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
50
|
+
name: rack-cors
|
51
51
|
requirement: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
56
|
-
- - ">="
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
version: 3.5.1
|
55
|
+
version: '1.0'
|
59
56
|
type: :runtime
|
60
57
|
prerelease: false
|
61
58
|
version_requirements: !ruby/object:Gem::Requirement
|
62
59
|
requirements:
|
63
60
|
- - "~>"
|
64
61
|
- !ruby/object:Gem::Version
|
65
|
-
version: '
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 3.5.1
|
62
|
+
version: '1.0'
|
69
63
|
- !ruby/object:Gem::Dependency
|
70
64
|
name: decidim-comments
|
71
65
|
requirement: !ruby/object:Gem::Requirement
|
72
66
|
requirements:
|
73
67
|
- - '='
|
74
68
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
69
|
+
version: 0.27.0.rc1
|
76
70
|
type: :development
|
77
71
|
prerelease: false
|
78
72
|
version_requirements: !ruby/object:Gem::Requirement
|
79
73
|
requirements:
|
80
74
|
- - '='
|
81
75
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
76
|
+
version: 0.27.0.rc1
|
83
77
|
- !ruby/object:Gem::Dependency
|
84
78
|
name: decidim-core
|
85
79
|
requirement: !ruby/object:Gem::Requirement
|
86
80
|
requirements:
|
87
81
|
- - '='
|
88
82
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
83
|
+
version: 0.27.0.rc1
|
90
84
|
type: :development
|
91
85
|
prerelease: false
|
92
86
|
version_requirements: !ruby/object:Gem::Requirement
|
93
87
|
requirements:
|
94
88
|
- - '='
|
95
89
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
90
|
+
version: 0.27.0.rc1
|
97
91
|
- !ruby/object:Gem::Dependency
|
98
92
|
name: decidim-dev
|
99
93
|
requirement: !ruby/object:Gem::Requirement
|
100
94
|
requirements:
|
101
95
|
- - '='
|
102
96
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
97
|
+
version: 0.27.0.rc1
|
104
98
|
type: :development
|
105
99
|
prerelease: false
|
106
100
|
version_requirements: !ruby/object:Gem::Requirement
|
107
101
|
requirements:
|
108
102
|
- - '='
|
109
103
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
104
|
+
version: 0.27.0.rc1
|
111
105
|
- !ruby/object:Gem::Dependency
|
112
106
|
name: decidim-participatory_processes
|
113
107
|
requirement: !ruby/object:Gem::Requirement
|
114
108
|
requirements:
|
115
109
|
- - '='
|
116
110
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
111
|
+
version: 0.27.0.rc1
|
118
112
|
type: :development
|
119
113
|
prerelease: false
|
120
114
|
version_requirements: !ruby/object:Gem::Requirement
|
121
115
|
requirements:
|
122
116
|
- - '='
|
123
117
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
118
|
+
version: 0.27.0.rc1
|
125
119
|
description: API engine for decidim
|
126
120
|
email:
|
127
121
|
- josepjaume@gmail.com
|
@@ -137,11 +131,11 @@ files:
|
|
137
131
|
- app/controllers/decidim/api/documentation_controller.rb
|
138
132
|
- app/controllers/decidim/api/graphiql_controller.rb
|
139
133
|
- app/controllers/decidim/api/queries_controller.rb
|
140
|
-
- app/helpers/decidim/api/application_helper.rb
|
141
134
|
- app/packs/entrypoints/decidim_api_docs.js
|
135
|
+
- app/packs/entrypoints/decidim_api_docs.scss
|
142
136
|
- app/packs/entrypoints/decidim_api_graphiql.js
|
143
137
|
- app/packs/entrypoints/decidim_api_graphiql.scss
|
144
|
-
- app/
|
138
|
+
- app/views/decidim/api/documentation/graphql_docs_template.html.erb
|
145
139
|
- app/views/decidim/api/documentation/show.html.erb
|
146
140
|
- app/views/decidim/api/graphiql/show.html.erb
|
147
141
|
- app/views/layouts/decidim/api/documentation.html.erb
|
@@ -170,6 +164,7 @@ files:
|
|
170
164
|
- lib/decidim/api/types/base_scalar.rb
|
171
165
|
- lib/decidim/api/types/base_union.rb
|
172
166
|
- lib/decidim/api/version.rb
|
167
|
+
- lib/tasks/decidim_api_docs.rake
|
173
168
|
homepage: https://github.com/decidim/decidim
|
174
169
|
licenses:
|
175
170
|
- AGPL-3.0
|
@@ -182,14 +177,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
177
|
requirements:
|
183
178
|
- - ">="
|
184
179
|
- !ruby/object:Gem::Version
|
185
|
-
version: '
|
180
|
+
version: '3.0'
|
186
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
182
|
requirements:
|
188
|
-
- - "
|
183
|
+
- - ">"
|
189
184
|
- !ruby/object:Gem::Version
|
190
|
-
version:
|
185
|
+
version: 1.3.1
|
191
186
|
requirements: []
|
192
|
-
rubygems_version: 3.
|
187
|
+
rubygems_version: 3.2.22
|
193
188
|
signing_key:
|
194
189
|
specification_version: 4
|
195
190
|
summary: Decidim API module
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "redcarpet"
|
4
|
-
|
5
|
-
module Decidim
|
6
|
-
module Api
|
7
|
-
# Custom helpers, scoped to the api engine.
|
8
|
-
#
|
9
|
-
module ApplicationHelper
|
10
|
-
def render_doc(file)
|
11
|
-
md_render File.read(File.join(File.dirname(__FILE__), "../../../../docs", "#{file}.md"))
|
12
|
-
end
|
13
|
-
|
14
|
-
def md_render(text)
|
15
|
-
text = Redcarpet::Markdown.new(markdown, autolink: true, tables: true, fenced_code_blocks: true).render(text)
|
16
|
-
text.html_safe
|
17
|
-
end
|
18
|
-
|
19
|
-
def markdown
|
20
|
-
@markdown ||= Redcarpet::Render::HTML.new
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
body{
|
2
|
-
max-width: 1200px;
|
3
|
-
}
|
4
|
-
|
5
|
-
.intro,
|
6
|
-
.info{
|
7
|
-
margin-left: 270px;
|
8
|
-
color: #333;
|
9
|
-
}
|
10
|
-
|
11
|
-
.info{
|
12
|
-
li{
|
13
|
-
margin-bottom: 1rem;
|
14
|
-
}
|
15
|
-
|
16
|
-
h3{
|
17
|
-
margin-top: 2em;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
|
-
.version{
|
22
|
-
display: inline-block;
|
23
|
-
font-size: .8rem;
|
24
|
-
margin-right: 1rem;
|
25
|
-
padding: 3px 7px;
|
26
|
-
background: #f33;
|
27
|
-
border-radius: 10px;
|
28
|
-
margin-top: 5px;
|
29
|
-
color: white;
|
30
|
-
}
|
31
|
-
|
32
|
-
@media only screen and (max-width: 767px){
|
33
|
-
.intro,
|
34
|
-
.info{
|
35
|
-
margin: 10px;
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
code{
|
40
|
-
font-size: .8em;
|
41
|
-
background: #ddd;
|
42
|
-
padding: .1em;
|
43
|
-
}
|
44
|
-
|
45
|
-
pre{
|
46
|
-
padding: .5rem;
|
47
|
-
background: #f0f0f0;
|
48
|
-
border: 1px solid #e8e8e8;
|
49
|
-
|
50
|
-
code{
|
51
|
-
background: none;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
blockquote{
|
56
|
-
border-left: 3px solid burlywood;
|
57
|
-
padding: .1em 0 .1em 1rem;
|
58
|
-
margin: 1rem 0;
|
59
|
-
background: #f9f7f5;
|
60
|
-
width: 100%;
|
61
|
-
}
|