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
@@ -51,12 +51,12 @@ module Praxis
|
|
51
51
|
unless path =~ ABSOLUTE_PATH_REGEX
|
52
52
|
path = prefix + path
|
53
53
|
end
|
54
|
-
|
54
|
+
prefixed_path = path.gsub('//','/')
|
55
55
|
path = (base + path).gsub('//','/')
|
56
56
|
# Reject our own options
|
57
57
|
route_name = options.delete(:name);
|
58
58
|
pattern = Mustermann.new(path, {ignore_unknown_options: true}.merge( options ))
|
59
|
-
route = Route.new(verb, pattern, version, name: route_name, **options)
|
59
|
+
route = Route.new(verb, pattern, version, name: route_name, prefixed_path: prefixed_path, **options)
|
60
60
|
@routes << route
|
61
61
|
route
|
62
62
|
end
|
data/lib/praxis/trait.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
module Praxis
|
2
|
+
module Types
|
3
|
+
|
4
|
+
class FuzzyHash
|
5
|
+
def initialize(value={})
|
6
|
+
@hash = {}
|
7
|
+
@regexes = []
|
8
|
+
update(value)
|
9
|
+
end
|
10
|
+
|
11
|
+
def update(value)
|
12
|
+
value.each do |k,v|
|
13
|
+
self[k] = v
|
14
|
+
end
|
15
|
+
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def []=(k,v)
|
20
|
+
case k
|
21
|
+
when Regexp
|
22
|
+
@regexes << k
|
23
|
+
end
|
24
|
+
@hash[k] = v
|
25
|
+
end
|
26
|
+
|
27
|
+
def [](k)
|
28
|
+
return @hash[k] if @hash.key?(k)
|
29
|
+
|
30
|
+
k = k.to_s
|
31
|
+
@regexes.each do |regex|
|
32
|
+
return @hash[regex] if regex.match(k)
|
33
|
+
end
|
34
|
+
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def method_missing(*args, &block)
|
39
|
+
@hash.send(*args, &block)
|
40
|
+
end
|
41
|
+
|
42
|
+
def respond_to_missing?(*args)
|
43
|
+
@hash.respond_to?(*args)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -1,31 +1,73 @@
|
|
1
1
|
module Praxis
|
2
|
-
|
3
2
|
class Multipart < Attributor::Hash
|
4
3
|
|
5
4
|
@key_type = Attributor::String
|
6
5
|
|
6
|
+
def self.inherited(klass)
|
7
|
+
warn "DEPRECATION: Praxis::Multipart is deprecated and will be removed in 1.0. Use Praxis::Types::MultipartArray instead"
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
7
11
|
def self.load(value, context=Attributor::DEFAULT_ROOT_CONTEXT, content_type:nil)
|
8
12
|
return value if value.kind_of?(self) || value.nil?
|
9
13
|
|
10
14
|
unless (value.kind_of?(::String) && ! content_type.nil?)
|
11
15
|
raise Attributor::CoercionError, context: context, from: value.class, to: self.name, value: value
|
12
|
-
end
|
13
|
-
|
16
|
+
end
|
17
|
+
|
14
18
|
headers = {'Content-Type' => content_type}
|
15
19
|
parser = MultipartParser.new(headers, value)
|
16
20
|
preamble, parts = parser.parse
|
17
21
|
|
18
|
-
|
22
|
+
parts_hash = parts.each_with_object({}) do |part, hash|
|
23
|
+
hash[part.name] = self.backconvert_part_data(part)
|
24
|
+
end
|
25
|
+
|
26
|
+
hash = Hash[parts_hash.collect { |name, part| [name, part.body] }]
|
19
27
|
|
20
28
|
instance = super(hash, context, **options)
|
21
29
|
|
22
30
|
instance.preamble = preamble
|
23
|
-
instance.parts =
|
31
|
+
instance.parts = parts_hash
|
24
32
|
instance.headers = headers
|
25
33
|
|
26
34
|
instance
|
27
35
|
end
|
28
36
|
|
37
|
+
def self.backconvert_part_data(part)
|
38
|
+
filename = part.filename
|
39
|
+
body = part.payload
|
40
|
+
name = part.name
|
41
|
+
|
42
|
+
content_type = part.headers['Content-Type']
|
43
|
+
|
44
|
+
# cheat and unparse the headers back to a head string. should be ok...
|
45
|
+
head = part.headers.collect {|k,v| "#{k}: #{v}" }.join("\r\n")
|
46
|
+
|
47
|
+
data = nil
|
48
|
+
if filename == ""
|
49
|
+
# filename is blank which means no file has been selected
|
50
|
+
return data
|
51
|
+
elsif filename
|
52
|
+
body.rewind
|
53
|
+
|
54
|
+
data = {:filename => filename, :type => content_type,
|
55
|
+
:name => name, :tempfile => body, :head => head}
|
56
|
+
elsif !filename && content_type && body.is_a?(IO)
|
57
|
+
body.rewind
|
58
|
+
|
59
|
+
# Generic multipart cases, not coming from a form
|
60
|
+
data = {:type => content_type,
|
61
|
+
:name => name, :tempfile => body, :head => head}
|
62
|
+
else
|
63
|
+
data = body
|
64
|
+
end
|
65
|
+
|
66
|
+
part.payload = data
|
67
|
+
part
|
68
|
+
end
|
69
|
+
|
70
|
+
|
29
71
|
def self.example(context=nil, options: {})
|
30
72
|
form = MIME::Multipart::FormData.new
|
31
73
|
|
@@ -45,13 +87,6 @@ module Praxis
|
|
45
87
|
body = form.body.to_s
|
46
88
|
|
47
89
|
self.load(body, context, content_type: content_type)
|
48
|
-
#result.each do |k, v|
|
49
|
-
# result.parts[k] = MultipartPart.new(v)
|
50
|
-
#end
|
51
|
-
|
52
|
-
#result.headers = {'Content-Type'}
|
53
|
-
|
54
|
-
|
55
90
|
end
|
56
91
|
|
57
92
|
attr_accessor :preamble
|
@@ -0,0 +1,320 @@
|
|
1
|
+
require 'praxis/types/multipart_array/part_definition'
|
2
|
+
|
3
|
+
module Praxis
|
4
|
+
module Types
|
5
|
+
class MultipartArray < Attributor::Collection
|
6
|
+
include Types::MediaTypeCommon
|
7
|
+
|
8
|
+
@member_type = Praxis::MultipartPart
|
9
|
+
@payload_type = Attributor::String
|
10
|
+
@name_type = Attributor::String
|
11
|
+
@attributes = FuzzyHash.new.freeze
|
12
|
+
@identifier = MediaTypeIdentifier.load('multipart/form-data').freeze
|
13
|
+
|
14
|
+
def self.inherited(klass)
|
15
|
+
klass.instance_eval do
|
16
|
+
@attributes = FuzzyHash.new
|
17
|
+
@saved_blocks = []
|
18
|
+
@multiple = []
|
19
|
+
@options = {}
|
20
|
+
|
21
|
+
@payload_type = Attributor::String
|
22
|
+
@name_type = Attributor::String
|
23
|
+
@member_type = Praxis::MultipartPart
|
24
|
+
|
25
|
+
@payload_attribute = nil
|
26
|
+
@part_attribute = nil
|
27
|
+
|
28
|
+
@identifier = MediaTypeIdentifier.load('multipart/form-data').freeze
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class << self
|
34
|
+
attr_reader :attributes
|
35
|
+
attr_reader :multiple
|
36
|
+
attr_reader :options
|
37
|
+
attr_reader :identifier
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.constructable?
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.construct(constructor_block, _options={})
|
45
|
+
Class.new(self, &constructor_block)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.name_type(type=nil)
|
49
|
+
return @name_type if type.nil?
|
50
|
+
|
51
|
+
@name_type = Attributor.resolve_type type
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.payload_type(type=nil, **opts, &block)
|
55
|
+
return @payload_type if type.nil?
|
56
|
+
|
57
|
+
@payload_type = Attributor.resolve_type(type)
|
58
|
+
@payload_attribute = Attributor::Attribute.new(@payload_type, **opts, &block)
|
59
|
+
@part_attribute = nil
|
60
|
+
@payload_type
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.payload_attribute
|
64
|
+
@payload_attribute ||= Attributor::Attribute.new(@payload_type)
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.part_attribute
|
68
|
+
@part_attribute ||= Attributor::Attribute.new(Praxis::MultipartPart, payload_attribute: self.payload_attribute)
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.part(name, payload_type=nil, multiple: false, filename: false, **opts, &block)
|
72
|
+
@attributes.default_proc = nil
|
73
|
+
|
74
|
+
if name.kind_of?(Regexp)
|
75
|
+
raise 'part with regexp name may not take :multiple option' if multiple
|
76
|
+
raise 'part with regexp name may not be required' if opts[:required] == true
|
77
|
+
end
|
78
|
+
|
79
|
+
self.multiple << name if multiple
|
80
|
+
|
81
|
+
compiler = Attributor::DSLCompiler.new(self, opts)
|
82
|
+
|
83
|
+
if filename
|
84
|
+
filename_attribute = compiler.define('filename', String, required: true)
|
85
|
+
end
|
86
|
+
|
87
|
+
if block_given?
|
88
|
+
definition = PartDefinition.new(&block)
|
89
|
+
payload_attribute = definition.payload_attribute
|
90
|
+
header_attribute = definition.headers_attribute
|
91
|
+
filename_attribute = definition.filename_attribute || filename_attribute
|
92
|
+
|
93
|
+
self.attributes[name] = compiler.define(name, Praxis::MultipartPart,
|
94
|
+
payload_attribute: payload_attribute,
|
95
|
+
headers_attribute: header_attribute,
|
96
|
+
filename_attribute: filename_attribute
|
97
|
+
)
|
98
|
+
else
|
99
|
+
payload_attribute = compiler.define(name, payload_type || self.payload_type, **opts)
|
100
|
+
self.attributes[name] = compiler.define(name, Praxis::MultipartPart,
|
101
|
+
payload_attribute: payload_attribute,
|
102
|
+
filename_attribute: filename_attribute
|
103
|
+
)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.file(name, payload_type=nil, filename: nil, **opts, &block)
|
108
|
+
self.part(name, payload_type=nil, filename: true, **opts, &block)
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.load(value, context=Attributor::DEFAULT_ROOT_CONTEXT, content_type:nil)
|
112
|
+
return value if value.kind_of?(self) || value.nil?
|
113
|
+
|
114
|
+
if value.kind_of?(::String) && content_type.nil?
|
115
|
+
raise ArgumentError, "content_type is required to load values of type String for #{Attributor.type_name(self)}"
|
116
|
+
end
|
117
|
+
|
118
|
+
parser = Praxis::MultipartParser.new({'Content-Type' => content_type}, value)
|
119
|
+
preamble, parts = parser.parse
|
120
|
+
|
121
|
+
instance = self.new
|
122
|
+
instance.push(*parts)
|
123
|
+
|
124
|
+
instance.preamble = preamble
|
125
|
+
instance.content_type = content_type
|
126
|
+
|
127
|
+
instance
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.example(context=Attributor::DEFAULT_ROOT_CONTEXT, **options)
|
131
|
+
example = self.new
|
132
|
+
|
133
|
+
self.attributes.each do |name, attribute|
|
134
|
+
next if name.kind_of? Regexp
|
135
|
+
sub_context = self.generate_subcontext(context, name)
|
136
|
+
|
137
|
+
part = attribute.example(sub_context)
|
138
|
+
part.name = name
|
139
|
+
example.push part
|
140
|
+
|
141
|
+
if self.multiple.include? name
|
142
|
+
part = attribute.example(sub_context + ['2'])
|
143
|
+
part.name = name
|
144
|
+
example.push part
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
example
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
def self.describe(shallow=true, example: nil)
|
153
|
+
type_name = Attributor.type_name(self)
|
154
|
+
hash = {
|
155
|
+
name: type_name.gsub(Attributor::MODULE_PREFIX_REGEX, ''),
|
156
|
+
family: self.family,
|
157
|
+
id: self.id
|
158
|
+
}
|
159
|
+
hash[:example] = example if example
|
160
|
+
|
161
|
+
hash[:part_name] = {type: name_type.describe(true)}
|
162
|
+
|
163
|
+
unless shallow
|
164
|
+
hash[:attributes] = {} if self.attributes.keys.any? { |name| name.kind_of? String}
|
165
|
+
hash[:pattern_attributes] = {} if self.attributes.keys.any? { |name| name.kind_of? Regexp}
|
166
|
+
|
167
|
+
if hash.key?(:attributes) || hash.key?(:pattern_attributes)
|
168
|
+
self.describe_attributes(shallow, example: example).each do |name, sub_hash|
|
169
|
+
case name
|
170
|
+
when String
|
171
|
+
hash[:attributes][name] = sub_hash
|
172
|
+
when Regexp
|
173
|
+
hash[:pattern_attributes][name.source] = sub_hash
|
174
|
+
end
|
175
|
+
end
|
176
|
+
else
|
177
|
+
hash[:part_payload] = {type: payload_type.describe(true)}
|
178
|
+
end
|
179
|
+
end
|
180
|
+
hash
|
181
|
+
end
|
182
|
+
|
183
|
+
def self.describe_attributes(shallow=true, example: nil)
|
184
|
+
self.attributes.each_with_object({}) do |(part_name, part_attribute), parts|
|
185
|
+
sub_example = example.part(part_name) if example
|
186
|
+
if sub_example && self.multiple.include?(part_name)
|
187
|
+
sub_example = sub_example.first
|
188
|
+
end
|
189
|
+
|
190
|
+
sub_hash = part_attribute.describe(shallow, example: sub_example)
|
191
|
+
|
192
|
+
|
193
|
+
if (options = sub_hash.delete(:options))
|
194
|
+
sub_hash[:options] = {}
|
195
|
+
if self.multiple.include?(part_name)
|
196
|
+
sub_hash[:options][:multiple] = true
|
197
|
+
end
|
198
|
+
|
199
|
+
if (payload_attribute = options.delete :payload_attribute)
|
200
|
+
if (required = payload_attribute.options[:required])
|
201
|
+
sub_hash[:options][:required] = true
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
sub_hash[:type] = MultipartPart.describe(shallow, example: sub_example, options: part_attribute.options)
|
207
|
+
|
208
|
+
|
209
|
+
parts[part_name] = sub_hash
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
attr_accessor :preamble
|
214
|
+
attr_reader :content_type
|
215
|
+
|
216
|
+
def initialize(content_type: self.class.identifier)
|
217
|
+
self.content_type = content_type
|
218
|
+
end
|
219
|
+
|
220
|
+
def content_type=(content_type)
|
221
|
+
@content_type = MediaTypeIdentifier.load(content_type)
|
222
|
+
if @content_type.parameters.get('boundary').nil?
|
223
|
+
@content_type.parameters.set 'boundary', 'Boundary_puppies'
|
224
|
+
end
|
225
|
+
@content_type
|
226
|
+
end
|
227
|
+
|
228
|
+
def payload_type
|
229
|
+
self.class.payload_type
|
230
|
+
end
|
231
|
+
|
232
|
+
def push(*parts, context: Attributor::DEFAULT_ROOT_CONTEXT)
|
233
|
+
part, *rest = parts
|
234
|
+
if rest.any?
|
235
|
+
return self.push(part, context: context).push(*rest, context:context)
|
236
|
+
end
|
237
|
+
|
238
|
+
original_context = context
|
239
|
+
|
240
|
+
part.name = self.class.name_type.load(part.name, self.class.generate_subcontext(context, part.name))
|
241
|
+
key = part.name
|
242
|
+
|
243
|
+
context = self.class.generate_subcontext(context, key)
|
244
|
+
|
245
|
+
# If no attributes are defined, we always use the default
|
246
|
+
# payload_attribute, otherwise we constrain the parts
|
247
|
+
# to the defined names.
|
248
|
+
attribute = if self.class.attributes.empty?
|
249
|
+
self.class.part_attribute
|
250
|
+
elsif (default_thingy = self.class.attributes[key])
|
251
|
+
default_thingy
|
252
|
+
else
|
253
|
+
nil
|
254
|
+
end
|
255
|
+
|
256
|
+
if attribute
|
257
|
+
part.attribute = attribute
|
258
|
+
part.load_payload(context + ['payload'])
|
259
|
+
part.load_headers(context + ['headers'])
|
260
|
+
return self << part
|
261
|
+
elsif self.class.options[:case_insensitive_load]
|
262
|
+
name = self.class.attributes.keys.find do |k|
|
263
|
+
k.kind_of?(String) && key.downcase == k.downcase
|
264
|
+
end
|
265
|
+
if name
|
266
|
+
part.name = name
|
267
|
+
return self.push(part, context: original_context)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
raise Attributor::AttributorException, "Unknown part name received: #{key.inspect} while loading #{Attributor.humanize_context(context)}"
|
272
|
+
end
|
273
|
+
|
274
|
+
def part(name)
|
275
|
+
if self.class.multiple.include?(name)
|
276
|
+
self.select { |i| i.name == name }
|
277
|
+
else
|
278
|
+
self.find { |i| i.name == name }
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
def validate(context=Attributor::DEFAULT_ROOT_CONTEXT)
|
283
|
+
errors = self.each_with_index.each_with_object([]) do |(part, idx), errors|
|
284
|
+
sub_context = if part.name
|
285
|
+
self.class.generate_subcontext(context, part.name)
|
286
|
+
else
|
287
|
+
context + ["at(#{idx})"]
|
288
|
+
end
|
289
|
+
|
290
|
+
errors.push *part.validate(sub_context)
|
291
|
+
end
|
292
|
+
|
293
|
+
self.class.attributes.each do |name, attribute|
|
294
|
+
payload_attribute = attribute.options[:payload_attribute]
|
295
|
+
next unless payload_attribute.options[:required]
|
296
|
+
next if self.part(name)
|
297
|
+
|
298
|
+
sub_context = self.class.generate_subcontext(context, name)
|
299
|
+
errors.push *payload_attribute.validate_missing_value(sub_context)
|
300
|
+
end
|
301
|
+
|
302
|
+
errors
|
303
|
+
end
|
304
|
+
|
305
|
+
|
306
|
+
def dump(**opts)
|
307
|
+
boundary = content_type.parameters.get 'boundary'
|
308
|
+
|
309
|
+
parts = self.collect do |part|
|
310
|
+
part.dump(**opts)
|
311
|
+
end
|
312
|
+
|
313
|
+
all_entities = parts.join("\r\n--#{boundary}\r\n")
|
314
|
+
"--#{boundary}\r\n#{all_entities}\r\n--#{boundary}--\r\n"
|
315
|
+
end
|
316
|
+
|
317
|
+
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|