This repository has been archived by the owner on Jul 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISSUE-#55: added swagger blocks and nested the api to v1
- Loading branch information
1 parent
b2a59d9
commit 7172ab3
Showing
8 changed files
with
204 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class Api::BaseController < ActionController::Base | ||
class << self | ||
Swagger::Docs::Generator.set_real_methods | ||
|
||
def inherited(subclass) | ||
super | ||
subclass.class_eval do | ||
setup_basic_api_documentation | ||
end | ||
end | ||
|
||
private | ||
|
||
def setup_basic_api_documentation; end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
# frozen_string_literal: true | ||
module Api | ||
module V1 | ||
class ListingsController < Api::BaseController | ||
include Swagger::Blocks | ||
|
||
swagger_path '/api/v1/listings' do | ||
operation :get do | ||
key :description, 'Returns all pets from the system that the user has access to' | ||
key :operationId, 'findPets' | ||
key :produces, [ | ||
'application/json', | ||
'text/html', | ||
] | ||
key :tags, [ | ||
'pet' | ||
] | ||
parameter do | ||
key :name, :tags | ||
key :in, :query | ||
key :description, 'tags to filter by' | ||
key :required, false | ||
key :type, :array | ||
items do | ||
key :type, :string | ||
end | ||
key :collectionFormat, :csv | ||
end | ||
parameter do | ||
key :name, :limit | ||
key :in, :query | ||
key :description, 'maximum number of results to return' | ||
key :required, false | ||
key :type, :integer | ||
key :format, :int32 | ||
end | ||
response 200 do | ||
key :description, 'pet response' | ||
schema do | ||
key :type, :array | ||
items do | ||
key :'$ref', :Pet | ||
end | ||
end | ||
end | ||
response :default do | ||
key :description, 'unexpected error' | ||
schema do | ||
key :'$ref', :ErrorModel | ||
end | ||
end | ||
end | ||
|
||
before_action :set_listing, only: [:show, :update, :destroy] | ||
|
||
# GET /listings | ||
def index | ||
@listings = Listing.all | ||
|
||
render json: @listings | ||
end | ||
|
||
# GET /listings/1 | ||
def show | ||
render json: @listing | ||
end | ||
|
||
# POST /listings | ||
def create | ||
@listing = Listing.new(listing_params) | ||
|
||
if @listing.save | ||
render json: @listing, status: :created, location: @listing | ||
else | ||
render json: @listing.errors, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
# PATCH/PUT /listings/1 | ||
def update | ||
if @listing.update(listing_params) | ||
render json: @listing | ||
else | ||
render json: @listing.errors, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
# DELETE /listings/1 | ||
def destroy | ||
@listing.destroy | ||
end | ||
|
||
private | ||
|
||
# Use callbacks to share common setup or constraints between actions. | ||
def set_listing | ||
@listing = Listing.find(params[:id]) | ||
end | ||
|
||
# Only allow a trusted parameter "white list" through. | ||
def listing_params | ||
params.require(:listing).permit( | ||
:listing_id, | ||
:property_type, | ||
:bedrooms, | ||
:bathrooms, | ||
:lease_length, | ||
:year_built_approx, | ||
:square_feet_approx, | ||
:furnished, | ||
:trash_service, | ||
:lawn_care, | ||
:basement, | ||
:parking_type, | ||
:allotted_parking_spaces, | ||
:parking_in_front_of_property_entrance, | ||
:lease_extra_spaces, | ||
:unit_entry, | ||
:lever_style_door_handles, | ||
:door_knock_and_bell_signaller, | ||
:standard_peephole, | ||
:entry_door_intercom, | ||
:deadbolt_on_entry_door, | ||
:secured_entry_to_building, | ||
:automatic_entry_door, | ||
:accessible_elevators, | ||
:unit_on_first_floor, | ||
:multi_story_unit, | ||
:bus_stop, | ||
:playground, | ||
:stove, | ||
:refrigerator_and_freezer, | ||
:air_conditioner, | ||
:clothes_washer, | ||
:clothes_dryer, | ||
:laundry_room_and_facility, | ||
:smoke_detector, | ||
:carbon_monoxide_detector, | ||
:heating_type, | ||
:water_heater, | ||
:counter_height, | ||
:non_digital_kitchen_appliances, | ||
:front_controls_on_stoveandcook_top, | ||
:vanity_height, | ||
:grab_bars, | ||
:reinforced_for_grab_bar, | ||
:roll_in_shower, | ||
:lowered_toilet, | ||
:raised_toilet, | ||
:gated_facility, | ||
:sidewalks, | ||
:emergency_exits, | ||
:dumpsters, | ||
:pool, | ||
:work_out_room, | ||
:theater, | ||
:community_shuttle, | ||
:within_paratransit_route, | ||
:sign_language_friendly, | ||
:recreational_facilities, | ||
:apartment_name, | ||
:address, | ||
:criminal_check, | ||
:credit_check, | ||
:accepts_section_8, | ||
:tax_credit_property, | ||
:subsidized_rent_ok, | ||
:seniors_only, | ||
:pets, | ||
:smoking, | ||
:security_deposit, | ||
:application_fee, | ||
:date_available, | ||
:flooring_materials, | ||
:other_appliances_included | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.JSONAPIAdapter.extend({ | ||
namespace: '/api' | ||
namespace: '/api/v1' | ||
}); |