praxis 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +15 -2
  4. data/CHANGELOG.md +54 -1
  5. data/bin/praxis +49 -2
  6. data/lib/api_browser/Gruntfile.js +247 -90
  7. data/lib/api_browser/app/bower_components/angular-mocks/.bower.json +19 -0
  8. data/lib/api_browser/app/bower_components/angular-mocks/README.md +57 -0
  9. data/lib/api_browser/app/bower_components/angular-mocks/angular-mocks.js +2193 -0
  10. data/lib/api_browser/app/bower_components/angular-mocks/bower.json +9 -0
  11. data/lib/api_browser/app/bower_components/angular-mocks/package.json +27 -0
  12. data/lib/api_browser/app/bower_components/angular/.bower.json +6 -5
  13. data/lib/api_browser/app/bower_components/angular/README.md +23 -4
  14. data/lib/api_browser/app/bower_components/angular/angular-csp.css +6 -0
  15. data/lib/api_browser/app/bower_components/angular/angular.js +2287 -1597
  16. data/lib/api_browser/app/bower_components/angular/angular.min.js +212 -205
  17. data/lib/api_browser/app/bower_components/angular/angular.min.js.gzip +0 -0
  18. data/lib/api_browser/app/bower_components/angular/angular.min.js.map +3 -3
  19. data/lib/api_browser/app/bower_components/angular/bower.json +2 -1
  20. data/lib/api_browser/app/bower_components/angular/package.json +25 -0
  21. data/lib/api_browser/app/bower_components/showdown/.bower.json +39 -0
  22. data/lib/api_browser/app/bower_components/showdown/.jshintignore +2 -0
  23. data/lib/api_browser/app/bower_components/showdown/.travis.yml +8 -0
  24. data/lib/api_browser/app/bower_components/showdown/Gruntfile.js +100 -0
  25. data/lib/api_browser/app/bower_components/showdown/README.md +317 -0
  26. data/lib/api_browser/app/bower_components/showdown/bower.json +26 -0
  27. data/lib/api_browser/app/bower_components/showdown/compressed/Showdown.js +1606 -0
  28. data/lib/api_browser/app/bower_components/showdown/compressed/Showdown.js.map +1 -0
  29. data/lib/api_browser/app/bower_components/showdown/compressed/Showdown.min.js +2 -0
  30. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/github.min.js +2 -0
  31. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/github.min.js.map +1 -0
  32. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/prettify.min.js +2 -0
  33. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/prettify.min.js.map +1 -0
  34. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/table.min.js +2 -0
  35. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/table.min.js.map +1 -0
  36. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/twitter.min.js +2 -0
  37. data/lib/api_browser/app/bower_components/showdown/compressed/extensions/twitter.min.js.map +1 -0
  38. data/lib/api_browser/app/bower_components/showdown/license.txt +34 -0
  39. data/lib/api_browser/app/bower_components/showdown/package.json +47 -0
  40. data/lib/api_browser/app/bower_components/showdown/src/extensions/github.js +25 -0
  41. data/lib/api_browser/app/bower_components/showdown/src/extensions/prettify.js +29 -0
  42. data/lib/api_browser/app/bower_components/showdown/src/extensions/table.js +106 -0
  43. data/lib/api_browser/app/bower_components/showdown/src/extensions/twitter.js +42 -0
  44. data/lib/api_browser/app/bower_components/showdown/src/ng-showdown.js +150 -0
  45. data/lib/api_browser/app/bower_components/showdown/src/showdown.js +1454 -0
  46. data/lib/api_browser/app/index.html +6 -4
  47. data/lib/api_browser/app/js/app.js +1 -2
  48. data/lib/api_browser/app/js/controllers/action.js +4 -4
  49. data/lib/api_browser/app/js/controllers/controller.js +1 -1
  50. data/lib/api_browser/app/js/controllers/menu.js +5 -3
  51. data/lib/api_browser/app/js/controllers/type.js +5 -5
  52. data/lib/api_browser/app/js/directives/attribute_description.js +5 -5
  53. data/lib/api_browser/app/js/directives/attribute_table.js +1 -1
  54. data/lib/api_browser/app/js/directives/attribute_table_row.js +2 -2
  55. data/lib/api_browser/app/js/directives/no_container.js +1 -1
  56. data/lib/api_browser/app/js/directives/request_body.js +5 -5
  57. data/lib/api_browser/app/js/directives/request_headers.js +3 -6
  58. data/lib/api_browser/app/js/directives/request_parameters.js +3 -6
  59. data/lib/api_browser/app/js/directives/type_label.js +4 -5
  60. data/lib/api_browser/app/js/factories/Documentation.js +4 -4
  61. data/lib/api_browser/app/js/factories/PayloadTemplates.js +2 -2
  62. data/lib/api_browser/app/js/factories/TypeTemplates.js +3 -3
  63. data/lib/api_browser/app/js/filters/markdown.js +6 -0
  64. data/lib/api_browser/app/js/filters/resource_name.js +2 -2
  65. data/lib/api_browser/app/sass/modules/_header.scss +2 -7
  66. data/lib/api_browser/app/sass/{main.scss → praxis.scss} +0 -0
  67. data/lib/api_browser/app/sass/variables/_bootstrap-variables.scss +370 -367
  68. data/lib/api_browser/app/views/action.html +2 -2
  69. data/lib/api_browser/app/views/controller.html +2 -2
  70. data/lib/api_browser/app/views/directives/attribute_description.html +1 -1
  71. data/lib/api_browser/app/views/layout.html +2 -11
  72. data/lib/api_browser/app/views/navbar.html +9 -0
  73. data/lib/api_browser/app/views/resource/_actions.html +1 -1
  74. data/lib/api_browser/app/views/type.html +2 -2
  75. data/lib/api_browser/app/views/type/_details.html +2 -1
  76. data/lib/api_browser/bower.json +5 -0
  77. data/lib/api_browser/package.json +18 -7
  78. data/lib/praxis.rb +8 -3
  79. data/lib/praxis/action_definition.rb +28 -6
  80. data/lib/praxis/api_definition.rb +30 -2
  81. data/lib/praxis/api_general_info.rb +36 -0
  82. data/lib/praxis/bootloader.rb +1 -0
  83. data/lib/praxis/collection.rb +34 -0
  84. data/lib/praxis/controller.rb +7 -0
  85. data/lib/praxis/dispatcher.rb +3 -0
  86. data/lib/praxis/links.rb +2 -8
  87. data/lib/praxis/media_type.rb +6 -24
  88. data/lib/praxis/media_type_collection.rb +6 -2
  89. data/lib/praxis/plugin_concern.rb +2 -1
  90. data/lib/praxis/request.rb +24 -15
  91. data/lib/praxis/request_stages/request_stage.rb +19 -4
  92. data/lib/praxis/request_stages/validate_params_and_headers.rb +1 -1
  93. data/lib/praxis/request_stages/validate_payload.rb +1 -1
  94. data/lib/praxis/resource_definition.rb +45 -10
  95. data/lib/praxis/response_definition.rb +46 -27
  96. data/lib/praxis/restful_doc_generator.rb +94 -7
  97. data/lib/praxis/simple_media_type.rb +2 -9
  98. data/lib/praxis/stage.rb +1 -4
  99. data/lib/praxis/tasks/api_docs.rb +51 -19
  100. data/lib/praxis/tasks/routes.rb +19 -15
  101. data/lib/praxis/types/media_type_common.rb +31 -0
  102. data/lib/praxis/types/multipart.rb +4 -4
  103. data/lib/praxis/version.rb +1 -1
  104. data/praxis.gemspec +2 -2
  105. data/spec/api_browser/factories/documentation_spec.js +50 -0
  106. data/spec/api_browser/filters/attribute_name_spec.js +23 -0
  107. data/spec/functional_spec.rb +62 -10
  108. data/spec/praxis/action_definition_spec.rb +12 -4
  109. data/spec/praxis/api_definition_spec.rb +159 -0
  110. data/spec/praxis/api_general_info_spec.rb +36 -0
  111. data/spec/praxis/bootloader_spec.rb +10 -1
  112. data/spec/praxis/media_type_collection_spec.rb +46 -53
  113. data/spec/praxis/media_type_spec.rb +6 -6
  114. data/spec/praxis/request_stage_spec.rb +7 -2
  115. data/spec/praxis/request_stages_validate_spec.rb +12 -7
  116. data/spec/praxis/resource_definition_spec.rb +62 -0
  117. data/spec/praxis/response_definition_spec.rb +26 -16
  118. data/spec/praxis/stage_spec.rb +4 -8
  119. data/spec/praxis/types/collection_spec.rb +144 -0
  120. data/spec/spec_app/app/controllers/instances.rb +8 -2
  121. data/spec/spec_app/design/api.rb +11 -0
  122. data/spec/spec_app/design/media_types/instance.rb +12 -0
  123. data/spec/spec_app/design/media_types/volume.rb +9 -2
  124. data/spec/spec_app/design/media_types/volume_snapshot.rb +9 -6
  125. data/spec/spec_app/design/resources/instances.rb +25 -10
  126. data/spec/support/spec_media_types.rb +1 -1
  127. data/spec/support/spec_resource_definitions.rb +2 -0
  128. data/tasks/thor/app.rb +15 -10
  129. data/tasks/thor/example.rb +115 -115
  130. data/tasks/thor/templates/generator/empty_app/.gitignore +2 -0
  131. data/tasks/thor/templates/generator/empty_app/docs/app.js +1 -0
  132. data/tasks/thor/templates/generator/empty_app/docs/styles.scss +3 -0
  133. metadata +50 -9
  134. data/lib/api_browser/app/css/main.css +0 -4511
  135. data/lib/praxis/types/collection.rb +0 -17
@@ -24,4 +24,15 @@ Praxis::ApiDefinition.define do
24
24
  end
25
25
  end
26
26
 
27
+ info do # applies to all API infos
28
+ name "Spec App"
29
+ title "A simple App to do some simple integration testing"
30
+ description "This example API should really be replaced by a set of more full-fledged example apps in the future"
31
+ end
32
+
33
+ info("1.0") do # Applies to 1.0 version (and inherits everything else form the global one)
34
+ description "A simple 1.0 App"
35
+ base_path "/"
36
+ end
37
+
27
38
  end
@@ -10,6 +10,8 @@ class Instance < Praxis::MediaType
10
10
 
11
11
  attribute :root_volume, Volume
12
12
 
13
+ attribute :volumes, Volume::Collection
14
+
13
15
  links do
14
16
  link :root_volume
15
17
  link :other_volume, Volume, using: :data_volume
@@ -32,4 +34,14 @@ class Instance < Praxis::MediaType
32
34
  attribute :name
33
35
  end
34
36
 
37
+ view :extended, include_nil: true do
38
+ attribute :id
39
+ attribute :name
40
+ attribute :root_volume
41
+ attribute :links do
42
+ attribute :root_volume
43
+ end
44
+ end
45
+
46
+
35
47
  end
@@ -7,12 +7,12 @@ class Volume < Praxis::MediaType
7
7
 
8
8
  attribute :source, VolumeSnapshot
9
9
 
10
- # returns VolumeSnapshot::Collection if exists
11
10
  attribute :snapshots, Praxis::Collection.of(VolumeSnapshot)
11
+ attribute :snapshots_summary, VolumeSnapshot::CollectionSummary
12
12
 
13
13
  links do
14
14
  link :source
15
- link :snapshots
15
+ link :snapshots, VolumeSnapshot::CollectionSummary, using: :snapshots_summary
16
16
  end
17
17
 
18
18
  end
@@ -22,6 +22,7 @@ class Volume < Praxis::MediaType
22
22
  attribute :name
23
23
  attribute :source
24
24
  attribute :snapshots
25
+
25
26
  attribute :links
26
27
  end
27
28
 
@@ -29,6 +30,12 @@ class Volume < Praxis::MediaType
29
30
  attribute :id
30
31
  end
31
32
 
33
+ class Collection < Praxis::Collection
34
+ member_type Volume
35
+
36
+ identifier 'application/vnd.acme.volumes'
37
+ end
38
+
32
39
  end
33
40
 
34
41
 
@@ -16,24 +16,27 @@ class VolumeSnapshot < Praxis::MediaType
16
16
  end
17
17
 
18
18
 
19
- class Collection < Praxis::MediaTypeCollection
20
- identifier 'application/json+collection'
21
-
22
- member_type VolumeSnapshot
19
+ class CollectionSummary < Praxis::MediaType
20
+ identifier 'application/json'
23
21
 
24
22
  attributes do
25
23
  attribute :name, String, regexp: /snapshots-(\w+)/
26
- attribute :size, Integer, example: proc { |collection| collection.to_a.count }
24
+ attribute :size, Integer
27
25
  attribute :href, String
28
26
  end
29
27
 
28
+ view :default do
29
+ attribute :name
30
+ attribute :size
31
+ attribute :href
32
+ end
33
+
30
34
  view :link do
31
35
  attribute :name
32
36
  attribute :size
33
37
  attribute :href
34
38
  end
35
39
 
36
- member_view :default, using: :default
37
40
  end
38
41
 
39
42
  end
@@ -4,13 +4,11 @@ module ApiResources
4
4
 
5
5
  media_type Instance
6
6
  version '1.0'
7
-
8
- #responses :instance_limit_reached
9
- #responses :pay_us_money
10
- #response :create, location: /instances/
11
-
12
7
 
13
-
8
+ # :show action is the canonical path for this resource.
9
+ # Note that the following is redundant, since :show is the default canonical path if none is defined.
10
+ canonical_path :show
11
+
14
12
  routing do
15
13
  prefix '/clouds/:cloud_id/instances'
16
14
  end
@@ -30,17 +28,17 @@ module ApiResources
30
28
  get ''
31
29
  end
32
30
 
33
- response_content_type = self.resource_definition.media_type.identifier + ";type=collection"
34
31
  params do
35
- attribute :response_content_type, String, default: response_content_type
32
+ attribute :response_content_type, String, default: 'application/vnd.acme.instance;type=collection'
36
33
  end
34
+
37
35
  headers do
38
36
  # BOTH ARE EQUIVALENT
39
37
  #key "FOO", String, required: true
40
38
  header "FOO", /bar/
41
39
  end
42
40
 
43
- response :ok, media_type: response_content_type
41
+ response :ok, media_type: Praxis::Collection.of(Instance)
44
42
  end
45
43
 
46
44
  action :show do
@@ -53,7 +51,7 @@ module ApiResources
53
51
  response :unauthorized
54
52
 
55
53
  params do
56
- attribute :id
54
+ attribute :id, required: true
57
55
  attribute :junk, String, default: ''
58
56
  attribute :some_date, DateTime, default: DateTime.parse('2012-12-21')
59
57
  attribute :fail_filter, Attributor::Boolean, default: false
@@ -160,6 +158,23 @@ module ApiResources
160
158
  response :ok, media_type: 'application/json'
161
159
  end
162
160
 
161
+ action :update do
162
+ routing do
163
+ patch '/:id'
164
+ end
165
+
166
+ params do
167
+ attribute :id, required: true
168
+ end
169
+
170
+ payload do
171
+ attribute :name
172
+ attribute :root_volume
173
+ end
174
+
175
+ response :ok
176
+ end
177
+
163
178
  # OTHER USAGES:
164
179
  # note: these are all hypothetical, pending, brainstorming usages.
165
180
 
@@ -3,7 +3,7 @@ class Person < Praxis::MediaType
3
3
  attribute :id, Integer
4
4
  attribute :name, String, example: /[:name:]/
5
5
  attribute :href, String, example: proc { |person| "/people/#{person.id}" }
6
- attribute :links, Praxis::Collection.of(String)
6
+ attribute :links, silence_warnings { Praxis::Collection.of(String) }
7
7
  end
8
8
 
9
9
  view :default do
@@ -9,6 +9,8 @@ class PeopleResource
9
9
 
10
10
  version '1.0'
11
11
 
12
+ canonical_path :show
13
+
12
14
  routing do
13
15
  prefix "/people"
14
16
  end
data/tasks/thor/app.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  module PraxisGen
2
2
  class App < Thor
3
3
  include Thor::Actions
4
-
4
+
5
5
  namespace "praxis:app"
6
6
  def self.source_root
7
7
  File.dirname(__FILE__) + "/templates/generator/empty_app"
8
8
  end
9
-
9
+
10
10
  argument :app_name, required: true
11
11
  desc "new", "Generates a blank new app under <app_name> (with a full skeleton ready to start coding)"
12
-
12
+
13
13
  # Generator for a blank new app (with a full skeleton ready to get you going)
14
14
  def new
15
15
  puts "Creating new blank Praxis app under #{app_name}"
@@ -18,31 +18,36 @@ module PraxisGen
18
18
  create_app
19
19
  create_design
20
20
  create_spec
21
+ create_docs
21
22
  end
22
-
23
- private
23
+
24
+ private
24
25
  def create_root_files
25
26
  ['config.ru','Gemfile','Guardfile','Rakefile','README.md'].each do |file|
26
27
  copy_file file, "#{app_name}/#{file}"
27
28
  end
28
29
  end
29
-
30
+
30
31
  def create_config
31
32
  copy_file "config/environment.rb", "#{app_name}/config/environment.rb"
32
33
  copy_file "config/rainbows.rb", "#{app_name}/config/rainbows.rb"
33
34
  end
34
-
35
+
35
36
  def create_app
36
37
  directory "app", "#{app_name}/app", :recursive => true
37
38
  end
38
-
39
+
39
40
  def create_design
40
41
  directory "design", "#{app_name}/design", :recursive => true
41
42
  end
42
-
43
+
43
44
  def create_spec
44
45
  directory "spec", "#{app_name}/spec", :recursive => true
45
46
  end
46
-
47
+
48
+ def create_docs
49
+ directory "docs", "#{app_name}/docs", :recursive => true
50
+ end
51
+
47
52
  end
48
53
  end
@@ -9,7 +9,7 @@ module PraxisGen
9
9
  desc "new", "Generates a new 'hello world' example application under an <app_name> directory"
10
10
 
11
11
  def new
12
- puts "GENERATION COMMENTED!! (for #{app_name})"
12
+ puts "GENERATION COMMENCED!! (for #{app_name})"
13
13
  # Fix weird symbols in the app name (if they are)
14
14
  @app_name = app_name.downcase.gsub(/[^a-z0-9_\/.]/, '')
15
15
  # Generate a new app
@@ -30,7 +30,7 @@ module PraxisGen
30
30
  puts " # terminal 1:"
31
31
  puts " cd #{app_name}"
32
32
  puts " bundle"
33
- puts " rackup -p 8888"
33
+ puts " bundle exec rackup"
34
34
  puts
35
35
  puts " # terminal 2:"
36
36
  puts " curl -i http://localhost:8888/api/hello -H 'X-Api-Version: 1.0' -X GET # Index"
@@ -74,29 +74,29 @@ private
74
74
  def generate_config_environment_rb
75
75
  create_file path('config/environment.rb') do
76
76
  <<-RUBY
77
- # Main entry point - DO NOT MODIFY THIS FILE
78
- ENV['RACK_ENV'] ||= 'development'
79
-
80
- Bundler.require(:default, ENV['RACK_ENV'])
81
-
82
- # Default application layout.
83
- # NOTE: This layout need NOT be specified explicitly.
84
- # It is provided just for illustration.
85
- Praxis::Application.instance.layout do
86
- map :initializers, 'config/initializers/**/*'
87
- map :lib, 'lib/**/*'
88
- map :design, 'design/' do
89
- map :api, 'api.rb'
90
- map :media_types, '**/media_types/**/*'
91
- map :resources, '**/resources/**/*'
92
- end
93
- map :app, 'app/' do
94
- map :models, 'models/**/*'
95
- map :controllers, '**/controllers/**/*'
96
- map :responses, '**/responses/**/*'
97
- end
77
+ # Main entry point - DO NOT MODIFY THIS FILE
78
+ ENV['RACK_ENV'] ||= 'development'
79
+
80
+ Bundler.require(:default, ENV['RACK_ENV'])
81
+
82
+ # Default application layout.
83
+ # NOTE: This layout need NOT be specified explicitly.
84
+ # It is provided just for illustration.
85
+ Praxis::Application.instance.layout do
86
+ map :initializers, 'config/initializers/**/*'
87
+ map :lib, 'lib/**/*'
88
+ map :design, 'design/' do
89
+ map :api, 'api.rb'
90
+ map :media_types, '**/media_types/**/*'
91
+ map :resources, '**/resources/**/*'
98
92
  end
99
- RUBY
93
+ map :app, 'app/' do
94
+ map :models, 'models/**/*'
95
+ map :controllers, '**/controllers/**/*'
96
+ map :responses, '**/responses/**/*'
97
+ end
98
+ end
99
+ RUBY
100
100
  end
101
101
  nil
102
102
  end
@@ -109,16 +109,16 @@ private
109
109
  def generate_gemfile
110
110
  create_file path('Gemfile') do
111
111
  <<-RUBY
112
- source 'https://rubygems.org'
113
-
114
- gem 'praxis'
115
- gem 'rack', '~> 1.0'
116
- gem 'rake'
117
-
118
- group :development, :test do
119
- gem 'rspec'
120
- end
121
- RUBY
112
+ source 'https://rubygems.org'
113
+
114
+ gem 'praxis'
115
+ gem 'rack', '~> 1.0'
116
+ gem 'rake'
117
+
118
+ group :development, :test do
119
+ gem 'rspec'
120
+ end
121
+ RUBY
122
122
  end
123
123
  nil
124
124
  end
@@ -131,9 +131,9 @@ private
131
131
  def generate_rakefile
132
132
  create_file path('Rakefile') do
133
133
  <<-RUBY
134
- require 'praxis'
135
- require 'praxis/tasks'
136
- RUBY
134
+ require 'praxis'
135
+ require 'praxis/tasks'
136
+ RUBY
137
137
  end
138
138
  nil
139
139
  end
@@ -146,17 +146,17 @@ private
146
146
  def generate_config_ru
147
147
  create_file path('config.ru') do
148
148
  <<-RUBY
149
- #\ -p 8888
150
-
151
- require 'bundler/setup'
152
- require 'praxis'
153
-
154
- application = Praxis::Application.instance
155
- application.logger = Logger.new(STDOUT)
156
- application.setup
157
-
158
- run application
159
- RUBY
149
+ #\\ -p 8888
150
+
151
+ require 'bundler/setup'
152
+ require 'praxis'
153
+
154
+ application = Praxis::Application.instance
155
+ application.logger = Logger.new(STDOUT)
156
+ application.setup
157
+
158
+ run application
159
+ RUBY
160
160
  end
161
161
  nil
162
162
  end
@@ -165,62 +165,62 @@ private
165
165
  def generate_app_definitions_hello_world
166
166
  create_file path('design/api.rb') do
167
167
  <<-RUBY
168
- # Use this file to define your response templates and traits.
169
- #
170
- # For example, to define a response template:
171
- # response_template :custom do |media_type:|
172
- # status 200
173
- # media_type media_type
174
- # end
175
- Praxis::ApiDefinition.define do
176
- trait :versionable do
177
- headers do
178
- key "X-Api-Version", String, values: ['1.0'], required: true
179
- end
168
+ # Use this file to define your response templates and traits.
169
+ #
170
+ # For example, to define a response template:
171
+ # response_template :custom do |media_type:|
172
+ # status 200
173
+ # media_type media_type
174
+ # end
175
+ Praxis::ApiDefinition.define do
176
+ trait :versionable do
177
+ headers do
178
+ key "X-Api-Version", String, values: ['1.0'], required: true
180
179
  end
181
180
  end
182
- RUBY
181
+ end
182
+ RUBY
183
183
  end
184
184
 
185
185
  create_file path('design/resources/hello.rb') do
186
186
  <<-RUBY
187
- module V1
188
- module ApiResources
189
- class Hello
190
- include Praxis::ResourceDefinition
191
-
192
- media_type V1::MediaTypes::Hello
193
- version '1.0'
194
-
187
+ module V1
188
+ module ApiResources
189
+ class Hello
190
+ include Praxis::ResourceDefinition
191
+
192
+ media_type V1::MediaTypes::Hello
193
+ version '1.0'
194
+
195
+ routing do
196
+ prefix '/api/hello'
197
+ end
198
+
199
+ action :index do
200
+ use :versionable
201
+
195
202
  routing do
196
- prefix '/api/hello'
203
+ get ''
197
204
  end
198
-
199
- action :index do
200
- use :versionable
201
-
202
- routing do
203
- get ''
204
- end
205
- response :ok
205
+ response :ok
206
+ end
207
+
208
+ action :show do
209
+ use :versionable
210
+
211
+ routing do
212
+ get '/:id'
206
213
  end
207
-
208
- action :show do
209
- use :versionable
210
-
211
- routing do
212
- get '/:id'
213
- end
214
- params do
215
- attribute :id, Integer, required: true, min: 0
216
- end
217
- response :ok
218
- response :not_found
214
+ params do
215
+ attribute :id, Integer, required: true, min: 0
219
216
  end
217
+ response :ok
218
+ response :not_found
220
219
  end
221
220
  end
222
221
  end
223
- RUBY
222
+ end
223
+ RUBY
224
224
  end
225
225
 
226
226
  create_file path('design/media_types/hello.rb') do
@@ -249,33 +249,33 @@ private
249
249
  def generate_app_controllers_hello_world
250
250
  create_file path('app/controllers/hello.rb') do
251
251
  <<-RUBY
252
- module V1
253
- class Hello
254
- include Praxis::Controller
255
-
256
- implements V1::ApiResources::Hello
257
-
258
- HELLO_WORLD = [ 'Hello world!', 'Привет мир!', 'Hola mundo!', '你好世界!', 'こんにちは世界!' ]
259
-
260
- def index(**params)
261
- response.headers['Content-Type'] = 'application/json'
262
- response.body = HELLO_WORLD.to_json
263
- response
264
- end
265
-
266
- def show(id:, **other_params)
267
- hello = HELLO_WORLD[id]
268
- if hello
269
- response.body = { id: id, data: hello }
270
- else
271
- self.response = Praxis::Responses::NotFound.new
272
- end
273
- response.headers['Content-Type'] = 'application/json'
274
- response
252
+ module V1
253
+ class Hello
254
+ include Praxis::Controller
255
+
256
+ implements V1::ApiResources::Hello
257
+
258
+ HELLO_WORLD = [ 'Hello world!', 'Привет мир!', 'Hola mundo!', '你好世界!', 'こんにちは世界!' ]
259
+
260
+ def index(**params)
261
+ response.headers['Content-Type'] = 'application/json'
262
+ response.body = HELLO_WORLD.to_json
263
+ response
264
+ end
265
+
266
+ def show(id:, **other_params)
267
+ hello = HELLO_WORLD[id]
268
+ if hello
269
+ response.body = { id: id, data: hello }
270
+ else
271
+ self.response = Praxis::Responses::NotFound.new
275
272
  end
273
+ response.headers['Content-Type'] = 'application/json'
274
+ response
276
275
  end
277
276
  end
278
- RUBY
277
+ end
278
+ RUBY
279
279
  end
280
280
  end
281
281