From 7e123f902e17be3426189df9a8342de793eaac79 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 31 Mar 2015 17:15:57 +0300 Subject: [PATCH 1/4] Get route info --- spec/requests/domain_spec.rb | 2 +- spec/support/request.rb | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/spec/requests/domain_spec.rb b/spec/requests/domain_spec.rb index d1d17b819..16bff3993 100644 --- a/spec/requests/domain_spec.rb +++ b/spec/requests/domain_spec.rb @@ -10,7 +10,7 @@ describe Repp::DomainV1 do describe 'GET /repp/v1/domains', autodoc: true do it 'returns domains of the current registrar' do - + binding.pry get_with_auth '/repp/v1/domains', { limit: 1, details: true }, @api_user response.status.should == 200 diff --git a/spec/support/request.rb b/spec/support/request.rb index 053874f0b..6bd90e35c 100644 --- a/spec/support/request.rb +++ b/spec/support/request.rb @@ -29,6 +29,28 @@ module Request ) }) end + + def get_route_info(path) + route = Repp::API.routes.select do |x| + x.route_path.gsub('(.:format)', '').gsub(':version', x.route_version) == path + end.first + + route_path = route.route_path.gsub('(.:format)', '').gsub(':version', route.route_version) + + puts "#{route.route_method} #{route_path}" + puts " #{route.route_description}" if route.route_description + + if route.route_params.is_a?(Hash) + params = route.route_params.map do |name, desc| + required = desc.is_a?(Hash) ? desc[:required] : false + description = desc.is_a?(Hash) ? desc[:description] : desc.to_s + [name, required, " * #{name}: #{description} #{required ? '(required)' : ''}"] + end + + puts " parameters:" + params.each { |p| puts p[2] } + end + end end RSpec.configure do |c| From 21f07076cd58c2750439041101ec1a34cd105360 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 1 Apr 2015 13:32:38 +0300 Subject: [PATCH 2/4] New REPP doc --- app/api/repp/contact_v1.rb | 1 + app/api/repp/domain_v1.rb | 1 + doc/repp/v1/contact.md | 87 +++++++------------------- doc/repp/v1/domain.md | 80 +++++------------------ spec/rails_helper.rb | 1 + spec/requests/contact_spec.rb | 6 +- spec/requests/domain_spec.rb | 7 +-- spec/requests/repp_doc_template.md.erb | 20 ++++++ spec/support/request.rb | 63 ++++++++++++++----- 9 files changed, 113 insertions(+), 153 deletions(-) create mode 100644 spec/requests/repp_doc_template.md.erb diff --git a/app/api/repp/contact_v1.rb b/app/api/repp/contact_v1.rb index 52403fb2d..29fe675d5 100644 --- a/app/api/repp/contact_v1.rb +++ b/app/api/repp/contact_v1.rb @@ -7,6 +7,7 @@ module Repp params do optional :limit, type: Integer, values: (1..20).to_a optional :offset, type: Integer + optional :details, type: String, values: %w(true false) end get '/' do diff --git a/app/api/repp/domain_v1.rb b/app/api/repp/domain_v1.rb index dbdcc778d..112fcccaf 100644 --- a/app/api/repp/domain_v1.rb +++ b/app/api/repp/domain_v1.rb @@ -7,6 +7,7 @@ module Repp params do optional :limit, type: Integer, values: (1..20).to_a optional :offset, type: Integer + optional :details, type: String, values: %w(true false) end get '/' do diff --git a/doc/repp/v1/contact.md b/doc/repp/v1/contact.md index bc50cda54..a184f026d 100644 --- a/doc/repp/v1/contact.md +++ b/doc/repp/v1/contact.md @@ -1,7 +1,14 @@ ## GET /repp/v1/contacts Returns contacts of the current registrar. -### Example + +#### Parameters + +| Field name | Required | Type | Allowed values | +| ---------- | -------- | ---- | -------------- | +| limit | false | Integer | [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] | +| offset | false | Integer | | +| details | false | String | ["true", "false"] | #### Request ``` @@ -16,31 +23,36 @@ Content-Type: application/json ``` HTTP/1.1 200 Cache-Control: max-age=0, private, must-revalidate -Content-Length: 483 +Content-Length: 566 Content-Type: application/json { "contacts": [ { "id": 1, - "code": "sh470279120", + "code": "sh889404040", "reg_no": null, "phone": "+372.12345678", - "email": "bettye.feil@ratkegoldner.net", + "email": "annetta.toy@mitchell.org", "fax": null, - "created_at": "2015-03-31T07:39:10.854Z", - "updated_at": "2015-03-31T07:39:10.854Z", + "created_at": "2015-04-01T10:30:47.470Z", + "updated_at": "2015-04-01T10:30:47.470Z", "ident": "37605030299", "ident_type": "priv", "created_by_id": null, "updated_by_id": null, "auth_info": "password", - "name": "Leopoldo Waelchi0", + "name": "Rogers Bruen0", "org_name": null, "registrar_id": 1, "creator_str": "autotest", "updator_str": "autotest", - "ident_country_code": "EE" + "ident_country_code": "EE", + "city": "Tallinn", + "street": "Short street 11", + "zip": "11111", + "country_code": "EE", + "state": null } ], "total_number_of_records": 2 @@ -50,7 +62,6 @@ Content-Type: application/json ## GET /repp/v1/contacts Returns contact names with offset. -### Example #### Request ``` @@ -70,64 +81,8 @@ Content-Type: application/json { "contacts": [ - "sh226475261" + "sh914462381" ], "total_number_of_records": 2 } ``` - -## GET /repp/v1/contacts -Returns contact names of the current registrar. - -### Example - -#### Request -``` -GET /repp/v1/contacts HTTP/1.1 -Accept: application/json -Authorization: Basic Z2l0bGFiOmdoeXQ5ZTRmdQ== -Content-Length: 0 -Content-Type: application/json -``` - -#### Response -``` -HTTP/1.1 200 -Cache-Control: max-age=0, private, must-revalidate -Content-Length: 70 -Content-Type: application/json - -{ - "contacts": [ - "sh470279120", - "sh226475261" - ], - "total_number_of_records": 2 -} -``` - -## GET /repp/v1/contacts -Returns an error with invalid parameters in contact index. - -### Example - -#### Request -``` -GET /repp/v1/contacts?limit=0 HTTP/1.1 -Accept: application/json -Authorization: Basic Z2l0bGFiOmdoeXQ5ZTRmdQ== -Content-Length: 0 -Content-Type: application/json -``` - -#### Response -``` -HTTP/1.1 400 -Cache-Control: no-cache -Content-Length: 45 -Content-Type: application/json - -{ - "error": "limit does not have a valid value" -} -``` diff --git a/doc/repp/v1/domain.md b/doc/repp/v1/domain.md index f717f7da7..7648fec45 100644 --- a/doc/repp/v1/domain.md +++ b/doc/repp/v1/domain.md @@ -1,7 +1,14 @@ ## GET /repp/v1/domains Returns domains of the current registrar. -### Example + +#### Parameters + +| Field name | Required | Type | Allowed values | +| ---------- | -------- | ---- | -------------- | +| limit | false | Integer | [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] | +| offset | false | Integer | | +| details | false | String | ["true", "false"] | #### Request ``` @@ -25,21 +32,21 @@ Content-Type: application/json "id": 1, "name": "domain0.ee", "registrar_id": 1, - "registered_at": "2015-03-31T07:39:11.598Z", + "registered_at": "2015-04-01T10:30:48.773Z", "status": null, - "valid_from": "2015-03-31T00:00:00.000Z", - "valid_to": "2016-03-31T00:00:00.000Z", + "valid_from": "2015-04-01T00:00:00.000Z", + "valid_to": "2016-04-01T00:00:00.000Z", "owner_contact_id": 1, - "auth_info": "fc7828fbc275ff16b86a31def3e7a60d", - "created_at": "2015-03-31T07:39:11.595Z", - "updated_at": "2015-03-31T07:39:11.591Z", + "auth_info": "1a93d4599945df52de0a38c64b470e67", + "created_at": "2015-04-01T10:30:48.768Z", + "updated_at": "2015-04-01T10:30:48.762Z", "name_dirty": "domain0.ee", "name_puny": "domain0.ee", "period": 1, "period_unit": "y", "creator_str": null, "updator_str": null, - "whois_body": " This Whois Server contains information on\n Estonian Top Level Domain ee TLD\n\n domain: domain0.ee\n registrar: registrar1\n status:\n registered: \n changed: 2015-03-31 07:39:11\n expire:\n outzone:\n delete:\n\n \n\n nsset:\n nserver:\n\n registrar: registrar1\n phone: \n address: Street 111, Town, County, Postal\n created: 2015-03-31 07:39:11\n changed: 2015-03-31 07:39:11\n" + "whois_body": " This Whois Server contains information on\n Estonian Top Level Domain ee TLD\n\n domain: domain0.ee\n registrar: registrar1\n status:\n registered: \n changed: 2015-04-01 10:30:48\n expire:\n outzone:\n delete:\n\n \n\n nsset:\n nserver:\n\n registrar: registrar1\n phone: \n address: Street 111, Town, County, Postal\n created: 2015-04-01 10:30:48\n changed: 2015-04-01 10:30:48\n" } ], "total_number_of_records": 2 @@ -49,7 +56,6 @@ Content-Type: application/json ## GET /repp/v1/domains Returns domain names with offset. -### Example #### Request ``` @@ -74,59 +80,3 @@ Content-Type: application/json "total_number_of_records": 2 } ``` - -## GET /repp/v1/domains -Returns domain names of the current registrar. - -### Example - -#### Request -``` -GET /repp/v1/domains HTTP/1.1 -Accept: application/json -Authorization: Basic Z2l0bGFiOmdoeXQ5ZTRmdQ== -Content-Length: 0 -Content-Type: application/json -``` - -#### Response -``` -HTTP/1.1 200 -Cache-Control: max-age=0, private, must-revalidate -Content-Length: 67 -Content-Type: application/json - -{ - "domains": [ - "domain0.ee", - "domain1.ee" - ], - "total_number_of_records": 2 -} -``` - -## GET /repp/v1/domains -Returns an error with invalid parameters in domain index. - -### Example - -#### Request -``` -GET /repp/v1/domains?limit=0 HTTP/1.1 -Accept: application/json -Authorization: Basic Z2l0bGFiOmdoeXQ5ZTRmdQ== -Content-Length: 0 -Content-Type: application/json -``` - -#### Response -``` -HTTP/1.1 400 -Cache-Control: no-cache -Content-Length: 45 -Content-Type: application/json - -{ - "error": "limit does not have a valid value" -} -``` diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 8c63e5109..019f638cb 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -92,4 +92,5 @@ RSpec.configure do |config| Autodoc.configuration.path = 'doc/repp/v1' Autodoc.configuration.suppressed_request_header = ['Host'] Autodoc.configuration.suppressed_response_header = ['ETag', 'X-Request-Id', 'X-Runtime'] + Autodoc.configuration.template = File.read('spec/requests/repp_doc_template.md.erb') end diff --git a/spec/requests/contact_spec.rb b/spec/requests/contact_spec.rb index e9c9c4112..bd5f8567b 100644 --- a/spec/requests/contact_spec.rb +++ b/spec/requests/contact_spec.rb @@ -8,8 +8,8 @@ describe Repp::ContactV1 do Fabricate.times(2, :contact) end - describe 'GET /repp/v1/contacts', autodoc: true do - it 'returns contacts of the current registrar' do + describe 'GET /repp/v1/contacts' do + it 'returns contacts of the current registrar', autodoc: true, route_info_doc: true do get_with_auth '/repp/v1/contacts', { limit: 1, details: true }, @api_user expect(response.status).to eq(200) @@ -29,7 +29,7 @@ describe Repp::ContactV1 do expect(log[:ip]).to eq('127.0.0.1') end - it 'returns contact names with offset' do + it 'returns contact names with offset', autodoc: true do get_with_auth '/repp/v1/contacts', { offset: 1 }, @api_user expect(response.status).to eq(200) diff --git a/spec/requests/domain_spec.rb b/spec/requests/domain_spec.rb index 16bff3993..e4a10680a 100644 --- a/spec/requests/domain_spec.rb +++ b/spec/requests/domain_spec.rb @@ -8,9 +8,8 @@ describe Repp::DomainV1 do Fabricate.times(2, :domain, registrar: @api_user.registrar) end - describe 'GET /repp/v1/domains', autodoc: true do - it 'returns domains of the current registrar' do - binding.pry + describe 'GET /repp/v1/domains' do + it 'returns domains of the current registrar', autodoc: true, route_info_doc: true do get_with_auth '/repp/v1/domains', { limit: 1, details: true }, @api_user response.status.should == 200 @@ -30,7 +29,7 @@ describe Repp::DomainV1 do log[:ip].should == '127.0.0.1' end - it 'returns domain names with offset' do + it 'returns domain names with offset', autodoc: true do get_with_auth '/repp/v1/domains', { offset: 1 }, @api_user response.status.should == 200 diff --git a/spec/requests/repp_doc_template.md.erb b/spec/requests/repp_doc_template.md.erb new file mode 100644 index 000000000..100e95081 --- /dev/null +++ b/spec/requests/repp_doc_template.md.erb @@ -0,0 +1,20 @@ +<%# coding: UTF-8 -%> +## <%= title %> +<%= description %> +<% rid = route_info_doc %> +<% if rid %> +#### Parameters + +<%= rid %> +<% end %> +#### Request +``` +<%= method %> <%= request.path %><%= request_query %> <%= request_http_version %> +<%= request_header %><%= request_body_section %> +``` + +#### Response +``` +<%= response_http_version %> <%= response.status %> +<%= response_header %><%= response_body_section %> +``` diff --git a/spec/support/request.rb b/spec/support/request.rb index 6bd90e35c..219b0ad4b 100644 --- a/spec/support/request.rb +++ b/spec/support/request.rb @@ -29,26 +29,59 @@ module Request ) }) end +end - def get_route_info(path) - route = Repp::API.routes.select do |x| - x.route_path.gsub('(.:format)', '').gsub(':version', x.route_version) == path - end.first +module Autodoc + class Document + def route_info_doc + return unless example.metadata[:route_info_doc] + route = request.env["rack.routing_args"][:route_info] + return unless route.route_params.is_a?(Hash) - route_path = route.route_path.gsub('(.:format)', '').gsub(':version', route.route_version) + params_details = [ + "| Field name | Required | Type | Allowed values |", + "| ---------- | -------- | ---- | -------------- |" + ] - puts "#{route.route_method} #{route_path}" - puts " #{route.route_description}" if route.route_description - - if route.route_params.is_a?(Hash) - params = route.route_params.map do |name, desc| - required = desc.is_a?(Hash) ? desc[:required] : false - description = desc.is_a?(Hash) ? desc[:description] : desc.to_s - [name, required, " * #{name}: #{description} #{required ? '(required)' : ''}"] + route.route_params.each do |name, desc| + details = [] + details << "| #{name} " + details << "| #{desc[:required]} " + details << "| #{desc[:type]} " + details << "| #{desc[:values]} |" + params_details << details.join + # required = desc.is_a?(Hash) ? desc[:required] : false + # description = desc.is_a?(Hash) ? desc[:description] : desc.to_s + # [name, required, " * #{name}: #{description} #{required ? '(required)' : ''}"] end - puts " parameters:" - params.each { |p| puts p[2] } + prettify_table(params_details).join("\n") + end + + def prettify_table(rows) + # longest_in_col = 0 + matrix_array = [] + rows.each do |x| + matrix_array << x.split('|') + [''] # [''] is because split loses last | + end + + new_arr = [] + matrix_array.transpose.each do |col| + new_col = [] + longest = col.max_by(&:size).size + + col.each do |r| + new_col << r.center(longest) + end + new_arr << new_col + end + + matrix_array = [] + new_arr.transpose.each do |x| + matrix_array << x.join('|') + end + + matrix_array end end end From 42001c4601595195af90dc97d5bb155f9f406515 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 1 Apr 2015 13:45:59 +0300 Subject: [PATCH 3/4] Use ranges for allowed values instead of arrays --- doc/repp/v1/contact.md | 24 ++++++++++++------------ doc/repp/v1/domain.md | 20 ++++++++++---------- spec/support/request.rb | 27 +++++++++++++++++++-------- 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/doc/repp/v1/contact.md b/doc/repp/v1/contact.md index a184f026d..88a28d13f 100644 --- a/doc/repp/v1/contact.md +++ b/doc/repp/v1/contact.md @@ -4,11 +4,11 @@ Returns contacts of the current registrar. #### Parameters -| Field name | Required | Type | Allowed values | -| ---------- | -------- | ---- | -------------- | -| limit | false | Integer | [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] | -| offset | false | Integer | | -| details | false | String | ["true", "false"] | +| Field name | Required | Type | Allowed values | +| ---------- | -------- | ---- | -------------- | +| limit | false | Integer | [1..20] | +| offset | false | Integer | | +| details | false | String | ["true", "false"] | #### Request ``` @@ -23,26 +23,26 @@ Content-Type: application/json ``` HTTP/1.1 200 Cache-Control: max-age=0, private, must-revalidate -Content-Length: 566 +Content-Length: 586 Content-Type: application/json { "contacts": [ { "id": 1, - "code": "sh889404040", + "code": "sh651514820", "reg_no": null, "phone": "+372.12345678", - "email": "annetta.toy@mitchell.org", + "email": "giles_altenwerth@oberbrunnerbrakus.com", "fax": null, - "created_at": "2015-04-01T10:30:47.470Z", - "updated_at": "2015-04-01T10:30:47.470Z", + "created_at": "2015-04-01T10:45:28.045Z", + "updated_at": "2015-04-01T10:45:28.045Z", "ident": "37605030299", "ident_type": "priv", "created_by_id": null, "updated_by_id": null, "auth_info": "password", - "name": "Rogers Bruen0", + "name": "Ms. Lucienne Olson0", "org_name": null, "registrar_id": 1, "creator_str": "autotest", @@ -81,7 +81,7 @@ Content-Type: application/json { "contacts": [ - "sh914462381" + "sh371827431" ], "total_number_of_records": 2 } diff --git a/doc/repp/v1/domain.md b/doc/repp/v1/domain.md index 7648fec45..3e73f1962 100644 --- a/doc/repp/v1/domain.md +++ b/doc/repp/v1/domain.md @@ -4,11 +4,11 @@ Returns domains of the current registrar. #### Parameters -| Field name | Required | Type | Allowed values | -| ---------- | -------- | ---- | -------------- | -| limit | false | Integer | [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] | -| offset | false | Integer | | -| details | false | String | ["true", "false"] | +| Field name | Required | Type | Allowed values | +| ---------- | -------- | ---- | -------------- | +| limit | false | Integer | [1..20] | +| offset | false | Integer | | +| details | false | String | ["true", "false"] | #### Request ``` @@ -32,21 +32,21 @@ Content-Type: application/json "id": 1, "name": "domain0.ee", "registrar_id": 1, - "registered_at": "2015-04-01T10:30:48.773Z", + "registered_at": "2015-04-01T10:45:28.858Z", "status": null, "valid_from": "2015-04-01T00:00:00.000Z", "valid_to": "2016-04-01T00:00:00.000Z", "owner_contact_id": 1, - "auth_info": "1a93d4599945df52de0a38c64b470e67", - "created_at": "2015-04-01T10:30:48.768Z", - "updated_at": "2015-04-01T10:30:48.762Z", + "auth_info": "81d71922080506c636030ff5634823ba", + "created_at": "2015-04-01T10:45:28.854Z", + "updated_at": "2015-04-01T10:45:28.850Z", "name_dirty": "domain0.ee", "name_puny": "domain0.ee", "period": 1, "period_unit": "y", "creator_str": null, "updator_str": null, - "whois_body": " This Whois Server contains information on\n Estonian Top Level Domain ee TLD\n\n domain: domain0.ee\n registrar: registrar1\n status:\n registered: \n changed: 2015-04-01 10:30:48\n expire:\n outzone:\n delete:\n\n \n\n nsset:\n nserver:\n\n registrar: registrar1\n phone: \n address: Street 111, Town, County, Postal\n created: 2015-04-01 10:30:48\n changed: 2015-04-01 10:30:48\n" + "whois_body": " This Whois Server contains information on\n Estonian Top Level Domain ee TLD\n\n domain: domain0.ee\n registrar: registrar1\n status:\n registered: \n changed: 2015-04-01 10:45:28\n expire:\n outzone:\n delete:\n\n \n\n nsset:\n nserver:\n\n registrar: registrar1\n phone: \n address: Street 111, Town, County, Postal\n created: 2015-04-01 10:45:28\n changed: 2015-04-01 10:45:28\n" } ], "total_number_of_records": 2 diff --git a/spec/support/request.rb b/spec/support/request.rb index 219b0ad4b..2790e102b 100644 --- a/spec/support/request.rb +++ b/spec/support/request.rb @@ -38,7 +38,7 @@ module Autodoc route = request.env["rack.routing_args"][:route_info] return unless route.route_params.is_a?(Hash) - params_details = [ + rows = [ "| Field name | Required | Type | Allowed values |", "| ---------- | -------- | ---- | -------------- |" ] @@ -48,17 +48,14 @@ module Autodoc details << "| #{name} " details << "| #{desc[:required]} " details << "| #{desc[:type]} " - details << "| #{desc[:values]} |" - params_details << details.join - # required = desc.is_a?(Hash) ? desc[:required] : false - # description = desc.is_a?(Hash) ? desc[:description] : desc.to_s - # [name, required, " * #{name}: #{description} #{required ? '(required)' : ''}"] + details << "| #{ranges_from_array(desc[:values])} |" + rows << details.join end - prettify_table(params_details).join("\n") + pretty_table(rows).join("\n") end - def prettify_table(rows) + def pretty_table(rows) # longest_in_col = 0 matrix_array = [] rows.each do |x| @@ -83,6 +80,20 @@ module Autodoc matrix_array end + + def ranges_from_array(a) + return unless a + ranges = a.sort.uniq.reduce([]) do |spans, n| + return a if n.is_a?(String) + if spans.empty? || spans.last.last != n - 1 + spans + [n..n] + else + spans[0..-2] + [spans.last.first..n] + end + end + + ranges + end end end From 28d0cfd4dfdcb48ba7311b91e10747f42b82178d Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 1 Apr 2015 13:52:35 +0300 Subject: [PATCH 4/4] Add descriptions to fields --- app/api/repp/contact_v1.rb | 6 +++--- app/api/repp/domain_v1.rb | 6 +++--- doc/repp/v1/contact.md | 24 ++++++++++++------------ doc/repp/v1/domain.md | 20 ++++++++++---------- spec/support/request.rb | 7 ++++--- 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/app/api/repp/contact_v1.rb b/app/api/repp/contact_v1.rb index 29fe675d5..af7526231 100644 --- a/app/api/repp/contact_v1.rb +++ b/app/api/repp/contact_v1.rb @@ -5,9 +5,9 @@ module Repp resource :contacts do desc 'Return list of contact' params do - optional :limit, type: Integer, values: (1..20).to_a - optional :offset, type: Integer - optional :details, type: String, values: %w(true false) + optional :limit, type: Integer, values: (1..20).to_a, desc: 'How many contacts to show' + optional :offset, type: Integer, desc: 'Contact number to start at' + optional :details, type: String, values: %w(true false), desc: 'Whether to include details' end get '/' do diff --git a/app/api/repp/domain_v1.rb b/app/api/repp/domain_v1.rb index 112fcccaf..99b9c4cb3 100644 --- a/app/api/repp/domain_v1.rb +++ b/app/api/repp/domain_v1.rb @@ -5,9 +5,9 @@ module Repp resource :domains do desc 'Return list of domains' params do - optional :limit, type: Integer, values: (1..20).to_a - optional :offset, type: Integer - optional :details, type: String, values: %w(true false) + optional :limit, type: Integer, values: (1..20).to_a, desc: 'How many domains to show' + optional :offset, type: Integer, desc: 'Domain number to start at' + optional :details, type: String, values: %w(true false), desc: 'Whether to include details' end get '/' do diff --git a/doc/repp/v1/contact.md b/doc/repp/v1/contact.md index 88a28d13f..ebe38c476 100644 --- a/doc/repp/v1/contact.md +++ b/doc/repp/v1/contact.md @@ -4,11 +4,11 @@ Returns contacts of the current registrar. #### Parameters -| Field name | Required | Type | Allowed values | -| ---------- | -------- | ---- | -------------- | -| limit | false | Integer | [1..20] | -| offset | false | Integer | | -| details | false | String | ["true", "false"] | +| Field name | Required | Type | Allowed values | Description | +| ---------- | -------- | ---- | -------------- | ----------- | +| limit | false | Integer | [1..20] | How many contacts to show | +| offset | false | Integer | | Contact number to start at | +| details | false | String | ["true", "false"] | Whether to include details | #### Request ``` @@ -23,26 +23,26 @@ Content-Type: application/json ``` HTTP/1.1 200 Cache-Control: max-age=0, private, must-revalidate -Content-Length: 586 +Content-Length: 573 Content-Type: application/json { "contacts": [ { "id": 1, - "code": "sh651514820", + "code": "sh095058820", "reg_no": null, "phone": "+372.12345678", - "email": "giles_altenwerth@oberbrunnerbrakus.com", + "email": "shakira.reichert@corkery.com", "fax": null, - "created_at": "2015-04-01T10:45:28.045Z", - "updated_at": "2015-04-01T10:45:28.045Z", + "created_at": "2015-04-01T10:51:49.854Z", + "updated_at": "2015-04-01T10:51:49.854Z", "ident": "37605030299", "ident_type": "priv", "created_by_id": null, "updated_by_id": null, "auth_info": "password", - "name": "Ms. Lucienne Olson0", + "name": "Henderson Feest0", "org_name": null, "registrar_id": 1, "creator_str": "autotest", @@ -81,7 +81,7 @@ Content-Type: application/json { "contacts": [ - "sh371827431" + "sh331036241" ], "total_number_of_records": 2 } diff --git a/doc/repp/v1/domain.md b/doc/repp/v1/domain.md index 3e73f1962..06234524d 100644 --- a/doc/repp/v1/domain.md +++ b/doc/repp/v1/domain.md @@ -4,11 +4,11 @@ Returns domains of the current registrar. #### Parameters -| Field name | Required | Type | Allowed values | -| ---------- | -------- | ---- | -------------- | -| limit | false | Integer | [1..20] | -| offset | false | Integer | | -| details | false | String | ["true", "false"] | +| Field name | Required | Type | Allowed values | Description | +| ---------- | -------- | ---- | -------------- | ----------- | +| limit | false | Integer | [1..20] | How many domains to show | +| offset | false | Integer | | Domain number to start at | +| details | false | String | ["true", "false"] | Whether to include details | #### Request ``` @@ -32,21 +32,21 @@ Content-Type: application/json "id": 1, "name": "domain0.ee", "registrar_id": 1, - "registered_at": "2015-04-01T10:45:28.858Z", + "registered_at": "2015-04-01T10:51:53.445Z", "status": null, "valid_from": "2015-04-01T00:00:00.000Z", "valid_to": "2016-04-01T00:00:00.000Z", "owner_contact_id": 1, - "auth_info": "81d71922080506c636030ff5634823ba", - "created_at": "2015-04-01T10:45:28.854Z", - "updated_at": "2015-04-01T10:45:28.850Z", + "auth_info": "15d4b95d0611312ee96e63e48fcab2de", + "created_at": "2015-04-01T10:51:53.439Z", + "updated_at": "2015-04-01T10:51:53.432Z", "name_dirty": "domain0.ee", "name_puny": "domain0.ee", "period": 1, "period_unit": "y", "creator_str": null, "updator_str": null, - "whois_body": " This Whois Server contains information on\n Estonian Top Level Domain ee TLD\n\n domain: domain0.ee\n registrar: registrar1\n status:\n registered: \n changed: 2015-04-01 10:45:28\n expire:\n outzone:\n delete:\n\n \n\n nsset:\n nserver:\n\n registrar: registrar1\n phone: \n address: Street 111, Town, County, Postal\n created: 2015-04-01 10:45:28\n changed: 2015-04-01 10:45:28\n" + "whois_body": " This Whois Server contains information on\n Estonian Top Level Domain ee TLD\n\n domain: domain0.ee\n registrar: registrar1\n status:\n registered: \n changed: 2015-04-01 10:51:53\n expire:\n outzone:\n delete:\n\n \n\n nsset:\n nserver:\n\n registrar: registrar1\n phone: \n address: Street 111, Town, County, Postal\n created: 2015-04-01 10:51:53\n changed: 2015-04-01 10:51:53\n" } ], "total_number_of_records": 2 diff --git a/spec/support/request.rb b/spec/support/request.rb index 2790e102b..5c7315cfe 100644 --- a/spec/support/request.rb +++ b/spec/support/request.rb @@ -39,8 +39,8 @@ module Autodoc return unless route.route_params.is_a?(Hash) rows = [ - "| Field name | Required | Type | Allowed values |", - "| ---------- | -------- | ---- | -------------- |" + "| Field name | Required | Type | Allowed values | Description |", + "| ---------- | -------- | ---- | -------------- | ----------- |" ] route.route_params.each do |name, desc| @@ -48,7 +48,8 @@ module Autodoc details << "| #{name} " details << "| #{desc[:required]} " details << "| #{desc[:type]} " - details << "| #{ranges_from_array(desc[:values])} |" + details << "| #{ranges_from_array(desc[:values])} " + details << "| #{desc[:desc]} |" rows << details.join end