From fad5407327203c460e2af2ce42aaa5a97993e7ad Mon Sep 17 00:00:00 2001 From: Mike Fotinakis Date: Thu, 19 Mar 2015 11:43:19 -0700 Subject: [PATCH] Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index a06010b..470203f 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,15 @@ That is the only line necessary to build the full [root Swagger object](https:// Now, simply point Swagger UI at `/apidocs` and everything should Just Work™. If you change any of the Swagger block definitions, you can simply refresh Swagger UI to see the changes. +#### Writing JSON to a file + +If you are not serving the JSON directly and need to write it to a file for some reason, you can easily use `build_root_json` for that as well: + +```Ruby +swagger_data = Swagger::Blocks.build_root_json(SWAGGERED_CLASSES) +File.open('swagger.json', 'w') { |file| file.write(swagger_data.to_json) } +``` + ### Swagger 1.2 example (Rails) See the [v1.2 docs](https://github.com/fotinakis/swagger-blocks/blob/master/README_v1_2.md).