swagger_yard 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +126 -99
  3. data/Rakefile +6 -22
  4. data/lib/swagger_yard/api.rb +26 -109
  5. data/lib/swagger_yard/api_declaration.rb +89 -23
  6. data/lib/swagger_yard/authorization.rb +36 -0
  7. data/lib/swagger_yard/configuration.rb +14 -0
  8. data/lib/swagger_yard/listing_info.rb +15 -0
  9. data/lib/swagger_yard/model.rb +69 -0
  10. data/lib/swagger_yard/operation.rb +149 -0
  11. data/lib/swagger_yard/parameter.rb +62 -3
  12. data/lib/swagger_yard/property.rb +36 -0
  13. data/lib/swagger_yard/resource_listing.rb +57 -18
  14. data/lib/swagger_yard/type.rb +34 -0
  15. data/lib/swagger_yard/version.rb +1 -1
  16. data/lib/swagger_yard.rb +35 -78
  17. metadata +70 -48
  18. data/app/controllers/swagger_yard/application_controller.rb +0 -4
  19. data/app/controllers/swagger_yard/swagger_controller.rb +0 -21
  20. data/app/views/swagger_yard/swagger/doc.html.erb +0 -80
  21. data/lib/generators/swagger_yard/doc_generator.rb +0 -11
  22. data/lib/generators/swagger_yard/js_generator.rb +0 -13
  23. data/lib/swagger_yard/cache.rb +0 -50
  24. data/lib/swagger_yard/engine.rb +0 -18
  25. data/lib/swagger_yard/local_dispatcher.rb +0 -51
  26. data/lib/swagger_yard/parser.rb +0 -35
  27. data/public/swagger-ui/css/hightlight.default.css +0 -135
  28. data/public/swagger-ui/css/screen.css +0 -1759
  29. data/public/swagger-ui/images/logo_small.png +0 -0
  30. data/public/swagger-ui/images/pet_store_api.png +0 -0
  31. data/public/swagger-ui/images/throbber.gif +0 -0
  32. data/public/swagger-ui/images/wordnik_api.png +0 -0
  33. data/public/swagger-ui/lib/MD5.js +0 -319
  34. data/public/swagger-ui/lib/backbone-min.js +0 -38
  35. data/public/swagger-ui/lib/handlebars-1.0.rc.1.js +0 -1920
  36. data/public/swagger-ui/lib/highlight.7.3.pack.js +0 -1
  37. data/public/swagger-ui/lib/jquery-1.8.0.min.js +0 -2
  38. data/public/swagger-ui/lib/jquery.ba-bbq.min.js +0 -18
  39. data/public/swagger-ui/lib/jquery.slideto.min.js +0 -1
  40. data/public/swagger-ui/lib/jquery.wiggle.min.js +0 -8
  41. data/public/swagger-ui/lib/swagger.js +0 -794
  42. data/public/swagger-ui/lib/underscore-min.js +0 -32
  43. data/public/swagger-ui/swagger-ui.js +0 -2090
  44. data/public/swagger-ui/swagger-ui_org.js +0 -2005
metadata CHANGED
@@ -1,55 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagger_yard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - chtrinh (Chris Trinh)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-13 00:00:00.000000000 Z
11
+ date: 2015-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: yard
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.8
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.2.8
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: sqlite3
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: yard
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- type: :runtime
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ! '>='
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bourne
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
53
95
  - !ruby/object:Gem::Version
54
96
  version: '0'
55
97
  description: SwaggerYard API doc gem that uses YARD to parse the docs for a REST rails
@@ -60,43 +102,23 @@ executables: []
60
102
  extensions: []
61
103
  extra_rdoc_files: []
62
104
  files:
63
- - app/controllers/swagger_yard/application_controller.rb
64
- - app/controllers/swagger_yard/swagger_controller.rb
65
- - app/views/swagger_yard/swagger/doc.html.erb
105
+ - MIT-LICENSE
106
+ - README.md
107
+ - Rakefile
66
108
  - config/routes.rb
67
- - public/swagger-ui/css/hightlight.default.css
68
- - public/swagger-ui/css/screen.css
69
- - public/swagger-ui/images/logo_small.png
70
- - public/swagger-ui/images/pet_store_api.png
71
- - public/swagger-ui/images/throbber.gif
72
- - public/swagger-ui/images/wordnik_api.png
73
- - public/swagger-ui/lib/backbone-min.js
74
- - public/swagger-ui/lib/handlebars-1.0.rc.1.js
75
- - public/swagger-ui/lib/highlight.7.3.pack.js
76
- - public/swagger-ui/lib/jquery-1.8.0.min.js
77
- - public/swagger-ui/lib/jquery.ba-bbq.min.js
78
- - public/swagger-ui/lib/jquery.slideto.min.js
79
- - public/swagger-ui/lib/jquery.wiggle.min.js
80
- - public/swagger-ui/lib/MD5.js
81
- - public/swagger-ui/lib/swagger.js
82
- - public/swagger-ui/lib/underscore-min.js
83
- - public/swagger-ui/swagger-ui.js
84
- - public/swagger-ui/swagger-ui_org.js
85
- - lib/generators/swagger_yard/doc_generator.rb
86
- - lib/generators/swagger_yard/js_generator.rb
109
+ - lib/swagger_yard.rb
87
110
  - lib/swagger_yard/api.rb
88
111
  - lib/swagger_yard/api_declaration.rb
89
- - lib/swagger_yard/cache.rb
90
- - lib/swagger_yard/engine.rb
91
- - lib/swagger_yard/local_dispatcher.rb
112
+ - lib/swagger_yard/authorization.rb
113
+ - lib/swagger_yard/configuration.rb
114
+ - lib/swagger_yard/listing_info.rb
115
+ - lib/swagger_yard/model.rb
116
+ - lib/swagger_yard/operation.rb
92
117
  - lib/swagger_yard/parameter.rb
93
- - lib/swagger_yard/parser.rb
118
+ - lib/swagger_yard/property.rb
94
119
  - lib/swagger_yard/resource_listing.rb
120
+ - lib/swagger_yard/type.rb
95
121
  - lib/swagger_yard/version.rb
96
- - lib/swagger_yard.rb
97
- - MIT-LICENSE
98
- - Rakefile
99
- - README.md
100
122
  homepage: http://www.synctv.com
101
123
  licenses:
102
124
  - MIT
@@ -107,17 +129,17 @@ require_paths:
107
129
  - lib
108
130
  required_ruby_version: !ruby/object:Gem::Requirement
109
131
  requirements:
110
- - - ! '>='
132
+ - - ">="
111
133
  - !ruby/object:Gem::Version
112
134
  version: '0'
113
135
  required_rubygems_version: !ruby/object:Gem::Requirement
114
136
  requirements:
115
- - - ! '>='
137
+ - - ">="
116
138
  - !ruby/object:Gem::Version
117
139
  version: '0'
118
140
  requirements: []
119
141
  rubyforge_project:
120
- rubygems_version: 2.1.3
142
+ rubygems_version: 2.4.5
121
143
  signing_key:
122
144
  specification_version: 4
123
145
  summary: SwaggerYard API doc through YARD
@@ -1,4 +0,0 @@
1
- module SwaggerYard
2
- class ApplicationController < ActionController::Base
3
- end
4
- end
@@ -1,21 +0,0 @@
1
- module SwaggerYard
2
- class SwaggerController < ApplicationController
3
- layout false
4
-
5
- def index
6
- swagger_listing = SwaggerYard.get_listing
7
- swagger_listing.merge!("basePath" => request.url) if swagger_listing["basePath"].blank?
8
- render :json => swagger_listing
9
- end
10
-
11
- def show
12
- swagger_api = SwaggerYard.get_api("/#{params[:resource]}")
13
- swagger_api.merge!("basePath" => request.base_url + SwaggerYard.api_path) if swagger_api["basePath"].blank?
14
- render :json => swagger_api
15
- end
16
-
17
- def doc
18
- render :doc
19
- end
20
- end
21
- end
@@ -1,80 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Swagger UI</title>
5
- <link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
6
- <link href='../swagger-ui/css/hightlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
7
- <link href='../swagger-ui/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
8
- <script src='../swagger-ui/lib/jquery-1.8.0.min.js' type='text/javascript'></script>
9
- <script src='../swagger-ui/lib/jquery.slideto.min.js' type='text/javascript'></script>
10
- <script src='../swagger-ui/lib/jquery.wiggle.min.js' type='text/javascript'></script>
11
- <script src='../swagger-ui/lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
12
- <script src='../swagger-ui/lib/handlebars-1.0.rc.1.js' type='text/javascript'></script>
13
- <script src='../swagger-ui/lib/underscore-min.js' type='text/javascript'></script>
14
- <script src='../swagger-ui/lib/backbone-min.js' type='text/javascript'></script>
15
- <script src='../swagger-ui/lib/swagger.js' type='text/javascript'></script>
16
- <script src='../swagger-ui/lib/MD5.js' type='text/javascript'></script>
17
- <script src='../swagger-ui/lib/highlight.7.3.pack.js' type='text/javascript'></script>
18
- <script src='../swagger-ui/swagger-ui.js' type='text/javascript'></script>
19
-
20
- <script type="text/javascript">
21
- $(function () {
22
- window.swaggerUi = new SwaggerUi({
23
- discoveryUrl: location.protocol + "//" + location.host + "/swagger/api",
24
- dom_id:"swagger-ui-container",
25
- supportHeaderParams: true,
26
- supportedSubmitMethods: ['get', 'post', 'put'],
27
- onComplete: function(swaggerApi, swaggerUi){
28
- if(console) {
29
- console.log("Loaded SwaggerUI")
30
- console.log(swaggerApi);
31
- console.log(swaggerUi);
32
- }
33
- $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
34
- },
35
- onFailure: function(data) {
36
- if(console) {
37
- console.log("Unable to Load SwaggerUI");
38
- console.log(data);
39
- }
40
- },
41
- docExpansion: "none"
42
- });
43
-
44
- window.swaggerUi.load();
45
- });
46
-
47
- </script>
48
- </head>
49
-
50
- <body>
51
- <div id='header'>
52
- <div class="swagger-ui-wrap">
53
- <a id="logo" href="http://swagger.wordnik.com">swagger</a>
54
-
55
- <form id='api_selector'>
56
- <div class='input icon-btn'>
57
- <img id="show-pet-store-icon" src="../swagger-ui/images/pet_store_api.png" title="Show Swagger Petstore Example Apis">
58
- </div>
59
- <div class='input icon-btn'>
60
- <img id="show-wordnik-dev-icon" src="../swagger-ui/images/wordnik_api.png" title="Show Wordnik Developer Apis">
61
- </div>
62
- <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl"
63
- type="text"/></div>
64
- <div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
65
- <div class='input'><a id="explore" href="#">Explore</a></div>
66
- </form>
67
- </div>
68
- </div>
69
-
70
- <div id="message-bar" class="swagger-ui-wrap">
71
- &nbsp;
72
- </div>
73
-
74
- <div id="swagger-ui-container" class="swagger-ui-wrap">
75
-
76
- </div>
77
-
78
- </body>
79
-
80
- </html>
@@ -1,11 +0,0 @@
1
- require 'rails/generators'
2
- module SwaggerYard
3
- class DocGenerator < Rails::Generators::Base
4
- source_root File.expand_path("../../../../app/views/swagger_yard/swagger", __FILE__)
5
- desc "Add swagger-ui doc ERB file to app/views for customization"
6
-
7
- def generate_layout
8
- copy_file "doc.html.erb", "app/views/swagger_yard/swagger/doc.html.erb"
9
- end
10
- end
11
- end
@@ -1,13 +0,0 @@
1
- require 'rails/generators'
2
-
3
- module SwaggerYard
4
- class JsGenerator < Rails::Generators::Base
5
- source_root File.expand_path("../../../../public/swagger-ui", __FILE__)
6
- desc "Add swagger-ui js to /public for customization"
7
-
8
- def generate_layout
9
- copy_file "swagger-ui_org.js", "public/swagger-ui/swagger-ui.js"
10
- directory "lib", "public/swagger-ui/lib"
11
- end
12
- end
13
- end
@@ -1,50 +0,0 @@
1
- module SwaggerYard
2
- # For now just a simple wrapper class for a Memcache client.
3
- class Cache
4
-
5
- attr_reader :prefix, :store
6
-
7
- def initialize(store, prefix)
8
- @store = store
9
- @prefix = prefix
10
- end
11
-
12
- # Read from the Cache.
13
- def [](resource_name)
14
- case
15
- when store.respond_to?(:read)
16
- store.read key_for(resource_name)
17
- when store.respond_to?(:[])
18
- store[key_for(resource_name)]
19
- when store.respond_to?(:get)
20
- store.get key_for(resource_name)
21
- end
22
- end
23
-
24
- # Write to the Cache.
25
- def []=(resource_name, value)
26
- case
27
- when store.respond_to?(:write)
28
- store.write key_for(resource_name), value
29
- when store.respond_to?(:[]=)
30
- store[key_for(resource_name)] = value
31
- when store.respond_to?(:set)
32
- store.set key_for(resource_name), value
33
- end
34
- end
35
-
36
- def fetch(resource_name)
37
- value = self[resource_name]
38
- if value.nil? && block_given?
39
- value = yield
40
- self[resource_name] = yield
41
- end
42
- value
43
- end
44
-
45
- # Cache key for a given entry.
46
- def key_for(resource_name)
47
- [prefix, resource_name].join
48
- end
49
- end
50
- end
@@ -1,18 +0,0 @@
1
- require "swagger_yard/local_dispatcher"
2
-
3
- module SwaggerYard
4
- class Engine < ::Rails::Engine
5
- if SwaggerYard::LocalDispatcher.new.server?
6
- isolate_namespace SwaggerYard
7
-
8
- # NOTE: We should opt for asset pipeline instead of this.
9
- initializer 'swagger_yard.load_static_assets' do |app|
10
- app.middleware.use(::ActionDispatch::Static, "#{root}/public")
11
- end
12
-
13
- initializer "swagger_yard.finisher_hook" do |app|
14
- SwaggerYard.generate!("#{app.root}/app/controllers/**/*.rb")
15
- end
16
- end
17
- end
18
- end
@@ -1,51 +0,0 @@
1
- module SwaggerYard
2
- # An instance of LocalEnvironment is responsible for determining the dispatcher.
3
- # This is useful to determine whether or not to run SwaggerYard#generate!.
4
- #
5
- # Implementation heavily borrowed from NewRelic.
6
- class LocalDispatcher
7
- def discovered_dispatcher
8
- discover_dispatcher unless @discovered_dispatcher
9
- @discovered_dispatcher
10
- end
11
-
12
- def server?
13
- [:thin, :unicorn].include?(discovered_dispatcher)
14
- end
15
-
16
- private
17
-
18
- def discover_dispatcher
19
- dispatchers = %w[sidekiq thin unicorn]
20
- while dispatchers.any? && @discovered_dispatcher.nil?
21
- send 'check_for_' + (dispatchers.shift)
22
- end
23
- end
24
-
25
- def find_class_in_object_space(klass)
26
- ObjectSpace.each_object(klass) do |x|
27
- return x
28
- end
29
- return nil
30
- end
31
-
32
- def check_for_unicorn
33
- if defined?(::Unicorn) && defined?(::Unicorn::HttpServer)
34
- v = find_class_in_object_space(::Unicorn::HttpServer)
35
- @discovered_dispatcher = :unicorn if v
36
- end
37
- end
38
-
39
- def check_for_sidekiq
40
- if defined?(::Sidekiq) && File.basename($0) == 'sidekiq'
41
- @discovered_dispatcher = :sidekiq
42
- end
43
- end
44
-
45
- def check_for_thin
46
- if defined?(::Thin) && defined?(::Thin::VERSION)
47
- @discovered_dispatcher = :thin
48
- end
49
- end
50
- end
51
- end
@@ -1,35 +0,0 @@
1
- require_relative 'api'
2
- require_relative 'api_declaration'
3
- require_relative 'resource_listing'
4
-
5
- module SwaggerYard
6
- class Parser
7
- attr_reader :listing
8
-
9
- def initialize
10
- @listing = ResourceListing.new
11
- end
12
-
13
- def run(yard_objects)
14
- api_declaration = ApiDeclaration.new
15
- retain_api = true
16
-
17
- yard_objects.each do |yard_object|
18
- case yard_object.type
19
- when :class
20
- break unless retain_api = api_declaration.add_listing_info(yard_object)
21
- when :method
22
- api = Api.new(yard_object)
23
- api_declaration.add_api(api) if api.valid?
24
- end
25
- end
26
-
27
- if retain_api
28
- @listing.add(api_declaration)
29
- api_declaration
30
- else
31
- nil
32
- end
33
- end
34
- end
35
- end
@@ -1,135 +0,0 @@
1
- /*
2
-
3
- Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
4
-
5
- */
6
-
7
- pre code {
8
- display: block; padding: 0.5em;
9
- background: #F0F0F0;
10
- }
11
-
12
- pre code,
13
- pre .subst,
14
- pre .tag .title,
15
- pre .lisp .title,
16
- pre .clojure .built_in,
17
- pre .nginx .title {
18
- color: black;
19
- }
20
-
21
- pre .string,
22
- pre .title,
23
- pre .constant,
24
- pre .parent,
25
- pre .tag .value,
26
- pre .rules .value,
27
- pre .rules .value .number,
28
- pre .preprocessor,
29
- pre .ruby .symbol,
30
- pre .ruby .symbol .string,
31
- pre .aggregate,
32
- pre .template_tag,
33
- pre .django .variable,
34
- pre .smalltalk .class,
35
- pre .addition,
36
- pre .flow,
37
- pre .stream,
38
- pre .bash .variable,
39
- pre .apache .tag,
40
- pre .apache .cbracket,
41
- pre .tex .command,
42
- pre .tex .special,
43
- pre .erlang_repl .function_or_atom,
44
- pre .markdown .header {
45
- color: #800;
46
- }
47
-
48
- pre .comment,
49
- pre .annotation,
50
- pre .template_comment,
51
- pre .diff .header,
52
- pre .chunk,
53
- pre .markdown .blockquote {
54
- color: #888;
55
- }
56
-
57
- pre .number,
58
- pre .date,
59
- pre .regexp,
60
- pre .literal,
61
- pre .smalltalk .symbol,
62
- pre .smalltalk .char,
63
- pre .go .constant,
64
- pre .change,
65
- pre .markdown .bullet,
66
- pre .markdown .link_url {
67
- color: #080;
68
- }
69
-
70
- pre .label,
71
- pre .javadoc,
72
- pre .ruby .string,
73
- pre .decorator,
74
- pre .filter .argument,
75
- pre .localvars,
76
- pre .array,
77
- pre .attr_selector,
78
- pre .important,
79
- pre .pseudo,
80
- pre .pi,
81
- pre .doctype,
82
- pre .deletion,
83
- pre .envvar,
84
- pre .shebang,
85
- pre .apache .sqbracket,
86
- pre .nginx .built_in,
87
- pre .tex .formula,
88
- pre .erlang_repl .reserved,
89
- pre .prompt,
90
- pre .markdown .link_label,
91
- pre .vhdl .attribute,
92
- pre .clojure .attribute,
93
- pre .coffeescript .property {
94
- color: #88F
95
- }
96
-
97
- pre .keyword,
98
- pre .id,
99
- pre .phpdoc,
100
- pre .title,
101
- pre .built_in,
102
- pre .aggregate,
103
- pre .css .tag,
104
- pre .javadoctag,
105
- pre .phpdoc,
106
- pre .yardoctag,
107
- pre .smalltalk .class,
108
- pre .winutils,
109
- pre .bash .variable,
110
- pre .apache .tag,
111
- pre .go .typename,
112
- pre .tex .command,
113
- pre .markdown .strong,
114
- pre .request,
115
- pre .status {
116
- font-weight: bold;
117
- }
118
-
119
- pre .markdown .emphasis {
120
- font-style: italic;
121
- }
122
-
123
- pre .nginx .built_in {
124
- font-weight: normal;
125
- }
126
-
127
- pre .coffeescript .javascript,
128
- pre .javascript .xml,
129
- pre .tex .formula,
130
- pre .xml .javascript,
131
- pre .xml .vbscript,
132
- pre .xml .css,
133
- pre .xml .cdata {
134
- opacity: 0.5;
135
- }