Sha256: cd8b693e2b7d59374e563ccea1e18b59fff10b44542cf4abd0f6cce3c7ae8885

Contents?: true

Size: 774 Bytes

Versions: 1

Compression:

Stored size: 774 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'Float Params' do
  def app
    Class.new(Grape::API) do
      format :json

      desc 'splines' do
        consumes ['application/x-www-form-urlencoded']
      end
      params do
        requires :a_float, type: Float
      end
      post :splines do
        { message: 'hi' }
      end

      add_swagger_documentation
    end
  end

  subject do
    get '/swagger_doc/splines'
    expect(last_response.status).to eq 200
    body = JSON.parse last_response.body
    body['paths']['/splines']['post']['parameters']
  end

  it 'converts float types' do
    expect(subject).to eq [
      { 'in' => 'formData', 'name' => 'a_float', 'type' => 'number', 'required' => true, 'format' => 'float' }
    ]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitlab-grape-swagger-1.5.0 spec/swagger_v2/float_api_spec.rb