Sha256: dda953aafedbaab0db73204a0c54949064393c5034c10c6c72dab13a27b5d3ea

Contents?: true

Size: 1.78 KB

Versions: 5

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'

describe 'swagger spec v2.0' do
  include_context "#{MODEL_PARSER} swagger example"

  def app
    Class.new(Grape::API) do
      format :json

      desc 'This creates Thing after a delay',
           success: { code: 202, message: 'OK', model: Entities::Something }
      params do
        requires :text, type: String, documentation: { type: 'string', desc: 'Content of something.' }
        requires :links, type: Array, documentation: { type: 'link', is_array: true }
      end
      post '/delay_thing' do
        status 202
      end

      version 'v3', using: :path
      add_swagger_documentation api_version: 'v1',
                                base_path: '/api',
                                info: {
                                  title: 'The API title to be displayed on the API homepage.',
                                  description: 'A description of the API.',
                                  contact_name: 'Contact name',
                                  contact_email: 'Contact@email.com',
                                  contact_url: 'Contact URL',
                                  license: 'The name of the license.',
                                  license_url: 'www.The-URL-of-the-license.org',
                                  terms_of_service_url: 'www.The-URL-of-the-terms-and-service.com'
                                }
    end
  end

  before do
    get '/v3/swagger_doc'
  end

  let(:json) { JSON.parse(last_response.body) }

  it 'only returns one response if ignore_defaults is specified' do
    expect(json['paths']['/delay_thing']['post']['responses']).to eq('202' => { 'description' => 'OK', 'schema' => { '$ref' => '#/definitions/Something' } })
    expect(json['paths']['/delay_thing']['post']['responses'].keys).not_to include '201'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grape-swagger-0.26.1 spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb
grape-swagger-0.26.0 spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb
grape-swagger-0.25.3 spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb
grape-swagger-0.25.2 spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb
grape-swagger-0.25.1 spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb