Sha256: 461cce6954beae1cdc855760e487b50d0c6685e349a7dd9cbc6246f656a53156
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe 'response' do include_context "#{MODEL_PARSER} swagger example" before :all do module TheApi class ResponseApiModels < Grape::API format :json desc 'This returns something', success: [{ code: 200 }], failure: [ { code: 400, message: 'NotFound', model: '' }, { code: 404, message: 'BadRequest', model: Entities::ApiError } ], default_response: { message: 'Error', model: Entities::ApiError } get '/use-response' do { 'declared_params' => declared(params) } end add_swagger_documentation(models: [Entities::UseResponse]) end end end def app TheApi::ResponseApiModels end describe 'uses entity as response object implicitly with route name' do subject do get '/swagger_doc/use-response' JSON.parse(last_response.body) end specify do expect(subject['paths']['/use-response']['get']).to eql( 'description' => 'This returns something', 'produces' => ['application/json'], 'responses' => { '200' => { 'description' => 'This returns something', 'schema' => { '$ref' => '#/definitions/UseResponse' } }, '400' => { 'description' => 'NotFound' }, '404' => { 'description' => 'BadRequest', 'schema' => { '$ref' => '#/definitions/ApiError' } }, 'default' => { 'description' => 'Error', 'schema' => { '$ref' => '#/definitions/ApiError' } } }, 'tags' => ['use-response'], 'operationId' => 'getUseResponse' ) expect(subject['definitions']).to eql(swagger_entity_as_response_object) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grape-swagger-1.6.1 | spec/swagger_v2/api_swagger_v2_response_with_models_spec.rb |
grape-swagger-1.6.0 | spec/swagger_v2/api_swagger_v2_response_with_models_spec.rb |