mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
Add install generator and support Rails 3 or 4
This commit is contained in:
20
spec/generators/swagger_rails/install_generator_spec.rb
Normal file
20
spec/generators/swagger_rails/install_generator_spec.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
require 'rails_helper'
|
||||
require 'generators/swagger_rails/install/install_generator'
|
||||
|
||||
describe SwaggerRails::InstallGenerator do
|
||||
include GeneratorSpec::TestCase
|
||||
destination File.expand_path('../tmp', __FILE__)
|
||||
|
||||
before(:all) do
|
||||
prepare_destination
|
||||
run_generator
|
||||
end
|
||||
|
||||
it 'creates a default swagger.json file' do
|
||||
assert_file('config/swagger/v1/swagger.json')
|
||||
end
|
||||
|
||||
it 'creates a swagger_rails initializer' do
|
||||
assert_file('config/initializers/swagger_rails.rb')
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
SwaggerRails.configure do |c|
|
||||
|
||||
# Specify the API version and hence discovery_url (e.g. swagger/v1/swagger.json)
|
||||
# that will be used to power the embedded swagger-ui
|
||||
c.target_api_version = 'v1'
|
||||
end
|
||||
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"version": "0.0.0",
|
||||
"title": "[Enter a description for your API here]",
|
||||
"description": "The docs below are powered by the default swagger.json that was installed with swagger_rails. You can update it to describe your API. See here for the complete swagger spec - https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md"
|
||||
},
|
||||
"paths": {
|
||||
"/a/sample/resource": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"a/sample/resource"
|
||||
],
|
||||
"description": "Create a new sample resource",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/CreateSampleResource"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Ok"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"ClinicPatientLink": {
|
||||
"properties": {
|
||||
"clinic_patient_link": {
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ClinicPatientLink"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"ClinicPatientLink": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"date_time": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user