Class: ApiCanon::SwaggerController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- ApiCanon::SwaggerController
- Defined in:
- app/controllers/swagger_controller.rb
Instance Method Summary collapse
- #index ⇒ Object
-
#set_headers ⇒ Object
TODO: Not sure about this.
- #show ⇒ Object
Instance Method Details
#index ⇒ Object
16 17 18 19 20 |
# File 'app/controllers/swagger_controller.rb', line 16 def index set_headers api_docs = ::ApiCanon::DocumentationStore.docos render :json => api_docs, :serializer => ApiCanon::Swagger::ResourceListing end |
#set_headers ⇒ Object
TODO: Not sure about this
5 6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/swagger_controller.rb', line 5 def set_headers if request.headers["HTTP_ORIGIN"] headers['Access-Control-Allow-Origin'] = request.headers["HTTP_ORIGIN"] headers['Access-Control-Expose-Headers'] = 'ETag' headers['Access-Control-Allow-Methods'] = 'GET, POST, PATCH, PUT, DELETE, OPTIONS, HEAD' headers['Access-Control-Allow-Headers'] = '*,x-requested-with,Content-Type,If-Modified-Since,If-None-Match,Auth-User-Token' headers['Access-Control-Max-Age'] = '86400' headers['Access-Control-Allow-Credentials'] = 'true' end end |
#show ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/swagger_controller.rb', line 22 def show set_headers api_doc = ::ApiCanon::DocumentationStore.fetch params[:id] if api_doc render :json => api_doc, :serializer => ApiCanon::Swagger::ApiDeclaration else head :not_found end end |