mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 23:32:58 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf9170101b | ||
|
|
98d5b982c4 | ||
|
|
77d4cbe0ea | ||
|
|
32a7ab8234 | ||
|
|
95b009a72f |
@@ -1,13 +1,13 @@
|
||||
PATH
|
||||
remote: ./rswag-api
|
||||
specs:
|
||||
rswag-api (1.1.0)
|
||||
rswag-api (1.2.0)
|
||||
rails (>= 3.1, < 5.1)
|
||||
|
||||
PATH
|
||||
remote: ./rswag-specs
|
||||
specs:
|
||||
rswag-specs (1.1.0)
|
||||
rswag-specs (1.2.0)
|
||||
json-schema (~> 2.2)
|
||||
rails (>= 3.1, < 5.1)
|
||||
rspec-rails (>= 2.14, < 4)
|
||||
@@ -15,7 +15,7 @@ PATH
|
||||
PATH
|
||||
remote: ./rswag-ui
|
||||
specs:
|
||||
rswag-ui (1.1.0)
|
||||
rswag-ui (1.2.0)
|
||||
rails (>= 3.1, < 5.1)
|
||||
|
||||
GEM
|
||||
|
||||
16
README.md
16
README.md
@@ -284,6 +284,22 @@ describe 'Blogs API' do
|
||||
end
|
||||
```
|
||||
|
||||
### Enable generation examples from responses ###
|
||||
|
||||
To enable examples generation from responses add callback above run_test! like:
|
||||
```ruby
|
||||
after do |example|
|
||||
example.metadata[:response][:examples] = { 'application/json' => JSON.parse(response.body, symbolize_names: true) }
|
||||
end
|
||||
```
|
||||
You need to disable --dry-run option for Rspec > 3
|
||||
|
||||
Add to application.rb:
|
||||
```ruby
|
||||
RSpec.configure do |config|
|
||||
config.swagger_dry_run = false
|
||||
end
|
||||
```
|
||||
### Route Prefix for Swagger JSON Endpoints ###
|
||||
|
||||
The functionality to expose Swagger files, such as those generated by rswag-specs, as JSON endpoints is implemented as a Rails Engine. As with any Engine, you can change it's mount prefix in _routes.rb_:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module Rswag
|
||||
module Api
|
||||
VERSION = '1.1.0'
|
||||
VERSION = '1.2.0'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,6 +12,7 @@ module Rswag
|
||||
::RSpec.configure do |c|
|
||||
c.add_setting :swagger_root
|
||||
c.add_setting :swagger_docs
|
||||
c.add_setting :swagger_dry_run
|
||||
c.extend ExampleGroupHelpers, type: :request
|
||||
c.include ExampleHelpers, type: :request
|
||||
end
|
||||
|
||||
@@ -25,6 +25,12 @@ module Rswag
|
||||
end
|
||||
end
|
||||
|
||||
def swagger_dry_run
|
||||
@swagger_dry_run ||= begin
|
||||
@rspec_config.swagger_dry_run.nil? || @rspec_config.swagger_dry_run
|
||||
end
|
||||
end
|
||||
|
||||
def get_swagger_doc(name)
|
||||
return swagger_docs.values.first if name.nil?
|
||||
raise ConfigurationError, "Unknown swagger_doc '#{name}'" unless swagger_docs[name]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module Rswag
|
||||
module Specs
|
||||
VERSION = '1.1.0'
|
||||
VERSION = '1.2.0'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace :rswag do
|
||||
t.pattern = 'spec/requests/**/*_spec.rb, spec/api/**/*_spec.rb, spec/integration/**/*_spec.rb'
|
||||
|
||||
# NOTE: rspec 2.x support
|
||||
if Rswag::Specs::RSPEC_VERSION > 2
|
||||
if Rswag::Specs::RSPEC_VERSION > 2 && Rswag::Specs.config.swagger_dry_run
|
||||
t.rspec_opts = [ '--format Rswag::Specs::SwaggerFormatter', '--dry-run', '--order defined' ]
|
||||
else
|
||||
t.rspec_opts = [ '--format Rswag::Specs::SwaggerFormatter', '--order defined' ]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module Rswag
|
||||
module Ui
|
||||
VERSION = '1.1.0'
|
||||
VERSION = '1.2.0'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -880,7 +880,7 @@
|
||||
padding: 6px 8px;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header span.response_throbber {
|
||||
background-image: url('../images/throbber.gif');
|
||||
background-image: url(<%= asset_path('swagger-ui/images/throbber.gif') %>);
|
||||
width: 128px;
|
||||
height: 16px;
|
||||
display: block;
|
||||
@@ -1222,7 +1222,7 @@
|
||||
height: 18px;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
background: url(../images/explorer_icons.png) no-repeat;
|
||||
background: url(<%= asset_path('swagger-ui/images/explorer_icons.png') %>) no-repeat;
|
||||
}
|
||||
.swagger-section .authorize__btn_operation_login {
|
||||
background-position: 0 0;
|
||||
@@ -880,7 +880,7 @@
|
||||
padding: 6px 8px;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header span.response_throbber {
|
||||
background-image: url('../images/throbber.gif');
|
||||
background-image: url(<%= asset_path('swagger-ui/images/throbber.gif') %>);
|
||||
width: 128px;
|
||||
height: 16px;
|
||||
display: block;
|
||||
@@ -1222,7 +1222,7 @@
|
||||
height: 18px;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
background: url(../images/explorer_icons.png) no-repeat;
|
||||
background: url(<%= asset_path('swagger-ui/images/explorer_icons.png') %>) no-repeat;
|
||||
}
|
||||
.swagger-section .authorize__btn_operation_login {
|
||||
background-position: 0 0;
|
||||
@@ -1354,7 +1354,7 @@
|
||||
height: 18px;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
background: url(../images/explorer_icons.png) no-repeat;
|
||||
background: url(<%= asset_path('swagger-ui/images/explorer_icons.png') %>) no-repeat;
|
||||
}
|
||||
.swagger-section .api-ic .api_information_panel {
|
||||
position: relative;
|
||||
@@ -2,7 +2,7 @@
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
background: transparent url(../images/logo.png) no-repeat left center;
|
||||
background: transparent url(<%= asset_path('swagger-ui/images/logo.png') %>) no-repeat left center;
|
||||
padding: 20px 0 20px 40px;
|
||||
}
|
||||
#text-head {
|
||||
@@ -64,7 +64,7 @@ h1 {
|
||||
width: 1500px;
|
||||
margin: auto;
|
||||
margin-top: 0;
|
||||
background-image: url('../images/shield.png');
|
||||
background-image: url(<%= asset_path('swagger-ui/images/shield.png') %>);
|
||||
background-repeat: no-repeat;
|
||||
background-position: -40px -20px;
|
||||
margin-bottom: 210px;
|
||||
@@ -1,14 +0,0 @@
|
||||
/* Google Font's Droid Sans */
|
||||
@font-face {
|
||||
font-family: 'Droid Sans';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Droid Sans'), local('DroidSans'), url('../fonts/DroidSans.ttf'), format('truetype');
|
||||
}
|
||||
/* Google Font's Droid Sans Bold */
|
||||
@font-face {
|
||||
font-family: 'Droid Sans';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Droid Sans Bold'), local('DroidSans-Bold'), url('../fonts/DroidSans-Bold.ttf'), format('truetype');
|
||||
}
|
||||
14
rswag-ui/vendor/assets/components/swagger-ui/css/typography.css.erb
vendored
Normal file
14
rswag-ui/vendor/assets/components/swagger-ui/css/typography.css.erb
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/* Google Font's Droid Sans */
|
||||
@font-face {
|
||||
font-family: 'Droid Sans';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Droid Sans'), local('DroidSans'), url(<%= asset_path('swagger-ui/fonts/DroidSans.ttf') %>), format('truetype');
|
||||
}
|
||||
/* Google Font's Droid Sans Bold */
|
||||
@font-face {
|
||||
font-family: 'Droid Sans';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Droid Sans Bold'), local('DroidSans-Bold'), url(<%= asset_path('swagger-ui/fonts/DroidSans-Bold.ttf') %>), format('truetype');
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
module Rswag
|
||||
VERSION = '1.1.0'
|
||||
VERSION = '1.2.0'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user