tent-schemas 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ output/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tent-schema.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jonathan Rudenberg
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ # Tent Protocol Schemas
2
+
3
+ This repository contains [JSON Schemas](http://json-schema.org/) for most of the
4
+ [Tent Protocol](http://tent.io). Currently they are used to generate
5
+ documentation examples. In the future they will also contain specifications for
6
+ all API endpoints in Tent so that clients can be implemented/updated
7
+ programmtically.
8
+
9
+ Tent post and profile info types should also be implemented as JSON schemas, the
10
+ schema for these definitions has yet to be defined.
11
+
12
+ ## Contributions
13
+
14
+ Here are some things that need to be done:
15
+
16
+ - Fix errors in the schemas.
17
+ - Implement a version of JSON hyper schemas that defines API endpoints/actions.
18
+ - Write a schema for post type schemas.
19
+ - Write a schema for profile info type schemas.
@@ -0,0 +1,18 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ require File.expand_path('../lib/tent-schemas', __FILE__)
4
+ require 'fileutils'
5
+ require 'json'
6
+ require 'yaml'
7
+
8
+ Rake::TestTask.new do |t|
9
+ t.pattern = 'test/**/*_test.rb'
10
+ end
11
+
12
+ task :default => :test
13
+
14
+ desc "Generate schema json"
15
+ task :generate do
16
+ FileUtils.mkdir_p('output')
17
+ File.open("output/schema.json", 'w') { |f| f.write(JSON.pretty_generate(TentSchemas.schema)) }
18
+ end
@@ -0,0 +1,27 @@
1
+ require 'yaml'
2
+
3
+ module TentSchemas
4
+ extend self
5
+
6
+ def schema_files
7
+ Dir.glob(File.expand_path('../../schemas/*', __FILE__))
8
+ end
9
+
10
+ def schemas
11
+ @schemas ||= schema_files.inject(Hash.new { |h,k| h[k.to_s] }) { |hash,schema|
12
+ hash.merge(File.basename(schema, '.yaml') => YAML.load(File.read(schema)))
13
+ }
14
+ end
15
+
16
+ def each(&block)
17
+ schemas.each(&block)
18
+ end
19
+
20
+ def [](k)
21
+ schemas[k]
22
+ end
23
+
24
+ def schema
25
+ { 'schemas' => schemas }
26
+ end
27
+ end
@@ -0,0 +1,56 @@
1
+ title: Tent App
2
+ type: object
3
+ properties:
4
+ id:
5
+ description: The unique identifier of the app.
6
+ type: string
7
+ name:
8
+ description: The short display name for the app.
9
+ type: string
10
+ required: true
11
+ description:
12
+ description: The short display description of the app.
13
+ type: string
14
+ required: true
15
+ url:
16
+ descriptioon: The URL for the home page of the app.
17
+ type: string
18
+ format: uri
19
+ required: true
20
+ icon:
21
+ description: The URL to the icon for the app.
22
+ type: string
23
+ format: uri
24
+ redirect_uris:
25
+ description:
26
+ The exact (including parameters) uris that will be used as OAuth
27
+ `redirect_uri`.
28
+ type: array
29
+ required: true
30
+ items:
31
+ type: string
32
+ format: uri
33
+ scopes:
34
+ description:
35
+ All of the scopes that the application will use, and the reason why each
36
+ is required.
37
+ required: true
38
+ patternProperties:
39
+ .+:
40
+ type: string
41
+ mac_algorithm:
42
+ description: The MAC algorithm to use when authenticating the app.
43
+ type: string
44
+ enum:
45
+ - hmac-sha-1
46
+ - hmac-sha-256
47
+ mac_key_id:
48
+ description: The MAC key identifier to use when authenticating the app.
49
+ type: string
50
+ mac_key:
51
+ description: The MAC key to use when authenticating the app.
52
+ type: string
53
+ dependencies:
54
+ mac_key:
55
+ - mac_algorithm
56
+ - mac_key_id
@@ -0,0 +1,70 @@
1
+ title: Tent App Authorization
2
+ type: object
3
+ properties:
4
+ id:
5
+ description: The unique identifier of the app authorization.
6
+ type: string
7
+ scopes:
8
+ description: The scopes that the authorization allows the app to access.
9
+ type: array
10
+ items:
11
+ type: string
12
+ profile_info_types:
13
+ description: The profile info types that the app has access to.
14
+ type: array
15
+ items:
16
+ type: string
17
+ format: uri
18
+ post_types:
19
+ description:
20
+ The post types that the app has access to and will receive notifications
21
+ for.
22
+ type: array
23
+ items:
24
+ type: string
25
+ format: uri
26
+ notification_url:
27
+ description:
28
+ The endpoint used to send post notifications to the app. The app will not
29
+ receive notifications if this is not set.
30
+ type: string
31
+ format: uri
32
+ follow_url:
33
+ description:
34
+ The endpoint to redirect the user to when requesting a follow. Used when
35
+ the app has the `follow_ui` scope.
36
+ type: string
37
+ format: uri
38
+ app_auth_url:
39
+ description:
40
+ The endpoint to redirect the user to when requesting an app auth. Used
41
+ when the app has the `app_auth_ui` scope.
42
+ type: string
43
+ format: uri
44
+ groups:
45
+ description: The groups that the app is in.
46
+ type: array
47
+ items:
48
+ $ref: '#/schemas/group'
49
+ token_type:
50
+ description: The type of `access_token` issued.
51
+ type: string
52
+ enum:
53
+ - mac
54
+ mac_algorithm:
55
+ description: The MAC algorithm to use when authenticating the app.
56
+ type: string
57
+ enum:
58
+ - hmac-sha-1
59
+ - hmac-sha-256
60
+ mac_key_id:
61
+ description: The MAC key identifier to use when authenticating the app.
62
+ type: string
63
+ access_token:
64
+ description: The MAC key to use when authenticating the app.
65
+ type: string
66
+ dependencies:
67
+ access_token:
68
+ - mac_algorithm
69
+ - token_type
70
+ - mac_key_id
@@ -0,0 +1,46 @@
1
+ title: Tent Follow
2
+ type: object
3
+ properties:
4
+ id:
5
+ description: The unique identifier of the follow.
6
+ type: string
7
+ entity:
8
+ description: The entity that the follow refers to.
9
+ type: string
10
+ format: uri
11
+ required: true
12
+ groups:
13
+ description: The groups that the follow is in.
14
+ type: array
15
+ items:
16
+ $ref: '#/schemas/group'
17
+ types:
18
+ description: The types the follow is subscribed to notifications for.
19
+ type: array
20
+ items:
21
+ type: string
22
+ format: uri
23
+ licenses:
24
+ description: The licenses the follow uses in it's posts.
25
+ type: array
26
+ items:
27
+ type: string
28
+ format: uri
29
+ mac_algorithm:
30
+ description: The MAC algorithm to use when authenticating the follow.
31
+ type: string
32
+ enum:
33
+ - hmac-sha-1
34
+ - hmac-sha-256
35
+ mac_key_id:
36
+ description: The MAC key identifier to use when authenticating the follow.
37
+ type: string
38
+ mac_key:
39
+ description: The MAC key to use when authenticating the follow.
40
+ type: string
41
+ permissions:
42
+ $ref: '#/schemas/permissions'
43
+ dependencies:
44
+ mac_key:
45
+ - mac_algorithm
46
+ - mac_key_id
@@ -0,0 +1,10 @@
1
+ name: Tent Group
2
+ type: object
3
+ properties:
4
+ id:
5
+ description: The unique identifier of the group.
6
+ type: string
7
+ name:
8
+ description: The name of the group.
9
+ type: string
10
+ require: true
@@ -0,0 +1,23 @@
1
+ name: Tent Permissions
2
+ description: The permissions that apply to the instance.
3
+ type: object
4
+ properties:
5
+ public:
6
+ description:
7
+ Indicates whether the instance is public, public instances are available
8
+ to unauthenticated requests.
9
+ type: boolean
10
+ required: true
11
+ groups:
12
+ description: The groups that are allowed to view the instance.
13
+ type: array
14
+ items:
15
+ $ref: '#/schemas/group'
16
+ entities:
17
+ type: object
18
+ patternProperties:
19
+ .+:
20
+ description:
21
+ An entity identifier and boolean value that indicates whether the
22
+ entity is allowed to view the instance.
23
+ type: boolean
@@ -0,0 +1,127 @@
1
+ title: Tent Post
2
+ type: object
3
+ properties:
4
+ id:
5
+ description: The unique identifier of the post.
6
+ type: string
7
+ entity:
8
+ description: The entity that published the post.
9
+ type: string
10
+ format: uri
11
+ required: true
12
+ published_at:
13
+ description: The date/time when the post was published in Unix time.
14
+ type: integer
15
+ required: true
16
+ received_at:
17
+ description:
18
+ The date/time when the post was received from the publishing server in
19
+ Unix time.
20
+ type: integer
21
+ mentions:
22
+ description: The entities and posts that this post mentions.
23
+ type: array
24
+ items:
25
+ type: object
26
+ properties:
27
+ entity:
28
+ description: The entity that is being mentioned.
29
+ type: string
30
+ format: uri
31
+ required: true
32
+ post:
33
+ description:
34
+ The unique post identifier published by the entity that is being
35
+ mentioned.
36
+ type: string
37
+ licenses:
38
+ description: The licenses that the post is released under.
39
+ type: array
40
+ required: true
41
+ items:
42
+ type: string
43
+ format: uri
44
+ type:
45
+ description:
46
+ The post type URL. This should resolve to a JSON Schema that describes
47
+ the data inside `content`.
48
+ type: string
49
+ format: uri
50
+ required: true
51
+ content:
52
+ description: The post content.
53
+ type: object
54
+ required: true
55
+ attachments:
56
+ description: Attachments to the post.
57
+ type: array
58
+ items:
59
+ type: object
60
+ properties:
61
+ category:
62
+ description:
63
+ The category this attachment is in, used to determine what to
64
+ include in a notification based on views.
65
+ type: string
66
+ required: true
67
+ type:
68
+ description: The media type of the attachment.
69
+ type: string
70
+ required: true
71
+ name:
72
+ description:
73
+ The name of the attachment. The name and media type combination are
74
+ the unique identifier for the attachment.
75
+ type: string
76
+ required: true
77
+ size:
78
+ description: The size in bytes of the attachment.
79
+ type: integer
80
+ required: true
81
+ app:
82
+ description: The application that published the post.
83
+ type: object
84
+ properties:
85
+ name:
86
+ description: The human readable name of the application.
87
+ type: string
88
+ url:
89
+ description: The URL of the application.
90
+ type: string
91
+ format: uri
92
+ views:
93
+ description: The available views of the post.
94
+ type: object
95
+ patternProperties:
96
+ .+:
97
+ type: object
98
+ properties:
99
+ content:
100
+ description:
101
+ An array of JSON pointers that point to keys inside of `content`
102
+ that should be included in this view.
103
+ type: array
104
+ items:
105
+ type: string
106
+ attachments:
107
+ description:
108
+ The attachments that should be included when making notifications
109
+ about this post. The `category`, `name`, and `type` specifier in
110
+ each object will be combined as an `OR` condition to select
111
+ attachments.
112
+ type: array
113
+ items:
114
+ type: object
115
+ properties:
116
+ category:
117
+ description: The category of attachment.
118
+ type: string
119
+ name:
120
+ description: The name of the attachment
121
+ type: string
122
+ type:
123
+ description: The media type of the attachment.
124
+ type: string
125
+
126
+ permissions:
127
+ $ref: '#/schemas/permissions'
@@ -0,0 +1,6 @@
1
+ title: Tent Profile
2
+ type: object
3
+ patternProperties:
4
+ .+:
5
+ description: A profile info type and its contents.
6
+ type: object
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'tent-schemas'
5
+ gem.version = '0.0.1'
6
+ gem.authors = ['Jonathan Rudenberg']
7
+ gem.email = ['jonathan@titanous.com']
8
+ gem.description = 'Tent protocol JSON schemas'
9
+ gem.summary = 'Tent protocol JSON schemas'
10
+ gem.homepage = 'http://tent.io'
11
+
12
+ gem.files = `git ls-files`.split($/)
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.require_paths = ['lib']
15
+
16
+ gem.add_runtime_dependency 'json-schema'
17
+ end
@@ -0,0 +1,19 @@
1
+ require 'bundler/setup'
2
+ require File.expand_path('../../lib/tent-schemas', __FILE__)
3
+ require 'test/unit'
4
+ require 'json-schema'
5
+ require 'yaml'
6
+ require 'json'
7
+
8
+ class SchemasTest < Test::Unit::TestCase
9
+ TentSchemas.each do |name,schema|
10
+ define_method "test_#{name}" do
11
+ validate_schema(schema)
12
+ end
13
+ end
14
+
15
+ def validate_schema(schema)
16
+ errors = JSON::Validator.fully_validate_schema(schema)
17
+ assert errors.empty?, errors.inspect
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tent-schemas
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jonathan Rudenberg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json-schema
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Tent protocol JSON schemas
31
+ email:
32
+ - jonathan@titanous.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - Gemfile.lock
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - lib/tent-schemas.rb
44
+ - schemas/app.yaml
45
+ - schemas/app_authorization.yaml
46
+ - schemas/follow.yaml
47
+ - schemas/group.yaml
48
+ - schemas/permissions.yaml
49
+ - schemas/post.yaml
50
+ - schemas/profile.yaml
51
+ - tent-schemas.gemspec
52
+ - test/schemas_test.rb
53
+ homepage: http://tent.io
54
+ licenses: []
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 1.8.23
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Tent protocol JSON schemas
77
+ test_files:
78
+ - test/schemas_test.rb