diff --git a/README.md b/README.md index 7f87fd0..5a5c0c3 100644 --- a/README.md +++ b/README.md @@ -591,11 +591,22 @@ end ### Enable auto generation examples from responses ### -This is now enabled by default in rswag. + +To enable examples generation from responses add callback above run_test! like: + +``` +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 config/environments/test.rb: ```ruby @@ -633,7 +644,7 @@ describe 'Blogs API', document: false do ``` ##### rswag helper methods ##### - + ### 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_: