praxis 0.16.1 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -1
- data/.ruby-version +1 -1
- data/.travis.yml +2 -1
- data/CHANGELOG.md +41 -0
- data/CONTRIBUTING.md +3 -0
- data/lib/api_browser/Gruntfile.js +20 -4
- data/lib/api_browser/app/bower_components/angular-mocks/.bower.json +6 -6
- data/lib/api_browser/app/bower_components/angular-mocks/README.md +11 -5
- data/lib/api_browser/app/bower_components/angular-mocks/angular-mocks.js +475 -216
- data/lib/api_browser/app/bower_components/angular-mocks/bower.json +2 -2
- data/lib/api_browser/app/bower_components/angular-mocks/ngAnimateMock.js +2 -0
- data/lib/api_browser/app/bower_components/angular-mocks/ngMock.js +2 -0
- data/lib/api_browser/app/bower_components/angular-mocks/ngMockE2E.js +2 -0
- data/lib/api_browser/app/bower_components/angular-mocks/package.json +1 -1
- data/lib/api_browser/app/bower_components/angular-sanitize/.bower.json +8 -8
- data/lib/api_browser/app/bower_components/angular-sanitize/README.md +19 -5
- data/lib/api_browser/app/bower_components/angular-sanitize/angular-sanitize.js +186 -127
- data/lib/api_browser/app/bower_components/angular-sanitize/angular-sanitize.min.js +12 -10
- data/lib/api_browser/app/bower_components/angular-sanitize/angular-sanitize.min.js.map +3 -3
- data/lib/api_browser/app/bower_components/angular-sanitize/bower.json +3 -2
- data/lib/api_browser/app/bower_components/angular-sanitize/index.js +2 -0
- data/lib/api_browser/app/bower_components/angular-sanitize/package.json +26 -0
- data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/.bower.json +15 -8
- data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/bower.json +11 -3
- data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/ui-bootstrap-csp.css +6 -0
- data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/ui-bootstrap-tpls.js +1177 -453
- data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/ui-bootstrap-tpls.min.js +4 -4
- data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/ui-bootstrap.js +1066 -404
- data/lib/api_browser/app/bower_components/angular-ui-bootstrap-bower/ui-bootstrap.min.js +3 -3
- data/lib/api_browser/app/bower_components/angular-ui-router/.bower.json +5 -6
- data/lib/api_browser/app/bower_components/angular-ui-router/CHANGELOG.md +208 -3
- data/lib/api_browser/app/bower_components/angular-ui-router/CONTRIBUTING.md +65 -0
- data/lib/api_browser/app/bower_components/angular-ui-router/LICENSE +1 -1
- data/lib/api_browser/app/bower_components/angular-ui-router/README.md +36 -71
- data/lib/api_browser/app/bower_components/angular-ui-router/api/angular-ui-router.d.ts +126 -0
- data/lib/api_browser/app/bower_components/angular-ui-router/bower.json +1 -1
- data/lib/api_browser/app/bower_components/angular-ui-router/release/angular-ui-router.js +1902 -755
- data/lib/api_browser/app/bower_components/angular-ui-router/release/angular-ui-router.min.js +2 -2
- data/lib/api_browser/app/bower_components/angular-ui-router/src/common.js +69 -23
- data/lib/api_browser/app/bower_components/angular-ui-router/src/resolve.js +15 -5
- data/lib/api_browser/app/bower_components/angular-ui-router/src/state.js +556 -295
- data/lib/api_browser/app/bower_components/angular-ui-router/src/stateDirectives.js +101 -42
- data/lib/api_browser/app/bower_components/angular-ui-router/src/stateFilters.js +6 -2
- data/lib/api_browser/app/bower_components/angular-ui-router/src/templateFactory.js +2 -2
- data/lib/api_browser/app/bower_components/angular-ui-router/src/urlMatcherFactory.js +822 -97
- data/lib/api_browser/app/bower_components/angular-ui-router/src/urlRouter.js +274 -120
- data/lib/api_browser/app/bower_components/angular-ui-router/src/viewDirective.js +33 -20
- data/lib/api_browser/app/bower_components/angular-ui-router/src/viewScroll.js +1 -1
- data/lib/api_browser/app/bower_components/angular/.bower.json +5 -5
- data/lib/api_browser/app/bower_components/angular/README.md +2 -5
- data/lib/api_browser/app/bower_components/angular/angular-csp.css +5 -8
- data/lib/api_browser/app/bower_components/angular/angular.js +12975 -6996
- data/lib/api_browser/app/bower_components/angular/angular.min.js +285 -213
- data/lib/api_browser/app/bower_components/angular/angular.min.js.gzip +0 -0
- data/lib/api_browser/app/bower_components/angular/angular.min.js.map +3 -3
- data/lib/api_browser/app/bower_components/angular/bower.json +1 -1
- data/lib/api_browser/app/bower_components/angular/index.js +2 -0
- data/lib/api_browser/app/bower_components/angular/package.json +2 -2
- data/lib/api_browser/app/bower_components/bootstrap-sass/.bower.json +31 -16
- data/lib/api_browser/app/bower_components/bootstrap-sass/CHANGELOG.md +108 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/CONTRIBUTING.md +55 -37
- data/lib/api_browser/app/bower_components/bootstrap-sass/README.md +147 -206
- data/lib/api_browser/app/bower_components/bootstrap-sass/bower.json +19 -8
- data/lib/api_browser/app/bower_components/bootstrap-sass/{dist/fonts → vendor/assets/fonts/bootstrap}/glyphicons-halflings-regular.eot +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{dist/fonts → vendor/assets/fonts/bootstrap}/glyphicons-halflings-regular.svg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{dist/fonts → vendor/assets/fonts/bootstrap}/glyphicons-halflings-regular.ttf +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{dist/fonts → vendor/assets/fonts/bootstrap}/glyphicons-halflings-regular.woff +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap.js +12 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{js → vendor/assets/javascripts/bootstrap}/affix.js +1 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/{js → vendor/assets/javascripts/bootstrap}/alert.js +1 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/{js → vendor/assets/javascripts/bootstrap}/button.js +11 -5
- data/lib/api_browser/app/bower_components/bootstrap-sass/{js → vendor/assets/javascripts/bootstrap}/carousel.js +5 -5
- data/lib/api_browser/app/bower_components/bootstrap-sass/{js → vendor/assets/javascripts/bootstrap}/collapse.js +1 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/{js → vendor/assets/javascripts/bootstrap}/dropdown.js +5 -5
- data/lib/api_browser/app/bower_components/bootstrap-sass/{js → vendor/assets/javascripts/bootstrap}/modal.js +1 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/{js → vendor/assets/javascripts/bootstrap}/popover.js +1 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/{js → vendor/assets/javascripts/bootstrap}/scrollspy.js +2 -2
- data/lib/api_browser/app/bower_components/bootstrap-sass/{js → vendor/assets/javascripts/bootstrap}/tab.js +1 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/{js → vendor/assets/javascripts/bootstrap}/tooltip.js +1 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/{js → vendor/assets/javascripts/bootstrap}/transition.js +1 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/vendor/assets/stylesheets/bootstrap.scss +1 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_alerts.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_badges.scss +6 -6
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_breadcrumbs.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_button-groups.scss +7 -33
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_buttons.scss +2 -5
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_carousel.scss +1 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_close.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_code.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_component-animations.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_dropdowns.scss +3 -8
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_forms.scss +11 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_glyphicons.scss +5 -5
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_grid.scss +12 -26
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_input-groups.scss +1 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_jumbotron.scss +8 -2
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_labels.scss +6 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_list-group.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_media.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_mixins.scss +38 -51
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_modals.scss +2 -5
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_navbar.scss +41 -53
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_navs.scss +0 -20
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_normalize.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_pager.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_pagination.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_panels.scss +11 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_popovers.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_print.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_progress-bars.scss +0 -12
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_responsive-utilities.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_scaffolding.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_tables.scss +5 -18
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_theme.scss +2 -2
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_thumbnails.scss +9 -3
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_tooltip.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_type.scss +54 -52
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_utilities.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_variables.scss +20 -11
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/_wells.scss +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/{lib → vendor/assets/stylesheets/bootstrap}/bootstrap.scss +0 -0
- data/lib/api_browser/app/bower_components/lodash/.bower.json +9 -13
- data/lib/api_browser/app/bower_components/lodash/LICENSE.txt +3 -3
- data/lib/api_browser/app/bower_components/lodash/bower.json +4 -7
- data/lib/api_browser/app/bower_components/lodash/lodash.js +12235 -0
- data/lib/api_browser/app/bower_components/lodash/lodash.min.js +98 -0
- data/lib/api_browser/app/index.html +0 -1
- data/lib/api_browser/app/js/app.js +2 -5
- data/lib/api_browser/app/js/controllers/action.js +21 -37
- data/lib/api_browser/app/js/controllers/controller.js +23 -1
- data/lib/api_browser/app/js/controllers/menu.js +46 -14
- data/lib/api_browser/app/js/controllers/type.js +2 -9
- data/lib/api_browser/app/js/directives/attribute_description.js +15 -5
- data/lib/api_browser/app/js/directives/attribute_table.js +6 -6
- data/lib/api_browser/app/js/directives/fixed_if_fits.js +20 -0
- data/lib/api_browser/app/js/directives/no_container.js +6 -6
- data/lib/api_browser/app/js/directives/type_placeholder.js +21 -0
- data/lib/api_browser/app/js/factories/Configuration.js +13 -0
- data/lib/api_browser/app/js/factories/Documentation.js +0 -3
- data/lib/api_browser/app/js/factories/normalize_attributes.js +19 -0
- data/lib/api_browser/app/js/factories/template_for.js +113 -0
- data/lib/api_browser/app/sass/modules/_body.scss +26 -4
- data/lib/api_browser/app/sass/modules/_sidebar.scss +68 -1
- data/lib/api_browser/app/sass/praxis.scss +1 -5
- data/lib/api_browser/app/sass/variables/_bootstrap-variables.scss +13 -4
- data/lib/api_browser/app/views/action.html +13 -17
- data/lib/api_browser/app/views/controller.html +32 -4
- data/lib/api_browser/app/views/directives/attribute_description.html +1 -1
- data/lib/api_browser/app/views/directives/attribute_description/{_default.html → default.html} +0 -0
- data/lib/api_browser/app/views/directives/attribute_description/example.html +13 -0
- data/lib/api_browser/app/views/directives/attribute_description/headers.html +8 -0
- data/lib/api_browser/app/views/directives/attribute_description/member_options.html +4 -0
- data/lib/api_browser/app/views/directives/attribute_description/values.html +14 -0
- data/lib/api_browser/app/views/directives/attribute_table.html +2 -2
- data/lib/api_browser/app/views/home.html +1 -3
- data/lib/api_browser/app/views/layout.html +3 -36
- data/lib/api_browser/app/views/menu.html +45 -0
- data/lib/api_browser/app/views/navbar.html +1 -1
- data/lib/api_browser/app/views/type.html +2 -2
- data/lib/api_browser/app/views/type/{_details.html → details.html} +6 -6
- data/lib/api_browser/app/views/types/embedded/default.html +10 -0
- data/lib/api_browser/app/views/types/embedded/links.html +11 -0
- data/lib/api_browser/app/views/types/embedded/struct.html +2 -0
- data/lib/api_browser/app/views/types/label/link.html +1 -0
- data/lib/api_browser/app/views/types/label/primitive.html +1 -0
- data/lib/api_browser/app/views/types/label/primitive_collection.html +1 -0
- data/lib/api_browser/app/views/types/label/type.html +1 -0
- data/lib/api_browser/app/views/types/label/type_collection.html +1 -0
- data/lib/api_browser/app/views/{directives/request_body/_default.html → types/standalone/default.html} +1 -1
- data/lib/api_browser/app/views/types/standalone/struct.html +1 -0
- data/lib/api_browser/bower.json +9 -9
- data/lib/api_browser/package.json +1 -1
- data/lib/praxis.rb +10 -4
- data/lib/praxis/action_definition.rb +16 -4
- data/lib/praxis/action_definition/headers_dsl_compiler.rb +5 -2
- data/lib/praxis/api_definition.rb +3 -1
- data/lib/praxis/api_general_info.rb +49 -5
- data/lib/praxis/application.rb +12 -4
- data/lib/praxis/bootloader.rb +1 -0
- data/lib/praxis/bootloader_stages/environment.rb +2 -0
- data/lib/praxis/bootloader_stages/routing.rb +1 -1
- data/lib/praxis/bootloader_stages/subgroup_loader.rb +1 -0
- data/lib/praxis/exceptions/validation.rb +7 -0
- data/lib/praxis/handlers/plain.rb +16 -0
- data/lib/praxis/handlers/xml.rb +4 -4
- data/lib/praxis/links.rb +13 -3
- data/lib/praxis/media_type_identifier.rb +3 -0
- data/lib/praxis/multipart/parser.rb +41 -48
- data/lib/praxis/multipart/part.rb +196 -3
- data/lib/praxis/request.rb +14 -11
- data/lib/praxis/request_stages/request_stage.rb +4 -0
- data/lib/praxis/request_stages/response.rb +10 -9
- data/lib/praxis/request_stages/validate.rb +1 -7
- data/lib/praxis/request_stages/validate_params_and_headers.rb +30 -5
- data/lib/praxis/request_stages/validate_payload.rb +14 -5
- data/lib/praxis/resource_definition.rb +117 -15
- data/lib/praxis/response.rb +6 -5
- data/lib/praxis/response_definition.rb +51 -5
- data/lib/praxis/responses/http.rb +5 -0
- data/lib/praxis/responses/multipart_ok.rb +51 -0
- data/lib/praxis/responses/validation_error.rb +7 -7
- data/lib/praxis/restful_doc_generator.rb +9 -4
- data/lib/praxis/route.rb +3 -2
- data/lib/praxis/router.rb +26 -16
- data/lib/praxis/router/rack.rb +51 -0
- data/lib/praxis/router/simple.rb +146 -0
- data/lib/praxis/routing_config.rb +2 -2
- data/lib/praxis/trait.rb +1 -1
- data/lib/praxis/types/fuzzy_hash.rb +49 -0
- data/lib/praxis/types/media_type_common.rb +1 -1
- data/lib/praxis/types/multipart.rb +47 -12
- data/lib/praxis/types/multipart_array.rb +320 -0
- data/lib/praxis/types/multipart_array/part_definition.rb +52 -0
- data/lib/praxis/validation_handler.rb +10 -0
- data/lib/praxis/version.rb +2 -2
- data/praxis.gemspec +3 -3
- data/spec/api_browser/directives/type_placeholder_spec.js +134 -0
- data/spec/api_browser/factories/normalize_attributes_spec.js +97 -0
- data/spec/api_browser/factories/template_for_spec.js +67 -0
- data/spec/functional_spec.rb +111 -45
- data/spec/praxis/action_definition_spec.rb +31 -7
- data/spec/praxis/api_definition_spec.rb +2 -2
- data/spec/praxis/api_general_info_spec.rb +25 -0
- data/spec/praxis/application_spec.rb +24 -11
- data/spec/praxis/handlers/xml_spec.rb +55 -33
- data/spec/praxis/links_spec.rb +18 -1
- data/spec/praxis/media_type_collection_spec.rb +1 -1
- data/spec/praxis/media_type_spec.rb +2 -2
- data/spec/praxis/multipart/parser_spec.rb +21 -13
- data/spec/praxis/plugins/praxis_mapper_plugin_spec.rb +1 -1
- data/spec/praxis/request_spec.rb +52 -24
- data/spec/praxis/{request_stages_action_spec.rb → request_stages/action_spec.rb} +1 -1
- data/spec/praxis/{request_stage_spec.rb → request_stages/request_stage_spec.rb} +0 -0
- data/spec/praxis/{request_stages_validate_spec.rb → request_stages/validate_spec.rb} +1 -1
- data/spec/praxis/resource_definition_spec.rb +30 -4
- data/spec/praxis/response_definition_spec.rb +60 -19
- data/spec/praxis/response_spec.rb +2 -2
- data/spec/praxis/responses/validation_error_spec.rb +33 -16
- data/spec/praxis/route_spec.rb +4 -2
- data/spec/praxis/router_spec.rb +28 -12
- data/spec/praxis/routing_config_spec.rb +11 -5
- data/spec/praxis/types/collection_spec.rb +1 -1
- data/spec/praxis/types/fuzzy_hash_spec.rb +20 -0
- data/spec/praxis/types/multipart_array/part_definition_spec.rb +5 -0
- data/spec/praxis/types/multipart_array_spec.rb +334 -0
- data/spec/praxis/types/multipart_spec.rb +14 -5
- data/spec/spec_app/app/controllers/instances.rb +20 -10
- data/spec/spec_app/app/controllers/volumes.rb +8 -4
- data/spec/spec_app/app/responses/bulk_response.rb +0 -6
- data/spec/spec_app/config/environment.rb +13 -0
- data/spec/spec_app/design/api.rb +7 -10
- data/spec/spec_app/design/media_types/instance.rb +3 -1
- data/spec/spec_app/design/resources/instances.rb +50 -41
- data/spec/spec_app/design/resources/volume_snapshots.rb +39 -0
- data/spec/spec_app/design/resources/volumes.rb +11 -6
- data/spec/spec_helper.rb +3 -1
- metadata +125 -218
- data/lib/api_browser/app/bower_components/angular-ui-router/src/compat.js +0 -146
- data/lib/api_browser/app/bower_components/bootstrap-sass/CNAME +0 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/DOCS-LICENSE +0 -319
- data/lib/api_browser/app/bower_components/bootstrap-sass/Gemfile +0 -5
- data/lib/api_browser/app/bower_components/bootstrap-sass/Gemfile.lock +0 -14
- data/lib/api_browser/app/bower_components/bootstrap-sass/Gruntfile.js +0 -244
- data/lib/api_browser/app/bower_components/bootstrap-sass/LICENSE +0 -176
- data/lib/api_browser/app/bower_components/bootstrap-sass/LICENSE-MIT +0 -21
- data/lib/api_browser/app/bower_components/bootstrap-sass/Rakefile +0 -44
- data/lib/api_browser/app/bower_components/bootstrap-sass/_config.yml +0 -25
- data/lib/api_browser/app/bower_components/bootstrap-sass/_includes/ads.html +0 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/_includes/footer.html +0 -34
- data/lib/api_browser/app/bower_components/bootstrap-sass/_includes/header.html +0 -42
- data/lib/api_browser/app/bower_components/bootstrap-sass/_includes/nav-about.html +0 -12
- data/lib/api_browser/app/bower_components/bootstrap-sass/_includes/nav-components.html +0 -137
- data/lib/api_browser/app/bower_components/bootstrap-sass/_includes/nav-css.html +0 -99
- data/lib/api_browser/app/bower_components/bootstrap-sass/_includes/nav-customize.html +0 -40
- data/lib/api_browser/app/bower_components/bootstrap-sass/_includes/nav-getting-started.html +0 -44
- data/lib/api_browser/app/bower_components/bootstrap-sass/_includes/nav-javascript.html +0 -88
- data/lib/api_browser/app/bower_components/bootstrap-sass/_includes/nav-main.html +0 -37
- data/lib/api_browser/app/bower_components/bootstrap-sass/_includes/old-bs-docs.html +0 -8
- data/lib/api_browser/app/bower_components/bootstrap-sass/_includes/social-buttons.html +0 -16
- data/lib/api_browser/app/bower_components/bootstrap-sass/_layouts/default.html +0 -79
- data/lib/api_browser/app/bower_components/bootstrap-sass/_layouts/home.html +0 -47
- data/lib/api_browser/app/bower_components/bootstrap-sass/about.html +0 -93
- data/lib/api_browser/app/bower_components/bootstrap-sass/browserstack.json +0 -37
- data/lib/api_browser/app/bower_components/bootstrap-sass/components.html +0 -3689
- data/lib/api_browser/app/bower_components/bootstrap-sass/composer.json +0 -28
- data/lib/api_browser/app/bower_components/bootstrap-sass/css.html +0 -2674
- data/lib/api_browser/app/bower_components/bootstrap-sass/customize.html +0 -1715
- data/lib/api_browser/app/bower_components/bootstrap-sass/dist/css/bootstrap-theme.css +0 -427
- data/lib/api_browser/app/bower_components/bootstrap-sass/dist/css/bootstrap-theme.min.css +0 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/dist/css/bootstrap.css +0 -6350
- data/lib/api_browser/app/bower_components/bootstrap-sass/dist/css/bootstrap.min.css +0 -1
- data/lib/api_browser/app/bower_components/bootstrap-sass/dist/js/bootstrap.js +0 -2002
- data/lib/api_browser/app/bower_components/bootstrap-sass/dist/js/bootstrap.min.js +0 -9
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/css/docs.css +0 -1195
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/css/pygments-manni.css +0 -66
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/ico/apple-touch-icon-144-precomposed.png +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/ico/favicon.png +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/js/application.js +0 -103
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/js/customizer.js +0 -332
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/js/filesaver.js +0 -169
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/js/holder.js +0 -404
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/js/ie8-responsive-file-warning.js +0 -12
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/js/jszip.js +0 -1467
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/js/less.js +0 -9
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/js/raw-files.js +0 -3
- data/lib/api_browser/app/bower_components/bootstrap-sass/docs-assets/js/uglify.js +0 -14
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/carousel/carousel.css +0 -148
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/carousel/index.html +0 -206
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/grid/grid.css +0 -28
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/grid/index.html +0 -148
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/jumbotron-narrow/index.html +0 -82
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/jumbotron-narrow/jumbotron-narrow.css +0 -79
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/jumbotron/index.html +0 -99
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/jumbotron/jumbotron.css +0 -5
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/justified-nav/index.html +0 -83
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/justified-nav/justified-nav.css +0 -88
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/navbar-fixed-top/index.html +0 -91
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/navbar-fixed-top/navbar-fixed-top.css +0 -4
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/navbar-static-top/index.html +0 -92
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/navbar-static-top/navbar-static-top.css +0 -7
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/navbar/index.html +0 -88
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/navbar/navbar.css +0 -8
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/non-responsive/index.html +0 -101
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/non-responsive/non-responsive.css +0 -116
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/offcanvas/index.html +0 -130
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/offcanvas/offcanvas.css +0 -50
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/offcanvas/offcanvas.js +0 -5
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/carousel.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/grid.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/jumbotron-narrow.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/jumbotron.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/justified-nav.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/navbar-fixed.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/navbar-static.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/navbar.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/non-responsive.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/offcanvas.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/sign-in.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/starter-template.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/sticky-footer-navbar.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/sticky-footer.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/screenshots/theme.jpg +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/signin/index.html +0 -50
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/signin/signin.css +0 -40
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/starter-template/index.html +0 -68
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/starter-template/starter-template.css +0 -7
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/sticky-footer-navbar/index.html +0 -91
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/sticky-footer-navbar/sticky-footer-navbar.css +0 -45
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/sticky-footer/index.html +0 -55
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/sticky-footer/sticky-footer.css +0 -38
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/theme/index.html +0 -384
- data/lib/api_browser/app/bower_components/bootstrap-sass/examples/theme/theme.css +0 -14
- data/lib/api_browser/app/bower_components/bootstrap-sass/fonts/glyphicons-halflings-regular.eot +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/fonts/glyphicons-halflings-regular.svg +0 -229
- data/lib/api_browser/app/bower_components/bootstrap-sass/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/fonts/glyphicons-halflings-regular.woff +0 -0
- data/lib/api_browser/app/bower_components/bootstrap-sass/getting-started.html +0 -1021
- data/lib/api_browser/app/bower_components/bootstrap-sass/index.html +0 -16
- data/lib/api_browser/app/bower_components/bootstrap-sass/javascript.html +0 -1983
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/index.html +0 -52
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/affix.js +0 -25
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/alert.js +0 -62
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/button.js +0 -116
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/carousel.js +0 -87
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/collapse.js +0 -164
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/dropdown.js +0 -219
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/modal.js +0 -196
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/phantom.js +0 -69
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/popover.js +0 -133
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/scrollspy.js +0 -37
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/tab.js +0 -86
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/tooltip.js +0 -437
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/unit/transition.js +0 -13
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/vendor/jquery.js +0 -6
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/vendor/qunit.css +0 -232
- data/lib/api_browser/app/bower_components/bootstrap-sass/js/tests/vendor/qunit.js +0 -1510
- data/lib/api_browser/app/bower_components/bootstrap-sass/package.json +0 -40
- data/lib/api_browser/app/bower_components/lodash/dist/lodash.compat.js +0 -7157
- data/lib/api_browser/app/bower_components/lodash/dist/lodash.compat.min.js +0 -61
- data/lib/api_browser/app/bower_components/lodash/dist/lodash.js +0 -6785
- data/lib/api_browser/app/bower_components/lodash/dist/lodash.min.js +0 -56
- data/lib/api_browser/app/bower_components/lodash/dist/lodash.underscore.js +0 -4979
- data/lib/api_browser/app/bower_components/lodash/dist/lodash.underscore.min.js +0 -39
- data/lib/api_browser/app/js/directives/attribute_table_row.js +0 -17
- data/lib/api_browser/app/js/directives/request_body.js +0 -25
- data/lib/api_browser/app/js/directives/request_headers.js +0 -17
- data/lib/api_browser/app/js/directives/request_parameters.js +0 -17
- data/lib/api_browser/app/js/directives/type_label.js +0 -52
- data/lib/api_browser/app/js/factories/PayloadTemplates.js +0 -10
- data/lib/api_browser/app/js/factories/TemplateProvider.js +0 -45
- data/lib/api_browser/app/js/factories/TypeTemplates.js +0 -11
- 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_table_row/_default.html +0 -10
- data/lib/api_browser/app/views/directives/attribute_table_row/_links.html +0 -11
- data/lib/api_browser/app/views/directives/attribute_table_row/_struct.html +0 -2
- data/lib/api_browser/app/views/directives/request_body/_struct.html +0 -1
- data/lib/api_browser/app/views/resource/_actions.html +0 -27
data/lib/praxis/request.rb
CHANGED
@@ -18,7 +18,6 @@ module Praxis
|
|
18
18
|
@env = env
|
19
19
|
@query = Rack::Utils.parse_nested_query(env[QUERY_STRING_NAME])
|
20
20
|
@route_params = {}
|
21
|
-
@path_version_matcher = path_version_matcher
|
22
21
|
end
|
23
22
|
|
24
23
|
# Determine the content type of this request as indicated by the Content-Type header.
|
@@ -83,23 +82,29 @@ module Praxis
|
|
83
82
|
PATH_VERSION_PREFIX
|
84
83
|
end
|
85
84
|
|
85
|
+
# DEPRECATED: remove with ResourceDefinition.version using: :path
|
86
86
|
PATH_VERSION_MATCHER = %r{^#{self.path_version_prefix}(?<version>[^\/]+)\/}.freeze
|
87
87
|
|
88
88
|
def path_version_matcher
|
89
|
-
|
89
|
+
if Application.instance.versioning_scheme == :path
|
90
|
+
matcher = Mustermann.new(ApiDefinition.instance.info.base_path + '*')
|
91
|
+
matcher.params(self.path)[API_VERSION_PARAM_NAME]
|
92
|
+
else
|
93
|
+
PATH_VERSION_MATCHER.match(self.path)[:version]
|
94
|
+
end
|
90
95
|
end
|
91
96
|
|
92
|
-
def version
|
97
|
+
def version
|
93
98
|
result = nil
|
94
|
-
|
99
|
+
|
100
|
+
Array(Application.instance.versioning_scheme).find do |mode|
|
95
101
|
case mode
|
96
102
|
when :header;
|
97
103
|
result = env[API_VERSION_HEADER_NAME]
|
98
104
|
when :params;
|
99
105
|
result = @query[API_VERSION_PARAM_NAME]
|
100
106
|
when :path;
|
101
|
-
|
102
|
-
result = m[:version] unless m.nil?
|
107
|
+
result = self.path_version_matcher
|
103
108
|
else
|
104
109
|
raise "Unknown method for retrieving the API version: #{mode}"
|
105
110
|
end
|
@@ -124,13 +129,11 @@ module Praxis
|
|
124
129
|
return unless action.payload
|
125
130
|
return if content_type.nil?
|
126
131
|
|
127
|
-
handler = Praxis::Application.instance.handlers[content_type.handler_name]
|
128
|
-
|
129
|
-
if handler
|
130
|
-
raw = handler.parse(self.raw_payload)
|
132
|
+
raw = if (handler = Praxis::Application.instance.handlers[content_type.handler_name])
|
133
|
+
handler.parse(self.raw_payload)
|
131
134
|
else
|
132
135
|
# TODO is this a good default?
|
133
|
-
|
136
|
+
self.raw_payload
|
134
137
|
end
|
135
138
|
|
136
139
|
self.payload = action.payload.load(raw, context, content_type: content_type.to_s)
|
@@ -2,24 +2,25 @@ module Praxis
|
|
2
2
|
module RequestStages
|
3
3
|
|
4
4
|
class Response < RequestStage
|
5
|
-
WHITELIST_RESPONSES = [:validation_error]
|
6
5
|
|
7
6
|
def execute
|
8
7
|
response = controller.response
|
9
8
|
|
10
|
-
unless action.responses.include?(response.response_name) || WHITELIST_RESPONSES.include?(response.response_name)
|
11
|
-
raise Exceptions::InvalidResponse.new(
|
12
|
-
"Response #{response.name.inspect} is not allowed for #{action.name.inspect}"
|
13
|
-
)
|
14
|
-
end
|
15
|
-
|
16
9
|
response.handle
|
17
10
|
|
18
11
|
if Application.instance.config.praxis.validate_responses == true
|
19
|
-
|
12
|
+
validate_body = Application.instance.config.praxis.validate_response_bodies
|
13
|
+
|
14
|
+
response.validate(action, validate_body: validate_body)
|
20
15
|
end
|
21
16
|
rescue Exceptions::Validation => e
|
22
|
-
controller.response =
|
17
|
+
controller.response = validation_handler.handle!(
|
18
|
+
summary: "Error validating response",
|
19
|
+
exception: e,
|
20
|
+
request: request,
|
21
|
+
stage: name,
|
22
|
+
errors: e.errors
|
23
|
+
)
|
23
24
|
retry
|
24
25
|
end
|
25
26
|
|
@@ -8,16 +8,10 @@ module Praxis
|
|
8
8
|
# Add our sub-stages
|
9
9
|
@stages = [
|
10
10
|
RequestStages::ValidateParamsAndHeaders.new(:params_and_headers, context, parent: self),
|
11
|
-
RequestStages::ValidatePayload.new(:payload, context, parent: self)
|
11
|
+
RequestStages::ValidatePayload.new(:payload, context, parent: self)
|
12
12
|
]
|
13
13
|
end
|
14
14
|
|
15
|
-
def execute
|
16
|
-
super
|
17
|
-
rescue Attributor::AttributorException => e
|
18
|
-
return Responses::ValidationError.new(exception: e)
|
19
|
-
end
|
20
|
-
|
21
15
|
end
|
22
16
|
|
23
17
|
end
|
@@ -9,14 +9,34 @@ module Praxis
|
|
9
9
|
@parent = parent
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
12
|
def path
|
14
13
|
@_path ||= ( @parent.path + [name] )
|
15
14
|
end
|
16
15
|
|
17
16
|
def execute
|
18
|
-
|
19
|
-
|
17
|
+
begin
|
18
|
+
request.load_headers(CONTEXT_FOR[:headers])
|
19
|
+
rescue => e
|
20
|
+
message = "Error loading headers."
|
21
|
+
return validation_handler.handle!(
|
22
|
+
exception: e,
|
23
|
+
summary: message,
|
24
|
+
request: request,
|
25
|
+
stage: name
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
request.load_params(CONTEXT_FOR[:params])
|
31
|
+
rescue Attributor::AttributorException => e
|
32
|
+
message = "Error loading params."
|
33
|
+
return validation_handler.handle!(
|
34
|
+
exception: e,
|
35
|
+
summary: message,
|
36
|
+
request: request,
|
37
|
+
stage: name
|
38
|
+
)
|
39
|
+
end
|
20
40
|
|
21
41
|
attribute_resolver = Attributor::AttributeResolver.new
|
22
42
|
Attributor::AttributeResolver.current = attribute_resolver
|
@@ -26,9 +46,14 @@ module Praxis
|
|
26
46
|
|
27
47
|
errors = request.validate_headers(CONTEXT_FOR[:headers])
|
28
48
|
errors += request.validate_params(CONTEXT_FOR[:params])
|
29
|
-
|
30
49
|
if errors.any?
|
31
|
-
|
50
|
+
message = "Error validating request data."
|
51
|
+
return validation_handler.handle!(
|
52
|
+
summary: message,
|
53
|
+
errors: errors,
|
54
|
+
request: request,
|
55
|
+
stage: name
|
56
|
+
)
|
32
57
|
end
|
33
58
|
end
|
34
59
|
|
@@ -18,16 +18,25 @@ module Praxis
|
|
18
18
|
if request.action.payload
|
19
19
|
begin
|
20
20
|
request.load_payload(CONTEXT_FOR[:payload])
|
21
|
-
rescue
|
22
|
-
message =
|
23
|
-
|
24
|
-
|
21
|
+
rescue => e
|
22
|
+
message = "Error loading payload. Used Content-Type: '#{request.content_type}'"
|
23
|
+
return validation_handler.handle!(
|
24
|
+
exception: e,
|
25
|
+
summary: message,
|
26
|
+
request: request,
|
27
|
+
stage: name
|
28
|
+
)
|
25
29
|
end
|
26
30
|
Attributor::AttributeResolver.current.register("payload",request.payload)
|
27
31
|
|
28
32
|
errors = request.validate_payload(CONTEXT_FOR[:payload])
|
29
33
|
if errors.any?
|
30
|
-
return
|
34
|
+
return validation_handler.handle!(
|
35
|
+
summary: "Errors validating payload data",
|
36
|
+
errors: errors,
|
37
|
+
request: request,
|
38
|
+
stage: name
|
39
|
+
)
|
31
40
|
end
|
32
41
|
end
|
33
42
|
end
|
@@ -4,6 +4,7 @@ require 'active_support/inflector'
|
|
4
4
|
module Praxis
|
5
5
|
module ResourceDefinition
|
6
6
|
extend ActiveSupport::Concern
|
7
|
+
|
7
8
|
DEFAULT_RESOURCE_HREF_ACTION = :show
|
8
9
|
|
9
10
|
included do
|
@@ -11,34 +12,62 @@ module Praxis
|
|
11
12
|
@actions = Hash.new
|
12
13
|
@responses = Hash.new
|
13
14
|
@action_defaults = Trait.new
|
15
|
+
|
14
16
|
@version_options = {}
|
15
17
|
@metadata = {}
|
16
18
|
@traits = []
|
17
19
|
|
18
20
|
if self.name
|
19
|
-
@
|
21
|
+
@prefix = '/' + self.name.split("::").last.underscore
|
20
22
|
else
|
21
|
-
@
|
23
|
+
@prefix = '/'
|
22
24
|
end
|
23
25
|
|
24
26
|
@version_prefix = ''
|
25
27
|
|
28
|
+
@parent = nil
|
29
|
+
@parent_prefix = ''
|
30
|
+
|
31
|
+
@routing_prefix = nil
|
32
|
+
|
33
|
+
@on_finalize = Array.new
|
34
|
+
|
26
35
|
Application.instance.resource_definitions << self
|
27
36
|
end
|
28
37
|
|
38
|
+
def self.finalize!
|
39
|
+
Application.instance.resource_definitions.each do |resource_definition|
|
40
|
+
|
41
|
+
while (block = resource_definition.on_finalize.shift)
|
42
|
+
block.call
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
29
49
|
module ClassMethods
|
30
50
|
attr_reader :actions
|
31
51
|
attr_reader :responses
|
32
52
|
attr_reader :version_options
|
33
53
|
attr_reader :traits
|
34
|
-
attr_reader :routing_prefix
|
35
54
|
attr_reader :version_prefix
|
55
|
+
attr_reader :parent_prefix
|
56
|
+
|
36
57
|
# opaque hash of user-defined medata, used to decorate the definition,
|
37
58
|
# and also available in the generated JSON documents
|
38
59
|
attr_reader :metadata
|
39
60
|
|
40
61
|
attr_accessor :controller
|
41
62
|
|
63
|
+
def on_finalize
|
64
|
+
if block_given?
|
65
|
+
@on_finalize << Proc.new
|
66
|
+
end
|
67
|
+
|
68
|
+
@on_finalize
|
69
|
+
end
|
70
|
+
|
42
71
|
# FIXME: this is inconsistent with the rest of the magic DSL convention.
|
43
72
|
def routing(&block)
|
44
73
|
warn "DEPRECATED: ResourceDefinition.routing is deprecated use prefix directly instead."
|
@@ -48,14 +77,13 @@ module Praxis
|
|
48
77
|
end
|
49
78
|
|
50
79
|
def prefix(prefix=nil)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
@routing_prefix
|
80
|
+
return @prefix if prefix.nil?
|
81
|
+
@routing_prefix = nil # reset routing_prefix
|
82
|
+
@prefix = prefix
|
55
83
|
end
|
56
84
|
|
57
85
|
def media_type(media_type=nil)
|
58
|
-
return @media_type
|
86
|
+
return @media_type if media_type.nil?
|
59
87
|
|
60
88
|
if media_type.kind_of?(String)
|
61
89
|
media_type = SimpleMediaType.new(media_type)
|
@@ -63,12 +91,81 @@ module Praxis
|
|
63
91
|
@media_type = media_type
|
64
92
|
end
|
65
93
|
|
94
|
+
|
95
|
+
def parent(parent=nil, **mapping)
|
96
|
+
return @parent if parent.nil?
|
97
|
+
|
98
|
+
@routing_prefix = nil # reset routing_prefix
|
99
|
+
|
100
|
+
parent_action = parent.canonical_path
|
101
|
+
parent_route = parent_action.primary_route.path
|
102
|
+
|
103
|
+
# if a mapping is passed, it *must* resolve any param name conflicts
|
104
|
+
unless mapping.any?
|
105
|
+
# assume last capture is the relevant one to replace
|
106
|
+
# if not... then I quit.
|
107
|
+
parent_param_name = parent_route.names.last
|
108
|
+
|
109
|
+
# more assumptions about names
|
110
|
+
parent_name = parent.name.demodulize.underscore.singularize
|
111
|
+
|
112
|
+
# put it together to find what we should call this new param
|
113
|
+
param = "#{parent_name}_#{parent_param_name}".to_sym
|
114
|
+
mapping[parent_param_name.to_sym] = param
|
115
|
+
end
|
116
|
+
|
117
|
+
# complete the mapping and massage the route
|
118
|
+
parent_route.names.collect(&:to_sym).each do |name|
|
119
|
+
if mapping.key?(name)
|
120
|
+
param = mapping[name]
|
121
|
+
# FIXME: this won't handle URI Template type paths, ie '/{parent_id}'
|
122
|
+
prefixed_path = parent_action.primary_route.prefixed_path
|
123
|
+
@parent_prefix = prefixed_path.gsub(/(:)(#{name})(\W+|$)/, "\\1#{param.to_s}\\3")
|
124
|
+
else
|
125
|
+
mapping[name] = name
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
self.on_finalize do
|
130
|
+
self.inherit_params_from_parent(parent_action, **mapping)
|
131
|
+
end
|
132
|
+
|
133
|
+
@parent = parent
|
134
|
+
end
|
135
|
+
|
136
|
+
def inherit_params_from_parent(parent_action, **mapping)
|
137
|
+
actions.each do |name, action|
|
138
|
+
action.params do
|
139
|
+
mapping.each do |parent_name, name|
|
140
|
+
next if action.params && action.params.attributes.key?(name)
|
141
|
+
|
142
|
+
parent_attribute = parent_action.params.attributes[parent_name]
|
143
|
+
|
144
|
+
attribute name, parent_attribute.type, parent_attribute.options
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
attr_writer :routing_prefix
|
152
|
+
|
153
|
+
def routing_prefix
|
154
|
+
return @routing_prefix if @routing_prefix
|
155
|
+
|
156
|
+
@routing_prefix = parent_prefix + prefix
|
157
|
+
end
|
158
|
+
|
159
|
+
|
66
160
|
def version(version=nil, options=nil)
|
67
161
|
return @version unless version
|
162
|
+
|
68
163
|
@version = version
|
69
|
-
@version_options = options || {using: [:header,:params]}
|
70
164
|
|
71
|
-
|
165
|
+
unless options.nil?
|
166
|
+
warn 'DEPRECATED: ResourceDefinition.version with options is no longer supported. Define in api global info instead.'
|
167
|
+
|
168
|
+
@version_options = options
|
72
169
|
version_using = Array(@version_options[:using])
|
73
170
|
if version_using.include?(:path)
|
74
171
|
@version_prefix = "#{Praxis::Request::path_version_prefix}#{self.version}"
|
@@ -76,7 +173,8 @@ module Praxis
|
|
76
173
|
end
|
77
174
|
end
|
78
175
|
|
79
|
-
|
176
|
+
|
177
|
+
def canonical_path(action_name=nil)
|
80
178
|
if action_name
|
81
179
|
raise "Canonical path for #{self.name} is already defined as: '#{@canonical_action_name}'. 'canonical_path' can only be defined once." if @canonical_action_name
|
82
180
|
@canonical_action_name = action_name
|
@@ -98,6 +196,9 @@ module Praxis
|
|
98
196
|
end
|
99
197
|
|
100
198
|
def parse_href(path)
|
199
|
+
if path.kind_of?(::URI::Generic)
|
200
|
+
path = path.path
|
201
|
+
end
|
101
202
|
param_values = canonical_path.primary_route.path.params(path)
|
102
203
|
attrs = canonical_path.params.attributes
|
103
204
|
param_values.each_with_object({}) do |(key,value),hash|
|
@@ -125,28 +226,28 @@ module Praxis
|
|
125
226
|
end
|
126
227
|
|
127
228
|
def params(type=Attributor::Struct, **opts, &block)
|
128
|
-
warn '
|
229
|
+
warn 'DEPRECATED: ResourceDefinition.params is deprecated. Use it in action_defaults instead.'
|
129
230
|
action_defaults do
|
130
231
|
params type, **opts, &block
|
131
232
|
end
|
132
233
|
end
|
133
234
|
|
134
235
|
def payload(type=Attributor::Struct, **opts, &block)
|
135
|
-
warn '
|
236
|
+
warn 'DEPRECATED: ResourceDefinition.payload is deprecated. Use action_defaults instead.'
|
136
237
|
action_defaults do
|
137
238
|
payload type, **opts, &block
|
138
239
|
end
|
139
240
|
end
|
140
241
|
|
141
242
|
def headers(**opts, &block)
|
142
|
-
warn '
|
243
|
+
warn 'DEPRECATED: ResourceDefinition.headers is deprecated. Use action_defaults instead.'
|
143
244
|
action_defaults do
|
144
245
|
headers **opts, &block
|
145
246
|
end
|
146
247
|
end
|
147
248
|
|
148
249
|
def response(name, **args)
|
149
|
-
warn '
|
250
|
+
warn 'DEPRECATED: ResourceDefinition.response is deprecated. Use action_defaults instead.'
|
150
251
|
action_defaults do
|
151
252
|
response name, **args
|
152
253
|
end
|
@@ -173,6 +274,7 @@ module Praxis
|
|
173
274
|
hash[:media_type] = media_type.id if media_type
|
174
275
|
hash[:actions] = actions.values.map(&:describe)
|
175
276
|
hash[:name] = self.name
|
277
|
+
hash[:parent] = self.parent.id if self.parent
|
176
278
|
hash[:metadata] = metadata
|
177
279
|
hash[:traits] = self.traits
|
178
280
|
end
|
data/lib/praxis/response.rb
CHANGED
@@ -54,7 +54,7 @@ module Praxis
|
|
54
54
|
end
|
55
55
|
|
56
56
|
name ||= "part-#{part.object_id}"
|
57
|
-
|
57
|
+
part.name = name
|
58
58
|
@parts[name.to_s] = part
|
59
59
|
end
|
60
60
|
|
@@ -112,14 +112,15 @@ module Praxis
|
|
112
112
|
#
|
113
113
|
# @param [Object] action
|
114
114
|
#
|
115
|
-
def validate(action)
|
115
|
+
def validate(action, validate_body: false)
|
116
116
|
return if response_name == :validation_error
|
117
|
-
|
118
|
-
|
117
|
+
|
118
|
+
unless (response_definition = action.responses[response_name])
|
119
|
+
raise Exceptions::Validation, "Attempting to return a response with name #{response_name} " \
|
119
120
|
"but no response definition with that name can be found"
|
120
121
|
end
|
121
122
|
|
122
|
-
response_definition.validate(self)
|
123
|
+
response_definition.validate(self, validate_body: validate_body)
|
123
124
|
end
|
124
125
|
|
125
126
|
|