praxis 2.0.pre.6 → 2.0.pre.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +1 -3
- data/CHANGELOG.md +25 -0
- data/TODO.md +1 -4
- data/bin/praxis +67 -12
- data/lib/praxis.rb +10 -3
- data/lib/praxis/action_definition.rb +15 -13
- data/lib/praxis/action_definition/headers_dsl_compiler.rb +0 -7
- data/lib/praxis/api_general_info.rb +1 -1
- data/lib/praxis/application.rb +6 -2
- data/lib/praxis/blueprint.rb +357 -0
- data/lib/praxis/bootloader.rb +9 -3
- data/lib/praxis/bootloader_stages/environment.rb +16 -13
- data/lib/praxis/collection.rb +1 -11
- data/lib/praxis/config_hash.rb +44 -0
- data/lib/praxis/docs/{openapi → open_api}/info_object.rb +18 -10
- data/lib/praxis/docs/{openapi → open_api}/media_type_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/operation_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/parameter_object.rb +2 -2
- data/lib/praxis/docs/{openapi → open_api}/paths_object.rb +12 -15
- data/lib/praxis/docs/{openapi → open_api}/request_body_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/response_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/responses_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/schema_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/server_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/tag_object.rb +0 -0
- data/lib/praxis/docs/open_api_generator.rb +91 -6
- data/lib/praxis/endpoint_definition.rb +273 -0
- data/lib/praxis/extensions/attribute_filtering/active_record_filter_query_builder.rb +57 -8
- data/lib/praxis/extensions/attribute_filtering/filtering_params.rb +3 -16
- data/lib/praxis/extensions/attribute_filtering/sequel_filter_query_builder.rb +20 -8
- data/lib/praxis/extensions/field_expansion.rb +3 -36
- data/lib/praxis/extensions/pagination.rb +5 -32
- data/lib/praxis/extensions/pagination/ordering_params.rb +5 -1
- data/lib/praxis/extensions/pagination/pagination_params.rb +10 -4
- data/lib/praxis/field_expander.rb +90 -0
- data/lib/praxis/finalizable.rb +34 -0
- data/lib/praxis/mapper/active_model_compat.rb +4 -0
- data/lib/praxis/mapper/resource.rb +18 -2
- data/lib/praxis/mapper/selector_generator.rb +2 -1
- data/lib/praxis/mapper/sequel_compat.rb +7 -0
- data/lib/praxis/media_type.rb +3 -68
- data/lib/praxis/plugin_concern.rb +1 -1
- data/lib/praxis/plugins/mapper_plugin.rb +24 -15
- data/lib/praxis/plugins/pagination_plugin.rb +34 -4
- data/lib/praxis/renderer.rb +88 -0
- data/lib/praxis/request.rb +1 -1
- data/lib/praxis/resource_definition.rb +2 -311
- data/lib/praxis/response_definition.rb +2 -10
- data/lib/praxis/response_template.rb +3 -3
- data/lib/praxis/router.rb +2 -2
- data/lib/praxis/routing_config.rb +1 -1
- data/lib/praxis/tasks/api_docs.rb +17 -64
- data/lib/praxis/tasks/routes.rb +2 -2
- data/lib/praxis/types/media_type_common.rb +1 -11
- data/lib/praxis/version.rb +1 -1
- data/praxis.gemspec +0 -1
- data/spec/functional_spec.rb +5 -9
- data/spec/praxis/action_definition_spec.rb +12 -20
- data/spec/praxis/blueprint_spec.rb +373 -0
- data/spec/praxis/bootloader_spec.rb +10 -2
- data/spec/praxis/collection_spec.rb +0 -13
- data/spec/praxis/config_hash_spec.rb +64 -0
- data/spec/praxis/{resource_definition_spec.rb → endpoint_definition_spec.rb} +37 -64
- data/spec/praxis/extensions/attribute_filtering/active_record_filter_query_builder_spec.rb +19 -8
- data/spec/praxis/extensions/attribute_filtering/filtering_params_spec.rb +106 -0
- data/spec/praxis/extensions/field_expansion_spec.rb +5 -24
- data/spec/praxis/extensions/field_selection/active_record_query_selector_spec.rb +1 -1
- data/spec/praxis/extensions/field_selection/sequel_query_selector_spec.rb +1 -1
- data/spec/praxis/extensions/support/spec_resources_active_model.rb +1 -1
- data/spec/praxis/field_expander_spec.rb +149 -0
- data/spec/praxis/mapper/selector_generator_spec.rb +1 -1
- data/spec/praxis/media_type_identifier_spec.rb +5 -4
- data/spec/praxis/media_type_spec.rb +4 -93
- data/spec/praxis/renderer_spec.rb +188 -0
- data/spec/praxis/response_definition_spec.rb +0 -31
- data/spec/praxis/response_spec.rb +1 -1
- data/spec/praxis/router_spec.rb +8 -8
- data/spec/praxis/routing_config_spec.rb +3 -3
- data/spec/spec_app/app/controllers/instances.rb +13 -7
- data/spec/spec_app/design/media_types/instance.rb +1 -19
- data/spec/spec_app/design/media_types/volume.rb +1 -1
- data/spec/spec_app/design/media_types/volume_snapshot.rb +2 -14
- data/spec/spec_app/design/resources/instances.rb +5 -8
- data/spec/spec_app/design/resources/volume_snapshots.rb +1 -1
- data/spec/spec_app/design/resources/volumes.rb +1 -1
- data/spec/support/spec_authorization_plugin.rb +1 -1
- data/spec/support/spec_blueprints.rb +72 -0
- data/spec/support/{spec_resource_definitions.rb → spec_endpoint_definitions.rb} +2 -2
- data/spec/support/spec_media_types.rb +6 -26
- data/tasks/thor/app.rb +8 -34
- data/tasks/thor/example.rb +51 -285
- data/tasks/thor/model.rb +40 -0
- data/tasks/thor/scaffold.rb +117 -0
- data/tasks/thor/templates/generator/empty_app/.gitignore +0 -1
- data/tasks/thor/templates/generator/empty_app/Gemfile +7 -23
- data/tasks/thor/templates/generator/empty_app/README.md +1 -1
- data/tasks/thor/templates/generator/empty_app/Rakefile +4 -13
- data/tasks/thor/templates/generator/empty_app/{design/response_templates → app/v1/resources}/.empty_directory +0 -0
- data/tasks/thor/templates/generator/empty_app/{design/response_templates → app/v1/resources}/.gitkeep +0 -0
- data/tasks/thor/templates/generator/empty_app/config/environment.rb +26 -17
- data/tasks/thor/templates/generator/empty_app/{design/v1/resources → config/initializers}/.empty_directory +0 -0
- data/tasks/thor/templates/generator/empty_app/{design/v1/resources → config/initializers}/.gitkeep +0 -0
- data/tasks/thor/templates/generator/empty_app/design/v1/endpoints/.empty_directory +0 -0
- data/tasks/thor/templates/generator/empty_app/design/v1/endpoints/.gitkeep +0 -0
- data/tasks/thor/templates/generator/empty_app/docs/.empty_directory +0 -0
- data/tasks/thor/templates/generator/empty_app/docs/.gitkeep +0 -0
- data/tasks/thor/templates/generator/empty_app/spec/spec_helper.rb +14 -9
- data/tasks/thor/templates/generator/example_app/.gitignore +1 -0
- data/tasks/thor/templates/generator/example_app/Gemfile +19 -0
- data/tasks/thor/templates/generator/example_app/Rakefile +61 -0
- data/tasks/thor/templates/generator/example_app/app/models/user.rb +6 -0
- data/tasks/thor/templates/generator/example_app/app/v1/concerns/controller_base.rb +24 -0
- data/tasks/thor/templates/generator/example_app/app/v1/controllers/users.rb +17 -0
- data/tasks/thor/templates/generator/example_app/app/v1/resources/base.rb +11 -0
- data/tasks/thor/templates/generator/example_app/app/v1/resources/user.rb +25 -0
- data/tasks/thor/templates/generator/example_app/config.ru +30 -0
- data/tasks/thor/templates/generator/example_app/config/environment.rb +41 -0
- data/tasks/thor/templates/generator/example_app/db/migrate/20201010101010_create_users_table.rb +12 -0
- data/tasks/thor/templates/generator/example_app/db/seeds.rb +6 -0
- data/tasks/thor/templates/generator/example_app/design/api.rb +18 -0
- data/tasks/thor/templates/generator/example_app/design/v1/endpoints/users.rb +37 -0
- data/tasks/thor/templates/generator/example_app/design/v1/media_types/user.rb +21 -0
- data/tasks/thor/templates/generator/example_app/spec/helpers/database_helper.rb +20 -0
- data/tasks/thor/templates/generator/example_app/spec/spec_helper.rb +42 -0
- data/tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb +37 -0
- data/tasks/thor/templates/generator/scaffold/design/endpoints/collection.rb +98 -0
- data/tasks/thor/templates/generator/scaffold/design/media_types/item.rb +18 -0
- data/tasks/thor/templates/generator/scaffold/implementation/controllers/collection.rb +77 -0
- data/tasks/thor/templates/generator/scaffold/implementation/resources/base.rb +11 -0
- data/tasks/thor/templates/generator/scaffold/implementation/resources/item.rb +45 -0
- data/tasks/thor/templates/generator/scaffold/models/active_record.rb +6 -0
- data/tasks/thor/templates/generator/scaffold/models/sequel.rb +6 -0
- metadata +62 -136
- data/lib/api_browser/.bowerrc +0 -3
- data/lib/api_browser/.editorconfig +0 -21
- data/lib/api_browser/Gruntfile.js +0 -581
- data/lib/api_browser/app/index.html +0 -59
- data/lib/api_browser/app/js/app.js +0 -48
- data/lib/api_browser/app/js/controllers/action.js +0 -47
- data/lib/api_browser/app/js/controllers/controller.js +0 -10
- data/lib/api_browser/app/js/controllers/menu.js +0 -93
- data/lib/api_browser/app/js/controllers/trait.js +0 -10
- data/lib/api_browser/app/js/controllers/type.js +0 -24
- data/lib/api_browser/app/js/directives/attribute_description.js +0 -56
- data/lib/api_browser/app/js/directives/attribute_table.js +0 -28
- data/lib/api_browser/app/js/directives/conditional_requirements.js +0 -13
- data/lib/api_browser/app/js/directives/fixed_if_fits.js +0 -38
- data/lib/api_browser/app/js/directives/highlight.js +0 -14
- data/lib/api_browser/app/js/directives/menu_item.js +0 -59
- data/lib/api_browser/app/js/directives/no_container.js +0 -8
- data/lib/api_browser/app/js/directives/readable_list.js +0 -87
- data/lib/api_browser/app/js/directives/request_examples.js +0 -31
- data/lib/api_browser/app/js/directives/type_placeholder.js +0 -30
- data/lib/api_browser/app/js/directives/url.js +0 -15
- data/lib/api_browser/app/js/factories/Configuration.js +0 -12
- data/lib/api_browser/app/js/factories/Documentation.js +0 -61
- data/lib/api_browser/app/js/factories/Example.js +0 -51
- data/lib/api_browser/app/js/factories/PageInfo.js +0 -9
- data/lib/api_browser/app/js/factories/normalize_attributes.js +0 -20
- data/lib/api_browser/app/js/factories/prepare_template.js +0 -15
- data/lib/api_browser/app/js/factories/template_for.js +0 -128
- data/lib/api_browser/app/js/filters/attribute_name.js +0 -10
- data/lib/api_browser/app/js/filters/friendly_json.js +0 -5
- data/lib/api_browser/app/js/filters/has_requirement.js +0 -14
- data/lib/api_browser/app/js/filters/header_info.js +0 -9
- data/lib/api_browser/app/js/filters/is_empty.js +0 -8
- data/lib/api_browser/app/js/filters/markdown.js +0 -6
- data/lib/api_browser/app/js/filters/resource_name.js +0 -5
- data/lib/api_browser/app/js/filters/tag_requirement.js +0 -13
- data/lib/api_browser/app/sass/modules/_body.scss +0 -40
- data/lib/api_browser/app/sass/modules/_cloke.scss +0 -8
- data/lib/api_browser/app/sass/modules/_header.scss +0 -10
- data/lib/api_browser/app/sass/modules/_nav.scss +0 -7
- data/lib/api_browser/app/sass/modules/_sidebar.scss +0 -134
- data/lib/api_browser/app/sass/modules/_switch.scss +0 -55
- data/lib/api_browser/app/sass/modules/_table.scss +0 -13
- data/lib/api_browser/app/sass/praxis.scss +0 -70
- data/lib/api_browser/app/sass/variables/_bootstrap-variables.scss +0 -774
- data/lib/api_browser/app/views/action.html +0 -97
- data/lib/api_browser/app/views/builtin/field-selector.html +0 -24
- data/lib/api_browser/app/views/controller.html +0 -55
- data/lib/api_browser/app/views/directives/attribute_description.html +0 -2
- data/lib/api_browser/app/views/directives/attribute_description/default.html +0 -2
- data/lib/api_browser/app/views/directives/attribute_description/example.html +0 -13
- data/lib/api_browser/app/views/directives/attribute_description/headers.html +0 -8
- data/lib/api_browser/app/views/directives/attribute_description/member_options.html +0 -4
- data/lib/api_browser/app/views/directives/attribute_description/values.html +0 -14
- data/lib/api_browser/app/views/directives/attribute_table.html +0 -17
- data/lib/api_browser/app/views/directives/menu_item.html +0 -8
- data/lib/api_browser/app/views/directives/url.html +0 -3
- data/lib/api_browser/app/views/examples/general.html +0 -26
- data/lib/api_browser/app/views/home.html +0 -5
- data/lib/api_browser/app/views/layout.html +0 -8
- data/lib/api_browser/app/views/menu.html +0 -42
- data/lib/api_browser/app/views/navbar.html +0 -9
- data/lib/api_browser/app/views/trait.html +0 -13
- data/lib/api_browser/app/views/type.html +0 -6
- data/lib/api_browser/app/views/type/details.html +0 -33
- data/lib/api_browser/app/views/types/embedded/array.html +0 -2
- data/lib/api_browser/app/views/types/embedded/default.html +0 -12
- data/lib/api_browser/app/views/types/embedded/field-selector.html +0 -13
- data/lib/api_browser/app/views/types/embedded/links.html +0 -11
- data/lib/api_browser/app/views/types/embedded/requirements.html +0 -6
- data/lib/api_browser/app/views/types/embedded/single_req.html +0 -9
- data/lib/api_browser/app/views/types/embedded/struct.html +0 -14
- data/lib/api_browser/app/views/types/label/link.html +0 -1
- data/lib/api_browser/app/views/types/label/primitive.html +0 -1
- data/lib/api_browser/app/views/types/label/primitive_collection.html +0 -1
- data/lib/api_browser/app/views/types/label/type.html +0 -1
- data/lib/api_browser/app/views/types/label/type_collection.html +0 -1
- data/lib/api_browser/app/views/types/main/array.html +0 -22
- data/lib/api_browser/app/views/types/main/default.html +0 -23
- data/lib/api_browser/app/views/types/main/hash.html +0 -23
- data/lib/api_browser/app/views/types/standalone/array.html +0 -3
- data/lib/api_browser/app/views/types/standalone/default.html +0 -18
- data/lib/api_browser/app/views/types/standalone/struct.html +0 -2
- data/lib/api_browser/bower_template.json +0 -41
- data/lib/api_browser/package-lock.json +0 -7110
- data/lib/api_browser/package.json +0 -43
- data/lib/praxis/docs/generator.rb +0 -243
- data/lib/praxis/docs/link_builder.rb +0 -30
- data/lib/praxis/links.rb +0 -135
- data/lib/praxis/types/multipart.rb +0 -109
- data/spec/api_browser/directives/type_placeholder_spec.js +0 -134
- data/spec/api_browser/factories/configuration_spec.js +0 -32
- data/spec/api_browser/factories/documentation_spec.js +0 -100
- data/spec/api_browser/factories/normalize_attributes_spec.js +0 -92
- data/spec/api_browser/factories/template_for_spec.js +0 -67
- data/spec/api_browser/filters/attribute_name_spec.js +0 -23
- data/spec/praxis/types/multipart_spec.rb +0 -112
- data/tasks/thor/templates/generator/empty_app/.rspec +0 -1
- data/tasks/thor/templates/generator/empty_app/Guardfile +0 -3
- data/tasks/thor/templates/generator/empty_app/config/rainbows.rb +0 -57
- data/tasks/thor/templates/generator/empty_app/docs/app.js +0 -1
- data/tasks/thor/templates/generator/empty_app/docs/styles.scss +0 -3
@@ -443,37 +443,6 @@ describe Praxis::ResponseDefinition do
|
|
443
443
|
end
|
444
444
|
end
|
445
445
|
end
|
446
|
-
|
447
|
-
describe '#validate_parts!' do
|
448
|
-
context 'with legacy multipart response' do
|
449
|
-
subject(:response) { Praxis::Responses::Ok.new(status: response_status, headers: response_headers) }
|
450
|
-
|
451
|
-
let(:part) { Praxis::MultipartPart.new('done', {'Status' => 200, 'Content-Type' => 'application/special'},**{}) }
|
452
|
-
|
453
|
-
before do
|
454
|
-
response_definition.parts like: :ok, media_type: 'application/special'
|
455
|
-
response.add_part(part)
|
456
|
-
end
|
457
|
-
|
458
|
-
it 'validates each part' do
|
459
|
-
response_definition.parts
|
460
|
-
expect {
|
461
|
-
response_definition.validate_parts!(response)
|
462
|
-
}.to_not raise_error
|
463
|
-
end
|
464
|
-
|
465
|
-
context 'with invalid part' do
|
466
|
-
let(:part) { Praxis::MultipartPart.new('done', {'Status' => 200, "Location" => "somewhere"}) }
|
467
|
-
|
468
|
-
it 'validates' do
|
469
|
-
expect {
|
470
|
-
response_definition.validate_parts!(response)
|
471
|
-
}.to raise_error(Praxis::Exceptions::Validation)
|
472
|
-
end
|
473
|
-
|
474
|
-
end
|
475
|
-
end
|
476
|
-
end
|
477
446
|
end
|
478
447
|
|
479
448
|
end
|
data/spec/praxis/router_spec.rb
CHANGED
@@ -2,8 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Praxis::Router do
|
4
4
|
describe Praxis::Router::VersionMatcher do
|
5
|
-
let(:
|
6
|
-
let(:action){ double("action",
|
5
|
+
let(:endpoint_definition){ double("endpoint_definition", version_options: { using: [:header, :params] }) }
|
6
|
+
let(:action){ double("action", endpoint_definition: endpoint_definition ) }
|
7
7
|
let(:target){ double("target", action: action ) }
|
8
8
|
let(:args){ {version: "1.0"} }
|
9
9
|
subject(:matcher){ Praxis::Router::VersionMatcher.new(target,**args) }
|
@@ -80,8 +80,8 @@ describe Praxis::Router do
|
|
80
80
|
let(:target){ double('target') }
|
81
81
|
let(:verb_router){ double('verb_router') }
|
82
82
|
|
83
|
-
let(:
|
84
|
-
let(:action) { double('action',
|
83
|
+
let(:endpoint_definition) { double('endpoint_definition', version_options: {using: [:header, :params]} ) }
|
84
|
+
let(:action) { double('action', endpoint_definition: endpoint_definition) }
|
85
85
|
let(:target) { double('target', action: action) }
|
86
86
|
|
87
87
|
|
@@ -111,8 +111,8 @@ describe Praxis::Router do
|
|
111
111
|
let(:post_target_router){ double("POST target", call: router_response_for_post) }
|
112
112
|
let(:any_target_router){ double("ANY target", call: router_response_for_wildcard) }
|
113
113
|
|
114
|
-
let(:
|
115
|
-
let(:action) { double('action',
|
114
|
+
let(:endpoint_definition) { double('endpoint_definition', version_options: {using: [:header, :params]} ) }
|
115
|
+
let(:action) { double('action', endpoint_definition: endpoint_definition) }
|
116
116
|
let(:target) { double('target', action: action) }
|
117
117
|
|
118
118
|
before do
|
@@ -142,8 +142,8 @@ describe Praxis::Router do
|
|
142
142
|
end
|
143
143
|
|
144
144
|
context 'for routes with wildcards (a POST and a * route)' do
|
145
|
-
let(:
|
146
|
-
let(:action) { double('action',
|
145
|
+
let(:endpoint_definition) { double('endpoint_definition', version_options: {using: [:header, :params]} ) }
|
146
|
+
let(:action) { double('action', endpoint_definition: endpoint_definition) }
|
147
147
|
let(:target) { double('target', action: action) }
|
148
148
|
|
149
149
|
before do
|
@@ -2,16 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Praxis::RoutingConfig do
|
4
4
|
|
5
|
-
let(:
|
5
|
+
let(:endpoint_definition) do
|
6
6
|
Class.new do
|
7
|
-
include Praxis::
|
7
|
+
include Praxis::EndpointDefinition
|
8
8
|
def self.name; 'MyResource'; end
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
let(:routing_block) { Proc.new{} }
|
13
13
|
let(:base_path){ '' }
|
14
|
-
let(:default_route_prefix) { "/" +
|
14
|
+
let(:default_route_prefix) { "/" + endpoint_definition.name.split("::").last.underscore }
|
15
15
|
|
16
16
|
subject(:routing_config){ Praxis::RoutingConfig.new(base: base_path, &routing_block) }
|
17
17
|
|
@@ -68,7 +68,7 @@ class Instances < BaseClass
|
|
68
68
|
|
69
69
|
part_body = {
|
70
70
|
key: instance_id,
|
71
|
-
value: instance.render(
|
71
|
+
value: instance.render(fields: {id: true, name: true})
|
72
72
|
}
|
73
73
|
|
74
74
|
headers = {
|
@@ -78,7 +78,6 @@ class Instances < BaseClass
|
|
78
78
|
}
|
79
79
|
|
80
80
|
part = Praxis::MultipartPart.new(part_body, headers, name: instance_id)
|
81
|
-
|
82
81
|
response.body.push(part)
|
83
82
|
end
|
84
83
|
|
@@ -89,13 +88,20 @@ class Instances < BaseClass
|
|
89
88
|
def attach_file(id:, cloud_id:)
|
90
89
|
response.headers['Content-Type'] = 'application/json'
|
91
90
|
|
92
|
-
destination_path = request.payload
|
93
|
-
file = request.payload
|
94
|
-
|
91
|
+
destination_path = request.payload.part('destination_path').payload
|
92
|
+
file = request.payload.part('file')
|
93
|
+
file.payload.rewind # Ensure contents is at the beggining.
|
94
|
+
extra_part_names = request.payload.map(&:name) - ['destination_path', 'file']
|
95
|
+
extra_parts = extra_part_names.each_with_object({}) do |pname, hash|
|
96
|
+
hash[pname] = request.payload.part(pname).body
|
97
|
+
end
|
95
98
|
result = {
|
96
99
|
destination_path: destination_path,
|
97
|
-
|
98
|
-
|
100
|
+
name: file.name,
|
101
|
+
filename: file.filename,
|
102
|
+
type: file.content_type.to_s,
|
103
|
+
contents: file.payload.read,
|
104
|
+
options: extra_parts
|
99
105
|
}
|
100
106
|
|
101
107
|
response.body = JSON.pretty_generate(result)
|
@@ -16,26 +16,8 @@ class Instance < Praxis::MediaType
|
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
default_fieldset do
|
20
20
|
attribute :id
|
21
21
|
attribute :root_volume
|
22
22
|
end
|
23
|
-
|
24
|
-
view :link do
|
25
|
-
attribute :id
|
26
|
-
attribute :href
|
27
|
-
end
|
28
|
-
|
29
|
-
view :create do
|
30
|
-
attribute :id
|
31
|
-
attribute :name
|
32
|
-
end
|
33
|
-
|
34
|
-
view :extended, include_nil: true do
|
35
|
-
attribute :id
|
36
|
-
attribute :name
|
37
|
-
attribute :root_volume
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
23
|
end
|
@@ -6,16 +6,11 @@ class VolumeSnapshot < Praxis::MediaType
|
|
6
6
|
attribute :name, String, regexp: /snapshot-(\w+)/
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
default_fieldset do
|
10
10
|
attribute :id
|
11
11
|
attribute :name
|
12
12
|
end
|
13
13
|
|
14
|
-
view :link do
|
15
|
-
attribute :id
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
14
|
class CollectionSummary < Praxis::MediaType
|
20
15
|
identifier 'application/json'
|
21
16
|
|
@@ -25,18 +20,11 @@ class VolumeSnapshot < Praxis::MediaType
|
|
25
20
|
attribute :href, String
|
26
21
|
end
|
27
22
|
|
28
|
-
|
29
|
-
attribute :name
|
30
|
-
attribute :size
|
31
|
-
attribute :href
|
32
|
-
end
|
33
|
-
|
34
|
-
view :link do
|
23
|
+
default_fieldset do
|
35
24
|
attribute :name
|
36
25
|
attribute :size
|
37
26
|
attribute :href
|
38
27
|
end
|
39
|
-
|
40
28
|
end
|
41
29
|
|
42
30
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ApiResources
|
2
2
|
class Instances
|
3
|
-
include Praxis::
|
3
|
+
include Praxis::EndpointDefinition
|
4
4
|
|
5
5
|
media_type Instance
|
6
6
|
version '1.0'
|
@@ -119,13 +119,10 @@ module ApiResources
|
|
119
119
|
attribute :id
|
120
120
|
end
|
121
121
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
key 'file', Attributor::FileUpload, required: false
|
127
|
-
extra 'options'
|
128
|
-
end
|
122
|
+
payload Praxis::Types::MultipartArray do
|
123
|
+
part 'destination_path', String, required: true
|
124
|
+
file 'file', Attributor::Tempfile, required: false
|
125
|
+
part(/.*/, String) # Allows extra parts
|
129
126
|
end
|
130
127
|
|
131
128
|
response :ok, media_type: 'application/json'
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
class PersonBlueprint < Praxis::Blueprint
|
3
|
+
attributes do
|
4
|
+
attribute :name, String, example: /[:first_name:]/
|
5
|
+
attribute :email, String, example: proc { |person| "#{person.name}@example.com" }
|
6
|
+
|
7
|
+
attribute :age, Integer
|
8
|
+
|
9
|
+
attribute :full_name, FullName
|
10
|
+
attribute :aliases, Attributor::Collection.of(FullName)
|
11
|
+
|
12
|
+
attribute :address, AddressBlueprint, example: proc { |person, context| AddressBlueprint.example(context, resident: person) }
|
13
|
+
attribute :work_address, AddressBlueprint
|
14
|
+
|
15
|
+
attribute :prior_addresses, Attributor::Collection.of(AddressBlueprint)
|
16
|
+
attribute :parents do
|
17
|
+
attribute :father, String
|
18
|
+
attribute :mother, String
|
19
|
+
end
|
20
|
+
|
21
|
+
attribute :tags, Attributor::Collection.of(String)
|
22
|
+
attribute :href, String
|
23
|
+
attribute :alive, Attributor::Boolean, default: true
|
24
|
+
attribute :myself, PersonBlueprint
|
25
|
+
attribute :friends, Attributor::Collection.of(PersonBlueprint)
|
26
|
+
attribute :metadata, Attributor::Hash
|
27
|
+
end
|
28
|
+
|
29
|
+
default_fieldset do
|
30
|
+
attribute :name
|
31
|
+
attribute :full_name
|
32
|
+
attribute :address do
|
33
|
+
attribute :name
|
34
|
+
attribute :street
|
35
|
+
end
|
36
|
+
attribute :prior_addresses do
|
37
|
+
attribute :name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class AddressBlueprint < Praxis::Blueprint
|
43
|
+
attributes do
|
44
|
+
attribute :id, Integer
|
45
|
+
attribute :name, String
|
46
|
+
attribute :street, String
|
47
|
+
attribute :state, String, values: %w(OR CA)
|
48
|
+
|
49
|
+
attribute :resident, PersonBlueprint, example: proc { |address, context| PersonBlueprint.example(context, address: address) }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class FullName < Attributor::Model
|
54
|
+
attributes do
|
55
|
+
attribute :first, String, example: /[:first_name:]/
|
56
|
+
attribute :last, String, example: /[:last_name:]/
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class SimpleHash < Attributor::Model
|
61
|
+
attributes do
|
62
|
+
attribute :id, Integer
|
63
|
+
attribute :hash, Hash
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class SimpleHashCollection < Attributor::Model
|
68
|
+
attributes do
|
69
|
+
attribute :id, Integer
|
70
|
+
attribute :hash_collection, Attributor::Collection.of(Hash)
|
71
|
+
end
|
72
|
+
end
|
@@ -7,7 +7,7 @@ Praxis::ApiDefinition.define do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class PeopleResource
|
10
|
-
include Praxis::
|
10
|
+
include Praxis::EndpointDefinition
|
11
11
|
|
12
12
|
description 'People resource'
|
13
13
|
|
@@ -42,7 +42,7 @@ end
|
|
42
42
|
|
43
43
|
|
44
44
|
class AddressResource
|
45
|
-
include Praxis::
|
45
|
+
include Praxis::EndpointDefinition
|
46
46
|
|
47
47
|
description 'Address resource'
|
48
48
|
|
@@ -8,7 +8,7 @@ class Person < Praxis::MediaType
|
|
8
8
|
attribute :href, String, example: proc { |person| "/people/#{person.id}" }
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
default_fieldset do
|
12
12
|
attribute :id
|
13
13
|
attribute :name
|
14
14
|
end
|
@@ -20,7 +20,7 @@ class Person < Praxis::MediaType
|
|
20
20
|
attribute :size, Integer
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
default_fieldset do
|
24
24
|
attribute :href
|
25
25
|
end
|
26
26
|
|
@@ -47,7 +47,7 @@ class Address < Praxis::MediaType
|
|
47
47
|
attribute :fields, Praxis::Types::FieldSelector.for(Person)
|
48
48
|
end
|
49
49
|
|
50
|
-
|
50
|
+
default_fieldset do
|
51
51
|
attribute :id
|
52
52
|
attribute :name
|
53
53
|
attribute :owner
|
@@ -95,7 +95,7 @@ class Blog < Praxis::MediaType
|
|
95
95
|
|
96
96
|
end
|
97
97
|
|
98
|
-
|
98
|
+
default_fieldset do
|
99
99
|
attribute :id
|
100
100
|
attribute :href
|
101
101
|
attribute :name
|
@@ -105,12 +105,6 @@ class Blog < Praxis::MediaType
|
|
105
105
|
|
106
106
|
attribute :owner
|
107
107
|
end
|
108
|
-
|
109
|
-
view :overview do
|
110
|
-
attribute :id
|
111
|
-
attribute :name
|
112
|
-
attribute :description
|
113
|
-
end
|
114
108
|
end
|
115
109
|
|
116
110
|
|
@@ -147,7 +141,7 @@ class Post < Praxis::MediaType
|
|
147
141
|
end
|
148
142
|
end
|
149
143
|
|
150
|
-
|
144
|
+
default_fieldset do
|
151
145
|
attribute :id
|
152
146
|
attribute :href
|
153
147
|
|
@@ -198,25 +192,11 @@ class User < Praxis::MediaType
|
|
198
192
|
example: proc { |user,ctx| Post::CollectionSummary.example(ctx, href: "#{user.href}/posts") }
|
199
193
|
end
|
200
194
|
|
201
|
-
|
195
|
+
default_fieldset do
|
202
196
|
attribute :id
|
203
197
|
attribute :href
|
204
198
|
|
205
199
|
attribute :first
|
206
200
|
attribute :last
|
207
201
|
end
|
208
|
-
|
209
|
-
view :extended do
|
210
|
-
attribute :id
|
211
|
-
attribute :href
|
212
|
-
|
213
|
-
attribute :first
|
214
|
-
attribute :last
|
215
|
-
attribute :primary_blog, view: :overview
|
216
|
-
end
|
217
|
-
|
218
|
-
view :with_post_links do
|
219
|
-
attribute :id
|
220
|
-
attribute :posts, view: :link
|
221
|
-
end
|
222
202
|
end
|