nexmo-oas-renderer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.example +1 -0
- data/.gitignore +5 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTING.md +46 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +183 -0
- data/LICENSE.txt +21 -0
- data/README.md +73 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/nexmo-oas-renderer +5 -0
- data/lib/nexmo/oas/engine.rb +9 -0
- data/lib/nexmo/oas/renderer.rb +13 -0
- data/lib/nexmo/oas/renderer/app.rb +116 -0
- data/lib/nexmo/oas/renderer/config.ru +7 -0
- data/lib/nexmo/oas/renderer/config/code_languages.yml +138 -0
- data/lib/nexmo/oas/renderer/config/dynamic_content.yml +1 -0
- data/lib/nexmo/oas/renderer/config/redirects.yml +8 -0
- data/lib/nexmo/oas/renderer/constraints/open_api.rb +76 -0
- data/lib/nexmo/oas/renderer/constraints/redirector.rb +17 -0
- data/lib/nexmo/oas/renderer/decorators/response_parser_decorator.rb +55 -0
- data/lib/nexmo/oas/renderer/filters/anchor.rb +17 -0
- data/lib/nexmo/oas/renderer/filters/audio.rb +21 -0
- data/lib/nexmo/oas/renderer/filters/block_escape.rb +24 -0
- data/lib/nexmo/oas/renderer/filters/break.rb +13 -0
- data/lib/nexmo/oas/renderer/filters/code.rb +64 -0
- data/lib/nexmo/oas/renderer/filters/code_snippet.rb +194 -0
- data/lib/nexmo/oas/renderer/filters/code_snippet_list.rb +33 -0
- data/lib/nexmo/oas/renderer/filters/code_snippets.rb +158 -0
- data/lib/nexmo/oas/renderer/filters/collapsible.rb +27 -0
- data/lib/nexmo/oas/renderer/filters/columns.rb +50 -0
- data/lib/nexmo/oas/renderer/filters/concept_list.rb +33 -0
- data/lib/nexmo/oas/renderer/filters/dynamic_content.rb +30 -0
- data/lib/nexmo/oas/renderer/filters/external_link.rb +32 -0
- data/lib/nexmo/oas/renderer/filters/frontmatter.rb +14 -0
- data/lib/nexmo/oas/renderer/filters/heading.rb +61 -0
- data/lib/nexmo/oas/renderer/filters/icon.rb +22 -0
- data/lib/nexmo/oas/renderer/filters/indent.rb +20 -0
- data/lib/nexmo/oas/renderer/filters/inline_escape.rb +17 -0
- data/lib/nexmo/oas/renderer/filters/js_sequence_diagram.rb +21 -0
- data/lib/nexmo/oas/renderer/filters/label.rb +32 -0
- data/lib/nexmo/oas/renderer/filters/language.rb +15 -0
- data/lib/nexmo/oas/renderer/filters/markdown.rb +85 -0
- data/lib/nexmo/oas/renderer/filters/modal.rb +41 -0
- data/lib/nexmo/oas/renderer/filters/partial.rb +28 -0
- data/lib/nexmo/oas/renderer/filters/php_inliner.rb +15 -0
- data/lib/nexmo/oas/renderer/filters/screenshot.rb +26 -0
- data/lib/nexmo/oas/renderer/filters/tab.rb +250 -0
- data/lib/nexmo/oas/renderer/filters/techio.rb +24 -0
- data/lib/nexmo/oas/renderer/filters/tooltip.rb +22 -0
- data/lib/nexmo/oas/renderer/filters/tutorial_link.rb +27 -0
- data/lib/nexmo/oas/renderer/filters/tutorials.rb +28 -0
- data/lib/nexmo/oas/renderer/filters/unfreeze.rb +20 -0
- data/lib/nexmo/oas/renderer/filters/user_personalization.rb +43 -0
- data/lib/nexmo/oas/renderer/helpers/navigation.rb +66 -0
- data/lib/nexmo/oas/renderer/helpers/render.rb +24 -0
- data/lib/nexmo/oas/renderer/helpers/summary.rb +30 -0
- data/lib/nexmo/oas/renderer/helpers/url.rb +17 -0
- data/lib/nexmo/oas/renderer/lib/core_ext/string.rb +14 -0
- data/lib/nexmo/oas/renderer/lib/redcarpet.rb +14 -0
- data/lib/nexmo/oas/renderer/models/code_snippet.rb +75 -0
- data/lib/nexmo/oas/renderer/models/tutorial.rb +83 -0
- data/lib/nexmo/oas/renderer/pipelines/markdown_pipeline.rb +52 -0
- data/lib/nexmo/oas/renderer/presenters/api_specification.rb +42 -0
- data/lib/nexmo/oas/renderer/presenters/groups.rb +35 -0
- data/lib/nexmo/oas/renderer/presenters/navigation.rb +24 -0
- data/lib/nexmo/oas/renderer/presenters/open_api_specification.rb +68 -0
- data/lib/nexmo/oas/renderer/presenters/versions.rb +40 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Black.woff +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Black.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Heavy.woff +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Heavy.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Regular.woff +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Regular.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Semibold.woff +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Semibold.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/android.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/curl.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/dotnet.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/ios.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/java.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/javascript.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/node.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/php.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/python.svg +11 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/ruby.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/lost.svg +37 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/components/format.js +42 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.accordion.js +249 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.core.js +230 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.modal.js +300 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.tabs.js +139 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/api.css +95 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/buttons.css +80 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/core.css +79 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/mediaqueries.css +2 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/mediaqueries.css.map +7 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/navigation.css +79 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/nexmo.css +68 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/api.scss +147 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/core.scss +133 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/mediaqueries.scss +48 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/navigation.scss +106 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/nexmo.scss +61 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/style.scss +10 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/syntax.scss +63 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/typography.scss +248 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/variables.scss +91 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/volta-templates.scss +119 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/style.css +2 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/style.css.map +7 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/syntax.css +79 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/typography.css +86 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/variables.css +2 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/variables.css.map +7 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta-templates.css +2 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta-templates.css.map +7 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta.min.css +1 -0
- data/lib/nexmo/oas/renderer/public/assets/symbol/volta-icons.svg +1 -0
- data/lib/nexmo/oas/renderer/public/favicon.ico +0 -0
- data/lib/nexmo/oas/renderer/services/code_language_api.rb +98 -0
- data/lib/nexmo/oas/renderer/services/oas_parser.rb +21 -0
- data/lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb +33 -0
- data/lib/nexmo/oas/renderer/version.rb +7 -0
- data/lib/nexmo/oas/renderer/views/api/show.erb +1 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_application_messages_dispatch.html.erb +9 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_application_rtc.html.erb +41 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_application_voice.html.erb +24 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_code_only.html.erb +6 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_configure_client.html.erb +20 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_dependencies.html.erb +11 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_write_code.html.erb +13 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/list/plain.html.erb +10 -0
- data/lib/nexmo/oas/renderer/views/concepts/list/plain.html.erb +5 -0
- data/lib/nexmo/oas/renderer/views/layouts/_head.erb +4 -0
- data/lib/nexmo/oas/renderer/views/layouts/_javascripts.erb +9 -0
- data/lib/nexmo/oas/renderer/views/layouts/api.erb +23 -0
- data/lib/nexmo/oas/renderer/views/layouts/open_api.erb +10 -0
- data/lib/nexmo/oas/renderer/views/open_api/_callback.erb +5 -0
- data/lib/nexmo/oas/renderer/views/open_api/_callback_endpoint.erb +48 -0
- data/lib/nexmo/oas/renderer/views/open_api/_code_examples.erb +16 -0
- data/lib/nexmo/oas/renderer/views/open_api/_endpoint.erb +156 -0
- data/lib/nexmo/oas/renderer/views/open_api/_model.erb +38 -0
- data/lib/nexmo/oas/renderer/views/open_api/_navigation.erb +80 -0
- data/lib/nexmo/oas/renderer/views/open_api/_parameter_groups.erb +50 -0
- data/lib/nexmo/oas/renderer/views/open_api/_parameters.erb +165 -0
- data/lib/nexmo/oas/renderer/views/open_api/_response_description_parameters.erb +61 -0
- data/lib/nexmo/oas/renderer/views/open_api/_response_descriptions.erb +41 -0
- data/lib/nexmo/oas/renderer/views/open_api/show.erb +104 -0
- data/lib/nexmo/oas/renderer/views/static/404.erb +6 -0
- data/lib/nexmo/oas/renderer/views/tutorials/_index.html.erb +32 -0
- data/lib/nexmo/oas/renderer/views/tutorials/index.html.erb +7 -0
- data/lib/nexmo/oas/renderer/views/tutorials/list/plain.html.erb +5 -0
- data/lib/nexmo/oas/renderer/views/tutorials/show.html.erb +8 -0
- data/nexmo-oas-renderer.gemspec +49 -0
- metadata +399 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6beab21d8740f78831e7bba38afdc63069fd4febe1592f8f66e41695c59b6c68
|
4
|
+
data.tar.gz: 1718a8b238ea7a4aab0fd538cb0249588463a5b66b06eccc37f7f9c355b8e484
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: de94333a3c2cc2af75dd092adaa2ae639f98e5f3bc4e3fc23055ac4866a3b237bc6a7d3bedacaf769896db7a77a038ed5758f299814c1eb08bad6edbdab8150a
|
7
|
+
data.tar.gz: cd6e3abb06560e9f4c7eb305d1869a1f8ca488c61e7f6bbc47f0b640d2ad8d7ea70e4ebe681810f640d9288e0452a3e72aa97f3d0bbee03828583bdc435610c9
|
data/.env.example
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
OAS_PATH='../nexmo-developer'
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
Thanks for considering contributing to Nexmo OAS Renderer! From typos, to sample code, tutorials and beyond, we truly appreciate and welcome input from everyone.
|
4
|
+
|
5
|
+
You can read all about our markdown additions, writing style guide and standard placeholders on our [Contributing page](https://developer.nexmo.com/contribute/overview). Once you have a change to share with us, read on ...
|
6
|
+
|
7
|
+
## Git process
|
8
|
+
|
9
|
+
This project uses [GitHub Flow](https://guides.github.com/introduction/flow/index.html). We are happy to have issues opened for discussion, but we don't require an issue to be created before a pull request is opened. When you have a change you want us to consider:
|
10
|
+
|
11
|
+
* Create a new branch on your own fork, from an up-to-date master branch.
|
12
|
+
* Make the changes on that new branch.
|
13
|
+
* Open a pull request for us, making sure to tell us what you changed and why in the pull request title and description. Pull requests without a meaningful title and a completed template may be closed.
|
14
|
+
|
15
|
+
If you need more information about how to do any of the above, we recommend the [GitHub Help pages](https://help.github.com/), which are indeed very helpful.
|
16
|
+
|
17
|
+
Tips:
|
18
|
+
|
19
|
+
* Keep it small! Small changes are easy to review and more likely to be accepted. More involved changes probably need discussion first.
|
20
|
+
* Tell us _what_ changed and _why_. This helps us to understand the change and get the right people to review it.
|
21
|
+
|
22
|
+
### For maintainers/reviewers
|
23
|
+
|
24
|
+
* If you know who can review a particular pull request, tag those people. Tagging a few can be useful as we're in different timezones and can often be travelling.
|
25
|
+
* Review with an eye to accuracy and maintainability as well as correctness. Ask yourself "do we want this change?" and "will users find this information here, could it be added to existing docs?" as well as "is everything spelled correctly?"
|
26
|
+
* Before accepting a change, check that the markdown renders as expected, and the code runs ... this probably means either pulling the code down to your development platform or deploying a review application.
|
27
|
+
* If changes are needed, then either:
|
28
|
+
- make the changes yourself (especially for minor or editorial changes).
|
29
|
+
- set your review as "changes requested" and comment for what is needed to make this pull request ready to accept.
|
30
|
+
* If everything is good then go ahead and approve the pull request.
|
31
|
+
* Now merge the pull request! If the change is good to go, then it should go (unless there are special circumstances of course). In the main, anyone can merge an accepted pull request at the earliest opportunity.
|
32
|
+
* Delete the branch if it's on our repo.
|
33
|
+
|
34
|
+
## Work in Progress [WIP]
|
35
|
+
|
36
|
+
* Please feel free to open a pull request when you are at the early stages of working on something. Put "[WIP]" in the title so we know it's not ready yet.
|
37
|
+
* Work in progress has a cost, merging things that have been branched for a long time can be harder work and cause more issues than smaller changes that can be completed quickly. Please consider whether to start a task that you can't finish in the time you have available.
|
38
|
+
* Inactive pull requests will be closed. When you are ready to complete the work, please rebase your branch and open a new pull request.
|
39
|
+
|
40
|
+
## GitHub Pull Request Labels
|
41
|
+
|
42
|
+
We use a few different labels for our pull request workflows:
|
43
|
+
|
44
|
+
* `don't merge` for things that might need external review, or where it needs to be merged on a specific date, or to clearly note that things are not ready yet!
|
45
|
+
* `help wanted` when anyone is welcome to dive in.
|
46
|
+
* `stale` when the pull request is abandoned and will soon be closed.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
nexmo-oas-renderer (0.1.0)
|
5
|
+
activemodel (~> 5.2)
|
6
|
+
activesupport (~> 5.2)
|
7
|
+
banzai (~> 0.1.2)
|
8
|
+
neatjson (~> 0.8)
|
9
|
+
oas_parser (= 0.18.1)
|
10
|
+
octicons_helper (~> 8.2)
|
11
|
+
redcarpet (= 3.4.0)
|
12
|
+
rouge (= 2.0.7)
|
13
|
+
sass (~> 3.1)
|
14
|
+
shotgun (~> 0.9)
|
15
|
+
sinatra (~> 2.0)
|
16
|
+
|
17
|
+
GEM
|
18
|
+
remote: https://rubygems.org/
|
19
|
+
specs:
|
20
|
+
actioncable (5.2.3)
|
21
|
+
actionpack (= 5.2.3)
|
22
|
+
nio4r (~> 2.0)
|
23
|
+
websocket-driver (>= 0.6.1)
|
24
|
+
actionmailer (5.2.3)
|
25
|
+
actionpack (= 5.2.3)
|
26
|
+
actionview (= 5.2.3)
|
27
|
+
activejob (= 5.2.3)
|
28
|
+
mail (~> 2.5, >= 2.5.4)
|
29
|
+
rails-dom-testing (~> 2.0)
|
30
|
+
actionpack (5.2.3)
|
31
|
+
actionview (= 5.2.3)
|
32
|
+
activesupport (= 5.2.3)
|
33
|
+
rack (~> 2.0)
|
34
|
+
rack-test (>= 0.6.3)
|
35
|
+
rails-dom-testing (~> 2.0)
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
37
|
+
actionview (5.2.3)
|
38
|
+
activesupport (= 5.2.3)
|
39
|
+
builder (~> 3.1)
|
40
|
+
erubi (~> 1.4)
|
41
|
+
rails-dom-testing (~> 2.0)
|
42
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
43
|
+
activejob (5.2.3)
|
44
|
+
activesupport (= 5.2.3)
|
45
|
+
globalid (>= 0.3.6)
|
46
|
+
activemodel (5.2.3)
|
47
|
+
activesupport (= 5.2.3)
|
48
|
+
activerecord (5.2.3)
|
49
|
+
activemodel (= 5.2.3)
|
50
|
+
activesupport (= 5.2.3)
|
51
|
+
arel (>= 9.0)
|
52
|
+
activestorage (5.2.3)
|
53
|
+
actionpack (= 5.2.3)
|
54
|
+
activerecord (= 5.2.3)
|
55
|
+
marcel (~> 0.3.1)
|
56
|
+
activesupport (5.2.3)
|
57
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
58
|
+
i18n (>= 0.7, < 2)
|
59
|
+
minitest (~> 5.1)
|
60
|
+
tzinfo (~> 1.1)
|
61
|
+
addressable (2.6.0)
|
62
|
+
public_suffix (>= 2.0.2, < 4.0)
|
63
|
+
arel (9.0.0)
|
64
|
+
banzai (0.1.3)
|
65
|
+
builder (3.2.3)
|
66
|
+
concurrent-ruby (1.1.5)
|
67
|
+
crass (1.0.4)
|
68
|
+
deep_merge (1.2.1)
|
69
|
+
dotenv (2.7.2)
|
70
|
+
erubi (1.8.0)
|
71
|
+
ffi (1.11.1)
|
72
|
+
globalid (0.4.2)
|
73
|
+
activesupport (>= 4.2.0)
|
74
|
+
hansi (0.2.0)
|
75
|
+
i18n (1.6.0)
|
76
|
+
concurrent-ruby (~> 1.0)
|
77
|
+
loofah (2.2.3)
|
78
|
+
crass (~> 1.0.2)
|
79
|
+
nokogiri (>= 1.5.9)
|
80
|
+
mail (2.7.1)
|
81
|
+
mini_mime (>= 0.1.1)
|
82
|
+
marcel (0.3.3)
|
83
|
+
mimemagic (~> 0.3.2)
|
84
|
+
method_source (0.9.2)
|
85
|
+
mimemagic (0.3.3)
|
86
|
+
mini_mime (1.0.1)
|
87
|
+
mini_portile2 (2.4.0)
|
88
|
+
minitest (5.11.3)
|
89
|
+
mustermann (1.0.3)
|
90
|
+
mustermann-contrib (1.0.3)
|
91
|
+
hansi (~> 0.2.0)
|
92
|
+
mustermann (= 1.0.3)
|
93
|
+
neatjson (0.8.4)
|
94
|
+
nio4r (2.3.1)
|
95
|
+
nokogiri (1.10.3)
|
96
|
+
mini_portile2 (~> 2.4.0)
|
97
|
+
oas_parser (0.18.1)
|
98
|
+
activesupport (>= 4.0.0)
|
99
|
+
addressable (~> 2.3)
|
100
|
+
builder (~> 3.2.3)
|
101
|
+
deep_merge (~> 1.2.1)
|
102
|
+
mustermann-contrib (~> 1.0.3s)
|
103
|
+
nokogiri
|
104
|
+
octicons (8.5.0)
|
105
|
+
nokogiri (>= 1.6.3.1)
|
106
|
+
octicons_helper (8.5.0)
|
107
|
+
octicons (= 8.5.0)
|
108
|
+
rails
|
109
|
+
public_suffix (3.0.3)
|
110
|
+
rack (2.0.7)
|
111
|
+
rack-protection (2.0.5)
|
112
|
+
rack
|
113
|
+
rack-test (1.1.0)
|
114
|
+
rack (>= 1.0, < 3)
|
115
|
+
rails (5.2.3)
|
116
|
+
actioncable (= 5.2.3)
|
117
|
+
actionmailer (= 5.2.3)
|
118
|
+
actionpack (= 5.2.3)
|
119
|
+
actionview (= 5.2.3)
|
120
|
+
activejob (= 5.2.3)
|
121
|
+
activemodel (= 5.2.3)
|
122
|
+
activerecord (= 5.2.3)
|
123
|
+
activestorage (= 5.2.3)
|
124
|
+
activesupport (= 5.2.3)
|
125
|
+
bundler (>= 1.3.0)
|
126
|
+
railties (= 5.2.3)
|
127
|
+
sprockets-rails (>= 2.0.0)
|
128
|
+
rails-dom-testing (2.0.3)
|
129
|
+
activesupport (>= 4.2.0)
|
130
|
+
nokogiri (>= 1.6)
|
131
|
+
rails-html-sanitizer (1.0.4)
|
132
|
+
loofah (~> 2.2, >= 2.2.2)
|
133
|
+
railties (5.2.3)
|
134
|
+
actionpack (= 5.2.3)
|
135
|
+
activesupport (= 5.2.3)
|
136
|
+
method_source
|
137
|
+
rake (>= 0.8.7)
|
138
|
+
thor (>= 0.19.0, < 2.0)
|
139
|
+
rake (10.5.0)
|
140
|
+
rb-fsevent (0.10.3)
|
141
|
+
rb-inotify (0.10.0)
|
142
|
+
ffi (~> 1.0)
|
143
|
+
redcarpet (3.4.0)
|
144
|
+
rouge (2.0.7)
|
145
|
+
sass (3.7.4)
|
146
|
+
sass-listen (~> 4.0.0)
|
147
|
+
sass-listen (4.0.0)
|
148
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
149
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
150
|
+
shotgun (0.9.2)
|
151
|
+
rack (>= 1.0)
|
152
|
+
sinatra (2.0.5)
|
153
|
+
mustermann (~> 1.0)
|
154
|
+
rack (~> 2.0)
|
155
|
+
rack-protection (= 2.0.5)
|
156
|
+
tilt (~> 2.0)
|
157
|
+
sprockets (3.7.2)
|
158
|
+
concurrent-ruby (~> 1.0)
|
159
|
+
rack (> 1, < 3)
|
160
|
+
sprockets-rails (3.2.1)
|
161
|
+
actionpack (>= 4.0)
|
162
|
+
activesupport (>= 4.0)
|
163
|
+
sprockets (>= 3.0.0)
|
164
|
+
thor (0.20.3)
|
165
|
+
thread_safe (0.3.6)
|
166
|
+
tilt (2.0.9)
|
167
|
+
tzinfo (1.2.5)
|
168
|
+
thread_safe (~> 0.1)
|
169
|
+
websocket-driver (0.7.0)
|
170
|
+
websocket-extensions (>= 0.1.0)
|
171
|
+
websocket-extensions (0.1.3)
|
172
|
+
|
173
|
+
PLATFORMS
|
174
|
+
ruby
|
175
|
+
|
176
|
+
DEPENDENCIES
|
177
|
+
bundler (~> 2.0)
|
178
|
+
dotenv (~> 2.7)
|
179
|
+
nexmo-oas-renderer!
|
180
|
+
rake (~> 10.0)
|
181
|
+
|
182
|
+
BUNDLED WITH
|
183
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Nexmo Inc
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Nexmo OAS Renderer
|
2
|
+
Sinatra application that provides a preview of how the OAS documents will be rendered within [Nexmo Developer](https://developer.nexmo.com/).
|
3
|
+
|
4
|
+
* [Dependencies](#requirements)
|
5
|
+
* [Installation and Usage](#installation-and-usage)
|
6
|
+
* [As a standalone application](#as-a-standalone-application)
|
7
|
+
* [Mounted into a Rails application](#mounted-into-a-rails-application)
|
8
|
+
* [Specifying the path to the documents](#specifying-the-path-to-the-documents)
|
9
|
+
* [Contributing](#contributing)
|
10
|
+
* [License](#license)
|
11
|
+
|
12
|
+
## Dependencies
|
13
|
+
|
14
|
+
|
15
|
+
## Installation and Usage
|
16
|
+
|
17
|
+
### As a standalone application
|
18
|
+
|
19
|
+
Install the gem:
|
20
|
+
|
21
|
+
``` shell
|
22
|
+
$ gem install nexmo-oas-renderer
|
23
|
+
```
|
24
|
+
|
25
|
+
And simply run the executable:
|
26
|
+
``` shell
|
27
|
+
$ nexmo-oas-renderer
|
28
|
+
```
|
29
|
+
|
30
|
+
### Mounted into a Rails Application
|
31
|
+
|
32
|
+
Add this to your application's `Gemfile`:
|
33
|
+
|
34
|
+
```
|
35
|
+
gem 'nexmo-oas-renderer', require: false
|
36
|
+
```
|
37
|
+
|
38
|
+
And then run `bundle install`.
|
39
|
+
|
40
|
+
Require the gem in `config/environment.rb` as follows:
|
41
|
+
|
42
|
+
``` ruby
|
43
|
+
# Load the Rails application.
|
44
|
+
require_relative 'application'
|
45
|
+
|
46
|
+
require 'nexmo/oas/renderer'
|
47
|
+
|
48
|
+
# Initialize the Rails application.
|
49
|
+
Rails.application.initialize!
|
50
|
+
```
|
51
|
+
|
52
|
+
And finally mount the Sinatra app into your Rails application by adding the following line to `config/routes.rb`:
|
53
|
+
|
54
|
+
``` ruby
|
55
|
+
mount Nexmo::OAS::Renderer::API, at: '/api'
|
56
|
+
```
|
57
|
+
|
58
|
+
### Specifying the path to the documents
|
59
|
+
|
60
|
+
This gem uses [dotenv](https://github.com/bkeepers/dotenv) to handle environment variables, so you should copy the `.env.example` provided by running:
|
61
|
+
``` shell
|
62
|
+
$ cp .env.example .env
|
63
|
+
```
|
64
|
+
and assign values to the corresponding variables.
|
65
|
+
|
66
|
+
#### Note
|
67
|
+
The app won't boot if the env variable `OAS_PATH` is not set. This variable indicates the path to the documents that will be rendered.
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
We ❤️ contributions from everyone! [Bug reports](https://github.com/Nexmo/nexmo-oas-renderer/issues), [bug fixes](https://github.com/Nexmo/nexmo-oas-renderer/pulls) and feedback on the library is always appreciated. Look at the [Contributor Guidelines](https://github.com/Nexmo/nexmo-oas-renderer/blob/master/CONTRIBUTING.md) for more information and please follow the [GitHub Flow](https://guides.github.com/introduction/flow/index.html).
|
71
|
+
|
72
|
+
## License
|
73
|
+
This project is under the [MIT LICENSE](https://github.com/Nexmo/nexmo-oas-renderer/blob/master/LICENSE).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "nexmo/oas/renderer"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require 'active_support'
|
3
|
+
require 'active_support/core_ext/array/conversions'
|
4
|
+
require 'active_support/core_ext/string/output_safety'
|
5
|
+
require 'active_model'
|
6
|
+
|
7
|
+
require_relative'./constraints/redirector'
|
8
|
+
require_relative'./decorators/response_parser_decorator'
|
9
|
+
require_relative'./pipelines/markdown_pipeline'
|
10
|
+
require_relative'./presenters/api_specification'
|
11
|
+
require_relative'./presenters/open_api_specification'
|
12
|
+
require_relative'./presenters/navigation'
|
13
|
+
require_relative'./helpers/render'
|
14
|
+
require_relative'./helpers/navigation'
|
15
|
+
require_relative'./helpers/summary'
|
16
|
+
require_relative'./helpers/url'
|
17
|
+
|
18
|
+
require_relative'./lib/core_ext/string'
|
19
|
+
|
20
|
+
require 'dotenv/load'
|
21
|
+
|
22
|
+
module Nexmo
|
23
|
+
module OAS
|
24
|
+
module Renderer
|
25
|
+
class API < Sinatra::Base
|
26
|
+
|
27
|
+
Tilt.register Tilt::ERBTemplate, 'html.erb'
|
28
|
+
|
29
|
+
if defined?(NexmoDeveloper::Application)
|
30
|
+
view_paths = [views, NexmoDeveloper::Application.root.join("app", "views")]
|
31
|
+
set :views, view_paths
|
32
|
+
end
|
33
|
+
|
34
|
+
set :mustermann_opts, { type: :rails }
|
35
|
+
set :show_exceptions, :after_handler
|
36
|
+
set :oas_path, (ENV['OAS_PATH'] || '.')
|
37
|
+
|
38
|
+
helpers do
|
39
|
+
include Helpers::Render
|
40
|
+
include Helpers::Navigation
|
41
|
+
include Helpers::Summary
|
42
|
+
include Helpers::URL
|
43
|
+
end
|
44
|
+
|
45
|
+
def parse_params(extension)
|
46
|
+
extensions = extension.split('.')
|
47
|
+
case extensions.size
|
48
|
+
when 1
|
49
|
+
{ definition: extensions.first}
|
50
|
+
when 2
|
51
|
+
if extensions.second.match? /v\d+/
|
52
|
+
{ definition: extensions.first, version: extensions.second }
|
53
|
+
else
|
54
|
+
{ definition: extensions.first, format: extensions.second }
|
55
|
+
end
|
56
|
+
when 3
|
57
|
+
{ definition: extensions.first, version: extensions.second, format: extensions.last }
|
58
|
+
else
|
59
|
+
{}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def check_redirect!
|
64
|
+
redirect_path = Constraints::Redirector.find(request)
|
65
|
+
redirect(redirect_path) if redirect_path
|
66
|
+
end
|
67
|
+
|
68
|
+
error Errno::ENOENT do
|
69
|
+
layout = defined?(NexmoDeveloper::Application) ? :'layouts/api.html' : false
|
70
|
+
not_found erb :'static/404', layout: layout
|
71
|
+
end
|
72
|
+
|
73
|
+
get '(/api)/*definition' do
|
74
|
+
check_redirect!
|
75
|
+
|
76
|
+
parameters = parse_params(params[:definition])
|
77
|
+
definition = [parameters[:definition], parameters[:version]].compact.join('.')
|
78
|
+
pass if !Constraints::OpenApi.match?(definition)
|
79
|
+
|
80
|
+
@specification = Presenters::OpenApiSpecification.new(
|
81
|
+
definition_name: definition,
|
82
|
+
expand_responses: params.fetch(:expandResponses, nil),
|
83
|
+
)
|
84
|
+
|
85
|
+
if ['yml', 'json'].include?(parameters[:format])
|
86
|
+
send_file @specification.definition.path, disposition: :attachment
|
87
|
+
else
|
88
|
+
if defined?(NexmoDeveloper::Application)
|
89
|
+
erb :'open_api/show', layout: :'layouts/page-full.html'
|
90
|
+
else
|
91
|
+
erb :'open_api/show', layout: :'layouts/open_api'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
get '(/api)/*document' do
|
97
|
+
@specification = Presenters::ApiSpecification.new(document_name: params[:document])
|
98
|
+
|
99
|
+
@navigation = Presenters::Navigation.new(
|
100
|
+
content: @specification.content,
|
101
|
+
title: @specification.side_navigation_title,
|
102
|
+
)
|
103
|
+
|
104
|
+
if defined?(NexmoDeveloper::Application)
|
105
|
+
@content = @navigation.content
|
106
|
+
@side_navigation_title = @navigation.title
|
107
|
+
|
108
|
+
erb :'api/show', layout: :'layouts/api.html'
|
109
|
+
else
|
110
|
+
erb :'api/show', layout: :'layouts/api'
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|