2017-03-08 16:32:31 +08:00
|
|
|
# frozen_string_literal: true
|
2017-03-28 17:15:33 +08:00
|
|
|
|
2017-02-04 00:35:34 +08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-02-06 00:20:41 +08:00
|
|
|
describe '#532 allow custom format' do
|
2017-02-04 00:35:34 +08:00
|
|
|
let(:app) do
|
|
|
|
Class.new(Grape::API) do
|
|
|
|
namespace :issue_532 do
|
2024-05-10 18:42:54 +08:00
|
|
|
desc 'issue_532' do
|
|
|
|
consumes ['application/x-www-form-urlencoded']
|
|
|
|
end
|
|
|
|
|
2017-02-04 00:35:34 +08:00
|
|
|
params do
|
|
|
|
requires :logs, type: String, documentation: { format: 'log' }
|
|
|
|
optional :phone_number, type: Integer, documentation: { format: 'phone_number' }
|
|
|
|
end
|
|
|
|
|
|
|
|
post do
|
|
|
|
present params
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
add_swagger_documentation format: :json
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
subject do
|
|
|
|
get '/swagger_doc'
|
|
|
|
JSON.parse(last_response.body)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:parameters) { subject['paths']['/issue_532']['post']['parameters'] }
|
|
|
|
|
|
|
|
specify do
|
|
|
|
expect(parameters).to eql(
|
|
|
|
[
|
|
|
|
{ 'in' => 'formData', 'name' => 'logs', 'type' => 'string', 'format' => 'log', 'required' => true },
|
|
|
|
{ 'in' => 'formData', 'name' => 'phone_number', 'type' => 'integer', 'format' => 'phone_number', 'required' => false }
|
|
|
|
]
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|