praxis 2.0.pre.6 → 2.0.pre.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +1 -3
- data/CHANGELOG.md +25 -0
- data/TODO.md +1 -4
- data/bin/praxis +67 -12
- data/lib/praxis.rb +10 -3
- data/lib/praxis/action_definition.rb +15 -13
- data/lib/praxis/action_definition/headers_dsl_compiler.rb +0 -7
- data/lib/praxis/api_general_info.rb +1 -1
- data/lib/praxis/application.rb +6 -2
- data/lib/praxis/blueprint.rb +357 -0
- data/lib/praxis/bootloader.rb +9 -3
- data/lib/praxis/bootloader_stages/environment.rb +16 -13
- data/lib/praxis/collection.rb +1 -11
- data/lib/praxis/config_hash.rb +44 -0
- data/lib/praxis/docs/{openapi → open_api}/info_object.rb +18 -10
- data/lib/praxis/docs/{openapi → open_api}/media_type_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/operation_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/parameter_object.rb +2 -2
- data/lib/praxis/docs/{openapi → open_api}/paths_object.rb +12 -15
- data/lib/praxis/docs/{openapi → open_api}/request_body_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/response_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/responses_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/schema_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/server_object.rb +0 -0
- data/lib/praxis/docs/{openapi → open_api}/tag_object.rb +0 -0
- data/lib/praxis/docs/open_api_generator.rb +91 -6
- data/lib/praxis/endpoint_definition.rb +273 -0
- data/lib/praxis/extensions/attribute_filtering/active_record_filter_query_builder.rb +57 -8
- data/lib/praxis/extensions/attribute_filtering/filtering_params.rb +3 -16
- data/lib/praxis/extensions/attribute_filtering/sequel_filter_query_builder.rb +20 -8
- data/lib/praxis/extensions/field_expansion.rb +3 -36
- data/lib/praxis/extensions/pagination.rb +5 -32
- data/lib/praxis/extensions/pagination/ordering_params.rb +5 -1
- data/lib/praxis/extensions/pagination/pagination_params.rb +10 -4
- data/lib/praxis/field_expander.rb +90 -0
- data/lib/praxis/finalizable.rb +34 -0
- data/lib/praxis/mapper/active_model_compat.rb +4 -0
- data/lib/praxis/mapper/resource.rb +18 -2
- data/lib/praxis/mapper/selector_generator.rb +2 -1
- data/lib/praxis/mapper/sequel_compat.rb +7 -0
- data/lib/praxis/media_type.rb +3 -68
- data/lib/praxis/plugin_concern.rb +1 -1
- data/lib/praxis/plugins/mapper_plugin.rb +24 -15
- data/lib/praxis/plugins/pagination_plugin.rb +34 -4
- data/lib/praxis/renderer.rb +88 -0
- data/lib/praxis/request.rb +1 -1
- data/lib/praxis/resource_definition.rb +2 -311
- data/lib/praxis/response_definition.rb +2 -10
- data/lib/praxis/response_template.rb +3 -3
- data/lib/praxis/router.rb +2 -2
- data/lib/praxis/routing_config.rb +1 -1
- data/lib/praxis/tasks/api_docs.rb +17 -64
- data/lib/praxis/tasks/routes.rb +2 -2
- data/lib/praxis/types/media_type_common.rb +1 -11
- data/lib/praxis/version.rb +1 -1
- data/praxis.gemspec +0 -1
- data/spec/functional_spec.rb +5 -9
- data/spec/praxis/action_definition_spec.rb +12 -20
- data/spec/praxis/blueprint_spec.rb +373 -0
- data/spec/praxis/bootloader_spec.rb +10 -2
- data/spec/praxis/collection_spec.rb +0 -13
- data/spec/praxis/config_hash_spec.rb +64 -0
- data/spec/praxis/{resource_definition_spec.rb → endpoint_definition_spec.rb} +37 -64
- data/spec/praxis/extensions/attribute_filtering/active_record_filter_query_builder_spec.rb +19 -8
- data/spec/praxis/extensions/attribute_filtering/filtering_params_spec.rb +106 -0
- data/spec/praxis/extensions/field_expansion_spec.rb +5 -24
- data/spec/praxis/extensions/field_selection/active_record_query_selector_spec.rb +1 -1
- data/spec/praxis/extensions/field_selection/sequel_query_selector_spec.rb +1 -1
- data/spec/praxis/extensions/support/spec_resources_active_model.rb +1 -1
- data/spec/praxis/field_expander_spec.rb +149 -0
- data/spec/praxis/mapper/selector_generator_spec.rb +1 -1
- data/spec/praxis/media_type_identifier_spec.rb +5 -4
- data/spec/praxis/media_type_spec.rb +4 -93
- data/spec/praxis/renderer_spec.rb +188 -0
- data/spec/praxis/response_definition_spec.rb +0 -31
- data/spec/praxis/response_spec.rb +1 -1
- data/spec/praxis/router_spec.rb +8 -8
- data/spec/praxis/routing_config_spec.rb +3 -3
- data/spec/spec_app/app/controllers/instances.rb +13 -7
- data/spec/spec_app/design/media_types/instance.rb +1 -19
- data/spec/spec_app/design/media_types/volume.rb +1 -1
- data/spec/spec_app/design/media_types/volume_snapshot.rb +2 -14
- data/spec/spec_app/design/resources/instances.rb +5 -8
- data/spec/spec_app/design/resources/volume_snapshots.rb +1 -1
- data/spec/spec_app/design/resources/volumes.rb +1 -1
- data/spec/support/spec_authorization_plugin.rb +1 -1
- data/spec/support/spec_blueprints.rb +72 -0
- data/spec/support/{spec_resource_definitions.rb → spec_endpoint_definitions.rb} +2 -2
- data/spec/support/spec_media_types.rb +6 -26
- data/tasks/thor/app.rb +8 -34
- data/tasks/thor/example.rb +51 -285
- data/tasks/thor/model.rb +40 -0
- data/tasks/thor/scaffold.rb +117 -0
- data/tasks/thor/templates/generator/empty_app/.gitignore +0 -1
- data/tasks/thor/templates/generator/empty_app/Gemfile +7 -23
- data/tasks/thor/templates/generator/empty_app/README.md +1 -1
- data/tasks/thor/templates/generator/empty_app/Rakefile +4 -13
- data/tasks/thor/templates/generator/empty_app/{design/response_templates → app/v1/resources}/.empty_directory +0 -0
- data/tasks/thor/templates/generator/empty_app/{design/response_templates → app/v1/resources}/.gitkeep +0 -0
- data/tasks/thor/templates/generator/empty_app/config/environment.rb +26 -17
- data/tasks/thor/templates/generator/empty_app/{design/v1/resources → config/initializers}/.empty_directory +0 -0
- data/tasks/thor/templates/generator/empty_app/{design/v1/resources → config/initializers}/.gitkeep +0 -0
- data/tasks/thor/templates/generator/empty_app/design/v1/endpoints/.empty_directory +0 -0
- data/tasks/thor/templates/generator/empty_app/design/v1/endpoints/.gitkeep +0 -0
- data/tasks/thor/templates/generator/empty_app/docs/.empty_directory +0 -0
- data/tasks/thor/templates/generator/empty_app/docs/.gitkeep +0 -0
- data/tasks/thor/templates/generator/empty_app/spec/spec_helper.rb +14 -9
- data/tasks/thor/templates/generator/example_app/.gitignore +1 -0
- data/tasks/thor/templates/generator/example_app/Gemfile +19 -0
- data/tasks/thor/templates/generator/example_app/Rakefile +61 -0
- data/tasks/thor/templates/generator/example_app/app/models/user.rb +6 -0
- data/tasks/thor/templates/generator/example_app/app/v1/concerns/controller_base.rb +24 -0
- data/tasks/thor/templates/generator/example_app/app/v1/controllers/users.rb +17 -0
- data/tasks/thor/templates/generator/example_app/app/v1/resources/base.rb +11 -0
- data/tasks/thor/templates/generator/example_app/app/v1/resources/user.rb +25 -0
- data/tasks/thor/templates/generator/example_app/config.ru +30 -0
- data/tasks/thor/templates/generator/example_app/config/environment.rb +41 -0
- data/tasks/thor/templates/generator/example_app/db/migrate/20201010101010_create_users_table.rb +12 -0
- data/tasks/thor/templates/generator/example_app/db/seeds.rb +6 -0
- data/tasks/thor/templates/generator/example_app/design/api.rb +18 -0
- data/tasks/thor/templates/generator/example_app/design/v1/endpoints/users.rb +37 -0
- data/tasks/thor/templates/generator/example_app/design/v1/media_types/user.rb +21 -0
- data/tasks/thor/templates/generator/example_app/spec/helpers/database_helper.rb +20 -0
- data/tasks/thor/templates/generator/example_app/spec/spec_helper.rb +42 -0
- data/tasks/thor/templates/generator/example_app/spec/v1/controllers/users_spec.rb +37 -0
- data/tasks/thor/templates/generator/scaffold/design/endpoints/collection.rb +98 -0
- data/tasks/thor/templates/generator/scaffold/design/media_types/item.rb +18 -0
- data/tasks/thor/templates/generator/scaffold/implementation/controllers/collection.rb +77 -0
- data/tasks/thor/templates/generator/scaffold/implementation/resources/base.rb +11 -0
- data/tasks/thor/templates/generator/scaffold/implementation/resources/item.rb +45 -0
- data/tasks/thor/templates/generator/scaffold/models/active_record.rb +6 -0
- data/tasks/thor/templates/generator/scaffold/models/sequel.rb +6 -0
- metadata +62 -136
- data/lib/api_browser/.bowerrc +0 -3
- data/lib/api_browser/.editorconfig +0 -21
- data/lib/api_browser/Gruntfile.js +0 -581
- data/lib/api_browser/app/index.html +0 -59
- data/lib/api_browser/app/js/app.js +0 -48
- data/lib/api_browser/app/js/controllers/action.js +0 -47
- data/lib/api_browser/app/js/controllers/controller.js +0 -10
- data/lib/api_browser/app/js/controllers/menu.js +0 -93
- data/lib/api_browser/app/js/controllers/trait.js +0 -10
- data/lib/api_browser/app/js/controllers/type.js +0 -24
- data/lib/api_browser/app/js/directives/attribute_description.js +0 -56
- data/lib/api_browser/app/js/directives/attribute_table.js +0 -28
- data/lib/api_browser/app/js/directives/conditional_requirements.js +0 -13
- data/lib/api_browser/app/js/directives/fixed_if_fits.js +0 -38
- data/lib/api_browser/app/js/directives/highlight.js +0 -14
- data/lib/api_browser/app/js/directives/menu_item.js +0 -59
- data/lib/api_browser/app/js/directives/no_container.js +0 -8
- data/lib/api_browser/app/js/directives/readable_list.js +0 -87
- data/lib/api_browser/app/js/directives/request_examples.js +0 -31
- data/lib/api_browser/app/js/directives/type_placeholder.js +0 -30
- data/lib/api_browser/app/js/directives/url.js +0 -15
- data/lib/api_browser/app/js/factories/Configuration.js +0 -12
- data/lib/api_browser/app/js/factories/Documentation.js +0 -61
- data/lib/api_browser/app/js/factories/Example.js +0 -51
- data/lib/api_browser/app/js/factories/PageInfo.js +0 -9
- data/lib/api_browser/app/js/factories/normalize_attributes.js +0 -20
- data/lib/api_browser/app/js/factories/prepare_template.js +0 -15
- data/lib/api_browser/app/js/factories/template_for.js +0 -128
- data/lib/api_browser/app/js/filters/attribute_name.js +0 -10
- data/lib/api_browser/app/js/filters/friendly_json.js +0 -5
- data/lib/api_browser/app/js/filters/has_requirement.js +0 -14
- data/lib/api_browser/app/js/filters/header_info.js +0 -9
- data/lib/api_browser/app/js/filters/is_empty.js +0 -8
- data/lib/api_browser/app/js/filters/markdown.js +0 -6
- data/lib/api_browser/app/js/filters/resource_name.js +0 -5
- data/lib/api_browser/app/js/filters/tag_requirement.js +0 -13
- data/lib/api_browser/app/sass/modules/_body.scss +0 -40
- data/lib/api_browser/app/sass/modules/_cloke.scss +0 -8
- data/lib/api_browser/app/sass/modules/_header.scss +0 -10
- data/lib/api_browser/app/sass/modules/_nav.scss +0 -7
- data/lib/api_browser/app/sass/modules/_sidebar.scss +0 -134
- data/lib/api_browser/app/sass/modules/_switch.scss +0 -55
- data/lib/api_browser/app/sass/modules/_table.scss +0 -13
- data/lib/api_browser/app/sass/praxis.scss +0 -70
- data/lib/api_browser/app/sass/variables/_bootstrap-variables.scss +0 -774
- data/lib/api_browser/app/views/action.html +0 -97
- data/lib/api_browser/app/views/builtin/field-selector.html +0 -24
- data/lib/api_browser/app/views/controller.html +0 -55
- data/lib/api_browser/app/views/directives/attribute_description.html +0 -2
- data/lib/api_browser/app/views/directives/attribute_description/default.html +0 -2
- data/lib/api_browser/app/views/directives/attribute_description/example.html +0 -13
- data/lib/api_browser/app/views/directives/attribute_description/headers.html +0 -8
- data/lib/api_browser/app/views/directives/attribute_description/member_options.html +0 -4
- data/lib/api_browser/app/views/directives/attribute_description/values.html +0 -14
- data/lib/api_browser/app/views/directives/attribute_table.html +0 -17
- data/lib/api_browser/app/views/directives/menu_item.html +0 -8
- data/lib/api_browser/app/views/directives/url.html +0 -3
- data/lib/api_browser/app/views/examples/general.html +0 -26
- data/lib/api_browser/app/views/home.html +0 -5
- data/lib/api_browser/app/views/layout.html +0 -8
- data/lib/api_browser/app/views/menu.html +0 -42
- data/lib/api_browser/app/views/navbar.html +0 -9
- data/lib/api_browser/app/views/trait.html +0 -13
- data/lib/api_browser/app/views/type.html +0 -6
- data/lib/api_browser/app/views/type/details.html +0 -33
- data/lib/api_browser/app/views/types/embedded/array.html +0 -2
- data/lib/api_browser/app/views/types/embedded/default.html +0 -12
- data/lib/api_browser/app/views/types/embedded/field-selector.html +0 -13
- data/lib/api_browser/app/views/types/embedded/links.html +0 -11
- data/lib/api_browser/app/views/types/embedded/requirements.html +0 -6
- data/lib/api_browser/app/views/types/embedded/single_req.html +0 -9
- data/lib/api_browser/app/views/types/embedded/struct.html +0 -14
- data/lib/api_browser/app/views/types/label/link.html +0 -1
- data/lib/api_browser/app/views/types/label/primitive.html +0 -1
- data/lib/api_browser/app/views/types/label/primitive_collection.html +0 -1
- data/lib/api_browser/app/views/types/label/type.html +0 -1
- data/lib/api_browser/app/views/types/label/type_collection.html +0 -1
- data/lib/api_browser/app/views/types/main/array.html +0 -22
- data/lib/api_browser/app/views/types/main/default.html +0 -23
- data/lib/api_browser/app/views/types/main/hash.html +0 -23
- data/lib/api_browser/app/views/types/standalone/array.html +0 -3
- data/lib/api_browser/app/views/types/standalone/default.html +0 -18
- data/lib/api_browser/app/views/types/standalone/struct.html +0 -2
- data/lib/api_browser/bower_template.json +0 -41
- data/lib/api_browser/package-lock.json +0 -7110
- data/lib/api_browser/package.json +0 -43
- data/lib/praxis/docs/generator.rb +0 -243
- data/lib/praxis/docs/link_builder.rb +0 -30
- data/lib/praxis/links.rb +0 -135
- data/lib/praxis/types/multipart.rb +0 -109
- data/spec/api_browser/directives/type_placeholder_spec.js +0 -134
- data/spec/api_browser/factories/configuration_spec.js +0 -32
- data/spec/api_browser/factories/documentation_spec.js +0 -100
- data/spec/api_browser/factories/normalize_attributes_spec.js +0 -92
- data/spec/api_browser/factories/template_for_spec.js +0 -67
- data/spec/api_browser/filters/attribute_name_spec.js +0 -23
- data/spec/praxis/types/multipart_spec.rb +0 -112
- data/tasks/thor/templates/generator/empty_app/.rspec +0 -1
- data/tasks/thor/templates/generator/empty_app/Guardfile +0 -3
- data/tasks/thor/templates/generator/empty_app/config/rainbows.rb +0 -57
- data/tasks/thor/templates/generator/empty_app/docs/app.js +0 -1
- data/tasks/thor/templates/generator/empty_app/docs/styles.scss +0 -3
@@ -1,59 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html ng-app="DocBrowser">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6
|
-
<title ng-bind="subtitle ? title + ' – ' + subtitle : title">API Browser</title>
|
7
|
-
<meta name="description" content="">
|
8
|
-
<meta name="viewport" content="width=device-width">
|
9
|
-
<!-- build:base base -->
|
10
|
-
<base src="/">
|
11
|
-
<!-- endbuild -->
|
12
|
-
<!-- build:css({.tmp,app,/}) css/other.css -->
|
13
|
-
<!-- bower:css -->
|
14
|
-
<!-- endbower -->
|
15
|
-
<!-- endbuild -->
|
16
|
-
<link rel="stylesheet" href="css/main.css">
|
17
|
-
</head>
|
18
|
-
<body>
|
19
|
-
<div ui-view=""></div>
|
20
|
-
<!-- build:js({.tmp,app,/}) scripts/praxis.js -->
|
21
|
-
<!-- bower:js -->
|
22
|
-
<script src="bower_components/jquery/dist/jquery.js"></script>
|
23
|
-
<script src="bower_components/angular/angular.js"></script>
|
24
|
-
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
|
25
|
-
<script src="bower_components/angular-ui-bootstrap-bower/ui-bootstrap-tpls.js"></script>
|
26
|
-
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
|
27
|
-
<!-- endbower -->
|
28
|
-
<!-- fileblock:js scripts -->
|
29
|
-
<script src="js/app.js"></script>
|
30
|
-
<script src="js/filters/resource_name.js"></script>
|
31
|
-
<script src="js/controllers/menu.js"></script>
|
32
|
-
<script src="js/controllers/action.js"></script>
|
33
|
-
<script src="js/directives/attribute_table.js"></script>
|
34
|
-
<script src="js/controllers/type.js"></script>
|
35
|
-
<script src="js/controllers/controller.js"></script>
|
36
|
-
<script src="js/factories/Documentation.js"></script>
|
37
|
-
<script src="js/directives/type_label.js"></script>
|
38
|
-
<script src="js/filters/attribute_name.js"></script>
|
39
|
-
<script src="js/filters/friendly_json.js"></script>
|
40
|
-
<script src="js/directives/attribute_description.js"></script>
|
41
|
-
<script src="js/directives/attribute_table_row.js"></script>
|
42
|
-
<script src="js/factories/TypeTemplates.js"></script>
|
43
|
-
<script src="js/directives/no_container.js"></script>
|
44
|
-
<script src="js/filters/is_empty.js"></script>
|
45
|
-
<script src="js/directives/request_body.js"></script>
|
46
|
-
<script src="js/factories/PayloadTemplates.js"></script>
|
47
|
-
<script src="js/factories/TemplateProvider.js"></script>
|
48
|
-
<script src="js/directives/request_headers.js"></script>
|
49
|
-
<script src="js/directives/request_parameters.js"></script>
|
50
|
-
<!-- endfileblock -->
|
51
|
-
<!-- fileblock:js pluginscripts -->
|
52
|
-
<!-- endfileblock -->
|
53
|
-
<!-- endbuild -->
|
54
|
-
<!-- build:js({/,.tmp}) scripts/docs.js -->
|
55
|
-
<!-- fileblock:js userscripts -->
|
56
|
-
<!-- endfileblock -->
|
57
|
-
<!-- endbuild -->
|
58
|
-
</body>
|
59
|
-
</html>
|
@@ -1,48 +0,0 @@
|
|
1
|
-
var app = angular.module('PraxisDocBrowser', ['ui.router', 'ui.bootstrap', 'ngSanitize']);
|
2
|
-
|
3
|
-
app.config(function ($stateProvider, $urlRouterProvider, $uiViewScrollProvider) {
|
4
|
-
|
5
|
-
$uiViewScrollProvider.useAnchorScroll();
|
6
|
-
|
7
|
-
$urlRouterProvider
|
8
|
-
.otherwise('/');
|
9
|
-
|
10
|
-
$stateProvider
|
11
|
-
.state('root', {
|
12
|
-
abstract: true,
|
13
|
-
templateUrl: 'views/layout.html'
|
14
|
-
})
|
15
|
-
.state('root.home', {
|
16
|
-
url: '/',
|
17
|
-
templateUrl: 'views/home.html'
|
18
|
-
})
|
19
|
-
.state('root.controller', {
|
20
|
-
url: '/:version/controller/:controller',
|
21
|
-
templateUrl: 'views/controller.html',
|
22
|
-
controller: 'ControllerCtrl'
|
23
|
-
})
|
24
|
-
.state('root.type', {
|
25
|
-
url: '/:version/type/:type',
|
26
|
-
templateUrl: 'views/type.html',
|
27
|
-
controller: 'TypeCtrl'
|
28
|
-
})
|
29
|
-
.state('root.action', {
|
30
|
-
url: '/:version/controller/:controller/:action',
|
31
|
-
templateUrl: 'views/action.html',
|
32
|
-
controller: 'ActionCtrl'
|
33
|
-
})
|
34
|
-
.state('root.trait', {
|
35
|
-
url: '/:version/trait/:trait',
|
36
|
-
templateUrl: 'views/trait.html',
|
37
|
-
controller: 'TraitCtrl'
|
38
|
-
})
|
39
|
-
.state('root.builtin', {
|
40
|
-
abstract: true,
|
41
|
-
url: '/builtin',
|
42
|
-
template: '<ui-view/>'
|
43
|
-
})
|
44
|
-
.state('root.builtin.field-selector', {
|
45
|
-
url: '/field-selector',
|
46
|
-
templateUrl: 'views/builtin/field-selector.html'
|
47
|
-
});
|
48
|
-
});
|
@@ -1,47 +0,0 @@
|
|
1
|
-
app.controller('ActionCtrl', function($scope, $stateParams, Documentation, normalizeAttributes, PageInfo) {
|
2
|
-
$scope.controllerName = $stateParams.controller;
|
3
|
-
$scope.actionName = $stateParams.action;
|
4
|
-
$scope.apiVersion = $stateParams.version;
|
5
|
-
|
6
|
-
Documentation.controller($stateParams.version, $stateParams.controller).then(function(response) {
|
7
|
-
|
8
|
-
$scope.controller = response;
|
9
|
-
PageInfo.title = $scope.controller.display_name + ' » ' + $scope.actionName;
|
10
|
-
$scope.action = _.find(response.actions, function(action) { return action.name === $scope.actionName; });
|
11
|
-
if (!$scope.action) {
|
12
|
-
$scope.error = true;
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
// Extract the example and attach it to each attribute
|
16
|
-
_.forEach(['headers', 'params', 'payload'], function(n) {
|
17
|
-
var set = $scope.action[n];
|
18
|
-
if (set) {
|
19
|
-
normalizeAttributes(set, set.type.attributes);
|
20
|
-
}
|
21
|
-
});
|
22
|
-
|
23
|
-
$scope.responses = [];
|
24
|
-
_.forEach($scope.action.responses, function(response, name) {
|
25
|
-
response.name = name;
|
26
|
-
response.options = {
|
27
|
-
headers: response.headers
|
28
|
-
};
|
29
|
-
|
30
|
-
response.numExamples = _.keys(_.get(response, 'payload.examples')).length;
|
31
|
-
|
32
|
-
$scope.responses.push(response);
|
33
|
-
|
34
|
-
if(response.parts_like) {
|
35
|
-
response.parts_like.isMultipart = true;
|
36
|
-
response.parts_like.options = {
|
37
|
-
headers: response.parts_like.headers
|
38
|
-
};
|
39
|
-
$scope.responses.push(response.parts_like);
|
40
|
-
}
|
41
|
-
});
|
42
|
-
});
|
43
|
-
|
44
|
-
$scope.hasResponses = function() {
|
45
|
-
return $scope.action ? _.any($scope.action.responses) : false;
|
46
|
-
};
|
47
|
-
});
|
@@ -1,10 +0,0 @@
|
|
1
|
-
app.controller('ControllerCtrl', function($scope, $stateParams, Documentation) {
|
2
|
-
$scope.controllerName = $stateParams.controller;
|
3
|
-
$scope.apiVersion = $stateParams.version;
|
4
|
-
|
5
|
-
Documentation.controller($stateParams.version, $stateParams.controller).then(function(response) {
|
6
|
-
$scope.controller = response;
|
7
|
-
}, function() {
|
8
|
-
$scope.error = true;
|
9
|
-
});
|
10
|
-
});
|
@@ -1,93 +0,0 @@
|
|
1
|
-
app.controller('MenuCtrl', function($scope, $state, Documentation) {
|
2
|
-
var parentLookup = {};
|
3
|
-
$scope.versions = [];
|
4
|
-
$scope.resources = {};
|
5
|
-
$scope.schemas = {};
|
6
|
-
$scope.traits = {};
|
7
|
-
$scope.selectedVersion = '';
|
8
|
-
$scope.currentType = '';
|
9
|
-
$scope.active = {};
|
10
|
-
|
11
|
-
Documentation.versions().then(function(versions) {
|
12
|
-
$scope.versions = versions;
|
13
|
-
_.each(versions, function(version) {
|
14
|
-
Documentation.items(version).then(function(items) {
|
15
|
-
var resources = $scope.resources[version] = [];
|
16
|
-
var schemas = $scope.schemas[version] = [];
|
17
|
-
var traits = $scope.traits[version] = [];
|
18
|
-
var children = [];
|
19
|
-
_.each(items.resources, function(item, name) {
|
20
|
-
var link = { name: item.display_name, stateRef: '' };
|
21
|
-
|
22
|
-
parentLookup[name] = link;
|
23
|
-
link.stateRef = $state.href('root.controller', { version: version, controller: name });
|
24
|
-
link.id = name;
|
25
|
-
|
26
|
-
link.actions = _.map(item.actions, function(action) {
|
27
|
-
var actionLink = { name: action.name, stateRef: '' };
|
28
|
-
parentLookup[name + '_action_' + action.name] = actionLink;
|
29
|
-
actionLink.parent = name;
|
30
|
-
actionLink.stateRef = $state.href('root.action', { version: version, controller: name, action: action.name });
|
31
|
-
actionLink.id = name + '_action_' + action.name;
|
32
|
-
actionLink.isAction = true;
|
33
|
-
actionLink.parentRef = link;
|
34
|
-
return actionLink;
|
35
|
-
});
|
36
|
-
link.childResources = [];
|
37
|
-
if (item.parent) {
|
38
|
-
link.parent = item.parent;
|
39
|
-
children.push(link);
|
40
|
-
} else {
|
41
|
-
resources.push(link);
|
42
|
-
}
|
43
|
-
});
|
44
|
-
_.each(items.schemas, function(item, name) {
|
45
|
-
var link = { name: item.display_name, stateRef: '' };
|
46
|
-
link.stateRef = $state.href('root.type', { version: version, type: item.id });
|
47
|
-
link.id = name;
|
48
|
-
schemas.push(link);
|
49
|
-
});
|
50
|
-
_.each(items.traits, function(item, name) {
|
51
|
-
var link = { name: name, stateRef: '' };
|
52
|
-
link.stateRef = $state.href('root.trait', { version: version, trait: name });
|
53
|
-
link.id = name;
|
54
|
-
traits.push(link);
|
55
|
-
});
|
56
|
-
_.each(children, function(link) {
|
57
|
-
if (parentLookup[link.parent]) {
|
58
|
-
link.parentRef = parentLookup[link.parent];
|
59
|
-
parentLookup[link.parent].childResources.push(link);
|
60
|
-
} else {
|
61
|
-
throw 'No parent resource found';
|
62
|
-
}
|
63
|
-
});
|
64
|
-
});
|
65
|
-
});
|
66
|
-
var numeralVersions = _.filter($scope.versions, function(n) { return !isNaN(parseFloat(n)); })
|
67
|
-
.sort(function(a,b) { return parseFloat(b) - parseFloat(a); });
|
68
|
-
$scope.selectedVersion = $state.params.version || numeralVersions[0] || $scope.versions[0];
|
69
|
-
});
|
70
|
-
|
71
|
-
$scope.select = function(version) {
|
72
|
-
$scope.selectedVersion = version;
|
73
|
-
};
|
74
|
-
|
75
|
-
$scope.availableResources = function() {
|
76
|
-
return $scope.resources[$scope.selectedVersion];
|
77
|
-
};
|
78
|
-
|
79
|
-
$scope.availableSchemas = function() {
|
80
|
-
return $scope.schemas[$scope.selectedVersion];
|
81
|
-
};
|
82
|
-
|
83
|
-
$scope.availableTraits = function() {
|
84
|
-
return $scope.traits[$scope.selectedVersion];
|
85
|
-
};
|
86
|
-
|
87
|
-
$scope.$on('$stateChangeSuccess', function(e, state, params) {
|
88
|
-
if (params.version) $scope.selectedVersion = params.version;
|
89
|
-
$scope.active.resources = state.name !== 'root.type' && state.name !== 'root.trait';
|
90
|
-
$scope.active.schemas = state.name === 'root.type';
|
91
|
-
$scope.active.traits = state.name === 'root.trait';
|
92
|
-
});
|
93
|
-
});
|
@@ -1,10 +0,0 @@
|
|
1
|
-
app.controller('TraitCtrl', function ($scope, $stateParams, Documentation) {
|
2
|
-
$scope.traitName = $stateParams.trait;
|
3
|
-
$scope.apiVersion = $stateParams.version;
|
4
|
-
|
5
|
-
Documentation.trait($stateParams.version, $scope.traitName).then(function(data) {
|
6
|
-
$scope.trait = data;
|
7
|
-
}, function() {
|
8
|
-
$scope.error = true;
|
9
|
-
});
|
10
|
-
});
|
@@ -1,24 +0,0 @@
|
|
1
|
-
app.controller('TypeCtrl', function ($scope, $stateParams, Documentation, normalizeAttributes) {
|
2
|
-
$scope.typeId = $stateParams.type || $scope.controller.media_type.id;
|
3
|
-
$scope.apiVersion = $stateParams.version;
|
4
|
-
$scope.controllers = [];
|
5
|
-
$scope.views = [];
|
6
|
-
|
7
|
-
Documentation.type($stateParams.version, $scope.typeId).then(function(data) {
|
8
|
-
$scope.type = data;
|
9
|
-
$scope.views = _(data.views)
|
10
|
-
.map(function(view, name) { return _.extend(view, { name: name }); })
|
11
|
-
.select(function(view) { return view.name !== 'master'; })
|
12
|
-
.value();
|
13
|
-
normalizeAttributes($scope.type, $scope.type.attributes);
|
14
|
-
|
15
|
-
Documentation.items($scope.apiVersion).then(function(response) {
|
16
|
-
$scope.controllers = _.select(response.resources, function(item, id) {
|
17
|
-
item.id = id;
|
18
|
-
return item.media_type.id == $scope.type.id;
|
19
|
-
});
|
20
|
-
});
|
21
|
-
}, function() {
|
22
|
-
$scope.error = true;
|
23
|
-
});
|
24
|
-
});
|
@@ -1,56 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* This directive renders out various attributes of types. It will render the description
|
3
|
-
* in Markdown and use several dynamic templates to show each piece.
|
4
|
-
*/
|
5
|
-
app.directive('attributeDescription', function($compile, $templateCache, $http) {
|
6
|
-
return {
|
7
|
-
restrict: 'E',
|
8
|
-
templateUrl: 'views/directives/attribute_description.html',
|
9
|
-
scope: {
|
10
|
-
attribute: '='
|
11
|
-
},
|
12
|
-
link: function(scope, element) {
|
13
|
-
var list = element.find('dl');
|
14
|
-
|
15
|
-
_.forEach(scope.attribute.options, function(option, name) {
|
16
|
-
var templatePath = 'views/directives/attribute_description/default.html';
|
17
|
-
var skip_keys = ['reference','dsl_compiler','dsl_compiler_options'];
|
18
|
-
|
19
|
-
switch (name) {
|
20
|
-
case 'example':
|
21
|
-
// expects string
|
22
|
-
if(typeof option !== 'string') {
|
23
|
-
option = JSON.stringify(option, null, 2);
|
24
|
-
}
|
25
|
-
templatePath = 'views/directives/attribute_description/example.html';
|
26
|
-
break;
|
27
|
-
case 'headers':
|
28
|
-
templatePath = 'views/directives/attribute_description/headers.html';
|
29
|
-
break;
|
30
|
-
case 'values':
|
31
|
-
templatePath = 'views/directives/attribute_description/values.html';
|
32
|
-
break;
|
33
|
-
case 'member_options':
|
34
|
-
templatePath = 'views/directives/attribute_description/member_options.html';
|
35
|
-
break;
|
36
|
-
}
|
37
|
-
|
38
|
-
if( ! _.contains( skip_keys, name ) ) {
|
39
|
-
$http.get(templatePath, { cache: $templateCache }).success(function(template) {
|
40
|
-
var row = $(template);
|
41
|
-
var rowScope = scope.$new(true);
|
42
|
-
|
43
|
-
rowScope.row = {
|
44
|
-
name: _.startCase(name),
|
45
|
-
value: option
|
46
|
-
};
|
47
|
-
|
48
|
-
$compile(row)(rowScope);
|
49
|
-
list.append(row);
|
50
|
-
});
|
51
|
-
}
|
52
|
-
|
53
|
-
});
|
54
|
-
}
|
55
|
-
};
|
56
|
-
});
|
@@ -1,28 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* This directive is responsible for showing attributes in a table structure.
|
3
|
-
*/
|
4
|
-
|
5
|
-
app.directive('attributeTable', function() {
|
6
|
-
return {
|
7
|
-
restrict: 'E',
|
8
|
-
templateUrl: 'views/directives/attribute_table.html',
|
9
|
-
scope: {
|
10
|
-
attributes: '=',
|
11
|
-
showGroups: '=',
|
12
|
-
parentRequirements: '='
|
13
|
-
},
|
14
|
-
link: function(scope) {
|
15
|
-
scope.groups = [{attributes: []}];
|
16
|
-
|
17
|
-
if(scope.showGroups) {
|
18
|
-
scope.groups[0].name = 'Required';
|
19
|
-
scope.groups.push({name: 'Optional', attributes: []});
|
20
|
-
}
|
21
|
-
|
22
|
-
_.forEach(scope.attributes, function(attr, key) {
|
23
|
-
attr.name = attr.name || key;
|
24
|
-
scope.groups[(scope.showGroups && !attr.required ? 1 : 0)].attributes.push(attr);
|
25
|
-
});
|
26
|
-
}
|
27
|
-
};
|
28
|
-
});
|
@@ -1,13 +0,0 @@
|
|
1
|
-
app.directive('conditionalRequirements', function() {
|
2
|
-
return {
|
3
|
-
restrict: 'E',
|
4
|
-
scope: {
|
5
|
-
requirements: '=',
|
6
|
-
},
|
7
|
-
templateUrl: 'views/types/embedded/requirements.html',
|
8
|
-
link: function(scope, element, attrs) {
|
9
|
-
// Reject requirements of type "all"
|
10
|
-
scope.condRequirements = _.reject(scope.requirements, {type: 'all'});
|
11
|
-
}
|
12
|
-
};
|
13
|
-
});
|
@@ -1,38 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* This directive adds the css position fixed if the tabs fit on screen
|
3
|
-
*/
|
4
|
-
|
5
|
-
app.directive('fixedIfFits', function($timeout, $rootScope) {
|
6
|
-
return {
|
7
|
-
restrict: 'C',
|
8
|
-
link: function(scope, element) {
|
9
|
-
function recalculateLayout() {
|
10
|
-
$timeout(function() {
|
11
|
-
var height = _(element.find('.tab-content .tab-pane').get()).map(function(el) {
|
12
|
-
return angular.element(el).height();
|
13
|
-
}).concat([element[0].scrollHeight]).max() + element.offset().top + element.find('.row:first-of-type').height();
|
14
|
-
var mq = window.matchMedia('(min-width: 768px)');
|
15
|
-
if (height < $(window).height() && mq.matches) {
|
16
|
-
var padding = 20;
|
17
|
-
element[0].style.width = (element.width() + padding) + 'px';
|
18
|
-
element[0].style.paddingRight = padding + 'px';
|
19
|
-
var navbarHeight = '' + ($('.navbar').height() || 60) + 'px';
|
20
|
-
element[0].style.height = 'calc(100vh - ' + navbarHeight + ')';
|
21
|
-
element[0].style.paddingBottom = '30px';
|
22
|
-
element[0].style['overflow-y'] = 'auto';
|
23
|
-
element[0].style.position = 'fixed';
|
24
|
-
} else {
|
25
|
-
element[0].style.width = null;
|
26
|
-
element[0].style.paddingRight = null;
|
27
|
-
element[0].style.height = null;
|
28
|
-
element[0].style.paddingBottom = null;
|
29
|
-
element[0].style['overflow-y'] = null;
|
30
|
-
element[0].style.position = 'static';
|
31
|
-
}
|
32
|
-
}, 100);
|
33
|
-
}
|
34
|
-
recalculateLayout();
|
35
|
-
$rootScope.$on('$stateChangeSuccess', recalculateLayout);
|
36
|
-
}
|
37
|
-
};
|
38
|
-
});
|
@@ -1,14 +0,0 @@
|
|
1
|
-
app.directive('highlight', function() {
|
2
|
-
return {
|
3
|
-
restrict: 'EA',
|
4
|
-
link: function ($scope, element, attrs) {
|
5
|
-
var prism = window.Prism;
|
6
|
-
prism.plugins.autoloader.languages_path = 'https://cdn.jsdelivr.net/prism/1.3.0/components/';
|
7
|
-
element.ready(function() {
|
8
|
-
element.html('<code>' + element.text() + '</code>');
|
9
|
-
element.addClass('language-' + attrs.highlight);
|
10
|
-
prism.highlightElement(element.find('code')[0]);
|
11
|
-
});
|
12
|
-
}
|
13
|
-
};
|
14
|
-
});
|