Use JSON schema files for your Swagger/OpenAPI definitions, instead of storing them in swagger_helper.rb
Add this line to your Gemfile
gem 'rswag_json_loader'
Add this line to your swagger_helper.rb
RswagJsonLoader::SchemaHandler.setup!
By default, JSON Schema files are expeted to be in:
./spec/requests/api/schemas/json/*.json
If you want them elsewhere, override schema_path
.
Just create a JSON file in the aforementioned folder, e.g. sessions_login_payload.json
, enter your JSON Schema inside it
{
"type": "object",
"required": [
"email",
"password"
],
"properties": {
"email": {
"type": "string"
},
"password": {
"type": "string"
}
}
}
- YAML support
- Tests