From aa59c5ff91de32229aac3f081f91315ac174bd33 Mon Sep 17 00:00:00 2001 From: Jay Danielian Date: Thu, 18 Jul 2019 22:01:00 -0400 Subject: [PATCH] Fixes response validators specs for v3 structure --- .../rswag/specs/response_validator_spec.rb | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/rswag-specs/spec/rswag/specs/response_validator_spec.rb b/rswag-specs/spec/rswag/specs/response_validator_spec.rb index 9411cbc..66f2422 100644 --- a/rswag-specs/spec/rswag/specs/response_validator_spec.rb +++ b/rswag-specs/spec/rswag/specs/response_validator_spec.rb @@ -11,7 +11,7 @@ module Rswag allow(config).to receive(:get_swagger_doc).and_return(swagger_doc) end let(:config) { double('config') } - let(:swagger_doc) { {} } + let(:swagger_doc) { {:components => {}} } let(:example) { double('example') } let(:metadata) do { @@ -58,14 +58,21 @@ module Rswag context 'referenced schemas' do before do - swagger_doc[:definitions] = { - 'blog' => { - type: :object, - properties: { foo: { type: :string } }, - required: ['foo'] - } + # swagger_doc[:definitions] = { + # 'blog' => { + # type: :object, + # properties: { foo: { type: :string } }, + # required: ['foo'] + # } + # } + swagger_doc[:components][:schemas] = { + 'blog' => { + type: :object, + properties: { foo: { type: :string } }, + required: ['foo'] + } } - metadata[:response][:schema] = { '$ref' => '#/definitions/blog' } + metadata[:response][:schema] = { '$ref' => '#/components/schemas/blog' } end it 'uses the referenced schema to validate the response body' do